X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a37d422a667124e4cb9c7413deda637d3b1926ec..3baaf31317b1380ba9f33f8a23ff04bd20356d63:/src/msw/app.cpp diff --git a/src/msw/app.cpp b/src/msw/app.cpp index 72d8437e63..378dccbe3e 100644 --- a/src/msw/app.cpp +++ b/src/msw/app.cpp @@ -115,8 +115,7 @@ #define _WIN32_IE 0x0200 #endif -#if _WIN32_IE >= 0x0300 \ - && !( defined(__MINGW32__) && !wxCHECK_W32API_VERSION( 1, 0 ) ) +#if _WIN32_IE >= 0x0300 && !defined(__MINGW32__) #include #endif @@ -455,6 +454,96 @@ bool wxApp::RegisterWindowClasses() return TRUE; } +// --------------------------------------------------------------------------- +// UnregisterWindowClasses +// --------------------------------------------------------------------------- + +bool wxApp::UnregisterWindowClasses() +{ + bool retval = TRUE; + + // frame window class. + if ( !UnregisterClass(wxFrameClassName, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(frame)")); + + retval = FALSE; + } + + // "no redraw" frame + if ( !UnregisterClass(wxFrameClassNameNoRedraw, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(no redraw frame)")); + + return FALSE; + } + + // MDI frame window class. + if ( !UnregisterClass(wxMDIFrameClassName, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(MDI parent)")); + + retval = FALSE; + } + + // "no redraw" MDI frame + if ( !UnregisterClass(wxMDIFrameClassNameNoRedraw, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(no redraw MDI parent frame)")); + + retval = FALSE; + } + + // MDI child frame window class. + if ( !UnregisterClass(wxMDIChildFrameClassName, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(MDI child)")); + + retval = FALSE; + } + + // "no redraw" MDI child frame + if ( !UnregisterClass(wxMDIChildFrameClassNameNoRedraw, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(no redraw MDI child)")); + + retval = FALSE; + } + + // panel window class. + if ( !UnregisterClass(wxPanelClassName, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(panel)")); + + retval = FALSE; + } + + // no redraw panel window class. + if ( !UnregisterClass(wxPanelClassNameNR, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(no redraw panel)")); + + retval = FALSE; + } + + // canvas and textsubwindow class name + if ( !UnregisterClass(wxCanvasClassName, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(canvas)")); + + retval = FALSE; + } + + if ( !UnregisterClass(wxCanvasClassNameNR, wxhInstance) ) + { + wxLogLastError(wxT("UnregisterClass(no redraw canvas)")); + + retval = FALSE; + } + + return retval; +} + // --------------------------------------------------------------------------- // Convert Windows to argc, argv style // --------------------------------------------------------------------------- @@ -600,6 +689,14 @@ void wxApp::CleanUp() ::OleUninitialize(); #endif +#ifdef WXMAKINGDLL + // for an EXE the classes are unregistered when it terminates but DLL may + // be loaded several times (load/unload/load) into the same process in + // which case the registration will fail after the first time if we don't + // unregister the classes now + UnregisterWindowClasses(); +#endif // WXMAKINGDLL + #if wxUSE_CTL3D Ctl3dUnregister(wxhInstance); #endif @@ -1058,12 +1155,12 @@ bool wxApp::ProcessMessage(WXMSG *wxmsg) // we need to find the dialog containing this control as // IsDialogMessage() just eats all the messages (i.e. returns TRUE for // them) if we call it for the control itself - while ( ::GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD ) + while ( hwnd && ::GetWindowLong(hwnd, GWL_STYLE) & WS_CHILD ) { hwnd = ::GetParent(hwnd); } - return ::IsDialogMessage(hwnd, msg) != 0; + return hwnd && ::IsDialogMessage(hwnd, msg) != 0; } #if wxUSE_TOOLTIPS