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


C++ GetMenuItemInfo函数代码示例

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


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

示例1: LoadMenu

//----------------------------------------------------------------------------------------------
//	ShowRightPopupMenu
//----------------------------------------------------------------------------------------------
VOID CStatusAreaIcon::ShowRightPopupMenu()
{
	//	プロパティ シートの状態を取得する
	BOOL	PropertySheetOpened	= PropertySheet->IsOpened();

	//	ポップアップ メニューを作成する
	HMENU	Menu		= LoadMenu( Instance, MAKEINTRESOURCE( IDR_MENU ) );
	HMENU	PopupMenu	= GetSubMenu( Menu, 0 );

	//	「プロパティ」をデフォルトにする
	MENUITEMINFO	ItemInfo;
	ZeroMemory( &ItemInfo, sizeof( ItemInfo ) );
	ItemInfo.cbSize	= sizeof( ItemInfo );
	GetMenuItemInfo( PopupMenu, IDM_PROPERTY, FALSE, &ItemInfo );
	ItemInfo.fMask	= MIIM_STATE;
	ItemInfo.fState	= MFS_ENABLED | MFS_DEFAULT;
	if( PropertySheetOpened == TRUE )
	{
		ItemInfo.fState	|= MFS_DISABLED;
	}
	SetMenuItemInfo( PopupMenu, IDM_PROPERTY, FALSE, &ItemInfo );

	//	「設定の自動切換え」のチェックを設定する
	GetMenuItemInfo( PopupMenu, IDM_AUTO_SETTING_CHANGE, FALSE, &ItemInfo );
	ItemInfo.fMask	= MIIM_STATE;
	ItemInfo.fState	= MFS_ENABLED;
	if( Setting->AutoSettingChange == TRUE )
	{
		ItemInfo.fState	|= MFS_CHECKED;
	}
	if( PropertySheetOpened == TRUE )
	{
		ItemInfo.fState	|= MFS_DISABLED;
	}
	SetMenuItemInfo( PopupMenu, IDM_AUTO_SETTING_CHANGE, FALSE, &ItemInfo );

	//	「終了」の有効・無効を設定する
	GetMenuItemInfo( PopupMenu, IDM_EXIT, FALSE, &ItemInfo );
	ItemInfo.fMask	= MIIM_STATE;
	ItemInfo.fState	= MFS_ENABLED;
	if( PropertySheetOpened == TRUE )
	{
		ItemInfo.fState	|= MFS_DISABLED;
	}
	SetMenuItemInfo( PopupMenu, IDM_EXIT, FALSE, &ItemInfo );

	//	ポップアップ メニューを表示する
	SetForegroundWindow( Wnd );
	POINT	CursorPos;
	GetCursorPos( &CursorPos );
	TrackPopupMenuEx(
		 PopupMenu
		,TPM_LEFTALIGN | TPM_RIGHTBUTTON
		,CursorPos.x
		,CursorPos.y
		,Wnd
		,NULL );
	DestroyMenu( Menu );
	PostMessage( Wnd, WM_NULL, 0, 0 );
}
开发者ID:MasashiWada,项目名称:Xbox360-Controller-Driver,代码行数:63,代码来源:status_area_icon.cpp

示例2: onConfigMenuCommand

BOOL    onConfigMenuCommand(HWND hWnd, DWORD id)
{
	wchar_t path[MAX_PATH+1];
    get_directory_path(path);

	MENUITEMINFO mii;
	memset(&mii, 0, sizeof(mii));
	mii.cbSize = sizeof(mii);
	mii.fMask = MIIM_TYPE | MIIM_ID;
    mii.fType = MFT_STRING;

	HMENU hMenu = GetSystemMenu(hWnd, FALSE);
    if (GetMenuItemInfo(hMenu, id, 0, &mii))
    {
        wchar_t sz[MAX_PATH+1], filepath[MAX_PATH+1];
        mii.dwTypeData = sz;
        mii.cch++;
        GetMenuItemInfo(hMenu, id, 0, &mii);
        wsprintf(filepath, L"%s\\%s", path, sz);
        /* need to open file and update config here */
        MessageBox(hWnd, filepath, L"", MB_OK);
		reloadConfig(filepath);
    }

    return(TRUE);
}
开发者ID:u338steven,项目名称:afxtools,代码行数:26,代码来源:misc.cpp

示例3: DeleteAllBitmaps

