]> git.saurik.com Git - wxWidgets.git/commitdiff
added UnregisterWindowClasses() (patch 447443)
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 22 Aug 2001 14:42:54 +0000 (14:42 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 22 Aug 2001 14:42:54 +0000 (14:42 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11436 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/app.h
src/msw/app.cpp

index e7341edb9e8643589b49b061ed6dcfd6d06a88f7..dad32116b98f0e15d81a9d3902f18d28438fb23e 100644 (file)
@@ -77,6 +77,7 @@ public:
     static void CleanUp();
 
     static bool RegisterWindowClasses();
+    static bool UnregisterWindowClasses();
 
     // Convert Windows to argc, argv style
     void ConvertToStandardCommandArgs(char* p);
index 72d8437e63cf690832c1acdc218c5fd79db1c2b0..a0c1e2cda053e9716a7131d69fb0006899a5d0b8 100644 (file)
@@ -455,6 +455,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 +690,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