Prevent idMenuTitle from being accidentally used as invalid wx ID.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64257 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2010-05-09 10:27:44 +00:00
parent 0c51948f7d
commit 008809c73c

View File

@@ -82,7 +82,7 @@
// ----------------------------------------------------------------------------
// the (popup) menu title has this special id
static const UINT idMenuTitle = (UINT)-3;
static const int idMenuTitle = wxID_NONE;
// ----------------------------------------------------------------------------
// private functions
@@ -695,7 +695,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
// if we just appended the title, highlight it
if ( id == idMenuTitle )
if ( id == (UINT_PTR)idMenuTitle )
{
// visually select the menu title
SetDefaultMenuItem(GetHmenu(), id);
@@ -901,7 +901,7 @@ void wxMenu::SetTitle(const wxString& label)
if ( !label.empty() )
{
if ( !::InsertMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING,
idMenuTitle, m_title.wx_str()) ||
(UINT_PTR)idMenuTitle, m_title.wx_str()) ||
!::InsertMenu(hMenu, 1u, MF_BYPOSITION, (unsigned)-1, NULL) )
{
wxLogLastError(wxT("InsertMenu"));
@@ -937,7 +937,7 @@ void wxMenu::SetTitle(const wxString& label)
#else
if ( !ModifyMenu(hMenu, 0u,
MF_BYPOSITION | MF_STRING,
idMenuTitle, m_title.wx_str()) )
(UINT_PTR)idMenuTitle, m_title.wx_str()) )
{
wxLogLastError(wxT("ModifyMenu"));
}
@@ -949,7 +949,7 @@ void wxMenu::SetTitle(const wxString& label)
// put the title string in bold face
if ( !m_title.empty() )
{
SetDefaultMenuItem(GetHmenu(), idMenuTitle);
SetDefaultMenuItem(GetHmenu(), (UINT_PTR)idMenuTitle);
}
#endif // Win32
}
@@ -963,7 +963,7 @@ bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id_)
const int id = (signed short)id_;
// ignore commands from the menu title
if ( id != (int)idMenuTitle )
if ( id != idMenuTitle )
{
// update the check item when it's clicked
wxMenuItem * const item = FindItem(id);