void DeleteAllBitmaps (HWND hwnd)
{
     HMENU        hMenu ;
     int          i ;
     MENUITEMINFO mii = { sizeof (MENUITEMINFO), MIIM_SUBMENU | MIIM_TYPE } ;

          // Delete Help bitmap on system menu

     hMenu = GetSystemMenu (hwnd, FALSE);
     GetMenuItemInfo (hMenu, IDM_HELP, FALSE, &mii) ;
     DeleteObject ((HBITMAP) mii.dwTypeData) ;

          // Delete top-level menu bitmaps

     hMenu = GetMenu (hwnd) ;

     for (i = 0 ; i < 3 ; i++)
     {
          GetMenuItemInfo (hMenu, i, TRUE, &mii) ;
          DeleteObject ((HBITMAP) mii.dwTypeData) ;
     }

          // Delete bitmap items on Font menu

     hMenu = mii.hSubMenu ;;

     for (i = 0 ; i < 3 ; i++)
     {
          GetMenuItemInfo (hMenu, i, TRUE, &mii) ;
          DeleteObject ((HBITMAP) mii.dwTypeData) ;
     }
}
开发者ID:Jeanhwea,项目名称:petzold-pw5e,代码行数:32,代码来源:GrafMenu.c

示例4: FindSortedPos

// find sorted position after the last separator
int FindSortedPos(HMENU hMenu, const char* text)
{
	int pos = -1, nbItems = GetMenuItemCount(hMenu);
#ifdef _WIN32
	wchar_t widetext[4096], widebuf[4096];
	MultiByteToWideChar(CP_UTF8, 0, text, -1, widetext, 4096);
	_locale_t locale = _create_locale(LC_ALL, "");
#else
	char buf[4096] = "";
#endif
	MENUITEMINFO mi = {sizeof(MENUITEMINFO),};
	mi.fMask = MIIM_TYPE;

	for (int i=nbItems-1; i>=0 ; i--)
	{
		GetMenuItemInfo(hMenu, i, true, &mi);
		if (mi.fType == MFT_SEPARATOR)
			break;
#ifdef _WIN32
		GetMenuStringW(hMenu, i, widebuf, 4096, MF_BYPOSITION);
		if (_wcsnicoll_l(widetext, widebuf, 4096, locale) < 0) // setLocale() can break things (atof and comma as a decimal mark) so use temporary locale object
			pos = i;
#else
		GetMenuString(hMenu, i, buf, sizeof(buf), MF_BYPOSITION);
		if (strcasecmp(text, buf) < 0) // not as good as on Win OS, e.g. French "Sélectionner" vs "Supprimer"
			pos = i;
#endif
	}
#ifdef _WIN32
	_free_locale(locale);
#endif
	return pos<0 ? nbItems : pos;
}
开发者ID:AusRedNeck,项目名称:sws,代码行数:34,代码来源:Menus.cpp

示例5: LocalizeMenu

void LocalizeMenu(HMENU hMenu, LocaleStringLookup *lookup)
{
    if(!lookup) lookup = locale;

    int itemCount = GetMenuItemCount(hMenu);
    if(itemCount == -1)
        return;

    bool bRTL = LocaleIsRTL(lookup);

    for(int i=0; i<itemCount; i++)
    {
        MENUITEMINFO mii;
        zero(&mii, sizeof(mii));
        mii.cbSize = sizeof(mii);
        mii.fMask = MIIM_SUBMENU|MIIM_STRING|MIIM_FTYPE;
        GetMenuItemInfo(hMenu, i, TRUE, &mii);

        if(mii.fType & MFT_SEPARATOR || mii.cch < 2)
            continue;

        HMENU hSubMenu = mii.hSubMenu;

        String strLookup;
        strLookup.SetLength(mii.cch);

        mii.fMask = MIIM_STRING;
        mii.dwTypeData = strLookup.Array();
        mii.cch = strLookup.Length()+1;
        GetMenuItemInfo(hMenu, i, TRUE, &mii);

        String strName;
        if(strLookup[0] == '.')
            strName = strLookup.Array()+1;
        else if(!lookup->HasLookup(strLookup))
            strName = strLookup;
        else
            strName = lookup->LookupString(strLookup);

        mii.fMask = MIIM_STRING|MIIM_FTYPE;
        mii.dwTypeData = strName.Array();

        SetMenuItemInfo(hMenu, i, TRUE, &mii);

        if(hSubMenu)
            LocalizeMenu(hSubMenu);
    }
}
开发者ID:Demiguise,项目名称:OBS,代码行数:48,代码来源:OBSApi.cpp

示例6: LocalizeMenu

