allow calling SetItemLabel() for items not attached to the menu or menu bar yet (comment 9 of #10452)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@58574 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -358,13 +358,18 @@ void wxMenuItem::SetItemLabel(const wxString& txt)
|
|||||||
SetAccelString(m_text.AfterFirst(_T('\t')));
|
SetAccelString(m_text.AfterFirst(_T('\t')));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
HMENU hMenu = GetHMenuOf(m_parentMenu);
|
|
||||||
wxCHECK_RET( hMenu, wxT("menuitem without menu") );
|
|
||||||
|
|
||||||
#if wxUSE_ACCEL
|
#if wxUSE_ACCEL
|
||||||
m_parentMenu->UpdateAccel(this);
|
if ( m_parentMenu )
|
||||||
|
m_parentMenu->UpdateAccel(this);
|
||||||
#endif // wxUSE_ACCEL
|
#endif // wxUSE_ACCEL
|
||||||
|
|
||||||
|
// the item can be not attached to any menu yet and SetItemLabel() is still
|
||||||
|
// valid to call in this case and should do nothing else
|
||||||
|
const UINT id = GetMSWId();
|
||||||
|
HMENU hMenu = GetHMenuOf(m_parentMenu);
|
||||||
|
if ( !hMenu || ::GetMenuState(hMenu, id, MF_BYCOMMAND) == (UINT)-1 )
|
||||||
|
return;
|
||||||
|
|
||||||
#if wxUSE_OWNER_DRAWN
|
#if wxUSE_OWNER_DRAWN
|
||||||
if ( IsOwnerDrawn() )
|
if ( IsOwnerDrawn() )
|
||||||
{
|
{
|
||||||
@@ -375,8 +380,6 @@ void wxMenuItem::SetItemLabel(const wxString& txt)
|
|||||||
#endif // owner drawn
|
#endif // owner drawn
|
||||||
|
|
||||||
// update the text of the native menu item
|
// update the text of the native menu item
|
||||||
const UINT id = GetMSWId();
|
|
||||||
|
|
||||||
WinStruct<MENUITEMINFO> info;
|
WinStruct<MENUITEMINFO> info;
|
||||||
|
|
||||||
// surprisingly, calling SetMenuItemInfo() with just MIIM_STRING doesn't
|
// surprisingly, calling SetMenuItemInfo() with just MIIM_STRING doesn't
|
||||||
|
Reference in New Issue
Block a user