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


C++ GetMenuString函数代码示例

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


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

示例1: mh_getLabel

static const wchar_t* mh_getLabel (menu* m) {
int ll = GetMenuString(m->parent, m->command, NULL, 0, MF_BYCOMMAND);
wchar_t* wc = malloc(sizeof(wchar_t) * (ll+1));
GetMenuString(m->parent, m->command, wc, ll+1, MF_BYCOMMAND);
wc[ll]=0;
wchar_t* z = wcschr(wc, 8);
if (z)  *z=0;
return wc;
}
开发者ID:qtnc,项目名称:6pad,代码行数:9,代码来源:luamenuhandle.c

示例2: 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

示例3: GetMenuItemCount

void COwnMenu::MakeItemsOwnDraw(BOOL bFirst)
{
	int iMaxItems = GetMenuItemCount();
	for(int i = 0; i < iMaxItems; i++)
	{
		CString nameHolder;
		MenuObject* pObject = new MenuObject;
		deleteItem.push_back((DWORD)pObject);
		pObject->m_hIcon = NULL;
		pObject->bFirstMenu = bFirst;
		GetMenuString(i, pObject->m_strCaption, MF_BYPOSITION);
		MENUITEMINFO mInfo;
		ZeroMemory(&mInfo, sizeof(MENUITEMINFO));
		UINT uID = mInfo.wID; //I dont use GetMenuItemID because it doesn't return 0/-1 when it's a Popup (so the MSDN is wrong)
		ModifyMenu(i, MF_BYPOSITION | MF_OWNERDRAW,
			uID, (char*)pObject);


		if(GetSubMenu(i))
		{
		COwnMenu* pSubMenu = new COwnMenu;
		deleteMenu.push_back((DWORD)pSubMenu);
		pSubMenu->Attach(GetSubMenu(i)->GetSafeHmenu());		
		pSubMenu->MakeItemsOwnDraw();
		}
	}
}
开发者ID:SulfredLee,项目名称:MFC_collections,代码行数:27,代码来源:OwnMenu.cpp

示例4: 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

示例5: GetCodeTitle

void GetCodeTitle(
    LPEVENTINFOS2 eiPtr,
    short code,
    short param,
    short mn,
    LPSTR strBuf,
    WORD maxLen )
{
	HMENU		hMn;

	// Finds event in array
	eiPtr=GetEventInformations(eiPtr, code);

	// If a special string is to be returned
	short strID = EVINFO2_PARAMTITLE(eiPtr, param);

	if ( strID != 0 )
		LoadString(hInstLib, strID, strBuf, maxLen);
	else
	{
		// Otherwise, returns the menu option 
		if ((hMn = LoadMenu(hInstLib, MAKEINTRESOURCE(mn))) != NULL )
		{
			GetMenuString(hMn, eiPtr->menu, strBuf, maxLen, MF_BYCOMMAND);
			DestroyMenu(hMn);
		}
	}
}
开发者ID:clickteam-plugin,项目名称:ASCII,代码行数:28,代码来源:Edittime.cpp

示例6: 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

示例7: MenuAddLanguage

/*
 * MenuAddLanguage:  Add given language to Language menu.
 */
void MenuAddLanguage(int lang_id)
{
   int num, index, len;
   char item_name[MAXRSCSTRING + 1], *name = NULL;

   if (lang_id > MAX_LANGUAGE_ID)
      return;

   num = GetMenuItemCount(language_menu);

   for(int i = 0; i < MAX_LANGUAGE_ID; i++)
      if(language_id_table[i].languageid == lang_id)
      {
         name = language_id_table[i].language_name;

         break;
      }

   // Add in sorted order.
   for (index = 0; index < num; index++)
   {
      len = GetMenuString(language_menu, index, item_name, MAXRSCSTRING, MF_BYPOSITION);
      if (len == 0)
         continue;
      if (stricmp(item_name, name) >= 0)
         break;
   }

   // Check for adding to end of list.
   if (index == num)
      index = -1;

   InsertMenu(language_menu, index, MF_STRING | MF_BYPOSITION, 
         ID_LANGUAGE + lang_id, name);
}
开发者ID:GarOfMeridian,项目名称:Meridian59_103,代码行数:38,代码来源:language.c

示例8: kwin_save_file_menu

/*
 * Function: Save the items on the file menu in the KERBEROS.INI file.
 *
 * Parameters:
 *	hwnd - handle of the dialog containing the file menu.
 */
static void
kwin_save_file_menu(HWND hwnd)
{
  HMENU hmenu;
  int i;
  int id;
  int ctitems;
  char menuitem[MAX_K_NAME_SZ + 3];

  hmenu = GetMenu(hwnd);
  assert(hmenu != NULL);

  hmenu = GetSubMenu(hmenu, 0);
  assert(hmenu != NULL);

  ctitems = GetMenuItemCount(hmenu);
  assert(ctitems >= FILE_MENU_ITEMS);

  id = 0;
  for (i = FILE_MENU_ITEMS + 1; i < ctitems; i++) {
    GetMenuString(hmenu, i, menuitem, sizeof(menuitem), MF_BYPOSITION);

    strcpy(cns_res.logins[id], menuitem + 3);

    id++;
  }
}
开发者ID:Akasurde,项目名称:krb5,代码行数:33,代码来源:cns.c

示例9: 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

示例10: DlgProc

