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:
{
wxMenuItem *pMenuItem = (wxMenuItem *)(pMeasureStruct->itemData);
- wxCHECK_MSG( pMenuItem && pMenuItem->IsKindOf(CLASSINFO(wxMenuItem)),
+ // according to Carsten Fuchs the pointer may be NULL under XP if an
+ // MDI child frame is initially maximized, see this for more info:
+ // http://article.gmane.org/gmane.comp.lib.wxwidgets.general/27745
+ //
+ // so silently ignore it instead of asserting
+ if ( !pMenuItem )
+ return false;
+
+ wxCHECK_MSG( wxDynamicCast(pMenuItem, wxMenuItem),
false, _T("MSWOnMeasureItem: bad wxMenuItem pointer") );
size_t w, h;
#ifndef __WXMICROWIN__
-bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush, WXHDC pDC, WXHWND pWnd)
+bool wxWindowMSW::HandleCtlColor(WXHBRUSH *brush, WXHDC hDC, WXHWND hWnd)
{
-#if wxUSE_CONTROLS
- wxControl *item = wxDynamicCast(FindItemByHWND(pWnd, true), wxControl);
+#if !wxUSE_CONTROLS || defined(__WXUNIVERSAL__)
+ wxUnusedVar(hDC);
+ wxUnusedVar(hWnd);
+#else
+ wxControl *item = wxDynamicCast(FindItemByHWND(hWnd, true), wxControl);
if ( item )
- *brush = item->MSWControlColor(pDC);
+ *brush = item->MSWControlColor(hDC, hWnd);
else
#endif // wxUSE_CONTROLS
*brush = NULL;
}
WXHBRUSH
-wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), wxWindow *child)
+wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), WXHWND hWnd)
{
if ( m_hasBgCol )
{
// children because it would look wrong if a child of non
// transparent child would show our bg colour when the child itself
// does not
- if ( child == this ||
+ wxWindow *win = wxFindWinFromHandle(hWnd);
+ if ( win == this ||
m_inheritBgCol ||
- (child->HasTransparentBackground() &&
- child->GetParent() == this) )
+ (win && win->HasTransparentBackground() &&
+ win->GetParent() == this) )
{
// draw children with the same colour as the parent
wxBrush *
return 0;
}
-WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC, wxWindow *winToPaint)
+WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC, WXHWND hWndToPaint)
{
- if ( !winToPaint )
- winToPaint = this;
+ if ( !hWndToPaint )
+ hWndToPaint = GetHWND();
for ( wxWindowMSW *win = this; win; win = win->GetParent() )
{
- WXHBRUSH hBrush = win->MSWGetBgBrushForChild(hDC, winToPaint);
+ WXHBRUSH hBrush = win->MSWGetBgBrushForChild(hDC, hWndToPaint);
if ( hBrush )
return hBrush;
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
// ---------------------------------------------------------------------------