#include <string.h>
#include <ctype.h>
-#if defined(__WIN95__) && !(defined(__GNUWIN32_OLD__) || defined(__TWIN32__))
+#if defined(__WIN95__) && !((defined(__GNUWIN32_OLD__) || defined(__TWIN32__)) && !defined(__CYGWIN10__))
#include <commctrl.h>
#endif
#endif // __WIN95__
-#if wxUSE_OLE
+#if wxUSE_OLE || wxUSE_DRAG_AND_DROP || wxUSE_DATAOBJ
#ifdef __WIN16__
// for OLE, enlarge message queue to be as large as possible
// we need to initialize OLE library
if ( FAILED(::OleInitialize(NULL)) )
wxLogError(_("Cannot initialize OLE"));
+
#endif // wxUSE_OLE
#if wxUSE_CTL3D
wxLogError(wxT("Cannot register CTL3D"));
Ctl3dAutoSubclass(wxhInstance);
-#endif
+#endif // wxUSE_CTL3D
// VZ: these icons are not in wx.rc anyhow (but should they?)!
#if 0
// GL: I'm annoyed ... I don't know where to put this and I don't want to
// create a module for that as it's part of the core.
delete wxPendingEvents;
+
#if wxUSE_THREADS
delete wxPendingEventsLocker;
- // If we don't do the following, we get an apparent memory leak.
+ // If we don't do the following, we get an apparent memory leak
+#if wxUSE_VALIDATORS
((wxEvtHandler&) wxDefaultValidator).ClearEventLocker();
-#endif
+#endif // wxUSE_VALIDATORS
+#endif // wxUSE_THREADS
wxClassInfo::CleanUpClasses();
int WXDLLEXPORT wxEntryInitGui()
{
- wxTheApp->OnInitGui();
- return 0;
+ return wxTheApp->OnInitGui();
}
void WXDLLEXPORT wxEntryCleanup()
wxTheApp->ConvertToStandardCommandArgs(lpCmdLine);
wxTheApp->m_nCmdShow = nCmdShow;
- // GUI-specific initialisation. In fact on Windows we don't have any,
- // but this call is provided for compatibility across platforms.
- wxEntryInitGui();
-
// We really don't want timestamps by default, because it means
// we can't simply double-click on the error message and get to that
// line in the source. So VC++ at least, let's have a sensible default.
wxTheApp->SetExitOnFrameDelete(FALSE);
// init the app
- retValue = wxTheApp->OnInit() ? 0 : -1;
+ retValue = wxEntryInitGui() && wxTheApp->OnInit() ? 0 : -1;
// restore the old flag value
wxTheApp->SetExitOnFrameDelete(exitOnLastFrameDelete);
wxApp::wxApp()
{
- m_topWindow = NULL;
- wxTheApp = this;
- m_wantDebugOutput = TRUE;
-
argc = 0;
argv = NULL;
m_printMode = wxPRINT_WINDOWS;
- m_exitOnFrameDelete = TRUE;
m_auto3D = TRUE;
}
#endif // wxUSE_THREADS
// Process the message
- if ( !ProcessMessage((WXMSG *)&s_currentMsg) )
- {
- ::TranslateMessage(&s_currentMsg);
- ::DispatchMessage(&s_currentMsg);
- }
+ DoMessage((WXMSG *)&s_currentMsg);
}
return TRUE;
}
+void wxApp::DoMessage(WXMSG *pMsg)
+{
+ if ( !ProcessMessage(pMsg) )
+ {
+ ::TranslateMessage((MSG *)pMsg);
+ ::DispatchMessage((MSG *)pMsg);
+ }
+}
+
/*
* Keep trying to process messages until WM_QUIT
* received.
// a translation table.
wxWindow *wnd;
+ bool pastTopLevelWindow = FALSE;
for ( wnd = wndThis; wnd; wnd = wnd->GetParent() )
{
- if ( wnd->MSWTranslateMessage(wxmsg) )
+ if ( !pastTopLevelWindow && wnd->MSWTranslateMessage(wxmsg))
return TRUE;
- }
-
- // Anyone for a non-translation message? Try youngest descendants first.
- for ( wnd = wndThis; wnd; wnd = wnd->GetParent() )
- {
if ( wnd->MSWProcessMessage(wxmsg) )
return TRUE;
+
+ // stop at first top level window, i.e. don't try to process the key
+ // strokes originating in a dialog using the accelerators of the parent
+ // frame - this doesn't make much sense
+ if ( wnd->IsTopLevel() )
+ pastTopLevelWindow = TRUE;
}
return FALSE;
}
// Yield to incoming messages
+
+static bool gs_inYield = FALSE;
+
bool wxYield()
{
// disable log flushing from here because a call to wxYield() shouldn't
// normally result in message boxes popping up &c
wxLog::Suspend();
+#ifdef __WXDEBUG__
+ if (gs_inYield)
+ wxFAIL_MSG( wxT("wxYield called recursively" ) );
+#endif
+
+ gs_inYield = TRUE;
+
// we don't want to process WM_QUIT from here - it should be processed in
// the main event loop in order to stop it
MSG msg;
// let the logs be flashed again
wxLog::Resume();
+ gs_inYield = FALSE;
+
return TRUE;
}
+// Yield to incoming messages; but fail silently if recursion is detected.
+bool wxYieldIfNeeded()
+{
+ if (gs_inYield)
+ return FALSE;
+
+ return wxYield();
+}
+
bool wxHandleFatalExceptions(bool doit)
{
#if wxUSE_ON_FATAL_EXCEPTION
return TRUE;
#else
wxFAIL_MSG(_T("set wxUSE_ON_FATAL_EXCEPTION to 1 to sue this function"));
-
+
+ (void)doit;
return FALSE;
#endif
}