本文整理汇总了C++中GetMenuItemCount函数的典型用法代码示例。如果您正苦于以下问题:C++ GetMenuItemCount函数的具体用法?C++ GetMenuItemCount怎么用?C++ GetMenuItemCount使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetMenuItemCount函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wxCHECK_MSG
wxMenuItem* wxMenu::DoInsert(size_t pos, wxMenuItem *item)
{
if (m_menuWidget)
{
// this is a dynamic Append
#ifndef XmNpositionIndex
wxCHECK_MSG( pos == GetMenuItemCount(), -1, wxT("insert not implemented"));
#endif
item->CreateItem(m_menuWidget, GetMenuBar(), m_topLevelMenu, pos);
}
if ( item->IsSubMenu() )
{
item->GetSubMenu()->m_topLevelMenu = m_topLevelMenu;
}
return pos == GetMenuItemCount() ? wxMenuBase::DoAppend(item) :
wxMenuBase::DoInsert(pos, item);
}
示例2: RecursiveDeleteMenu
int RecursiveDeleteMenu(HMENU hMenu)
{
int cnt = GetMenuItemCount(hMenu);
for (int i = 0; i < cnt; i++) {
HMENU submenu = GetSubMenu(hMenu, 0);
if (submenu) DestroyMenu(submenu);
DeleteMenu(hMenu, 0, MF_BYPOSITION);
}
return 0;
}
示例3: GetSubMenuByChildID
HMENU GetSubMenuByChildID(HMENU menu, UINT id) {
int i, j, items, subitems, cur_id;
HMENU m;
items = GetMenuItemCount(menu);
for (i=0; i<items; i++) {
if (m = GetSubMenu(menu, i)) {
subitems = GetMenuItemCount(m);
for (j=0; j<subitems; j++) {
cur_id = GetMenuItemID(m, j);
if (cur_id == id) {
return m;
}
}
}
}
return NULL;
}
示例4: wxASSERT_MSG
// function appends a new item or submenu to the menu
// append a new item or submenu to the menu
bool wxMenu::DoInsertOrAppend(wxMenuItem *item, size_t pos)
{
wxASSERT_MSG( item != NULL, wxT("can't append NULL item to the menu") );
GetPeer()->InsertOrAppend( item, pos );
wxMenu *pSubMenu = item->GetSubMenu() ;
if ( pSubMenu != NULL )
{
wxASSERT_MSG( pSubMenu->GetHMenu() != NULL , wxT("invalid submenu added"));
pSubMenu->m_menuParent = this ;
pSubMenu->DoRearrange();
}
else if ( item->GetId() == idMenuTitle )
{
item->GetMenu()->Enable( idMenuTitle, false );
}
if ( pos == (size_t)-1 )
{
pos = GetMenuItemCount() - 1;
}
// Update radio groups if we're inserting a new menu item.
// Inserting radio and non-radio item has a different impact
// on radio groups, so we have to handle each case separately.
// (Inserting a radio item in the middle of existing groups extends this group,
// but inserting a non-radio item breaks it into two subgroups.)
bool check = false;
if ( item->IsRadio() )
{
if ( !m_radioData )
m_radioData = new wxMenuRadioItemsData;
if ( m_radioData->UpdateOnInsertRadio(pos) )
check = true; // ensure that we have a checked item in the radio group
}
else if ( m_radioData )
{
if ( m_radioData->UpdateOnInsertNonRadio(pos) )
{
// One of the existing groups has been split into two subgroups.
wxFAIL_MSG(wxS("Inserting non-radio item inside a radio group?"));
}
}
// if we're already attached to the menubar, we must update it
if ( IsAttached() && GetMenuBar()->IsAttached() )
GetMenuBar()->Refresh();
if ( check )
item->Check(true);
return true ;
}
示例5: add_user_menu_items
static void add_user_menu_items(HMENU menu)
{
MENUITEMINFO mii;
memset(&mii, 0, sizeof(MENUITEMINFO));
mii.type = MFT_SEPARATOR;
InsertMenuItem(menu, GetMenuItemCount(menu), TRUE, &mii);
#if 1
memset(&mii, 0, sizeof(MENUITEMINFO));
mii.type = MFT_STRING;
mii.hsubmenu = 0;
mii.id = IDM_POP_NEW_TAB;
mii.state = MFS_ENABLED;
mii.cch = strlen("New Tab");
mii.typedata = (DWORD)"New Tab";
InsertMenuItem(menu, GetMenuItemCount(menu), TRUE, &mii);
#endif
memset(&mii, 0, sizeof(MENUITEMINFO));
mii.type = MFT_STRING;
mii.hsubmenu = 0;
mii.id = IDM_POP_SAVE_AS;
mii.state = MFS_ENABLED;
mii.cch = strlen("Save As...");
mii.typedata = (DWORD)"Save As...";
InsertMenuItem(menu, GetMenuItemCount(menu), TRUE, &mii);
memset(&mii, 0, sizeof(MENUITEMINFO));
mii.type = MFT_STRING;
mii.hsubmenu = 0;
mii.id = IDM_POP_CLOSE_TAB;
int count = SendMessage(propsheet_hwnd, PSM_GETPAGECOUNT, 0, 0);
if (count >1) {
mii.state &= ~MFS_DISABLED;
mii.state |= MFS_ENABLED;
} else {
mii.state &= ~MFS_ENABLED;
mii.state |= MFS_DISABLED;
}
mii.cch = strlen("Close Tab");
mii.typedata = (DWORD)"Close Tab";
InsertMenuItem(menu, GetMenuItemCount(menu), TRUE, &mii);
}
示例6: GetBorderSize
//*********************************************************************************************************
void CBCGPBaseFilterPopupMenu::RecalcLayout(BOOL bNotify /* = TRUE */)
{
CBCGPPopupMenu::RecalcLayout(bNotify);
if (m_wndMenuBar.GetSafeHwnd() != NULL)
{
m_wndMenuBar.m_arColumns.RemoveAll();
m_wndMenuBar.AdjustLayout();
}
if (m_wndList.GetSafeHwnd() == NULL)
{
return;
}
const int nShadowSize = CBCGPToolBar::IsCustomizeMode () ? 0 : m_iShadowSize;
const int nBorderSize = GetBorderSize();
CRect rectClient;
GetClientRect(rectClient);
rectClient.DeflateRect (nBorderSize, nBorderSize);
if (GetExStyle() & WS_EX_LAYOUTRTL)
{
rectClient.left += nShadowSize;
}
else
{
rectClient.right -= nShadowSize;
}
rectClient.top += m_nMenuBarHeight;
rectClient.bottom -= nShadowSize;
#ifndef _BCGSUITE_
rectClient.left += m_wndMenuBar.GetGutterWidth();
#endif
if (!m_rectResize.IsRectEmpty())
{
if (m_bIsResizeBarOnTop)
{
rectClient.top += m_rectResize.Height();
}
else
{
rectClient.bottom -= m_rectResize.Height();
}
}
m_wndList.SetWindowPos(NULL, rectClient.left, rectClient.top, rectClient.Width(), rectClient.Height(), SWP_NOZORDER | SWP_NOACTIVATE);
m_wndList.m_bIsEmptyMenu = GetMenuItemCount() == 0;
}
示例7: SWELL_Menu_AddMenuItem
void SWELL_Menu_AddMenuItem(HMENU hMenu, const char *name, int idx, int flags)
{
MENUITEMINFO mi={sizeof(mi),MIIM_ID|MIIM_STATE|MIIM_TYPE,MFT_STRING,
(flags)?MFS_GRAYED:0,idx,NULL,NULL,NULL,0,(char *)name};
if (!name)
{
mi.fType = MFT_SEPARATOR;
mi.fMask&=~(MIIM_STATE|MIIM_ID);
}
InsertMenuItem(hMenu,GetMenuItemCount(hMenu),TRUE,&mi);
}
示例8: FillMarkerRegionMenu
// _flags: &1=marker, &2=region
void FillMarkerRegionMenu(ReaProject* _proj, HMENU _menu, int _msgStart, int _flags, UINT _uiState)
{
int x=0, lastx=0;
char desc[SNM_MAX_MARKER_NAME_LEN]="";
while ((x = EnumMarkerRegionDesc(_proj, x, desc, SNM_MAX_MARKER_NAME_LEN, _flags, true, true, true))) {
if (*desc) AddToMenu(_menu, desc, _msgStart+lastx, -1, false, _uiState);
lastx=x;
}
if (!GetMenuItemCount(_menu))
AddToMenu(_menu, __LOCALIZE("(No region!)","sws_menu"), 0, -1, false, MF_GRAYED);
}
示例9: winMouseOn
void MainWnd::OnContextMenu(CWnd* pWnd, CPoint point)
{
winMouseOn();
if(theApp.skin) {
if(theApp.popup == NULL) {
theApp.winAccelMgr.UpdateMenu(theApp.menu);
theApp.popup = CreatePopupMenu();
if(theApp.menu != NULL) {
int count = GetMenuItemCount(theApp.menu);
OSVERSIONINFO info;
info.dwOSVersionInfoSize = sizeof(info);
GetVersionEx(&info);
if(info.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) {
for(int i = 0; i < count; i++) {
char buffer[256];
MENUITEMINFO info;
ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info) - sizeof(HBITMAP);
info.fMask = MIIM_STRING | MIIM_SUBMENU;
info.dwTypeData = buffer;
info.cch = 256;
if(!GetMenuItemInfo(theApp.menu, i, MF_BYPOSITION, &info)) {
}
if(!AppendMenu(theApp.popup, MF_POPUP|MF_STRING, (UINT)info.hSubMenu, buffer)) {
}
}
} else {
for(int i = 0; i < count; i++) {
wchar_t buffer[256];
MENUITEMINFOW info;
ZeroMemory(&info, sizeof(info));
info.cbSize = sizeof(info) - sizeof(HBITMAP);
info.fMask = MIIM_STRING | MIIM_SUBMENU;
info.dwTypeData = buffer;
info.cch = 256;
if(!GetMenuItemInfoW(theApp.menu, i, MF_BYPOSITION, &info)) {
}
if(!AppendMenuW(theApp.popup, MF_POPUP|MF_STRING, (UINT)info.hSubMenu, buffer)) {
}
}
}
}
}
int x = point.x;
int y = point.y;
if(x == -1 && y == -1) {
x = (theApp.dest.left + theApp.dest.right) / 2;
y = (theApp.dest.top + theApp.dest.bottom) / 2;
}
if(!TrackPopupMenu(theApp.popup, 0, x, y, 0, m_hWnd, NULL)) {
}
}
}
示例10: get_menu_position
/* find index in menu bar; returns -1 if not installed */
static int get_menu_position(HMENU addr)
{
int n, i;
if (addr == NULL) return -1;
n = GetMenuItemCount(hMainMenu);
for (i = 0; i < n; i++)
if (addr == GetSubMenu(hMainMenu, i))
return(i);
return(-1);
}
示例11: mh_additem
static int mh_additem (lua_State* l) {
menu* m = lua_touserdata(l,1);
if (!m->sub) return 0;
int k = 2, pos = 0;
if (lua_isnumber(l,k)) pos = lua_tointeger(l,k++);
if (pos==0) pos = -1;
else if (pos>0) pos--;
else if (pos<-1) pos += GetMenuItemCount(m->menu);
const char* str = luaL_checkstring(l,k++);
const char* sShortcut = NULL;
if (lua_isstring(l,k)) sShortcut = lua_tostring(l,k++);
else if (lua_isnoneornil(l,k)) k++;
if (!lua_isfunction(l,k)) luaL_typerror(l, k, "function");
void* p = lua_topointer(l,k++);
if (!p) return 0;
const wchar_t* wstr = strcvt(str, CP_UTF8, CP_UTF16, NULL);
int command = addCustomCommand(p) + IDM_CUSTOMCOMMAND;
int kFlags = 0, key=0;
if (parseKeyName(sShortcut, &kFlags, &key)) {
addAccelerator(kFlags, key, command);
const wchar_t* z = mh_buildLabel(wstr, kFlags, key);
if (z!=wstr) {
free(wstr);
wstr = z;
}}
menu it;
it.sub = FALSE;
it.parent = m->menu;
it.origin = m->origin;
it.position = (pos==-1? GetMenuItemCount(m->menu) -1 : pos);
it.command = command;
InsertMenu(m->menu, pos, MF_STRING | MF_BYPOSITION, command, wstr);
DrawMenuBar(win);
free(wstr);
lua_pushlightuserdata(l, command);
lua_pushluafunction(l, p);
lua_rawset(l, LUA_REGISTRYINDEX);
lua_settop(l,0);
lua_pushfulluserdata(l, &it, sizeof(it), "menuhandle");
return 1;
}
示例12: while
unsigned int Win32Popup::findInsertionPoint( unsigned int pos ) const
{
// For this simple algorithm, we rely on the fact that in the final state
// of the menu, the ID of each item is equal to its position in the menu
int i = 0;
while( i < GetMenuItemCount( m_hMenu ) &&
GetMenuItemID( m_hMenu, i ) < pos )
{
i++;
}
return i;
}
示例13: SWSGetMenuPosFromID
int SWSGetMenuPosFromID(HMENU hMenu, UINT id)
{ // Replacement for deprecated windows func GetMenuPosFromID
MENUITEMINFO mi={sizeof(MENUITEMINFO),};
mi.fMask = MIIM_ID;
for (int i = 0; i < GetMenuItemCount(hMenu); i++)
{
GetMenuItemInfo(hMenu, i, true, &mi);
if (mi.wID == id)
return i;
}
return -1;
}
示例14: EventArea_DrawWorker
static int EventArea_DrawWorker(HWND hWnd, HDC hDC)
{
RECT rc;
HFONT hOldFont;
GetClientRect(hWnd, &rc);
if (g_CluiData.fDisableSkinEngine)
sttDrawEventAreaBackground(hWnd, hDC, &rc);
else
SkinDrawGlyph(hDC, &rc, &rc, "Main,ID=EventArea");
hOldFont = g_clcPainter.ChangeToFont(hDC, NULL, FONTID_EVENTAREA, NULL);
SetBkMode(hDC, TRANSPARENT);
int iCount = GetMenuItemCount(g_CluiData.hMenuNotify);
rc.left += 26;
if (g_CluiData.hUpdateContact != 0) {
TCHAR *szName = pcli->pfnGetContactDisplayName(g_CluiData.hUpdateContact, 0);
int iIcon = cli_GetContactIcon(g_CluiData.hUpdateContact);
ske_ImageList_DrawEx(g_himlCListClc, iIcon, hDC, rc.left, (rc.bottom + rc.top - GetSystemMetrics(SM_CYSMICON)) / 2, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), CLR_NONE, CLR_NONE, ILD_NORMAL);
rc.left += 18;
ske_DrawText(hDC, szName, -1, &rc, DT_VCENTER | DT_SINGLELINE);
ske_ImageList_DrawEx(g_himlCListClc, (int)g_CluiData.iIconNotify, hDC, 4, (rc.bottom + rc.top - 16) / 2, 16, 16, CLR_NONE, CLR_NONE, ILD_NORMAL);
}
else if (iCount > 0) {
MENUITEMINFO mii = { 0 };
struct NotifyMenuItemExData *nmi;
TCHAR *szName;
int iIcon;
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_DATA;
GetMenuItemInfo(g_CluiData.hMenuNotify, iCount - 1, TRUE, &mii);
nmi = (struct NotifyMenuItemExData *) mii.dwItemData;
szName = pcli->pfnGetContactDisplayName(nmi->hContact, 0);
iIcon = cli_GetContactIcon(nmi->hContact);
ske_ImageList_DrawEx(g_himlCListClc, iIcon, hDC, rc.left, (rc.bottom + rc.top - GetSystemMetrics(SM_CYSMICON)) / 2, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), CLR_NONE, CLR_NONE, ILD_NORMAL);
rc.left += 18;
ske_ImageList_DrawEx(g_himlCListClc, nmi->iIcon, hDC, 4, (rc.bottom + rc.top) / 2 - 8, 16, 16, CLR_NONE, CLR_NONE, ILD_NORMAL);
ske_DrawText(hDC, szName, -1, &rc, DT_VCENTER | DT_SINGLELINE);
}
else {
HICON hIcon = (HICON)LoadImage(GetModuleHandle(NULL), MAKEINTRESOURCE(IDI_BLANK), IMAGE_ICON, 16, 16, 0);
TCHAR *ptszEvents = TranslateT("No events");
ske_DrawText(hDC, ptszEvents, (int)mir_tstrlen(ptszEvents), &rc, DT_VCENTER | DT_SINGLELINE);
ske_DrawIconEx(hDC, 4, (rc.bottom + rc.top - 16) / 2, hIcon, 16, 16, 0, 0, DI_NORMAL | DI_COMPAT);
DestroyIcon(hIcon);
}
ske_ResetTextEffect(hDC);
SelectObject(hDC, hOldFont);
return 0;
}
示例15:
OMenu::~OMenu() {
if (::IsMenu(m_hMenu)) {
for (int i = 0; i < GetMenuItemCount(); ++i)
CheckOwnerDrawn(i, TRUE);
} else {
// How can we end up here??? it sure happens sometimes..
for (OMenuItem::Iter i = items.begin(); i != items.end(); ++i) {
delete *i;
}
}
//pUnMap();
}