we must use TB_BUTTONSTRUCTSIZE before adding menu items to the toolbar; also send SHCMBM_GETMENU after creating the menus, otherwise it always returns NULL
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@47816 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -927,41 +927,41 @@ WXHMENU wxMenuBar::Create()
|
||||
if ( m_hMenu != 0 )
|
||||
return m_hMenu;
|
||||
|
||||
if (!GetToolBar())
|
||||
return 0;
|
||||
wxToolMenuBar * const bar = wx_static_cast(wxToolMenuBar *, GetToolBar());
|
||||
if ( !bar )
|
||||
return NULL;
|
||||
|
||||
HWND hCommandBar = (HWND) GetToolBar()->GetHWND();
|
||||
HMENU hMenu = (HMENU)::SendMessage(hCommandBar, SHCMBM_GETMENU, (WPARAM)0, (LPARAM)0);
|
||||
HWND hCommandBar = GetHwndOf(bar);
|
||||
|
||||
// notify comctl32.dll about the version of the headers we use before using
|
||||
// any other TB_XXX messages
|
||||
SendMessage(hCommandBar, TB_BUTTONSTRUCTSIZE, sizeof(TBBUTTON), 0);
|
||||
|
||||
// hMenu may be zero on Windows Mobile 5. So add the menus anyway.
|
||||
if (1) // (hMenu)
|
||||
{
|
||||
TBBUTTON tbButton;
|
||||
memset(&tbButton, 0, sizeof(TBBUTTON));
|
||||
wxZeroMemory(tbButton);
|
||||
tbButton.iBitmap = I_IMAGENONE;
|
||||
tbButton.fsState = TBSTATE_ENABLED;
|
||||
tbButton.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW | TBSTYLE_AUTOSIZE;
|
||||
tbButton.fsStyle = TBSTYLE_DROPDOWN |
|
||||
TBSTYLE_NO_DROPDOWN_ARROW |
|
||||
TBSTYLE_AUTOSIZE;
|
||||
|
||||
size_t i;
|
||||
for (i = 0; i < GetMenuCount(); i++)
|
||||
for ( unsigned i = 0; i < GetMenuCount(); i++ )
|
||||
{
|
||||
HMENU hPopupMenu = (HMENU) GetMenu(i)->GetHMenu();
|
||||
tbButton.dwData = (DWORD)hPopupMenu;
|
||||
wxString label = wxStripMenuCodes(GetLabelTop(i));
|
||||
tbButton.iString = (int) label.wx_str();
|
||||
|
||||
int position = i;
|
||||
|
||||
tbButton.idCommand = NewControlId();
|
||||
if (!::SendMessage(hCommandBar, TB_INSERTBUTTON, position, (LPARAM)&tbButton))
|
||||
if ( !::SendMessage(hCommandBar, TB_INSERTBUTTON, i, (LPARAM)&tbButton) )
|
||||
{
|
||||
wxLogLastError(wxT("TB_INSERTBUTTON"));
|
||||
}
|
||||
}
|
||||
}
|
||||
m_hMenu = (WXHMENU) hMenu;
|
||||
|
||||
m_hMenu = bar->GetHMenu();
|
||||
return m_hMenu;
|
||||
#else
|
||||
#else // !__WXWINCE__
|
||||
if ( m_hMenu != 0 )
|
||||
return m_hMenu;
|
||||
|
||||
@@ -987,7 +987,7 @@ WXHMENU wxMenuBar::Create()
|
||||
}
|
||||
|
||||
return m_hMenu;
|
||||
#endif
|
||||
#endif // __WXWINCE__/!__WXWINCE__
|
||||
}
|
||||
|
||||
int wxMenuBar::MSWPositionForWxMenu(wxMenu *menu, int wxpos)
|
||||
|
Reference in New Issue
Block a user