Fix changing labels of menu items with bitmaps in wxMSW.
We need to call SetMenuItemInfo() from wxMenuItem::SetItemLabel() even for the owner-drawn items, otherwise their width is not recomputed. Closes #3897. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73400 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -626,6 +626,7 @@ wxMSW:
|
|||||||
- Don't send any events from wxSpinCtrl::SetRange() even if the value changed.
|
- Don't send any events from wxSpinCtrl::SetRange() even if the value changed.
|
||||||
- Display system drag images during drag and drop if available (PeterO).
|
- Display system drag images during drag and drop if available (PeterO).
|
||||||
- Fix setting initial wxSpinCtrl value outside 0..100 range (joim).
|
- Fix setting initial wxSpinCtrl value outside 0..100 range (joim).
|
||||||
|
- Fix changing labels of menu items with bitmaps (Daniel Hyams).
|
||||||
|
|
||||||
wxOSX/Cocoa:
|
wxOSX/Cocoa:
|
||||||
|
|
||||||
|
@@ -681,15 +681,6 @@ void wxMenuItem::SetItemLabel(const wxString& txt)
|
|||||||
if ( !hMenu || ::GetMenuState(hMenu, id, MF_BYCOMMAND) == (UINT)-1 )
|
if ( !hMenu || ::GetMenuState(hMenu, id, MF_BYCOMMAND) == (UINT)-1 )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#if wxUSE_OWNER_DRAWN
|
|
||||||
if ( IsOwnerDrawn() )
|
|
||||||
{
|
|
||||||
// we don't need to do anything for owner drawn items, they will redraw
|
|
||||||
// themselves using the new text the next time they're displayed
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif // owner drawn
|
|
||||||
|
|
||||||
// update the text of the native menu item
|
// update the text of the native menu item
|
||||||
WinStruct<MENUITEMINFO> info;
|
WinStruct<MENUITEMINFO> info;
|
||||||
|
|
||||||
@@ -712,11 +703,26 @@ void wxMenuItem::SetItemLabel(const wxString& txt)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( isLaterThanWin95 )
|
#if wxUSE_OWNER_DRAWN
|
||||||
info.fMask |= MIIM_STRING;
|
// Don't set the text for the owner drawn items, they don't use it and even
|
||||||
//else: MIIM_TYPE already specified
|
// though setting it doesn't seem to actually do any harm under Windows 7,
|
||||||
info.dwTypeData = wxMSW_CONV_LPTSTR(m_text);
|
// avoid doing this relatively nonsensical operation just in case it does
|
||||||
info.cch = m_text.length();
|
// break something on other, past or future, Windows versions.
|
||||||
|
//
|
||||||
|
// Notice that we do need to call SetMenuItemInfo() even for the ownerdrawn
|
||||||
|
// items however as otherwise their size wouldn't be recalculated as
|
||||||
|
// WM_MEASUREITEM wouldn't be sent and this could result in display
|
||||||
|
// problems if the length of the menu item changed significantly.
|
||||||
|
if ( !IsOwnerDrawn() )
|
||||||
|
#endif // wxUSE_OWNER_DRAWN
|
||||||
|
{
|
||||||
|
if ( isLaterThanWin95 )
|
||||||
|
info.fMask |= MIIM_STRING;
|
||||||
|
//else: MIIM_TYPE already specified
|
||||||
|
info.dwTypeData = wxMSW_CONV_LPTSTR(m_text);
|
||||||
|
info.cch = m_text.length();
|
||||||
|
}
|
||||||
|
|
||||||
if ( !::SetMenuItemInfo(hMenu, id, FALSE, &info) )
|
if ( !::SetMenuItemInfo(hMenu, id, FALSE, &info) )
|
||||||
{
|
{
|
||||||
wxLogLastError(wxT("SetMenuItemInfo"));
|
wxLogLastError(wxT("SetMenuItemInfo"));
|
||||||
|
Reference in New Issue
Block a user