]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
Restored the ability to scroll.
[wxWidgets.git] / src / msw / window.cpp
index a4024565ad31b8d078e353702d6a2d80fc21c70f..161cdf53747fb725565b61bfd58c92a03504ebb9 100644 (file)
@@ -80,7 +80,7 @@
 
 #include <string.h>
 
 
 #include <string.h>
 
-#ifndef __GNUWIN32__
+#if !defined(__GNUWIN32__)|| defined(wxUSE_NORLANDER_HEADERS)
     #include <shellapi.h>
     #include <mmsystem.h>
 #endif
     #include <shellapi.h>
     #include <mmsystem.h>
 #endif
     #include <windowsx.h>
 #endif
 
     #include <windowsx.h>
 #endif
 
-#if ( defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__ )
+#if ( defined(__WIN95__) && !defined(__GNUWIN32__)) || defined(__TWIN32__ ) || defined(wxUSE_NORLANDER_HEADERS)
     #include <commctrl.h>
 #endif
 
 #ifndef __TWIN32__
     #ifdef __GNUWIN32__
     #include <commctrl.h>
 #endif
 
 #ifndef __TWIN32__
     #ifdef __GNUWIN32__
-        #include <wx/msw/gnuwin32/extra.h>
+        #ifndef wxUSE_NORLANDER_HEADERS
+            #include <wx/msw/gnuwin32/extra.h>
+        #endif
     #endif
 #endif
 
     #endif
 #endif
 
@@ -820,7 +822,7 @@ void wxWindow::UnsubclassWin()
     {
         m_hWnd = 0;
 
     {
         m_hWnd = 0;
 
-        wxCHECK_RET( ::IsWindow(hwnd), _T("invalid HWND in SubclassWin") );
+        wxCHECK_RET( ::IsWindow(hwnd), _T("invalid HWND in UnsubclassWin") );
 
         FARPROC farProc = (FARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
         if ( (m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc) )
 
         FARPROC farProc = (FARPROC) GetWindowLong(hwnd, GWL_WNDPROC);
         if ( (m_oldWndProc != 0) && (farProc != (FARPROC) m_oldWndProc) )
@@ -1115,12 +1117,9 @@ void wxWindow::DoGetPosition(int *x, int *y) const
 
         // We may be faking the client origin. So a window that's really at (0,
         // 30) may appear (to wxWin apps) to be at (0, 0).
 
         // We may be faking the client origin. So a window that's really at (0,
         // 30) may appear (to wxWin apps) to be at (0, 0).
-        if ( parent )
-        {
-            wxPoint pt(parent->GetClientAreaOrigin());
-            point.x -= pt.x;
-            point.y -= pt.y;
-        }
+        wxPoint pt(parent->GetClientAreaOrigin());
+        point.x -= pt.x;
+        point.y -= pt.y;
     }
 
     if ( x )
     }
 
     if ( x )
@@ -1372,10 +1371,14 @@ void wxWindow::GetTextExtent(const wxString& string,
 
     ReleaseDC(hWnd, dc);
 
 
     ReleaseDC(hWnd, dc);
 
-    if ( x ) *x = sizeRect.cx;
-    if ( y ) *y = sizeRect.cy;
-    if ( descent ) *descent = tm.tmDescent;
-    if ( externalLeading ) *externalLeading = tm.tmExternalLeading;
+    if ( x )
+        *x = sizeRect.cx;
+    if ( y )
+        *y = sizeRect.cy;
+    if ( descent )
+        *descent = tm.tmDescent;
+    if ( externalLeading )
+        *externalLeading = tm.tmExternalLeading;
 }
 
 #if wxUSE_CARET && WXWIN_COMPATIBILITY
 }
 
 #if wxUSE_CARET && WXWIN_COMPATIBILITY
@@ -1716,6 +1719,12 @@ LRESULT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARA
     // it with wxWindow stored in wxWndHook
     if ( !wnd && wxWndHook )
     {
     // it with wxWindow stored in wxWndHook
     if ( !wnd && wxWndHook )
     {
+#if 0 // def __WXDEBUG__
+        char buf[512];
+        ::GetClassNameA((HWND) hWnd, buf, 512);
+        wxString className(buf);
+#endif
+
         wxAssociateWinWithHandle(hWnd, wxWndHook);
         wnd = wxWndHook;
         wxWndHook = NULL;
         wxAssociateWinWithHandle(hWnd, wxWndHook);
         wnd = wxWndHook;
         wxWndHook = NULL;
@@ -2121,6 +2130,10 @@ wxWindow *wxFindWinFromHandle(WXHWND hWnd)
     return (wxWindow *)node->Data();
 }
 
     return (wxWindow *)node->Data();
 }
 
