当前位置: 首页>>代码示例>>C++>>正文


C++ GetMenuItemID函数代码示例

本文整理汇总了C++中GetMenuItemID函数的典型用法代码示例。如果您正苦于以下问题:C++ GetMenuItemID函数的具体用法?C++ GetMenuItemID怎么用?C++ GetMenuItemID使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetMenuItemID函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: playermenu_find_unique_id

WORD playermenu_find_unique_id( )
{
   WORD id = 1024; // Client menu IDs are well below this number.
   for (vector<MODULE*>::const_iterator i = g_modules.begin( ); i != g_modules.end( ); ++i)
   {
      const int count = GetMenuItemCount( (*i)->menu );
      for (int j = 0; j < count; ++j)
      {
         if ((WORD) GetMenuItemID( (*i)->menu, j ) == id)
            id = (WORD) GetMenuItemID( (*i)->menu, j ) + 1;
      }
   }
   return id;
}
开发者ID:Gerolkae,项目名称:Furnarchy,代码行数:14,代码来源:modules.cpp

示例2: switch

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 弹出菜单初始化
VOID CMainWnd::OnMenuPopup(WPARAM wParam, LPARAM lParam)
{
	HWND hWnd;
	DWORD dwSize;
	TCHAR tzTemp[512];
	TCHAR tzPath[512];

	switch (GetMenuItemID((HMENU) wParam, 0))
	{
	case IDM_Help_Desktop:
		// 判断快捷方式是否存在
		CheckCommand(IDM_Help_Desktop, CShortcut::Exist(CSIDL_DESKTOP));
		CheckCommand(IDM_Help_StartMenu, CShortcut::Exist(CSIDL_STARTMENU));
		CheckCommand(IDM_Help_ProgramMenu, CShortcut::Exist(CSIDL_PROGRAMS));
		CheckCommand(IDM_Help_QuickLaunch, CShortcut::Exist(CSIDL_APPDATA));
		CheckCommand(IDM_Help_VisualStudio, CVSTool::Exist());
		break;

	case IDM_Play_Play:
		hWnd = CClientWnd::GetActive();
		_ExIf(hWnd, SendMessage(hWnd, WM_INITMENUPOPUP, wParam, lParam));
		break;

	case IDM_View_Toolbar:
		GetModuleFileName(NULL, tzTemp, MAX_PATH);
		wsprintf(tzPath, TEXT("\"%s\" \"%%1\""), tzTemp);
		dwSize = _NumOf(tzTemp);
		SHGetValue(HKEY_CLASSES_ROOT, STR_AppName TEXT("\\shell\\open\\command"), NULL, NULL, tzTemp, &dwSize);
		CheckCommand(IDM_View_AssociateFile, lstrcmpi(tzTemp, tzPath) == 0);			
		break;
	}
}
开发者ID:Yonsm,项目名称:RawPlayer,代码行数:34,代码来源:MainWnd.cpp

示例3: CheckForMessage

/*
 * CheckForMessage - check for a WM_COMMAND message that needs to be
 *                   sent to the maximized window
 */
static bool CheckForMessage( HMENU menu, HWND currentWindow,
                             WPI_PARAM1 wparam, WPI_PARAM2 lparam )
{
    int         num;
    int         i;
    UINT        id;
    UINT        flags;

    if( menu != NULL ) {
        num = (int)_wpi_getmenuitemcount( menu );
        for( i = 0; i < num; i++ ) {
            flags = GetMenuState( menu, i, MF_BYPOSITION );
            if( flags & MF_POPUP ) {
                if( CheckForMessage( GetSubMenu( menu, i ), currentWindow,
                                     wparam, lparam ) ) {
                    return( TRUE );
                }
            } else {
                id = GetMenuItemID( menu, i );
                if( id == wparam ) {
                    _wpi_sendmessage( currentWindow, WM_COMMAND, wparam, lparam );
                    return( TRUE );
                }
            }
        }
    }
    return( FALSE );

} /* CheckForMessage */
开发者ID:hubei,项目名称:open-watcom,代码行数:33,代码来源:wmdisim.c

