]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
Correction in comment in closing #endif. Is VC++ 4 supported?
[wxWidgets.git] / src / msw / window.cpp
index 8681939a0186960884eb4238ce5ae027b5cb43c1..76b0b095edcad8f4aec147100b9e20eec079d463 100644 (file)
@@ -218,6 +218,18 @@ static void EnsureParentHasControlParentStyle(wxWindow *parent)
 
 #endif // !__WXWINCE__
 
+#ifdef __WXWINCE__
+// On Windows CE, GetCursorPos can return an error, so use this function
+// instead
+bool GetCursorPosWinCE(POINT* pt)
+{
+    DWORD pos = GetMessagePos();
+    pt->x = LOWORD(pos);
+    pt->y = HIWORD(pos);
+    return true;
+}
+#endif
+
 // ---------------------------------------------------------------------------
 // event tables
 // ---------------------------------------------------------------------------
@@ -470,7 +482,12 @@ wxWindowMSW::~wxWindowMSW()
             {
                 frame->SetLastFocus(NULL);
             }
-            break;
+
+            // apparently sometimes we can end up with our grand parent
+            // pointing to us as well: this is surely a bug in focus handling
+            // code but it's not clear where it happens so for now just try to
+            // fix it here by not breaking out of the loop
+            //break;
         }
     }
 #endif // __WXUNIVERSAL__
@@ -757,7 +774,11 @@ bool wxWindowMSW::SetCursor(const wxCursor& cursor)
 
         // Change the cursor NOW if we're within the correct window
         POINT point;
+#ifdef __WXWINCE__
+        ::GetCursorPosWinCE(&point);
+#else
         ::GetCursorPos(&point);
+#endif
 
         RECT rect = wxGetWindowRect(hWnd);
 
@@ -1235,7 +1256,11 @@ bool wxWindowMSW::IsMouseInWindow() const
 {
     // get the mouse position
     POINT pt;
+#ifdef __WXWINCE__
+    ::GetCursorPosWinCE(&pt);
+#else
     ::GetCursorPos(&pt);
+#endif
 
     // find the window which currently has the cursor and go up the window
     // chain until we find this window - or exhaust it
@@ -2319,30 +2344,7 @@ WXLRESULT wxWindowMSW::MSWWindowProc(WXUINT message, WXWPARAM wParam, WXLPARAM l
             break;
 
         case WM_PRINTCLIENT:
-            // we receive this message when DrawThemeParentBackground() is
-            // called from def window proc of several controls under XP and we
-            // must draw properly themed background here
-            //
-            // note that naively I'd expect filling the client rect with the
-            // brush returned by MSWGetBgBrush() work -- but for some reason it
-            // doesn't and we have to call parents MSWPrintChild() which is
-            // supposed to call DrawThemeBackground() with appropriate params
-            //
-            // also note that in this case lParam == PRF_CLIENT but we're
-            // clearly expected to paint the background and nothing else!
-            {
-                for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
-                {
-                    if ( win->MSWPrintChild((WXHDC)wParam, (wxWindow *)this) )
-                    {
-                        processed = true;
-                        break;
-                    }
-
-                    if ( win->IsTopLevel() || win->InheritsBackgroundColour() )
-                        break;
-                }
-            }
+            processed = HandlePrintClient((WXHDC)wParam);
             break;
 
         case WM_PAINT:
@@ -3513,7 +3515,11 @@ bool wxWindowMSW::HandleSetCursor(WXHWND WXUNUSED(hWnd),
     // first ask the user code - it may wish to set the cursor in some very
     // specific way (for example, depending on the current position)
     POINT pt;
+#ifdef __WXWINCE__
+    if ( !::GetCursorPosWinCE(&pt) )
+#else
     if ( !::GetCursorPos(&pt) )
+#endif
     {
         wxLogLastError(wxT("GetCursorPos"));
     }
@@ -3715,16 +3721,16 @@ bool wxWindowMSW::HandleDisplayChange()
 
 #ifndef __WXMICROWIN__
 
-bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush, WXHDC pDC, WXHWND hWnd)
+bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush, WXHDC hDC, WXHWND hWnd)
 {
 #if !wxUSE_CONTROLS || defined(__WXUNIVERSAL__)
-    wxUnusedVar(pDC);
+    wxUnusedVar(hDC);
     wxUnusedVar(hWnd);
 #else
     wxControl *item = wxDynamicCast(FindItemByHWND(hWnd, true), wxControl);
 
     if ( item )
-        *brush = item->MSWControlColor(pDC, hWnd);
+        *brush = item->MSWControlColor(hDC, hWnd);
     else
 #endif // wxUSE_CONTROLS
         *brush = NULL;
@@ -4062,6 +4068,31 @@ WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC, WXHWND hWndToPaint)
     return 0;
 }
 
+bool wxWindowMSW::HandlePrintClient(WXHDC hDC)
+{
+    // we receive this message when DrawThemeParentBackground() is
+    // called from def window proc of several controls under XP and we
+    // must draw properly themed background here
+    //
+    // note that naively I'd expect filling the client rect with the
+    // brush returned by MSWGetBgBrush() work -- but for some reason it
+    // doesn't and we have to call parents MSWPrintChild() which is
+    // supposed to call DrawThemeBackground() with appropriate params
+    //
+    // also note that in this case lParam == PRF_CLIENT but we're
+    // clearly expected to paint the background and nothing else!
+    for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
+    {
+        if ( win->MSWPrintChild(hDC, (wxWindow *)this) )
+            return true;
+
+        if ( win->IsTopLevel() || win->InheritsBackgroundColour() )
+            break;
+    }
+
+    return false;
+}
+
 // ---------------------------------------------------------------------------
 // moving and resizing
 // ---------------------------------------------------------------------------
@@ -4527,7 +4558,11 @@ void wxWindowMSW::GenerateMouseLeave()
         state |= MK_RBUTTON;
 
     POINT pt;
+#ifdef __WXWINCE__
+    if ( !::GetCursorPosWinCE(&pt) )
+#else
     if ( !::GetCursorPos(&pt) )
+#endif
     {
         wxLogLastError(_T("GetCursorPos"));
     }
@@ -4574,7 +4609,11 @@ wxKeyEvent wxWindowMSW::CreateKeyEvent(wxEventType evType,
 
     // translate the position to client coords
     POINT pt;
+#ifdef __WXWINCE__
+    GetCursorPosWinCE(&pt);
+#else
     GetCursorPos(&pt);
+#endif
     RECT rect;
     GetWindowRect(GetHwnd(),&rect);
     pt.x -= rect.left;
@@ -5795,7 +5834,11 @@ wxWindow* wxFindWindowAtPoint(const wxPoint& pt)
 wxPoint wxGetMousePosition()
 {
     POINT pt;
+#ifdef __WXWINCE__
+    GetCursorPosWinCE(&pt);
+#else
     GetCursorPos( & pt );
+#endif
 
     return wxPoint(pt.x, pt.y);
 }