1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "app.h"
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
19 #if defined(__BORLANDC__)
27 #include "wx/gdicmn.h"
30 #include "wx/cursor.h"
32 #include "wx/palette.h"
34 #include "wx/dialog.h"
35 #include "wx/msgdlg.h"
38 #include "wx/msw/private.h"
40 #include "wx/module.h"
42 #if wxUSE_WX_RESOURCES
43 #include "wx/resource.h"
49 #if defined(__WIN95__) && !defined(__GNUWIN32__)
53 // use debug CRT functions for memory leak detections in VC++
54 /* This still doesn't work for me, Vadim.
55 #if defined(__WXDEBUG__) && defined(_MSC_VER)
56 // VC++ uses this macro as debug/release mode indicator
65 extern char *wxBuffer
;
66 extern char *wxOsVersion
;
67 extern wxList
*wxWinHandleList
;
68 extern wxList wxPendingDelete
;
69 extern void wxSetKeyboardHook(bool doIt
);
70 extern wxCursor
*g_globalCursor
;
72 HINSTANCE wxhInstance
= 0;
73 static MSG s_currentMsg
;
74 wxApp
*wxTheApp
= NULL
;
76 // @@ why not const? and not static?
77 char wxFrameClassName
[] = "wxFrameClass";
78 char wxMDIFrameClassName
[] = "wxMDIFrameClass";
79 char wxMDIChildFrameClassName
[] = "wxMDIChildFrameClass";
80 char wxPanelClassName
[] = "wxPanelClass";
81 char wxCanvasClassName
[] = "wxCanvasClass";
83 HICON wxSTD_FRAME_ICON
= NULL
;
84 HICON wxSTD_MDICHILDFRAME_ICON
= NULL
;
85 HICON wxSTD_MDIPARENTFRAME_ICON
= NULL
;
87 HICON wxDEFAULT_FRAME_ICON
= NULL
;
88 HICON wxDEFAULT_MDICHILDFRAME_ICON
= NULL
;
89 HICON wxDEFAULT_MDIPARENTFRAME_ICON
= NULL
;
91 HBRUSH wxDisableButtonBrush
= 0;
93 LRESULT APIENTRY
wxWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
95 #if !USE_SHARED_LIBRARY
96 IMPLEMENT_DYNAMIC_CLASS(wxApp
, wxEvtHandler
)
98 BEGIN_EVENT_TABLE(wxApp
, wxEvtHandler
)
99 EVT_IDLE(wxApp::OnIdle
)
103 long wxApp::sm_lastMessageTime
= 0;
106 static HINSTANCE gs_hRichEdit
= NULL
;
111 bool wxApp::Initialize()
113 wxBuffer
= new char[1500];
116 #if defined(__WXDEBUG__) && defined(_MSC_VER)
117 // do check for memory leaks on program exit
118 // (another useful flag is _CRTDBG_DELAY_FREE_MEM_DF which doesn't free
119 // deallocated memory which may be used to simulate low-memory condition)
120 _CrtSetDbgFlag(_CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
121 #endif // debug build under MS VC++
124 #if (WXDEBUG && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
126 streambuf
* sBuf
= NULL
;
128 streambuf
* sBuf
= new wxDebugStreamBuf
;
131 ostream
* oStr
= new ostream(sBuf
) ;
132 wxDebugContext::SetStream(oStr
, sBuf
);
133 #endif // wxUSE_MEMORY_TRACING
135 wxClassInfo::InitializeClasses();
138 wxGetResource("wxWindows", "OsVersion", &wxOsVersion
);
141 wxTheColourDatabase
= new wxColourDatabase(wxKEY_STRING
);
142 wxTheColourDatabase
->Initialize();
144 wxInitializeStockLists();
145 wxInitializeStockObjects();
147 #if wxUSE_WX_RESOURCES
148 wxInitializeResourceSystem();
151 wxBitmap::InitStandardHandlers();
153 #if defined(__WIN95__)
154 InitCommonControls();
155 gs_hRichEdit
= LoadLibrary("RICHED32.DLL");
157 if (gs_hRichEdit
== NULL
)
159 wxMessageBox("Could not initialise Rich Edit DLL");
163 #if defined(WX_DRAG_DROP)
164 // we need to initialize OLE library
165 if ( FAILED(::OleInitialize(NULL
)) )
166 wxFatalError(_("Cannot initialize OLE"));
170 if (!Ctl3dRegister(wxhInstance
))
171 wxFatalError("Cannot register CTL3D");
173 Ctl3dAutoSubclass(wxhInstance
);
176 g_globalCursor
= new wxCursor
;
178 wxSTD_FRAME_ICON
= LoadIcon(wxhInstance
, "wxSTD_FRAME");
179 wxSTD_MDIPARENTFRAME_ICON
= LoadIcon(wxhInstance
, "wxSTD_MDIPARENTFRAME");
180 wxSTD_MDICHILDFRAME_ICON
= LoadIcon(wxhInstance
, "wxSTD_MDICHILDFRAME");
182 wxDEFAULT_FRAME_ICON
= LoadIcon(wxhInstance
, "wxDEFAULT_FRAME");
183 wxDEFAULT_MDIPARENTFRAME_ICON
= LoadIcon(wxhInstance
, "wxDEFAULT_MDIPARENTFRAME");
184 wxDEFAULT_MDICHILDFRAME_ICON
= LoadIcon(wxhInstance
, "wxDEFAULT_MDICHILDFRAME");
186 RegisterWindowClasses();
188 // Create the brush for disabling bitmap buttons
191 lb
.lbStyle
= BS_PATTERN
;
192 lb
.lbHatch
= (int)LoadBitmap( wxhInstance
, "wxDISABLE_BUTTON_BITMAP" ) ;
193 wxDisableButtonBrush
= ::CreateBrushIndirect( & lb
) ;
194 ::DeleteObject( (HGDIOBJ
)lb
.lbHatch
) ;
200 wxWinHandleList
= new wxList(wxKEY_INTEGER
);
202 // This is to foil optimizations in Visual C++ that
203 // throw out dummy.obj.
204 #if (_MSC_VER >= 800) && !defined(WXMAKINGDLL)
205 extern char wxDummyChar
;
206 if (wxDummyChar
) wxDummyChar
++;
209 wxSetKeyboardHook(TRUE
);
211 wxModule::RegisterModules();
212 if (!wxModule::InitializeModules())
217 //// RegisterWindowClasses
219 bool wxApp::RegisterWindowClasses()
221 ///////////////////////////////////////////////////////////////////////
222 // Register the frame window class.
223 WNDCLASS wndclass
; // Structure used to register Windows class.
225 wndclass
.style
= CS_HREDRAW
| CS_VREDRAW
;
226 wndclass
.lpfnWndProc
= (WNDPROC
)wxWndProc
;
227 wndclass
.cbClsExtra
= 0;
228 wndclass
.cbWndExtra
= sizeof( DWORD
); // was 4
229 wndclass
.hInstance
= wxhInstance
;
230 wndclass
.hIcon
= NULL
; // wxSTD_FRAME_ICON;
231 wndclass
.hCursor
= LoadCursor( NULL
, IDC_ARROW
);
232 wndclass
.hbrBackground
= (HBRUSH
)(COLOR_APPWORKSPACE
+1) ;
233 // wndclass.hbrBackground = GetStockObject( WHITE_BRUSH );
234 wndclass
.lpszMenuName
= NULL
;
235 #ifdef _MULTIPLE_INSTANCES
236 sprintf( wxFrameClassName
,"wxFrameClass%d", wxhInstance
);
238 wndclass
.lpszClassName
= wxFrameClassName
;
240 if (!RegisterClass( &wndclass
))
242 // wxFatalError("Can't register Frame Window class");
245 ///////////////////////////////////////////////////////////////////////
246 // Register the MDI frame window class.
247 WNDCLASS wndclass1
; // Structure used to register Windows class.
249 wndclass1
.style
= CS_HREDRAW
| CS_VREDRAW
;
250 wndclass1
.lpfnWndProc
= (WNDPROC
)wxWndProc
;
251 wndclass1
.cbClsExtra
= 0;
252 wndclass1
.cbWndExtra
= sizeof( DWORD
); // was 4
253 wndclass1
.hInstance
= wxhInstance
;
254 wndclass1
.hIcon
= NULL
; // wxSTD_MDIPARENTFRAME_ICON;
255 wndclass1
.hCursor
= LoadCursor( NULL
, IDC_ARROW
);
256 // wndclass1.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE+1) ;
257 wndclass1
.hbrBackground
= NULL
;
258 wndclass1
.lpszMenuName
= NULL
;
260 wndclass1
.lpszClassName
= wxMDIFrameClassName
;
261 if (!RegisterClass( &wndclass1
))
263 // wxFatalError("Can't register MDI Frame window class");
267 ///////////////////////////////////////////////////////////////////////
268 // Register the MDI child frame window class.
269 WNDCLASS wndclass4
; // Structure used to register Windows class.
271 wndclass4
.style
= CS_HREDRAW
| CS_VREDRAW
;
272 wndclass4
.lpfnWndProc
= (WNDPROC
)wxWndProc
;
273 wndclass4
.cbClsExtra
= 0;
274 wndclass4
.cbWndExtra
= sizeof( DWORD
); // was 4
275 wndclass4
.hInstance
= wxhInstance
;
276 wndclass4
.hIcon
= NULL
; // wxSTD_MDICHILDFRAME_ICON;
277 wndclass4
.hCursor
= LoadCursor( NULL
, IDC_ARROW
);
278 // TODO: perhaps this should be NULL so that Windows doesn't
279 // paint the background itself (would OnEraseBackground duplicate
281 wndclass4
.hbrBackground
= (HBRUSH
)(COLOR_WINDOW
+1) ;
282 // wndclass4.hbrBackground = NULL;
283 wndclass4
.lpszMenuName
= NULL
;
284 wndclass4
.lpszClassName
= wxMDIChildFrameClassName
;
286 if (!RegisterClass( &wndclass4
))
288 // wxFatalError("Can't register MDI child frame window class");
292 ///////////////////////////////////////////////////////////////////////
293 // Register the panel window class.
294 WNDCLASS wndclass2
; // Structure used to register Windows class.
295 memset(&wndclass2
, 0, sizeof(WNDCLASS
)); // start with NULL defaults
296 // Use CS_OWNDC to avoid messing about restoring the context
297 // for every graphic operation.
298 wndclass2
.style
= CS_HREDRAW
| CS_VREDRAW
;
299 wndclass2
.lpfnWndProc
= (WNDPROC
)wxWndProc
;
300 wndclass2
.cbClsExtra
= 0;
301 wndclass2
.cbWndExtra
= sizeof( DWORD
); // was 4
302 wndclass2
.hInstance
= wxhInstance
;
303 wndclass2
.hIcon
= NULL
;
304 wndclass2
.hCursor
= NULL
;
305 // wndclass2.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1) ;
306 wndclass2
.hbrBackground
= (HBRUSH
) GetStockObject( LTGRAY_BRUSH
);
307 wndclass2
.lpszMenuName
= NULL
;
308 wndclass2
.lpszClassName
= wxPanelClassName
;
309 if (!RegisterClass( &wndclass2
))
311 // wxFatalError("Can't register Panel Window class");
315 ///////////////////////////////////////////////////////////////////////
316 // Register the canvas and textsubwindow class name
317 WNDCLASS wndclass3
; // Structure used to register Windows class.
318 memset(&wndclass3
, 0, sizeof(WNDCLASS
)); // start with NULL defaults
319 // Use CS_OWNDC to avoid messing about restoring the context
320 // for every graphic operation.
321 // wndclass3.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS ;
323 wndclass3
.style
= CS_HREDRAW
| CS_VREDRAW
| CS_DBLCLKS
;
324 wndclass3
.lpfnWndProc
= (WNDPROC
)wxWndProc
;
325 wndclass3
.cbClsExtra
= 0;
326 wndclass3
.cbWndExtra
= sizeof( DWORD
); // was 4
327 wndclass3
.hInstance
= wxhInstance
;
328 wndclass3
.hIcon
= NULL
;
329 wndclass3
.hCursor
= NULL
;
330 // wndclass3.hbrBackground = (HBRUSH)(COLOR_WINDOW+1) ;
331 wndclass3
.hbrBackground
= NULL
;
332 wndclass3
.lpszMenuName
= NULL
;
333 wndclass3
.lpszClassName
= wxCanvasClassName
;
334 if (!RegisterClass( &wndclass3
))
336 // wxFatalError("Can't register Canvas class");
343 //// Convert Windows to argc, argv style
345 // FIXME this code should be rewritten (use wxArrayString instead...)
346 void wxApp::ConvertToStandardCommandArgs(char* lpCmdLine
)
348 // Split command line into tokens, as in usual main(argc, argv)
349 char **command
= new char*[50]; // VZ: sure? why not 25 or 73 and a half??
352 char *buf
= new char[strlen(lpCmdLine
) + 1];
354 /* Model independent strcpy */
356 for (i
= 0; (buf
[i
] = lpCmdLine
[i
]) != 0; i
++)
361 // Get application name
362 char name
[260]; // 260 is MAX_PATH value from windef.h
363 ::GetModuleFileName(wxhInstance
, name
, WXSIZEOF(name
));
365 // Is it only 16-bit Borland that already copies the program name
366 // to the first argv index?
367 #if !defined(__GNUWIN32__)
368 // #if ! (defined(__BORLANDC__) && !defined(__WIN32__))
369 command
[count
++] = copystring(name
);
373 strcpy(name
, wxFileNameFromPath(name
));
374 wxStripExtension(name
);
375 wxTheApp
->SetAppName(name
);
377 /* Break up string */
378 // Treat strings enclosed in double-quotes as single arguments
383 if ( count == WXSIZEOF(command) )
385 wxFAIL_MSG("too many command line args.");
389 while ( *str
&& isspace(*str
) ) // skip whitespace
395 command
[count
++] = str
;
396 while (*str
&& *str
!= '"')
401 command
[count
++] = str
;
402 while (*str
&& !isspace(*str
))
409 wxTheApp
->argv
= new char*[count
+ 1];
410 wxTheApp
->argv
[count
] = NULL
; /* argv[] is NULL terminated list! */
411 wxTheApp
->argc
= count
;
413 for (i
= 0; i
< count
; i
++)
415 wxTheApp
->argv
[i
] = copystring(command
[i
]);
417 delete [] command
[i
];
424 //// Cleans up any wxWindows internal structures left lying around
426 void wxApp::CleanUp()
429 wxModule::CleanUpModules();
431 #if wxUSE_WX_RESOURCES
432 wxCleanUpResourceSystem();
434 // wxDefaultResourceTable->ClearTable();
437 // Indicate that the cursor can be freed,
438 // so that cursor won't be deleted by deleting
439 // the bitmap list before g_globalCursor goes out
440 // of scope (double deletion of the cursor).
441 wxSetCursor(wxNullCursor
);
442 delete g_globalCursor
;
444 wxDeleteStockObjects() ;
446 // Destroy all GDI lists, etc.
447 wxDeleteStockLists();
449 delete wxTheColourDatabase
;
450 wxTheColourDatabase
= NULL
;
452 wxBitmap::CleanUpHandlers();
457 //// WINDOWS-SPECIFIC CLEANUP
459 wxSetKeyboardHook(FALSE
);
462 if (gs_hRichEdit
!= NULL
)
463 FreeLibrary(gs_hRichEdit
);
470 if (wxSTD_FRAME_ICON
)
471 DestroyIcon(wxSTD_FRAME_ICON
);
472 if (wxSTD_MDICHILDFRAME_ICON
)
473 DestroyIcon(wxSTD_MDICHILDFRAME_ICON
);
474 if (wxSTD_MDIPARENTFRAME_ICON
)
475 DestroyIcon(wxSTD_MDIPARENTFRAME_ICON
);
477 if (wxDEFAULT_FRAME_ICON
)
478 DestroyIcon(wxDEFAULT_FRAME_ICON
);
479 if (wxDEFAULT_MDICHILDFRAME_ICON
)
480 DestroyIcon(wxDEFAULT_MDICHILDFRAME_ICON
);
481 if (wxDEFAULT_MDIPARENTFRAME_ICON
)
482 DestroyIcon(wxDEFAULT_MDIPARENTFRAME_ICON
);
484 if ( wxDisableButtonBrush
)
485 ::DeleteObject( wxDisableButtonBrush
) ;
487 #if defined(WX_DRAG_DROP)
492 Ctl3dUnregister(wxhInstance
);
496 delete wxWinHandleList
;
498 wxClassInfo::CleanUpClasses();
500 // do it as the very last thing because everything else can log messages
501 wxLog::DontCreateOnDemand();
502 delete wxLog::SetActiveTarget(NULL
);
505 #if !defined(_WINDLL) || (defined(_WINDLL) && defined(WXMAKINGDLL))
507 //// Main wxWindows entry point
508 int wxEntry(WXHINSTANCE hInstance
,
509 WXHINSTANCE
WXUNUSED(hPrevInstance
),
514 #ifndef __WXDEBUG__ // take everything into a try-except block in release build
518 wxhInstance
= (HINSTANCE
) hInstance
;
520 if (!wxApp::Initialize())
523 // create the application object or ensure that one already exists
526 // The app may have declared a global application object, but we recommend
527 // the IMPLEMENT_APP macro is used instead, which sets an initializer
528 // function for delayed, dynamic app object construction.
529 wxCHECK_MSG( wxApp::GetInitializerFunction(), 0,
530 "No initializer - use IMPLEMENT_APP macro." );
532 wxTheApp
= (*wxApp::GetInitializerFunction()) ();
535 wxCHECK_MSG( wxTheApp
, 0, "You have to define an instance of wxApp!" );
537 // save the WinMain() parameters
538 wxTheApp
->ConvertToStandardCommandArgs(lpCmdLine
);
539 wxTheApp
->m_nCmdShow
= nCmdShow
;
541 // GUI-specific initialisation. In fact on Windows we don't have any,
542 // but this call is provided for compatibility across platforms.
543 wxTheApp
->OnInitGui() ;
547 if ( wxTheApp
->OnInit() )
551 retValue
= wxTheApp
->OnRun();
554 //else: app initialization failed, so we skipped OnRun()
556 wxWindow
*topWindow
= wxTheApp
->GetTopWindow();
559 // Forcibly delete the window.
560 if ( topWindow
->IsKindOf(CLASSINFO(wxFrame
)) ||
561 topWindow
->IsKindOf(CLASSINFO(wxDialog
)) )
563 topWindow
->Close(TRUE
);
564 wxTheApp
->DeletePendingObjects();
569 wxTheApp
->SetTopWindow(NULL
);
579 #if (WXDEBUG && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
580 // At this point we want to check if there are any memory
581 // blocks that aren't part of the wxDebugContext itself,
582 // as a special case. Then when dumping we need to ignore
583 // wxDebugContext, too.
584 if (wxDebugContext::CountObjectsLeft() > 0)
586 wxTrace("There were memory leaks.\n");
587 wxDebugContext::Dump();
588 wxDebugContext::PrintStatistics();
590 wxDebugContext::SetStream(NULL
, NULL
);
594 #ifndef __WXDEBUG__ // catch exceptions only in release build
596 except ( EXCEPTION_EXECUTE_HANDLER
) {
599 wxTheApp->OnFatalException();
602 ::ExitProcess(3); // the same exit code as abort()
609 //// Entry point for DLLs
611 int wxEntry(WXHINSTANCE hInstance
)
613 wxhInstance
= (HINSTANCE
) hInstance
;
616 // The app may have declared a global application object, but we recommend
617 // the IMPLEMENT_APP macro is used instead, which sets an initializer function
618 // for delayed, dynamic app object construction.
622 if (!wxApp::GetInitializerFunction())
624 MessageBox(NULL
, "No initializer - use IMPLEMENT_APP macro.", "wxWindows Error", MB_APPLMODAL
| MB_ICONSTOP
| MB_OK
);
628 wxTheApp
= (* wxApp::GetInitializerFunction()) ();
632 MessageBox(NULL
, "You have to define an instance of wxApp!", "wxWindows Error", MB_APPLMODAL
| MB_ICONSTOP
| MB_OK
);
637 wxTheApp
->argv
= NULL
;
639 wxTheApp
->OnInitGui();
643 if (wxTheApp
->GetTopWindow() && wxTheApp
->GetTopWindow()->GetHWND()) {
644 wxTheApp
->GetTopWindow()->Show(TRUE
);
651 //// Static member initialization
653 wxAppInitializerFunction
wxApp::m_appInitFn
= (wxAppInitializerFunction
) NULL
;
660 m_wantDebugOutput
= TRUE
;
665 m_printMode
= wxPRINT_WINDOWS
;
667 m_printMode
= wxPRINT_POSTSCRIPT
;
669 m_exitOnFrameDelete
= TRUE
;
675 // Delete command-line args
677 for (i
= 0; i
< argc
; i
++)
684 bool wxApp::Initialized()
692 #ifdef _WINDLL // Assume initialized if DLL (no way of telling)
698 * Get and process a message, returning FALSE if WM_QUIT
702 bool wxApp::DoMessage()
704 if (!::GetMessage(&s_currentMsg
, (HWND
) NULL
, 0, 0))
709 // Process the message
710 if (!ProcessMessage((WXMSG
*)&s_currentMsg
))
712 ::TranslateMessage(&s_currentMsg
);
713 wxApp::sm_lastMessageTime
= s_currentMsg
.time
; /* MATTHEW: timeStamp impl. */
714 ::DispatchMessage(&s_currentMsg
);
720 * Keep trying to process messages until WM_QUIT
723 * If there are messages to be processed, they will all be
724 * processed and OnIdle will not be called.
725 * When there are no more messages, OnIdle is called.
726 * If OnIdle requests more time,
727 * it will be repeatedly called so long as there are no pending messages.
728 * A 'feature' of this is that once OnIdle has decided that no more processing
729 * is required, then it won't get processing time until further messages
730 * are processed (it'll sit in DoMessage).
733 int wxApp::MainLoop()
738 while (!::PeekMessage(&s_currentMsg
, 0, 0, 0, PM_NOREMOVE
) &&
744 return s_currentMsg
.wParam
;
747 // Returns TRUE if more time is needed.
748 bool wxApp::ProcessIdle()
751 event
.SetEventObject(this);
754 return event
.MoreRequested();
757 void wxApp::ExitMainLoop()
762 bool wxApp::Pending()
764 return (::PeekMessage(&s_currentMsg
, 0, 0, 0, PM_NOREMOVE
) != 0) ;
767 void wxApp::Dispatch()
774 * Give all windows a chance to preprocess
775 * the message. Some may have accelerator tables, or have
778 bool wxApp::ProcessMessage(WXMSG
*Msg
)
780 MSG
*msg
= (MSG
*)Msg
;
784 // Try translations first; find the youngest window with
785 // a translation table.
786 for (hWnd
= msg
->hwnd
; hWnd
!= NULL
; hWnd
= ::GetParent(hWnd
))
788 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
791 if (wnd
->MSWTranslateMessage(Msg
))
796 // Anyone for a non-translation message? Try youngest descendants first.
797 for (hWnd
= msg
->hwnd
; hWnd
!= NULL
; hWnd
= ::GetParent(hWnd
))
799 wxWindow
*wnd
= wxFindWinFromHandle((WXHWND
) hWnd
);
802 if (wnd
->MSWProcessMessage(Msg
))
809 void wxApp::OnIdle(wxIdleEvent
& event
)
811 static bool inOnIdle
= FALSE
;
813 // Avoid recursion (via ProcessEvent default case)
819 // 'Garbage' collection of windows deleted with Close().
820 DeletePendingObjects();
822 // flush the logged messages if any
823 wxLog
*pLog
= wxLog::GetActiveTarget();
824 if ( pLog
!= NULL
&& pLog
->HasPendingMessages() )
827 // Send OnIdle events to all windows
828 bool needMore
= SendIdleEvents();
829 // bool needMore = FALSE;
832 event
.RequestMore(TRUE
);
837 // Send idle event to all top-level windows
838 bool wxApp::SendIdleEvents()
840 bool needMore
= FALSE
;
841 wxNode
* node
= wxTopLevelWindows
.First();
844 wxWindow
* win
= (wxWindow
*) node
->Data();
845 if (SendIdleEvents(win
))
853 // Send idle event to window and all subwindows
854 bool wxApp::SendIdleEvents(wxWindow
* win
)
856 bool needMore
= FALSE
;
859 event
.SetEventObject(win
);
860 win
->ProcessEvent(event
);
862 if (event
.MoreRequested())
865 wxNode
* node
= win
->GetChildren()->First();
868 wxWindow
* win
= (wxWindow
*) node
->Data();
869 if (SendIdleEvents(win
))
877 void wxApp::DeletePendingObjects()
879 wxNode
*node
= wxPendingDelete
.First();
882 wxObject
*obj
= (wxObject
*)node
->Data();
886 if (wxPendingDelete
.Member(obj
))
889 // Deleting one object may have deleted other pending
890 // objects, so start from beginning of list again.
891 node
= wxPendingDelete
.First();
895 wxLog
* wxApp::CreateLogTarget()
900 wxWindow
* wxApp::GetTopWindow() const
904 else if (wxTopLevelWindows
.Number() > 0)
905 return (wxWindow
*) wxTopLevelWindows
.First()->Data();
910 int wxApp::GetComCtl32Version() const
912 // have we loaded COMCTL32 yet?
913 HMODULE theModule
= ::GetModuleHandle("COMCTL32");
916 // if so, then we can check for the version
919 // InitCommonControlsEx is unique to 4.7 and later
920 FARPROC theProc
= ::GetProcAddress(theModule
, "InitCommonControlsEx");
923 { // not found, must be 4.00
928 // The following symbol are unique to 4.71
930 // FlatSB_EnableScrollBar FlatSB_GetScrollInfo FlatSB_GetScrollPos
931 // FlatSB_GetScrollProp FlatSB_GetScrollRange FlatSB_SetScrollInfo
932 // FlatSB_SetScrollPos FlatSB_SetScrollProp FlatSB_SetScrollRange
933 // FlatSB_ShowScrollBar
934 // _DrawIndirectImageList _DuplicateImageList
936 // UninitializeFlatSB
937 // we could check for any of these - I chose DllInstall
938 FARPROC theProc
= ::GetProcAddress(theModule
, "DllInstall");
941 // not found, must be 4.70
945 { // found, must be 4.71
956 FatalAppExit(0, "Fatal error: exiting");
959 // Yield to incoming messages
963 // We want to go back to the main message loop
964 // if we see a WM_QUIT. (?)
965 while (PeekMessage(&msg
, NULL
, 0, 0, PM_NOREMOVE
) && msg
.message
!= WM_QUIT
)
967 if (!wxTheApp
->DoMessage())
974 HINSTANCE
wxGetInstance()
979 // For some reason, with MSVC++ 1.5, WinMain isn't linked in properly
980 // if in a separate file. So include it here to ensure it's linked.
981 #if (defined(_MSC_VER) && !defined(__WIN32__)) || defined(__GNUWIN32__)