]> git.saurik.com Git - wxWidgets.git/commitdiff
making wxMSW MSLU(unicows)-friendly
authorVáclav Slavík <vslavik@fastmail.fm>
Mon, 17 Dec 2001 00:28:31 +0000 (00:28 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Mon, 17 Dec 2001 00:28:31 +0000 (00:28 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13043 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/private.h
src/msw/app.cpp
src/msw/fdrepdlg.cpp
src/msw/window.cpp

index 25d0b5d7869a3be917cdedd238737c645b81bb12..1e364e4b3c742428f49862d609697742d8f6d9a7 100644 (file)
@@ -391,6 +391,9 @@ WXDLLEXPORT extern wxString wxGetWindowClass(WXHWND hWnd);
 // is, for mainly historical reasons, signed)
 WXDLLEXPORT extern WXWORD wxGetWindowId(WXHWND hWnd);
 
+// check if hWnd's WNDPROC is wndProc. Return true if yes, false if they are different
+extern bool wxCheckWindowWndProc(WXHWND hWnd, WXFARPROC wndProc);
+
 // Does this window style specify any border?
 inline bool wxStyleHasBorder(long style)
 {
index c59675e7f6c7a2d8e9d301ca0187e11fa764b646..480bb9b54d2f54827412ce075a6375b2c579f4ac 100644 (file)
@@ -195,7 +195,7 @@ bool wxApp::Initialize()
     // the first thing to do is to check if we're trying to run an Unicode
     // program under Win9x - if so, abort right now as it has no chance to
     // work
-#if wxUSE_UNICODE
+#if wxUSE_UNICODE && !wxUSE_UNICODE_MSLU
     if ( wxGetOsVersion() != wxWINDOWS_NT )
     {
         // note that we can use MessageBoxW() as it's implemented even under
@@ -204,14 +204,14 @@ bool wxApp::Initialize()
         ::MessageBox
         (
          NULL,
-         _T("This program uses Unicode and requires Windows NT/2000.\nProgram aborted."),
+         _T("This program uses Unicode and requires Windows NT/2000/XP.\nProgram aborted."),
          _T("wxWindows Fatal Error"),
          MB_ICONERROR | MB_OK
         );
 
         return FALSE;
     }
-#endif // wxUSE_UNICODE
+#endif // wxUSE_UNICODE && !wxUSE_UNICODE_MSLU
 
     // Some people may wish to use this, but
     // probably it shouldn't be here by default.
index 13c4062c8c62c72d686db600e38beb28c8f3015f..5cc89364cd23e1dfd93960b74644ff48c981478d 100644 (file)
@@ -197,10 +197,9 @@ void wxFindReplaceDialogImpl::SubclassDialog(HWND hwnd)
 
     // check that we don't subclass the parent twice: this would be a bad idea
     // as then we'd have infinite recursion in wxFindReplaceWindowProc
-    WNDPROC oldParentWndProc = (WNDPROC)::GetWindowLong(hwnd, GWL_WNDPROC);
-
-    if ( oldParentWndProc != wxFindReplaceWindowProc )
+    if ( !wxCheckWindowWndProc((WXHWND)hwnd, (WXFARPROC)wxFindReplaceWindowProc) )
     {
+        WNDPROC oldParentWndProc = (WNDPROC)::GetWindowLong(hwnd, GWL_WNDPROC);
         // save old wnd proc elsewhere to access it from
         // wxFindReplaceWindowProc
         m_oldParentWndProc = oldParentWndProc;
index dd98fe4c43069099616a4337cc7b332a6cb9a9c3..4cfa88b3c9b8d4bf405f0f188916876a535c7496 100644 (file)
@@ -968,11 +968,11 @@ void wxWindowMSW::SubclassWin(WXHWND hWnd)
 
     wxAssociateWinWithHandle(hwnd, this);
 
-    m_oldWndProc = (WXFARPROC)::GetWindowLong(hwnd, GWL_WNDPROC);
-
+    m_oldWndProc = (WXFARPROC)::GetWindowLong((HWND)hWnd, GWL_WNDPROC);
+    
     // we don't need to subclass the window of our own class (in the Windows
     // sense of the word)
-    if ( (WXFARPROC) m_oldWndProc != (WXFARPROC) wxWndProc )
+    if ( !wxCheckWindowWndProc(hWnd, (WXFARPROC)wxWndProc) )
     {
         ::SetWindowLong(hwnd, GWL_WNDPROC, (LONG) wxWndProc);
     }
@@ -997,8 +997,7 @@ void wxWindowMSW::UnsubclassWin()
 
         if ( m_oldWndProc )
         {
-            FARPROC wndProc = (FARPROC)::GetWindowLong(hwnd, GWL_WNDPROC);
-            if ( wndProc != (FARPROC) m_oldWndProc )
+            if ( !wxCheckWindowWndProc((WXHWND)hwnd, m_oldWndProc) )
             {
                 ::SetWindowLong(hwnd, GWL_WNDPROC, (LONG) m_oldWndProc);
             }
@@ -1008,6 +1007,35 @@ void wxWindowMSW::UnsubclassWin()
     }
 }
 
+bool wxCheckWindowWndProc(WXHWND hWnd, WXFARPROC wndProc)
+{
+#if wxUSE_UNICODE_MSLU
+    // VS: We can't use GetWindowLong(hwnd, GWL_WNDPROC) together with unicows.dll
+    //     because it doesn't return pointer to the real wnd proc but rather a handle
+    //     of a fake proc that does Unicode<->ANSI translation.
+    //
+    //     The hack bellow works, because WNDCLASS contains original window handler
+    //     rather that the unicows fake one. This may not be on purpose, though; if
+    //     it stops working with future versions of unicows.dll, we can override
+    //     unicows hooks by setting Unicows_{Set,Get}WindowLong and
+    //     Unicows_RegisterClass to our own versions that keep track of
+    //     fake<->real wnd proc mapping.
+    //
+    //     FIXME: Doesn't handle wnd procs set by SetWindowLong, only these set
+    //            with RegisterClass!!
+
+    static wxChar buffer[512];
+    WNDCLASS cls;
+
+    ::GetClassName((HWND)hWnd, buffer, 512);
+    ::GetClassInfo(wxGetInstance(), buffer, &cls);
+    return wndProc == (WXFARPROC)cls.lpfnWndProc;
+#else
+    return wndProc == (WXFARPROC)::GetWindowLong((HWND)hWnd, GWL_WNDPROC);
+#endif
+}
+
+
 // Make a Windows extended style from the given wxWindows window style
 WXDWORD wxWindowMSW::MakeExtendedStyle(long style, bool eliminateBorders)
 {