示例4: GetMenuItemCount

void menu_helpers::win32_auto_mnemonics(HMENU menu)
{
	mnemonic_manager mgr;
	unsigned n, m = GetMenuItemCount(menu);
	pfc::string8_fastalloc temp,temp2;
	for(n=0;n<m;n++)//first pass, check existing mnemonics
	{
		unsigned type = uGetMenuItemType(menu,n);
		if (type==MFT_STRING)
		{
			uGetMenuString(menu,n,temp,MF_BYPOSITION);
			mgr.check_string(temp);
		}
	}

	for(n=0;n<m;n++)
	{
		HMENU submenu = GetSubMenu(menu,n);
		if (submenu) win32_auto_mnemonics(submenu);

		{
			unsigned type = uGetMenuItemType(menu,n);
			if (type==MFT_STRING)
			{
				unsigned state = submenu ? 0 : GetMenuState(menu,n,MF_BYPOSITION);
				unsigned id = GetMenuItemID(menu,n);
				uGetMenuString(menu,n,temp,MF_BYPOSITION);
				if (mgr.process_string(temp,temp2))
				{
					uModifyMenu(menu,n,MF_BYPOSITION|MF_STRING|state,id,temp2);
				}
			}
		}
	}
}
开发者ID:AICIDNN,项目名称:lastfm-desktop,代码行数:35,代码来源:menu_manager.cpp

示例5: GetSubMenu

///////////////////////////////////////////////////////////////////////////////
//// Event Handle
//
LRESULT CTrayIcon::OnTrayNotification( WPARAM wID, LPARAM lEvent )
{
	if ( wID!=m_nid.uID ||
		( lEvent!=WM_RBUTTONUP && lEvent!=WM_LBUTTONDBLCLK ) )
		return 0;

	HMENU pSubMenu = GetSubMenu( m_hMenu , 0 );	
	ASSERT( pSubMenu );
	if ( !pSubMenu ) 
		return 0;

	if( m_nDefMenuItem == 0 )
	{
		m_nDefMenuItem = GetMenuItemID( m_hMenu, 0 );
	}

	if ( lEvent==WM_RBUTTONUP )
	{

		// Make 'm_nDefMenuItem' menu item the default (bold font)
		ASSERT( SetMenuDefaultItem( pSubMenu, m_nDefMenuItem, FALSE ) != 0 );


		POINT mouse;
		GetCursorPos( &mouse );
		SetForegroundWindow( m_nid.hWnd );	
		TrackPopupMenu( pSubMenu, 0, mouse.x, mouse.y, 0, m_nid.hWnd, NULL );

	}
	else  // execute default menu item
		SendMessage( m_nid.hWnd, WM_COMMAND, m_nDefMenuItem, 0 );

	return 1; // handled
}
开发者ID:jsg2021,项目名称:Simply-Transparent,代码行数:37,代码来源:trayicon.cpp

示例6: GetMenuItemID

void CFrameWnd::OnShowMenuPopupHint(HMENU hMenu)
{
	// Get ID of first item in menu.
	int iFirstID = GetMenuItemID(hMenu, 0);
    
    // Is a first item?
    if (iFirstID != -1)
    {
		CString strHint;
		
		// Get application object.
		CTask* pApp = CTask::This();
		ASSERT(pApp);
	
		// Calculate menu hint and load.
		// The hint is always a multiple of 100.
		int iHintID = iFirstID - (iFirstID % 10);

		strHint.LoadRsc(iHintID);

		// Show hint.
		if (m_pStatusBar)
			m_pStatusBar->HintBar()->Hint(strHint);
	}
	else
	{
		// Show dummy hint.
		if (m_pStatusBar)
			m_pStatusBar->HintBar()->Hint("");
	}
}
开发者ID:chrisoldwood,项目名称:WIN16,代码行数:31,代码来源:FrameWnd.cpp

