X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c3732409acc7a1e0b3cdb1f0a5dec7cc49a4b28b..97c153e44634a9b2b17614f85035205a0d9eaa46:/src/msw/window.cpp diff --git a/src/msw/window.cpp b/src/msw/window.cpp index 43d21ba44d..136e06c3c5 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -2319,30 +2319,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: @@ -3656,7 +3633,15 @@ wxWindowMSW::MSWOnMeasureItem(int id, WXMEASUREITEMSTRUCT *itemStruct) { 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; @@ -3707,13 +3692,16 @@ bool wxWindowMSW::HandleDisplayChange() #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; @@ -4003,7 +3991,7 @@ bool wxWindowMSW::DoEraseBackground(WXHDC hDC) } WXHBRUSH -wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), wxWindow *child) +wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), WXHWND hWnd) { if ( m_hasBgCol ) { @@ -4015,10 +4003,11 @@ wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), wxWindow *child) // 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 * @@ -4031,14 +4020,14 @@ wxWindowMSW::MSWGetBgBrushForChild(WXHDC WXUNUSED(hDC), wxWindow *child) 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; @@ -4050,6 +4039,31 @@ WXHBRUSH wxWindowMSW::MSWGetBgBrush(WXHDC hDC, wxWindow *winToPaint) 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 // ---------------------------------------------------------------------------