X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/18138662efd0bc550d78cbe32e93e25b43bbcbd2..950905affdfa9041316f82308e1a11e82c783070:/src/msw/menu.cpp?ds=sidebyside diff --git a/src/msw/menu.cpp b/src/msw/menu.cpp index 0c2a54e3a9..ad2f91eac1 100644 --- a/src/msw/menu.cpp +++ b/src/msw/menu.cpp @@ -59,7 +59,25 @@ // other standard headers #include -#if wxUSE_OWNER_DRAWN && defined(MIIM_BITMAP) +//VC6 needs these defining, though they are in winuser.h +#ifndef MIIM_BITMAP +#define MIIM_STRING 0x00000040 +#define MIIM_BITMAP 0x00000080 +#define MIIM_FTYPE 0x00000100 +#define HBMMENU_CALLBACK ((HBITMAP) -1) +typedef struct tagMENUINFO +{ + DWORD cbSize; + DWORD fMask; + DWORD dwStyle; + UINT cyMax; + HBRUSH hbrBack; + DWORD dwContextHelpID; + DWORD dwMenuData; +} MENUINFO, FAR *LPMENUINFO; +#endif + +#if wxUSE_OWNER_DRAWN #include "wx/dynlib.h" #endif @@ -435,12 +453,10 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) { // try to use InsertMenuItem() as it's guaranteed to look correct // while our owner-drawn code is not - - // first compile-time check -#if defined(MIIM_BITMAP) && (_WIN32_WINNT >= 0x0500) +#ifndef __DMC__ + // DMC at march 2007 doesn't have HBITMAP hbmpItem tagMENUITEMINFOA /W + // MIIM_BITMAP only works under WinME/2000+ WinStruct mii; - - // now run-time one: MIIM_BITMAP only works under WinME/2000+ if ( wxGetWinVersion() >= wxWinVersion_98 ) { mii.fMask = MIIM_STRING | MIIM_DATA | MIIM_BITMAP; @@ -452,7 +468,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) } mii.cch = itemText.length(); - mii.dwTypeData = wx_const_cast(wxChar *, itemText.c_str()); + mii.dwTypeData = wx_const_cast(wxChar *, itemText.wx_str()); if (flags & MF_POPUP) { @@ -512,7 +528,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) pItem->ResetOwnerDrawn(); } } -#endif // MIIM_BITMAP +#endif // __DMC__ } if ( !ok ) @@ -532,7 +548,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos) itemText = wxMenuItem::GetLabelFromText(itemText); #endif - pData = (wxChar*)itemText.c_str(); + pData = (wxChar*)itemText.wx_str(); } // item might have already been inserted by InsertMenuItem() above @@ -715,7 +731,7 @@ void wxMenu::SetTitle(const wxString& label) if ( !label.empty() ) { if ( !::InsertMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING, - (unsigned)idMenuTitle, m_title) || + (unsigned)idMenuTitle, m_title.wx_str()) || !::InsertMenu(hMenu, 1u, MF_BYPOSITION, (unsigned)-1, NULL) ) { wxLogLastError(wxT("InsertMenu")); @@ -751,7 +767,7 @@ void wxMenu::SetTitle(const wxString& label) #else if ( !ModifyMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING, - (unsigned)idMenuTitle, m_title) ) + (unsigned)idMenuTitle, m_title.wx_str()) ) { wxLogLastError(wxT("ModifyMenu")); } @@ -782,10 +798,10 @@ bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id) if ( item && item->IsCheckable() ) item->Toggle(); - // get the checked status of the menu item: note that menuState is the - // old state of the menu, so the test for MF_CHECKED must be inverted + // get the status of the menu item: note that it has been just changed + // by Toggle() above so here we already get the new state of the item UINT menuState = ::GetMenuState(GetHmenu(), id, MF_BYCOMMAND); - SendEvent(id, !(menuState & MF_CHECKED)); + SendEvent(id, menuState & MF_CHECKED); } return true; @@ -963,7 +979,7 @@ WXHMENU wxMenuBar::Create() { if ( !::AppendMenu((HMENU)m_hMenu, MF_POPUP | MF_STRING, (UINT)(*it)->GetHMenu(), - m_titles[i]) ) + m_titles[i].wx_str()) ) { wxLogLastError(wxT("AppendMenu")); } @@ -1069,7 +1085,7 @@ void wxMenuBar::SetLabelTop(size_t pos, const wxString& label) #else if ( ::ModifyMenu(GetHmenu(), mswpos, MF_BYPOSITION | MF_STRING | flagsOld, - id, label) == (int)0xFFFFFFFF ) + id, label.wx_str()) == (int)0xFFFFFFFF ) { wxLogLastError(wxT("ModifyMenu")); } @@ -1114,7 +1130,7 @@ wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title) if ( !::InsertMenu(GetHmenu(), (UINT)mswpos, MF_BYPOSITION | MF_POPUP | MF_STRING, - (UINT)GetHmenuOf(menu), title) ) + (UINT)GetHmenuOf(menu), title.wx_str()) ) { wxLogLastError(wxT("InsertMenu")); } @@ -1181,7 +1197,7 @@ bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title) #else if ( !::InsertMenu(GetHmenu(), mswpos, MF_BYPOSITION | MF_POPUP | MF_STRING, - (UINT)GetHmenuOf(menu), title) ) + (UINT)GetHmenuOf(menu), title.wx_str()) ) { wxLogLastError(wxT("InsertMenu")); } @@ -1240,7 +1256,7 @@ bool wxMenuBar::Append(wxMenu *menu, const wxString& title) } #else if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING, - (UINT)submenu, title) ) + (UINT)submenu, title.wx_str()) ) { wxLogLastError(wxT("AppendMenu")); }