X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/937013e0fd914d4c42f9f5ec98da665986b93dfa..2e771cb838a8d22a73d5316e9fecde25ede316a4:/src/msw/tbar95.cpp diff --git a/src/msw/tbar95.cpp b/src/msw/tbar95.cpp index be1e998141..16ebe1ffc1 100644 --- a/src/msw/tbar95.cpp +++ b/src/msw/tbar95.cpp @@ -44,8 +44,10 @@ #endif #include "wx/sysopt.h" +#include "wx/dcclient.h" #include "wx/msw/private.h" +#include "wx/msw/dc.h" #if wxUSE_UXTHEME #include "wx/msw/uxtheme.h" @@ -308,13 +310,6 @@ bool wxToolBar::MSWCreateToolbar(const wxPoint& pos, const wxSize& size) ::SendMessage(GetHwnd(), TB_SETEXTENDEDSTYLE, 0, TBSTYLE_EX_DRAWDDARROWS); #endif - // Fix a bug on e.g. the Silver theme on WinXP where control backgrounds - // are incorrectly drawn, by forcing the background to a specific colour. - int majorVersion, minorVersion; - wxGetOsVersion(& majorVersion, & minorVersion); - if (majorVersion < 6) - SetBackgroundColour(GetBackgroundColour()); - return true; } @@ -810,8 +805,8 @@ bool wxToolBar::Realize() TBREPLACEBITMAP replaceBitmap; replaceBitmap.hInstOld = NULL; replaceBitmap.hInstNew = NULL; - replaceBitmap.nIDOld = (UINT) oldToolBarBitmap; - replaceBitmap.nIDNew = (UINT) hBitmap; + replaceBitmap.nIDOld = (UINT_PTR)oldToolBarBitmap; + replaceBitmap.nIDNew = (UINT_PTR)hBitmap; replaceBitmap.nButtons = nButtons; if ( !::SendMessage(GetHwnd(), TB_REPLACEBITMAP, 0, (LPARAM) &replaceBitmap) ) @@ -840,7 +835,7 @@ bool wxToolBar::Realize() { TBADDBITMAP addBitmap; addBitmap.hInst = 0; - addBitmap.nID = (UINT) hBitmap; + addBitmap.nID = (UINT_PTR)hBitmap; if ( ::SendMessage(GetHwnd(), TB_ADDBITMAP, (WPARAM) nButtons, (LPARAM)&addBitmap) == -1 ) { @@ -920,7 +915,7 @@ bool wxToolBar::Realize() { const wxString& label = tool->GetLabel(); if ( !label.empty() ) - button.iString = (int)label.wx_str(); + button.iString = (INT_PTR)label.wx_str(); } button.idCommand = tool->GetId(); @@ -1543,7 +1538,11 @@ void wxToolBar::OnMouseEvent(wxMouseEvent& event) void wxToolBar::OnEraseBackground(wxEraseEvent& event) { RECT rect = wxGetClientRect(GetHwnd()); - HDC hdc = GetHdcOf((*event.GetDC())); + + wxDC *dc = event.GetDC(); + if (!dc) return; + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc->GetImpl(); + HDC hdc = GetHdcOf(*impl); int majorVersion, minorVersion; wxGetOsVersion(& majorVersion, & minorVersion); @@ -1594,7 +1593,10 @@ void wxToolBar::OnEraseBackground(wxEraseEvent& event) #endif // wxUSE_UXTHEME - if ( UseBgCol() || (GetMSWToolbarStyle() & TBSTYLE_TRANSPARENT) ) + // we need to always draw our background under XP, as otherwise it doesn't + // appear correctly with some themes (e.g. Zune one) + if ( majorVersion == 5 || + UseBgCol() || (GetMSWToolbarStyle() & TBSTYLE_TRANSPARENT) ) { // do draw our background // @@ -1775,8 +1777,9 @@ bool wxToolBar::HandlePaint(WXWPARAM wParam, WXLPARAM lParam) r.right = clientSize.x; r.top = 0; r.bottom = clientSize.y; - - HRESULT hr = theme->DrawThemeBackground(hTheme, (HDC) dc.GetHDC(), 0, 0, & r, & clipRect); + + wxMSWDCImpl *impl = (wxMSWDCImpl*) dc.GetImpl(); + HRESULT hr = theme->DrawThemeBackground(hTheme, GetHdcOf(*impl), 0, 0, & r, & clipRect); if ( hr == S_OK ) haveRefreshed = true; }