示例7: LuaGuiGetMenuItemId

	static uint32_t LuaGuiGetMenuItemId(void *hMenu, uint32_t position)
	{
		return GetMenuItemID(
			reinterpret_cast<HMENU>(hMenu),
			position
			);
	}
开发者ID:myeang1,项目名称:YDWE,代码行数:7,代码来源:luaopen_gui.cpp

示例8: CompositeCMenu_HandleMenuMsg

static HRESULT WINAPI CompositeCMenu_HandleMenuMsg(IContextMenu3 *iface, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    CompositeCMenu *This = impl_from_IContextMenu3(iface);
    HMENU menu;
    UINT id;
    UINT index;
    IContextMenu2 *handler;
    HRESULT hres;
    TRACE("(%p)->(%x,%lx,%lx)\n",iface,uMsg,wParam,lParam);
    switch(uMsg)
    {
    case WM_INITMENUPOPUP:
        menu = (HMENU)wParam;
        id = GetMenuItemID(menu,LOWORD(lParam));
        break;
    case WM_DRAWITEM:
        id = ((DRAWITEMSTRUCT*)lParam)->itemID;
        break;
    case WM_MEASUREITEM:
        id = ((MEASUREITEMSTRUCT*)lParam)->itemID;
        break;
    default:
        WARN("Unimplemented uMsg: 0x%x\n",uMsg);
        return E_NOTIMPL;
    }
    index = CompositeCMenu_GetIndexForCommandId(This,id);
    hres = IContextMenu_QueryInterface(This->menus[index],&IID_IContextMenu2,
                                       (void**)&handler);
    if(SUCCEEDED(hres))
        return IContextMenu2_HandleMenuMsg(handler,uMsg,wParam,lParam);
    return S_OK;
}
开发者ID:AlexSteel,项目名称:wine,代码行数:32,代码来源:shlmenu.c

示例9: menucpy

void menucpy(HMENU hTargetMenu, HMENU hSourceMenu)
{
	int			n, id, nMn;
	TCHAR *		strBuf;
	HMENU		hSubMenu;

	nMn = GetMenuItemCount(hSourceMenu);
	strBuf = (TCHAR *)LocalAlloc(LPTR, 80);
	for (n=0; n<nMn; n++)
	{
		if (0 == (id = GetMenuItemID(hSourceMenu, n)))
			AppendMenu(hTargetMenu, MF_SEPARATOR, 0, 0L);
		else
		{
			GetMenuString(hSourceMenu, n, strBuf, 80, MF_BYPOSITION);
			if (id != -1)
				AppendMenu(hTargetMenu, GetMenuState(hSourceMenu, n, MF_BYPOSITION), id, strBuf);
			else
			{
				hSubMenu = CreatePopupMenu();
				AppendMenu(hTargetMenu, MF_POPUP | MF_STRING, (uint)hSubMenu, strBuf);
				menucpy(hSubMenu, GetSubMenu(hSourceMenu, n));
			}
		}
	}
	LocalFree((HLOCAL)strBuf);
}
开发者ID:clickteam-plugin,项目名称:WaveOut,代码行数:27,代码来源:Edittime.cpp

示例10: ASSERT

HMENU CMDIFrameWnd::GetWindowMenuPopup(HMENU hMenuBar)
	// find which popup is the "Window" menu
{
	if (hMenuBar == NULL)
		return NULL;

	ASSERT(::IsMenu(hMenuBar));

	int iItem = ::GetMenuItemCount(hMenuBar);
	while (iItem--)
	{
		HMENU hMenuPop = ::GetSubMenu(hMenuBar, iItem);
		if (hMenuPop != NULL)
		{
			int iItemMax = ::GetMenuItemCount(hMenuPop);
			for (int iItemPop = 0; iItemPop < iItemMax; iItemPop++)
			{
				UINT nID = GetMenuItemID(hMenuPop, iItemPop);
				if (nID >= AFX_IDM_WINDOW_FIRST && nID <= AFX_IDM_WINDOW_LAST)
					return hMenuPop;
			}
		}
	}

	// no default menu found
	TRACE(traceAppMsg, 0, "Warning: GetWindowMenuPopup failed!\n");
	return NULL;
}
开发者ID:AeonAxan,项目名称:mpc-hc,代码行数:28,代码来源:winmdi.cpp

