本文整理汇总了C++中GetHmenu函数的典型用法代码示例。如果您正苦于以下问题:C++ GetHmenu函数的具体用法?C++ GetHmenu怎么用?C++ GetHmenu使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetHmenu函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxCHECK_MSG
bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
{
WXHMENU submenu = menu ? menu->GetHMenu() : 0;
wxCHECK_MSG( submenu, false, wxT("can't append invalid menu to menubar") );
if ( !wxMenuBarBase::Append(menu, title) )
return false;
menu->wxMenuBase::SetTitle(title);
if (GetHmenu())
{
if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING,
(UINT_PTR)submenu, title.t_str()) )
{
wxLogLastError(wxT("AppendMenu"));
}
#if wxUSE_ACCEL
if ( menu->HasAccels() )
{
// need to rebuild accelerator table
RebuildAccelTable();
}
#endif // wxUSE_ACCEL
if (IsAttached())
Refresh();
}
return true;
}
示例2: wxLogLastError
wxMenu *wxMenuBar::Remove(size_t pos)
{
wxMenu *menu = wxMenuBarBase::Remove(pos);
if ( !menu )
return NULL;
if (GetHmenu())
{
if ( !::RemoveMenu(GetHmenu(), (UINT)MSWPositionForWxMenu(menu,pos), MF_BYPOSITION) )
{
wxLogLastError(wxT("RemoveMenu"));
}
#if wxUSE_ACCEL
if ( menu->HasAccels() )
{
// need to rebuild accell table
RebuildAccelTable();
}
#endif // wxUSE_ACCEL
if (IsAttached())
Refresh();
}
return menu;
}
示例3: GetMenuCount
bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
{
// Find out which MSW item before which we'll be inserting before
// wxMenuBarBase::Insert is called and GetMenu(pos) is the new menu.
// If IsAttached() is false this won't be used anyway
bool isAttached =
(GetHmenu() != 0);
if ( !wxMenuBarBase::Insert(pos, menu, title) )
return false;
menu->wxMenuBase::SetTitle(title);
if ( isAttached )
{
// We have a problem with the index if there is an extra "Window" menu
// in this menu bar, which is added by wxMDIParentFrame to it directly
// using Windows API (so that it remains invisible to the user code),
// but which does affect the indices of the items we insert after it.
// So we check if any of the menus before the insertion position is a
// foreign one and adjust the insertion index accordingly.
int mswExtra = 0;
// Skip all this if the total number of menus matches (notice that the
// internal menu count has already been incremented by wxMenuBarBase::
// Insert() call above, hence -1).
int mswCount = ::GetMenuItemCount(GetHmenu());
if ( mswCount != -1 &&
static_cast<unsigned>(mswCount) != GetMenuCount() - 1 )
{
wxMenuList::compatibility_iterator node = m_menus.GetFirst();
for ( size_t n = 0; n < pos; n++ )
{
if ( ::GetSubMenu(GetHmenu(), n) != GetHmenuOf(node->GetData()) )
mswExtra++;
else
node = node->GetNext();
}
}
if ( !::InsertMenu(GetHmenu(), pos + mswExtra,
MF_BYPOSITION | MF_POPUP | MF_STRING,
(UINT_PTR)GetHmenuOf(menu), title.t_str()) )
{
wxLogLastError(wxT("InsertMenu"));
}
#if wxUSE_ACCEL
if ( menu->HasAccels() )
{
// need to rebuild accell table
RebuildAccelTable();
}
#endif // wxUSE_ACCEL
if (IsAttached())
Refresh();
}
return true;
}
示例4: wxCHECK_MSG
bool wxMenuBar::Append(wxMenu *menu, const wxString& title)
{
WXHMENU submenu = menu ? menu->GetHMenu() : 0;
wxCHECK_MSG( submenu, false, wxT("can't append invalid menu to menubar") );
if ( !wxMenuBarBase::Append(menu, title) )
return false;
menu->wxMenuBase::SetTitle(title);
#if defined(WINCE_WITHOUT_COMMANDBAR)
if (IsAttached())
#else
if (GetHmenu())
#endif
{
#if defined(WINCE_WITHOUT_COMMANDBAR)
if (!GetToolBar())
return false;
TBBUTTON tbButton;
memset(&tbButton, 0, sizeof(TBBUTTON));
tbButton.iBitmap = I_IMAGENONE;
tbButton.fsState = TBSTATE_ENABLED;
tbButton.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW | TBSTYLE_AUTOSIZE;
size_t pos = GetMenuCount();
HMENU hPopupMenu = (HMENU) menu->GetHMenu() ;
tbButton.dwData = (DWORD)hPopupMenu;
wxString label = wxStripMenuCodes(title);
tbButton.iString = (int) label.wx_str();
tbButton.idCommand = NewControlId();
if (!::SendMessage((HWND) GetToolBar()->GetHWND(), TB_INSERTBUTTON, pos, (LPARAM)&tbButton))
{
wxLogLastError(wxT("TB_INSERTBUTTON"));
return false;
}
#else
if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING,
(UINT_PTR)submenu, title.wx_str()) )
{
wxLogLastError(wxT("AppendMenu"));
}
#endif
#if wxUSE_ACCEL
if ( menu->HasAccels() )
{
// need to rebuild accelerator table
RebuildAccelTable();
}
#endif // wxUSE_ACCEL
if (IsAttached())
Refresh();
}
return true;
}
示例5: GetHmenu
void wxMenu::SetTitle(const wxString& label)
{
bool hasNoTitle = m_title.empty();
m_title = label;
HMENU hMenu = GetHmenu();
if ( hasNoTitle )
{
if ( !label.empty() )
{
if ( !::InsertMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING,
(UINT_PTR)idMenuTitle, m_title.t_str()) ||
!::InsertMenu(hMenu, 1u, MF_BYPOSITION, (unsigned)-1, NULL) )
{
wxLogLastError(wxT("InsertMenu"));
}
}
}
else
{
if ( label.empty() )
{
// remove the title and the separator after it
if ( !RemoveMenu(hMenu, 0, MF_BYPOSITION) ||
!RemoveMenu(hMenu, 0, MF_BYPOSITION) )
{
wxLogLastError(wxT("RemoveMenu"));
}
}
else
{
// modify the title
if ( !ModifyMenu(hMenu, 0u,
MF_BYPOSITION | MF_STRING,
(UINT_PTR)idMenuTitle, m_title.t_str()) )
{
wxLogLastError(wxT("ModifyMenu"));
}
}
}
// put the title string in bold face
if ( !m_title.empty() )
{
SetDefaultMenuItem(GetHmenu(), (UINT)idMenuTitle);
}
}
示例6: WXUNUSED
bool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id_)
{
const int id = (signed short)id_;
// ignore commands from the menu title
if ( id != idMenuTitle )
{
// Default value for uncheckable items.
int checked = -1;
// update the check item when it's clicked
wxMenuItem * const item = FindItem(id);
if ( item && item->IsCheckable() )
{
item->Toggle();
// 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.
//
// Also notice that we must pass unsigned id_ and not sign-extended id
// to ::GetMenuState() as this is what it expects.
UINT menuState = ::GetMenuState(GetHmenu(), id_, MF_BYCOMMAND);
checked = (menuState & MF_CHECKED) != 0;
}
SendEvent(id, checked);
}
return true;
}
示例7: GetMenuItems
wxMenuItem* wxMenu::DoRemove(
wxMenuItem* pItem
)
{
//
// We need to find the items position in the child list
//
size_t nPos;
wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
for (nPos = 0; node; nPos++)
{
if (node->GetData() == pItem)
break;
node = node->GetNext();
}
//
// DoRemove() (unlike Remove) can only be called for existing item!
//
wxCHECK_MSG(node, NULL, wxT("bug in wxMenu::Remove logic"));
#if wxUSE_ACCEL
//
// Remove the corresponding accel from the accel table
//
int n = FindAccel(pItem->GetId());
if (n != wxNOT_FOUND)
{
delete m_vAccels[n];
m_vAccels.RemoveAt(n);
}
#endif // wxUSE_ACCEL
//
// Remove the item from the menu
//
::WinSendMsg( GetHmenu()
,MM_REMOVEITEM
,MPFROM2SHORT(pItem->GetId(), TRUE)
,(MPARAM)0
);
if (IsAttached() && GetMenuBar()->IsAttached())
{
//
// Otherwise, the chane won't be visible
//
GetMenuBar()->Refresh();
}
//
// And from internal data structures
//
return wxMenuBase::DoRemove(pItem);
} // end of wxMenu::DoRemove
示例8: defined
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
{
wxMenu *menuOld = wxMenuBarBase::Replace(pos, menu, title);
if ( !menuOld )
return NULL;
menu->wxMenuBase::SetTitle(title);
#if defined(WINCE_WITHOUT_COMMANDBAR)
if (IsAttached())
#else
if (GetHmenu())
#endif
{
int mswpos = MSWPositionForWxMenu(menuOld,pos);
// can't use ModifyMenu() because it deletes the submenu it replaces
if ( !::RemoveMenu(GetHmenu(), (UINT)mswpos, MF_BYPOSITION) )
{
wxLogLastError(wxT("RemoveMenu"));
}
if ( !::InsertMenu(GetHmenu(), (UINT)mswpos,
MF_BYPOSITION | MF_POPUP | MF_STRING,
(UINT_PTR)GetHmenuOf(menu), title.wx_str()) )
{
wxLogLastError(wxT("InsertMenu"));
}
#if wxUSE_ACCEL
if ( menuOld->HasAccels() || menu->HasAccels() )
{
// need to rebuild accell table
RebuildAccelTable();
}
#endif // wxUSE_ACCEL
if (IsAttached())
Refresh();
}
return menuOld;
}
示例9: defined
wxMenu *wxMenuBar::Remove(size_t pos)
{
wxMenu *menu = wxMenuBarBase::Remove(pos);
if ( !menu )
return NULL;
#if defined(WINCE_WITHOUT_COMMANDBAR)
if (IsAttached())
#else
if (GetHmenu())
#endif
{
#if defined(WINCE_WITHOUT_COMMANDBAR)
if (GetToolBar())
{
if (!::SendMessage((HWND) GetToolBar()->GetHWND(), TB_DELETEBUTTON, (UINT) pos, (LPARAM) 0))
{
wxLogLastError(wxT("TB_DELETEBUTTON"));
}
}
#else
if ( !::RemoveMenu(GetHmenu(), (UINT)MSWPositionForWxMenu(menu,pos), MF_BYPOSITION) )
{
wxLogLastError(wxT("RemoveMenu"));
}
#endif
#if wxUSE_ACCEL
if ( menu->HasAccels() )
{
// need to rebuild accell table
RebuildAccelTable();
}
#endif // wxUSE_ACCEL
if (IsAttached())
Refresh();
}
m_titles.RemoveAt(pos);
return menu;
}
示例10: SHORT1FROMMR
wxMenu* wxMenuBar::Remove(
size_t nPos
)
{
wxMenu* pMenu = wxMenuBarBase::Remove(nPos);
SHORT nId;
if (!pMenu)
return NULL;
nId = SHORT1FROMMR(::WinSendMsg( (HWND)GetHmenu()
,MM_ITEMIDFROMPOSITION
,MPFROMSHORT(nPos)
,(MPARAM)0)
);
if (nId == MIT_ERROR)
{
wxLogLastError(wxT("LogLastError"));
return NULL;
}
if (IsAttached())
{
::WinSendMsg( (HWND)GetHmenu()
,MM_REMOVEITEM
,MPFROM2SHORT(nId, TRUE)
,(MPARAM)0
);
#if wxUSE_ACCEL
if (pMenu->HasAccels())
{
//
// Need to rebuild accell table
//
RebuildAccelTable();
}
#endif // wxUSE_ACCEL
Refresh();
}
m_titles.RemoveAt(nPos);
return pMenu;
} // end of wxMenuBar::Remove
示例11: GetMenuItems
wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
{
// we need to find the item's position in the child list
size_t pos;
wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
for ( pos = 0; node; pos++ )
{
if ( node->GetData() == item )
break;
node = node->GetNext();
}
#if wxUSE_ACCEL
// remove the corresponding accel from the accel table
int n = FindAccel(item->GetId());
if ( n != wxNOT_FOUND )
{
delete m_accels[n];
m_accels.RemoveAt(n);
#if wxUSE_OWNER_DRAWN
ResetMaxAccelWidth();
#endif
}
//else: this item doesn't have an accel, nothing to do
#endif // wxUSE_ACCEL
// Update indices of radio groups.
if ( m_radioData )
{
bool inExistingGroup = m_radioData->UpdateOnRemoveItem(pos);
wxASSERT_MSG( !inExistingGroup || item->GetKind() == wxITEM_RADIO,
wxT("Removing non radio button from radio group?") );
}
// remove the item from the menu
if ( !::RemoveMenu(GetHmenu(), (UINT)pos, MF_BYPOSITION) )
{
wxLogLastError(wxT("RemoveMenu"));
}
if ( IsAttached() && GetMenuBar()->IsAttached() )
{
// otherwise, the change won't be visible
GetMenuBar()->Refresh();
}
// and from internal data structures
return wxMenuBase::DoRemove(item);
}
示例12: GetHmenu
void wxMenu::SetTitle( const wxString& rLabel )
{
bool bHasNoTitle = m_title.empty();
HWND hMenu = GetHmenu();
m_title = rLabel;
if (bHasNoTitle)
{
if (!rLabel.empty())
{
if (!::WinSetWindowText(hMenu, rLabel.c_str()))
{
wxLogLastError(wxT("SetMenuTitle"));
}
}
}
else
{
if (rLabel.empty() )
{
::WinSendMsg( GetHmenu()
,MM_REMOVEITEM
,MPFROM2SHORT(hMenu, TRUE)
,(MPARAM)0
);
}
else
{
//
// Modify the title
//
if (!::WinSetWindowText(hMenu, rLabel.c_str()))
{
wxLogLastError(wxT("SetMenuTitle"));
}
}
}
} // end of wxMenu::SetTitle
示例13: GetMenuItems
wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
{
// we need to find the item's position in the child list
size_t pos;
wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
for ( pos = 0; node; pos++ )
{
if ( node->GetData() == item )
break;
node = node->GetNext();
}
// DoRemove() (unlike Remove) can only be called for an existing item!
wxCHECK_MSG( node, NULL, wxT("bug in wxMenu::Remove logic") );
#if wxUSE_ACCEL
// remove the corresponding accel from the accel table
int n = FindAccel(item->GetId());
if ( n != wxNOT_FOUND )
{
delete m_accels[n];
m_accels.RemoveAt(n);
#if wxUSE_OWNER_DRAWN
ResetMaxAccelWidth();
#endif
}
//else: this item doesn't have an accel, nothing to do
#endif // wxUSE_ACCEL
// remove the item from the menu
if ( !::RemoveMenu(GetHmenu(), (UINT)pos, MF_BYPOSITION) )
{
wxLogLastError(wxT("RemoveMenu"));
}
if ( IsAttached() && GetMenuBar()->IsAttached() )
{
// otherwise, the change won't be visible
GetMenuBar()->Refresh();
}
// and from internal data structures
return wxMenuBase::DoRemove(item);
}
示例14: wxLogLastError
// The wxWindow destructor will take care of deleting the submenus.
wxMenu::~wxMenu()
{
// we should free Windows resources only if Windows doesn't do it for us
// which happens if we're attached to a menubar or a submenu of another
// menu
if ( !IsAttached() && !GetParent() )
{
if ( !::DestroyMenu(GetHmenu()) )
{
wxLogLastError(wxT("DestroyMenu"));
}
}
#if wxUSE_ACCEL
// delete accels
WX_CLEAR_ARRAY(m_accels);
#endif // wxUSE_ACCEL
}
示例15: WXUNUSED
bool wxMenu::OS2Command( WXUINT WXUNUSED(uParam),
WXWORD vId )
{
//
// Ignore commands from the menu title
//
if (vId != (WXWORD)idMenuTitle)
{
SendEvent( vId
,(int)::WinSendMsg( GetHmenu()
,MM_QUERYITEMATTR
,MPFROMSHORT(vId)
,(MPARAM)MIA_CHECKED
)
);
}
return true;
} // end of wxMenu::OS2Command