void LocalizeMenu(HMENU hMenu) {
	if (Localization == NULL)
		return;

	MENUITEMINFO mii;
	mii.cbSize = sizeof(mii);
	mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_DATA;

	UINT idx = 0;
	while (GetMenuItemInfo(hMenu, idx, TRUE, &mii)) {
		if (mii.fType == MFT_STRING) {
			TCHAR *str = Localization->GetStr(mii.wID);
			if (str != NULL) {
				mii.cbSize = sizeof(mii);
				mii.fMask = MIIM_TYPE;
				mii.dwTypeData = (LPTSTR) str;
				mii.cch = wcslen(str);
				SetMenuItemInfo(hMenu, idx, TRUE, &mii);
			}
		}

		idx++;

		mii.cbSize = sizeof(mii);
		mii.fMask = MIIM_ID | MIIM_TYPE | MIIM_DATA;
	}
}
开发者ID:ardy30,项目名称:tman,代码行数:27,代码来源:Localization.cpp

示例7: RUNTIME_CLASS

void CDownloadMonitorDlg::OnContextMenu(CWnd* /*pWnd*/, CPoint point)
{
	CMainWnd* pMainWnd = (CMainWnd*)AfxGetMainWnd();
	if ( ! pMainWnd || ! IsWindow( pMainWnd->m_hWnd ) ) return;

	CDownloadsWnd* pDownWnd = (CDownloadsWnd*)pMainWnd->m_pWindows.Find( RUNTIME_CLASS(CDownloadsWnd) );
	if ( ! pDownWnd ) return;

	if ( ! pDownWnd->Select( m_pDownload ) ) return;

	CMenu* pPopup = ::Skin.GetMenu( _T("CDownloadsWnd.Download") );
	if ( ! pPopup ) return;

	MENUITEMINFO pInfo;
	pInfo.cbSize	= sizeof(pInfo);
	pInfo.fMask		= MIIM_STATE;
	GetMenuItemInfo( pPopup->GetSafeHmenu(), m_pDownload->IsCompleted() ?
		ID_DOWNLOADS_LAUNCH_COMPLETE : ID_DOWNLOADS_LAUNCH_COPY, FALSE, &pInfo );
	pInfo.fState	|= MFS_DEFAULT;
	SetMenuItemInfo( pPopup->GetSafeHmenu(), m_pDownload->IsCompleted() ?
		ID_DOWNLOADS_LAUNCH_COMPLETE : ID_DOWNLOADS_LAUNCH_COPY, FALSE, &pInfo );

	CoolMenu.AddMenu( pPopup, TRUE );

	UINT nID = pPopup->TrackPopupMenu( TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON|TPM_RETURNCMD,
		point.x, point.y, pDownWnd );

	if ( nID && pDownWnd->Select( m_pDownload ) )
	{
		pDownWnd->SendMessage( WM_COMMAND, nID );
	}
}
开发者ID:ivan386,项目名称:Shareaza,代码行数:32,代码来源:DlgDownloadMonitor.cpp

示例8: menu_search

/**
 * Search a menu for an item containing the given data.
 *
 * @param menu Menu handle
 * @param data Pointer to menu item data
 * @return Item number within menu, or -1 if not found or error
 */
static int
menu_search(HMENU menu, const char *data)
{
	int item, count;

	count = GetMenuItemCount(menu);
	if (count == -1) {
		return -1;
	}

	for (item = 0; item < count; item++) {
		MENUITEMINFO mii;
		char buffer[1024];

		/* Retrieve the string if this menu item contains string data */
		buffer[0] = '\0';
		mii.cbSize = sizeof(MENUITEMINFO);
		mii.fMask = MIIM_STRING;
		mii.dwTypeData = buffer;
		mii.cch = sizeof(buffer);
		if (GetMenuItemInfo(menu, item, TRUE, &mii) == 0) {
			return -1;
		}

		/* Compare with given data */
		if (strcmp(buffer, data) == 0) {
			return item;
		}
	}

	return -1;
}
开发者ID:dwhinham,项目名称:rpcemu,代码行数:39,代码来源:rpc-win.c

示例9: menu_t

		menu_t( HWND hwnd, boost::string_ref path, boost::string_ref root_name ) :
			root_( winapi::load_menu( path, ID ) )
		{
			auto const src = winapi::get_menu( hwnd );
			if( !src ) {
				winapi::message_box( u8"MMAccel", u8"メニューハンドルを取得できません", MB_OK | MB_ICONERROR );
			}

			int index = 0;
			for(  ; index < winapi::get_menu_item_count( src ); ++index ) {
				MENUITEMINFO info;
				info.cbSize = sizeof( info );
				info.fMask = MIIM_FTYPE;
				GetMenuItemInfo( src.get(), index, TRUE, &info );
				if( info.fType & MFT_RIGHTJUSTIFY ) {
					break;
				}
			}

			if( src && !winapi::insert_menu( src, index, winapi::get_sub_menu( root_, 0 ), root_name ) ) {
				winapi::last_error_message_box( u8"MMAccel", u8"insert_menu error" );
			}

			DrawMenuBar( hwnd );
		}