示例11: BiasMenu

VOID NEAR PASCAL BiasMenu(HMENU hMenu, INT Bias)
{
        INT pos, id, count;
        HMENU hSubMenu;
        CHAR szMenuString[80];

        ENTER("BiasMenu");

        count = GetMenuItemCount(hMenu);

        if (count < 0)
                return;

        for (pos = 0; pos < count; pos++) {

                id = GetMenuItemID(hMenu, pos);

                if (id < 0) {
                        // must be a popup, recurse and update all ID's here
                        if (hSubMenu = GetSubMenu(hMenu, pos))
                                BiasMenu(hSubMenu, Bias);
                } else if (id) {
                        // replace the item that was there with a new
                        // one with the id adjusted

                        GetMenuString(hMenu, (WORD)pos, szMenuString, sizeof(szMenuString), MF_BYPOSITION);
                        DeleteMenu(hMenu, pos, MF_BYPOSITION);
                        InsertMenu(hMenu, (WORD)pos, MF_BYPOSITION | MF_STRING, id + Bias, szMenuString);
                }
        }
        LEAVE("BiasMenu");
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:32,代码来源:wfinit.c

示例12: CreateMenu

HMENU fsODMenu::CopyMenu(HMENU hMenu)
{
	HMENU hCopy = CreateMenu ();

	for (int i = 0; i < GetMenuItemCount (hMenu); i++)
	{
		UINT uState = GetMenuState (hMenu, i, MF_BYPOSITION);
		UINT nID;
		char szMenuText [100];

		if (uState & MF_POPUP)
		{
			nID = (UINT) CopyMenu (GetSubMenu (hMenu, i));
			uState = MF_POPUP | MF_STRING;
		}
		else
			nID = GetMenuItemID (hMenu, i);

		GetMenuString (hMenu, i, szMenuText, sizeof (szMenuText), MF_BYPOSITION);

		
		AppendMenu (hCopy, uState, nID, szMenuText);
	}

	return hCopy;
}
开发者ID:HackLinux,项目名称:Free-Download-Manager-vs2010,代码行数:26,代码来源:fsODMenu.cpp

示例13: ATLASSERT

// 增加窗口弹出的代码开始
///////////////////////////////////////////////////////////////////////////////////////////////////////
LRESULT CFloatingWnd::OnInitMenuPopup(UINT uMsg,WPARAM wParam,LPARAM lParam,BOOL& bHandled)
{
	int nPos;
	UINT uId;
	// Call CCoolContextMenu's implementation
	CCoolContextMenu<CFloatingWnd>::OnInitMenuPopup(uMsg, wParam, lParam, bHandled);
	// Set the cursor shape to an arrow
	m_hCursor = ::LoadCursor(NULL, IDC_ARROW);
	ATLASSERT(m_hCursor);
	::SetCursor(m_hCursor);
	CMenuHandle menuPopup = (HMENU)wParam;
	ATLASSERT(menuPopup.m_hMenu != NULL);
	for (nPos = 0; nPos < menuPopup.GetMenuItemCount(); nPos++)
	{ 
		uId = GetMenuItemID(menuPopup, nPos);
		switch (uId) 
		{ 
		case ID_EDIT_SELECT_ALL:
			EnableMenuItem(menuPopup, uId, (GetWindowTextLength() > 0) ? MF_BYCOMMAND | MF_ENABLED : MF_BYCOMMAND | MF_GRAYED);
			break;
		case ID_EDIT_CUT: 
		case ID_EDIT_COPY: 
		case ID_EDIT_PASTE: 
			EnableMenuItem(menuPopup, uId, IsClipboardFormatAvailable(CF_TEXT) ? MF_BYCOMMAND | MF_ENABLED : MF_BYCOMMAND | MF_GRAYED);
			break;
		default:
			break;
		}
	}
	return 0;
}
开发者ID:henrywoo,项目名称:ultraie,代码行数:33,代码来源:FloatingWnd.cpp

示例14: UINT

BOOL CRecBinViewer::ExecCommand (LPCONTEXTMENU pCtxMenu,  LPCTSTR lpszCommand)
{
	UINT uiID = UINT (-1);
	UINT uiCommand = 0;
	UINT uiMenuFirst = 1;
	UINT uiMenuLast = 0x00007FFF;
	HMENU hmenuCtx;
	int iMenuPos = 0;
	int iMenuMax = 0;
	TCHAR szMenuItem[MAX_PATH];	
	TCHAR verb[MAX_PATH] ;

	hmenuCtx = CreatePopupMenu();
	HRESULT hr = pCtxMenu->QueryContextMenu(hmenuCtx, 0, uiMenuFirst, uiMenuLast, CMF_NORMAL);

	iMenuMax = GetMenuItemCount(hmenuCtx);
	
	for (iMenuPos = 0 ; iMenuPos < iMenuMax; iMenuPos++)
	{
		GetMenuString(hmenuCtx, iMenuPos, szMenuItem, MAX_PATH, MF_BYPOSITION) ;
	
		uiID = GetMenuItemID(hmenuCtx, iMenuPos) ;
		
		if ((uiID == -1) || (uiID == 0))
		{
			
		}
		else
		{
			hr = pCtxMenu->GetCommandString(uiID - 1, GCS_VERB, NULL, (LPSTR)verb, MAX_PATH);
			if (FAILED (hr))
			{
				verb[0] = TCHAR ('\0') ;
			}
			else
			{
				if (0 == _tcsicmp (verb, lpszCommand))				
					uiCommand = uiID - 1;				
			}			
		}
	}
	
	if ((UINT)-1 != uiCommand)
	{
		CMINVOKECOMMANDINFO cmi;			
		ZeroMemory(&cmi, sizeof(CMINVOKECOMMANDINFO));
		cmi.cbSize			= sizeof(CMINVOKECOMMANDINFO);
		cmi.fMask			= CMIC_MASK_FLAG_NO_UI;
		cmi.hwnd			= m_hWnd;				
		cmi.lpVerb			= (LPSTR)MAKEINTRESOURCE (uiCommand);
		cmi.nShow			= SW_SHOWNORMAL;		
		hr = pCtxMenu->InvokeCommand(&cmi);			
		if (SUCCEEDED (hr))		
			return TRUE;		
	}

	return false;
}
开发者ID:avrionov,项目名称:explorerxp,代码行数:58,代码来源:RecBinViewer.cpp

示例15: InitMenuPopup

static void InitMenuPopup(HMENU hMenu, LPARAM index)
{
    if ((GetMenuItemID(hMenu, 0) == CMD_DELETE) || (GetMenuItemID(hMenu, 1) == CMD_SAVE_AS))
    {
        if (CountClipboardFormats() == 0)
        {
            EnableMenuItem(hMenu, CMD_DELETE, MF_GRAYED);
            EnableMenuItem(hMenu, CMD_SAVE_AS, MF_GRAYED);
        }
        else
        {
            EnableMenuItem(hMenu, CMD_DELETE, MF_ENABLED);
            EnableMenuItem(hMenu, CMD_SAVE_AS, MF_ENABLED);
        }
    }

    DrawMenuBar(Globals.hMainWnd);
}
开发者ID:JaredSmudde,项目名称:reactos,代码行数:18,代码来源:clipbrd.c


注:本文中的GetMenuItemID函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。