X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/03cc29918fa6d727cf4d635126adaeaca405f9af..8220f2f145758e44e84380767eb77723ab4ac5ef:/src/msw/menuitem.cpp diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index fb0369196d..a5233965bf 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -30,6 +30,8 @@ #include "wx/stockitem.h" #ifndef WX_PRECOMP + #include "wx/app.h" + #include "wx/dcmemory.h" #include "wx/font.h" #include "wx/bitmap.h" #include "wx/settings.h" @@ -239,6 +241,15 @@ public: static const MenuDrawData* Get() { + // notice that s_menuData can't be created as a global variable because + // it needs a window to initialize and no windows exist at the time of + // globals initialization yet + if ( !ms_instance ) + { + static MenuDrawData s_menuData; + ms_instance = &s_menuData; + } + #if wxUSE_UXTHEME bool theme = MenuLayout() == FullTheme; if ( ms_instance->Theme != theme ) @@ -249,7 +260,6 @@ public: MenuDrawData() { - ms_instance = this; Init(); } @@ -297,8 +307,6 @@ private: MenuDrawData* MenuDrawData::ms_instance = NULL; -MenuDrawData s_menuData; - void MenuDrawData::Init() { #if wxUSE_UXTHEME @@ -1035,7 +1043,7 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc, { if ( stat & wxODChecked ) { - DrawStdCheckMark(hdc, &rcImg, stat); + DrawStdCheckMark((WXHDC)hdc, &rcImg, stat); } } else @@ -1133,8 +1141,10 @@ void DrawColorCheckMark(HDC hdc, int x, int y, int cx, int cy, HDC hdcCheckMask, } // anonymous namespace -void wxMenuItem::DrawStdCheckMark(HDC hdc, const RECT* rc, wxODStatus stat) +void wxMenuItem::DrawStdCheckMark(WXHDC hdc_, const RECT* rc, wxODStatus stat) { + HDC hdc = (HDC)hdc_; + #if wxUSE_UXTHEME wxUxThemeEngine* theme = MenuDrawData::GetUxThemeEngine(); if ( theme )