BOOL CALLBACK DlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	HMENU hMenu;
	switch (message)
	{
	case WM_CLOSE:
		DestroyWindow(hWnd);
		PostQuitMessage(0);
		return TRUE;

	case WM_INITDIALOG:
		hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MENU1));
		// Присоединим меню к главному окну приложения
		SetMenu(hWnd, hMenu);
		return TRUE;

	case WM_COMMAND:
	{
		TCHAR str1[300], str2[50];
		HMENU hMenu = GetMenu(hWnd);
		GetMenuString(hMenu, LOWORD(wParam), str2, 50, MF_BYCOMMAND);
		if (HIWORD(wParam) == 1)
			_tcscpy_s(str1,300, TEXT("Пункт меню выбран с помощью акселератора\n"));
		else if (HIWORD(wParam) == 0)
			_tcscpy_s(str1,300, TEXT("Пункт меню выбран при непосредственном обращении к меню\n"));
		_tcscat_s(str1,300, str2);
		MessageBox(hWnd, str1, TEXT("Меню и акселераторы"), MB_OK | MB_ICONINFORMATION);
	}
		return TRUE;
	}
	return FALSE;
}
开发者ID:CAHbl4,项目名称:WinAPI,代码行数:32,代码来源:Main.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: switch

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 通知消息
VOID CChildWnd::OnNotify(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch ((uMsg == WM_NOTIFY)	? ((LPNMHDR) lParam)->code : uMsg)
	{
	case TTN_NEEDTEXT:
		// 显示工具栏提示
		GetMenuString(CMainWnd::m_hMenu, (UINT) wParam, ((LPTOOLTIPTEXT) lParam)->szText, 80, MF_BYCOMMAND);

	case WM_MENUSELECT:
		// 在状态栏显示相应的菜单项提示
		CLanguage::TranslateString(LOWORD(wParam));
		if (CLanguage::m_tzText[0])
		{
			SetStatusText(hWnd, CLanguage::m_tzText);
			break;
		}

	case TTN_POP:
	case WM_EXITMENULOOP:
		// 在状态栏显示“就绪”
		SetStatusText(hWnd, LNG_Ready);
		break;

	case NM_CLICK:
		if (((LPNMHDR) lParam)->idFrom == IDC_StatusBar)
		{
			GetWnd(hWnd)->OnClickStatusBar((UINT) ((LPNMMOUSE) lParam)->dwItemSpec);
		}
		break;
	}
}
开发者ID:Yonsm,项目名称:RawPlayer,代码行数:33,代码来源:ChildWnd.cpp

示例13: 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

示例14: oof

LRESULT CALLBACK oof(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	NMHDR *hdr = (NMHDR *)lParam;

	switch(msg)
	{
	case WM_COMMAND:
		switch(LOWORD(wParam))
		{
		case 6666:
			if(HIWORD(wParam) == CBN_EDITCHANGE)
			{
				TCHAR wstr[64];
				BYTE buf[64];
				int len;
				GetWindowText((HWND)lParam, wstr, 64);
				len = WideCharToMultiByte(CP_ACP, 0, wstr, -1, (char *)buf, 64, 0, 0);
				
				HexView_SetSearchPattern(g_hwndHexView, buf, len - 1);
				InvalidateRect(g_hwndHexView, 0, 0);
				return 0;
			}
			return 0;
		}
		return 0;

	case WM_NOTIFY:
		if(hdr->code == TBN_DROPDOWN)
		{
			RECT rect;
			HMENU hMenu;
			int cmd;
			TCHAR buf[20];
			TBBUTTONINFO tbbi = { sizeof(tbbi) };
			
			hMenu = LoadMenu(0, MAKEINTRESOURCE(IDR_SEARCHBAR_FINDTYPE));
			hMenu = GetSubMenu(hMenu, 0);
			SendMessage(hdr->hwndFrom, TB_GETITEMRECT, 0, (LPARAM)&rect);
			MapWindowPoints(hdr->hwndFrom, 0, (POINT *)&rect, 2);

			cmd = TrackPopupMenu(hMenu, TPM_LEFTALIGN|TPM_TOPALIGN|TPM_RETURNCMD|TPM_NONOTIFY, rect.left, rect.bottom, 0, hwnd, 0);

			if(cmd != 0)
			{
				GetMenuString(hMenu, cmd, buf, 20, MF_BYCOMMAND);
				tbbi.dwMask = TBIF_COMMAND|TBIF_TEXT;
				tbbi.idCommand = IDM_FILE_OPEN;
				tbbi.pszText   = buf;
				SendMessage(hdr->hwndFrom, TB_SETBUTTONINFO, IDM_FILE_OPEN, (LPARAM)&tbbi);
			}

			return TBDDRET_DEFAULT;
		}
		break;
	}
	
	return DefWindowProc(hwnd, msg, wParam, lParam);
}
开发者ID:HTshandou,项目名称:HexEdit,代码行数:58,代码来源:Searchbar.c

示例15: setupSystemMenu

static void setupSystemMenu( HWND hwnd ) {
    HMENU       smh;
    HMENU       mh;
    char        menuname[256];

    smh = GetSystemMenu( hwnd, FALSE );
    mh = GetMenu( hwnd );
    AppendMenu( smh, MF_SEPARATOR, 0,NULL );
    GetMenuString( mh, MENU_LOG_CURRENT_STATE, menuname, sizeof( menuname ),
                   MF_BYCOMMAND );
    AppendMenu( smh, MF_ENABLED, MENU_LOG_CURRENT_STATE, menuname );
    GetMenuString( mh, MENU_LOG_OPTIONS, menuname, sizeof( menuname ),
                   MF_BYCOMMAND );
    AppendMenu( smh, MF_ENABLED, MENU_LOG_OPTIONS, menuname );
    GetMenuString( mh, MENU_TASK_CTL, menuname, sizeof( menuname ),
                   MF_BYCOMMAND );
    AppendMenu( smh, MF_ENABLED, MENU_TASK_CTL, menuname );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:18,代码来源:drproc.c


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