开发者ID:LNSEAB,项目名称:mmaccel,代码行数:25,代码来源:menu.hpp

示例10: DestroyMenuData

BOOL DestroyMenuData(HMENU hMenu, BOOL destroyMenu)
{
   INT i;
   for (i = 0; i < GetMenuItemCount(hMenu); i++)
   {
      MENUITEMINFO menuInf;
      ZeroMemory(&menuInf, sizeof(menuInf));
      menuInf.cbSize = sizeof(menuInf);
      menuInf.fMask = MIIM_DATA | MIIM_SUBMENU;
      if (GetMenuItemInfo(hMenu, i, TRUE, &menuInf))
      {
         pItemData pData = (pItemData)menuInf.dwItemData;
         DestroyIcon(pData->largeIcon);
         DestroyIcon(pData->smallIcon);
         if (pData->extra)
            delete pData->extra;
         delete pData;
      }
      if (menuInf.hSubMenu)
         DestroyMenuData(menuInf.hSubMenu);
   }
   if (destroyMenu)
	   DestroyMenu(hMenu);
   return TRUE;
}
开发者ID:plerup,项目名称:LaunchBar,代码行数:25,代码来源:utils.cpp

示例11: IterateThroughItems

static void IterateThroughItems(HWND WND, HMENU menu, POINT *p)
{
	int count = GetMenuItemCount(menu);
	RECT rec;
	MENUITEMINFO info;
	int i;
	for (i=0; i<count; i++) {
		if (GetMenuItemRect(WND, menu, i, &rec) && (rec.left<=p->x) && (p->x<=rec.right) && (rec.top<=p->y) && (p->y<=rec.bottom)) {
			ZeroMemory(&info, sizeof(info));
			info.cbSize = sizeof(info);
			info.fMask = MIIM_TYPE | MIIM_SUBMENU;
			info.cch = 256;
			info.dwTypeData = malloc(256);
			GetMenuItemInfo(menu, i, TRUE, &info);
			if (info.cch>0) {
				if (info.cch > 255)
					CurParams->WordLen = 255;
				else
					CurParams->WordLen = info.cch;
				CurParams->Unicode = FALSE;
				CurParams->WordLen = MyCopyMemory(CurParams->MatchedWordA, info.dwTypeData, CurParams->WordLen);
				CurParams->BeginPos = 0;
			}
			free(info.dwTypeData);
			break;
		}
	}
}
开发者ID:PurlingNayuki,项目名称:stardictproject,代码行数:28,代码来源:TextOutHook.c

示例12: ZeroMemory

//===========================================================================
void ContextMenu::Copymenu(HMENU hm)
{
	TCHAR text_string[256];
	for (int i = 0; i < GetMenuItemCount(hm); i++)
	{
		MENUITEMINFO info;
		ZeroMemory(&info, sizeof(info));
		info.cbSize = sizeof(MENUITEMINFO_0400); // to make this work on win95
		info.fMask  = MIIM_DATA|MIIM_ID|MIIM_SUBMENU|MIIM_TYPE;
		GetMenuItemInfo (hm, i, TRUE, &info);

		text_string[0]=0;
		if (0 == (info.fType & MFT_OWNERDRAW))
			GetMenuString(hm, i, text_string, 128, MF_BYPOSITION);

		//TCHAR buffer[256]; _stprintf(buffer, _T("%d %s"), info.wID, text_string); _tcscpy(text_string, buffer);

		Menu *CM = NULL;
		if (info.hSubMenu)
		{
			wc->HandleMenuMsg(WM_INITMENUPOPUP, (WPARAM)info.hSubMenu, MAKELPARAM(i, FALSE));
			CM = new ContextMenu(text_string, wc, info.hSubMenu, 0);
		}
		else
		if (info.fType & MFT_SEPARATOR)
		{
			//MakeMenuNOP(this, NULL);
			continue;
		}

		MenuItem *CI = new ContextItem(CM, text_string, info.wID, info.dwItemData, info.fType);
		AddMenuItem(CI);
	}
}
开发者ID:fin-alice,项目名称:bb4nt,代码行数:35,代码来源:Contextmenu.cpp

示例13: ASSERT

