]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/window.cpp
updates from Adrián González Alba
[wxWidgets.git] / src / msw / window.cpp
index 2a8c8e308228e5f08f12ae50ab1807d5b48e1e43..0515fe88be44d7bea076d5e4aab2b57e8213ebbe 100644 (file)
@@ -2146,14 +2146,17 @@ bool wxWindowMSW::MSWProcessMessage(WXMSG* pMsg)
                         else // not a button itself
                         {
 #if wxUSE_BUTTON
-                            wxButton *btn = wxDynamicCast(GetDefaultItem(),
-                                                          wxButton);
-                            if ( btn && btn->IsEnabled() )
+                            wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+                            if ( tlw )
                             {
-                                // if we do have a default button, do press it
-                                btn->MSWCommand(BN_CLICKED, 0 /* unused */);
+                                wxButton *btn = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
+                                if ( btn && btn->IsEnabled() )
+                                {
+                                    // if we do have a default button, do press it
+                                    btn->MSWCommand(BN_CLICKED, 0 /* unused */);
 
-                                return true;
+                                    return true;
+                                }
                             }
                             else // no default button
 #endif // wxUSE_BUTTON
@@ -4409,37 +4412,11 @@ WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC, WXHWND hWndToPaint)
     return 0;
 }
 
-bool wxWindowMSW::HandlePrintClient(WXHDC hDC)
+bool wxWindowMSW::HandlePrintClient(WXHDC WXUNUSED(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!
-
-    if ( IsTopLevel() || InheritsBackgroundColour() )
-        return false;
-
-    // sometimes we don't want the parent to handle it at all, instead
-    // return whatever value this window wants
-    if ( !MSWShouldPropagatePrintChild() )
-        return MSWPrintChild(hDC, (wxWindow *)this);
-
-    for ( wxWindow *win = GetParent(); win; win = win->GetParent() )
-    {
-        if ( win->MSWPrintChild(hDC, (wxWindow *)this) )
-            return true;
-
-        if ( win->IsTopLevel() || win->InheritsBackgroundColour() )
-            break;
-    }
-
+    // TODO: handle wxBG_STYLE_CUSTOM and/or wxBG_STYLE_COLOUR here so when
+    // DrawParentThemeBackground() from uxtheme.dll is called we don't get
+    // the default background e.g. the border when custom drawing buttons
     return false;
 }