+#if 0 // def __WXDEBUG__
+static int gs_AssociationCount = 0;
+#endif
+
 void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
 {
     // adding NULL hWnd is (first) surely a result of an error and
 void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
 {
     // adding NULL hWnd is (first) surely a result of an error and
@@ -2128,12 +2141,33 @@ void wxAssociateWinWithHandle(HWND hWnd, wxWindow *win)
     wxCHECK_RET( hWnd != (HWND)NULL,
                  _T("attempt to add a NULL hWnd to window list ignored") );
 
     wxCHECK_RET( hWnd != (HWND)NULL,
                  _T("attempt to add a NULL hWnd to window list ignored") );
 
-    if ( !wxWinHandleList->Find((long)hWnd) )
+
+    wxWindow *oldWin = wxFindWinFromHandle((WXHWND) hWnd);
+    if ( oldWin && (oldWin != win) )
+    {
+        wxString str(win->GetClassInfo()->GetClassName());
+        wxLogError("Bug! Found existing HWND %X for new window of class %s", (int) hWnd, (const char*) str);
+    }
+    else if (!oldWin)
+    {
+#if 0 // def __WXDEBUG__
+        gs_AssociationCount ++;
+        wxLogDebug("+ Association %d", gs_AssociationCount);
+#endif
+
         wxWinHandleList->Append((long)hWnd, win);
         wxWinHandleList->Append((long)hWnd, win);
+    }
 }
 
 void wxRemoveHandleAssociation(wxWindow *win)
 {
 }
 
 void wxRemoveHandleAssociation(wxWindow *win)
 {
+#if 0 // def __WXDEBUG__
+    if (wxWinHandleList->Member(win))
+    {
+        wxLogDebug("- Association %d", gs_AssociationCount);
+        gs_AssociationCount --;
+    }
+#endif
     wxWinHandleList->DeleteObject(win);
 }
 
     wxWinHandleList->DeleteObject(win);
 }
 
@@ -2254,6 +2288,12 @@ bool wxWindow::MSWCreate(int id,
         if ( style & WS_CHILD )
             controlId = id;
 
         if ( style & WS_CHILD )
             controlId = id;
 
+        wxString className(wclass);
+        if ( GetWindowStyleFlag() & wxNO_FULL_REPAINT_ON_RESIZE )
+        {
+            className += _T("NR");
+        }
+
         m_hWnd = (WXHWND)CreateWindowEx(extendedStyle,
                                         wclass,
                                         title ? title : _T(""),
         m_hWnd = (WXHWND)CreateWindowEx(extendedStyle,
                                         wclass,
                                         title ? title : _T(""),
@@ -2275,7 +2315,18 @@ bool wxWindow::MSWCreate(int id,
     }
 
     wxWndHook = NULL;
     }
 
     wxWndHook = NULL;
-    wxWinHandleList->Append((long)m_hWnd, this);
+#ifdef __WXDEBUG__
+    wxNode* node = wxWinHandleList->Member(this);
+    if (node)
+    {
+        HWND hWnd = (HWND) node->GetKeyInteger();
+        if (hWnd != (HWND) m_hWnd)
+        {
+            wxLogError("A second HWND association is being added for the same window!");
+        }
+    }
+#endif
+    wxAssociateWinWithHandle((HWND) m_hWnd, this);
 
     return TRUE;
 }
 
     return TRUE;
 }
@@ -3313,8 +3364,11 @@ void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font)
         SelectObject(dc,was);
     }
     ReleaseDC((HWND)wnd, dc);
         SelectObject(dc,was);
     }
     ReleaseDC((HWND)wnd, dc);
-    *x = tm.tmAveCharWidth;
-    *y = tm.tmHeight + tm.tmExternalLeading;
+
+    if ( x )
+        *x = tm.tmAveCharWidth;
+    if ( y )
+        *y = tm.tmHeight + tm.tmExternalLeading;
 
     //  if ( the_font )
     //    the_font->ReleaseResource();
 
     //  if ( the_font )
     //    the_font->ReleaseResource();
@@ -3501,11 +3555,12 @@ void wxSetKeyboardHook(bool doIt)
     {
         wxTheKeyboardHookProc = MakeProcInstance((FARPROC) wxKeyboardHook, wxGetInstance());
         wxTheKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) wxTheKeyboardHookProc, wxGetInstance(),
     {
         wxTheKeyboardHookProc = MakeProcInstance((FARPROC) wxKeyboardHook, wxGetInstance());
         wxTheKeyboardHook = SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC) wxTheKeyboardHookProc, wxGetInstance(),
+
 #if defined(__WIN32__) && !defined(__TWIN32__)
             GetCurrentThreadId());
         //      (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
 #else
 #if defined(__WIN32__) && !defined(__TWIN32__)
             GetCurrentThreadId());
         //      (DWORD)GetCurrentProcess()); // This is another possibility. Which is right?
 #else
-        GetCurrentTask());
+            GetCurrentTask());
 #endif
     }
     else
 #endif
     }
     else