BOOL CCoolMenu::ReplaceMenuText(CMenu* pMenu, int nPosition, MENUITEMINFO FAR* mii, LPCTSTR pszText)
{
	if ( ! pMenu || mii == NULL )
		return FALSE;
	ASSERT( mii->dwTypeData );

	int nItemID = pMenu->GetMenuItemID( nPosition );

	if ( ! ModifyMenu( pMenu->GetSafeHmenu(), nPosition, MF_BYPOSITION|MF_STRING, nItemID, pszText ) )
		return FALSE;

	mii->dwTypeData = (LPTSTR)pszText;

	mii->cch = CString( pszText ).GetLength() + 1;
	mii->fMask = MIIM_DATA|MIIM_ID|MIIM_FTYPE|MIIM_STRING;

	// We modified menu, retrieve a new MII (validates and changes data)
	if ( ! GetMenuItemInfo( pMenu->GetSafeHmenu(), nPosition, TRUE, mii ) )
		return FALSE;

	// Replace the corresponding value in the collection
	mii->dwItemData	= ( (DWORD_PTR)pMenu->GetSafeHmenu() << 16 ) | ( mii->wID & 0xFFFF );
	CString strNew( (LPCTSTR)mii->dwTypeData );
	m_pStrings.SetAt( mii->dwItemData, strNew );

	return TRUE;
}
开发者ID:lemonxiao0,项目名称:peerproject,代码行数:27,代码来源:CoolMenu.cpp

示例14: IterateThroughItems

static void IterateThroughItems(HWND WND, HMENU menu, POINT *p)
{
	int count = GetMenuItemCount(menu);
	RECT rec;
	MENUITEMINFO info;
	int i;
	TCHAR buf[MATCHED_WORD_BUF_SIZE];
	for (i=0; i<count; i++) {
		if (GetMenuItemRect(WND, menu, i, &rec) && (rec.left<=p->x) 
			&& (p->x<=rec.right) && (rec.top<=p->y) && (p->y<=rec.bottom)) {
			ZeroMemory(&info, sizeof(info));
			info.cbSize = sizeof(info);
			info.fMask = MIIM_TYPE | MIIM_SUBMENU;
			info.cch = MATCHED_WORD_BUF_SIZE;
			info.dwTypeData = buf;
			GetMenuItemInfo(menu, i, TRUE, &info);
			if (info.cch>0) {
				if (info.cch >= MATCHED_WORD_BUF_SIZE)
					CurParams->WordLen = MATCHED_WORD_BUF_SIZE-1;
				else
					CurParams->WordLen = info.cch;
#ifdef UNICODE
				CurParams->Unicode = TRUE;
				CurParams->WordLen = MyCopyMemory(CurParams->MatchedWordW, info.dwTypeData, CurParams->WordLen);
#else
				CurParams->Unicode = FALSE;
				CurParams->WordLen = MyCopyMemory(CurParams->MatchedWordA, info.dwTypeData, CurParams->WordLen);
#endif
				CurParams->BeginPos = 0;
			}
			break;
		}
	}
}
开发者ID:2php,项目名称:stardict-3,代码行数:34,代码来源:TextOutHook.c

示例15: GetMenuItemInfo

void CaImMenu::MeasureItem (LPMEASUREITEMSTRUCT lpMeasureItemStruct) {
	MENUITEMINFO iInfo;
	GetMenuItemInfo (lpMeasureItemStruct->CtlID, &iInfo);
	CaImMenuItem* pItem = (CaImMenuItem*)lpMeasureItemStruct->itemData;

	CFont fntDef;
	LOGFONT lfDef;
	CClientDC dc (0);
	CFont* pFont = (CFont *)dc.SelectStockObject (ANSI_VAR_FONT);
	if (pItem->CheckStyle (AMIS_DEFAULT)) {
		CFont* pFnt = dc.GetCurrentFont ();
		pFnt->GetLogFont (&lfDef);
		lfDef.lfWeight = FW_BOLD;
		fntDef.CreateFontIndirect (&lfDef);
		dc.SelectObject (&fntDef);
	}

	if (pItem->CheckStyle (AMIS_BAR))
		lpMeasureItemStruct->itemHeight = 4;
	else
		lpMeasureItemStruct->itemHeight = m_dwHeight;
	lpMeasureItemStruct->itemWidth = 25 + 8 + 8 + 2 + dc.GetTextExtent (pItem->GetText ()).cx;

	dc.SelectObject (pFont);
	if (pItem->CheckStyle (AMIS_DEFAULT))
		fntDef.DeleteObject ();
}
开发者ID:macx0r,项目名称:dias-inet,代码行数:27,代码来源:aimmenu.cpp


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