本文整理汇总了C++中InsertMenuItem函数的典型用法代码示例。如果您正苦于以下问题:C++ InsertMenuItem函数的具体用法?C++ InsertMenuItem怎么用?C++ InsertMenuItem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了InsertMenuItem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
bool
MenuOperator::add_item(const Menu& submenu)
{
MENUITEMINFO menu_item_info;
menu_item_info.cbSize = sizeof(MENUITEMINFO);
menu_item_info.fMask = MIIM_SUBMENU | MIIM_TYPE;
menu_item_info.fType = MFT_STRING;
menu_item_info.hSubMenu = submenu.handle();
menu_item_info.dwTypeData = const_cast<char*>(submenu.label().c_str());
menu_item_info.cch = submenu.label().length();
InsertMenuItem(handle(), 0xffff, TRUE, &menu_item_info);
return true;
}
示例2: sysmenu_init_topmost
void sysmenu_init_topmost(HWND hWnd, HMENU hMenu)
{
MENUITEMINFO mii;
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_TYPE | MIIM_ID | MIIM_CHECKMARKS;
mii.fType = MFT_STRING;
mii.wID = IDM_TOPMOST;
mii.dwTypeData = (LPWSTR)L"TopMost (&T)";
mii.cch = (UINT) wcslen(mii.dwTypeData);
InsertMenuItem(hMenu, SC_CLOSE, FALSE, &mii);
changeStateTopMostMenu(hWnd,hMenu);
}
示例3: menuhook
static void menuhook(const char* menustr, HMENU hMenu, int flag)
{
if (flag == 1)
{
// Delete all related project entries and regenerate
int iFirstPos;
hMenu = FindMenuItem(hMenu, g_projMgrCmdTable[g_iORPCmdIndex].accel.accel.cmd, &iFirstPos);
if (hMenu)
{
int iSlot = 0;
int iPos;
while (true)
{
int iCmd = GetLoadCommandID(iSlot, false);
if (iCmd)
{
if (FindMenuItem(hMenu, iCmd, &iPos))
DeleteMenu(hMenu, iPos, MF_BYPOSITION);
else
break;
}
else
break;
iSlot++;
}
if (!g_relatedProjects.Get()->GetSize())
{
MENUITEMINFO mi={sizeof(MENUITEMINFO),};
mi.fMask = MIIM_TYPE | MIIM_STATE | MIIM_ID;
mi.fType = MFT_STRING;
mi.fState = MFS_GRAYED;
mi.dwTypeData = (char *)__localizeFunc(g_projMgrCmdTable[g_iORPCmdIndex].menuText,"sws_menu",0);
mi.wID = g_projMgrCmdTable[g_iORPCmdIndex].accel.accel.cmd;
InsertMenuItem(hMenu, iFirstPos, true, &mi);
}
else
{
for (int i = 0; i < g_relatedProjects.Get()->GetSize(); i++)
AddToMenu(hMenu, g_relatedProjects.Get()->Get(i)->Get(), GetLoadCommandID(i, true), iFirstPos++, true, MFS_UNCHECKED);
}
}
}
}
示例4: assert
void Explorerplusplus::AddMenuEntries(LPITEMIDLIST pidlParent,
const std::list<LPITEMIDLIST> &pidlItemList,DWORD_PTR dwData,HMENU hMenu)
{
assert(dwData != NULL);
FileContextMenuInfo_t *pfcmi = reinterpret_cast<FileContextMenuInfo_t *>(dwData);
bool AddNewTabMenuItem = false;
if(pfcmi->uFrom == FROM_LISTVIEW)
{
if(pidlItemList.size() == 1)
{
SFGAOF FileAttributes = SFGAO_FOLDER;
LPITEMIDLIST pidlComplete = ILCombine(pidlParent,pidlItemList.front());
GetItemAttributes(pidlComplete,&FileAttributes);
CoTaskMemFree(pidlComplete);
if(FileAttributes & SFGAO_FOLDER)
{
AddNewTabMenuItem = true;
}
}
}
else if(pfcmi->uFrom == FROM_TREEVIEW)
{
/* The treeview only contains folders,
so the new tab menu item will always
be shown. */
AddNewTabMenuItem = true;
}
if(AddNewTabMenuItem)
{
MENUITEMINFO mii;
TCHAR szTemp[64];
LoadString(m_hLanguageModule,IDS_GENERAL_OPEN_IN_NEW_TAB,szTemp,SIZEOF_ARRAY(szTemp));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING|MIIM_ID;
mii.wID = MENU_OPEN_IN_NEW_TAB;
mii.dwTypeData = szTemp;
InsertMenuItem(hMenu,1,TRUE,&mii);
}
}
示例5: createpmenusettings
static HMENU createpmenusettings (void)
{
HMENU hmnu;
MENUITEMINFO mii;
memset (&mii, 0, sizeof(MENUITEMINFO));
mii.type = MFT_STRING;
mii.id = 0;
mii.typedata = (DWORD)SM_ST_SET;
hmnu = CreatePopupMenu (&mii);
mii.type = MFT_STRING ;
mii.state = 0;
mii.id = IDM_PREF;
mii.typedata = (DWORD)SM_ST_PREF;
InsertMenuItem(hmnu, 0, TRUE, &mii);
return hmnu;
}
示例6: memset
void CGitExtensionsShellEx::AddMenuItem(HMENU hMenu, LPSTR text, int resource, int firstId, int id, UINT position)
{
MENUITEMINFO mii;
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING | MIIM_ID;
if (resource)
{
mii.fMask |= MIIM_BITMAP;
mii.hbmpItem = IsVistaOrLater() ? IconToBitmapPARGB32(resource) : HBMMENU_CALLBACK;
myIDMap[id] = resource;
myIDMap[firstId + id] = resource;
}
mii.wID = firstId + id;
mii.dwTypeData = text;
InsertMenuItem(hMenu, position, TRUE, &mii);
}
示例7: MyInsertMenu
bool MyInsertMenu(HMENU hMenu, int pos, UINT id, const LPCTSTR szTitle, HBITMAP bm = NULL)
{
MENUITEMINFO MenuItem;
MenuItem.cbSize = sizeof(MenuItem);
if (szTitle)
MenuItem.fType = MFT_STRING;
else
MenuItem.fType = MFT_SEPARATOR;
MenuItem.fMask = MIIM_TYPE | MIIM_ID | MIIM_DATA;
if (bm)
MenuItem.fMask |= MIIM_CHECKMARKS;
MenuItem.wID = id;
MenuItem.hbmpChecked = bm;
MenuItem.hbmpUnchecked = bm;
MenuItem.dwTypeData = (LPWSTR)szTitle;
return InsertMenuItem(hMenu, pos, TRUE, &MenuItem) != 0;
}
示例8: CreatePopupMenu
void CMainWindow::CreateDebugMenu()
{
HMENU hMenu = CreatePopupMenu();
InsertMenu(hMenu, 0, MF_STRING, ID_MAIN_DEBUG_SHOWDEBUG, _T("Show Debugger"));
InsertMenu(hMenu, 1, MF_SEPARATOR, 0, nullptr);
InsertMenu(hMenu, 2, MF_STRING, ID_MAIN_DEBUG_DUMPFRAME, _T("Dump Next Frame\tF11"));
InsertMenu(hMenu, 3, MF_STRING, ID_MAIN_DEBUG_SHOWFRAMEDEBUG, _T("Show Frame Debugger"));
InsertMenu(hMenu, 4, MF_STRING | MF_CHECKED, ID_MAIN_DEBUG_ENABLEGSDRAW, _T("GS Draw Enabled"));
MENUITEMINFO ItemInfo;
memset(&ItemInfo, 0, sizeof(MENUITEMINFO));
ItemInfo.cbSize = sizeof(MENUITEMINFO);
ItemInfo.fMask = MIIM_STRING | MIIM_SUBMENU;
ItemInfo.dwTypeData = _T("Debug");
ItemInfo.hSubMenu = hMenu;
InsertMenuItem(GetMenu(m_hWnd), 3, TRUE, &ItemInfo);
}
示例9: sizeof
bool
CUpgradrToolbar::OnDisableDropdown(LPNMTOOLBAR data)
{
RECT rect;
m_kToolbar.SendMessage(TB_GETRECT, data->iItem, reinterpret_cast<LPARAM>(&rect));
m_kToolbar.MapWindowPoints(HWND_DESKTOP, reinterpret_cast<LPPOINT>(&rect), 2);
TPMPARAMS tpm;
tpm.cbSize = sizeof(tpm);
tpm.rcExclude = rect;
CMenu menu;
menu.LoadMenu(MAKEINTRESOURCE(IDR_DISABLEMENU));
if (menu.IsNull()) throw CUpgradrWindowsError(GetLastError());
ScriptManagerLock scriptManager;
MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
UINT pos = 0;
UINT uID = 1000;
CMenuHandle popupMenu = menu.GetSubMenu(0);
if (popupMenu.IsNull()) throw CUpgradrWindowsError(GetLastError());
CScriptManager::iterator i = scriptManager->begin();
while (i!=scriptManager->end())
{
CScript* script = i->second;
memset(&mii, 0, sizeof(MENUITEMINFO));
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_STATE | MIIM_STRING | MIIM_ID | MIIM_DATA;
mii.wID = uID++;
mii.fState = MFS_CHECKED;
mii.dwItemData = i->first;
TCHAR buf[1024];
_tcscpy_s(buf, 1024, script->Name());
mii.dwTypeData = buf;
InsertMenuItem(popupMenu, pos++, TRUE, &mii);
++i;
}
TrackPopupMenuEx(popupMenu, TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_VERTICAL, rect.left, rect.bottom, m_kToolbar, &tpm);
return true;
}
示例10: wxTreeItemId
void BundlePane::OnTreeEndDrag(wxTreeEvent& event) {
if (!m_draggedItem.IsOk()) return;
const wxTreeItemId itemSrc = m_draggedItem;
const wxTreeItemId itemDst = event.GetItem();
m_draggedItem = wxTreeItemId();
if (!itemDst.IsOk()) return; // Invalid destintion
if (itemSrc == itemDst) return; // Can't drag to self
if (IsTreeItemParentOf(itemSrc, itemDst)) return; // Can't drag to one of your own children
wxLogDebug(wxT("Ending Drag over item: %s"), m_bundleTree->GetItemText(itemDst).c_str());
const BundleItemData* srcData = (BundleItemData*)m_bundleTree->GetItemData(itemSrc);
const BundleItemData* dstData = (BundleItemData*)m_bundleTree->GetItemData(itemDst);
if (!dstData->IsMenuItem()) return; // You can only drag items to menu
if (dstData->m_bundleId != srcData->m_bundleId) return; // Items can only be dragged within same bundle
// We have to cache uuid of submenus
const wxString subUuid = (srcData->m_type == BUNDLE_SUBDIR) ? srcData->m_uuid : wxString(wxEmptyString);
const unsigned int bundleId = srcData->m_bundleId;
PListDict infoDict = GetEditableMenuPlist(bundleId);
// Insert the item
Freeze();
const wxString name = m_bundleTree->GetItemText(itemSrc);
const wxTreeItemId insertedItem = InsertMenuItem(itemDst, name, new BundleItemData(*srcData), infoDict);
if (srcData->m_type == BUNDLE_SUBDIR) {
CopySubItems(itemSrc, insertedItem);
}
// Delete source ref
if (srcData->IsMenuItem()) RemoveMenuItem(itemSrc, false, infoDict);
Thaw();
// Save the modified plist
m_plistHandler.SaveBundle(bundleId);
// Update menu in editorFrame
m_syntaxHandler.ReParseBundles(true/*onlyMenu*/);
}
示例11: InsertMenuItemWithSeparators
static void InsertMenuItemWithSeparators(HMENU hMenu, int uItem, MENUITEMINFO *lpmii)
{
TMO_IntMenuItem *pimi = MO_GetIntMenuItem((HGENMENU)lpmii->dwItemData), *p;
if (pimi == NULL)
return;
// check for separator before
if (uItem) {
UINT fType = GetMenuItemTypeData(hMenu, uItem - 1, p);
if (p != NULL && fType != MFT_SEPARATOR) {
if ((p->mi.position / SEPARATORPOSITIONINTERVAL) != (pimi->mi.position / SEPARATORPOSITIONINTERVAL)) {
// but might be supposed to be after the next one instead
if (!(uItem < GetMenuItemCount(hMenu) && GetMenuItemType(hMenu, uItem) == MFT_SEPARATOR))
InsertSeparator(hMenu, uItem);
uItem++;
}
}
}
// check for separator after
if (uItem < GetMenuItemCount(hMenu)) {
UINT fType = GetMenuItemTypeData(hMenu, uItem, p);
if (p != NULL && fType != MFT_SEPARATOR)
if ((p->mi.position / SEPARATORPOSITIONINTERVAL) != (pimi->mi.position / SEPARATORPOSITIONINTERVAL))
InsertSeparator(hMenu, uItem);
}
// create local copy *lpmii so we can change some flags
MENUITEMINFO mii = *lpmii;
int count = GetMenuItemCount(hMenu);
if (count != 0 && (count % 33) == 0 && pimi->mi.root != NULL) {
if (!(mii.fMask & MIIM_FTYPE))
mii.fType = 0;
mii.fMask |= MIIM_FTYPE;
mii.fType |= MFT_MENUBARBREAK;
}
if (!pimi->CustomName)
mii.dwTypeData = GetMenuItemText(pimi);
InsertMenuItem(hMenu, uItem, TRUE, &mii);
}
示例12: sizeof
bool LiferayNativityContextMenus::_InsertMenu(HMENU hMenu, int location, int command, const wchar_t* text, bool enabled)
{
MENUITEMINFO menuItem = { sizeof(menuItem) };
menuItem.fMask = MIIM_STRING | MIIM_ID | MIIM_STATE;
menuItem.dwTypeData = (LPWSTR)text;
menuItem.wID = command;
menuItem.fState = enabled ? MFS_ENABLED : MFS_GRAYED;
if (!InsertMenuItem(hMenu, location, TRUE, &menuItem))
{
return false;
}
return true;
}
示例13: menuitem_add
BOOL menuitem_add(HMENU hmenu, TCHAR* lpstr, UINT index, UINT id)
{
MENUITEMINFO mi;
mi.cbSize = sizeof(MENUITEMINFO);
mi.fMask = MIIM_STATE | MIIM_TYPE | MIIM_ID;
if (lpstr)
{
mi.fType = MFT_STRING;
mi.dwTypeData = lpstr;
mi.cch = strlen(lpstr);
}
else
{
mi.fType = MFT_SEPARATOR;
}
mi.fState = MFS_ENABLED;
mi.wID = id;
return InsertMenuItem(hmenu, index, FALSE, &mi);
}
示例14: wcscpy_s
BOOL CIconMenu::AppendMenuIcon(UINT_PTR nIDNewItem, LPCTSTR lpszNewItem, UINT uIcon /* = 0 */)
{
TCHAR menutextbuffer[255] = {0};
wcscpy_s(menutextbuffer, lpszNewItem);
if ((uIcon == 0)||(!bShowIcons))
return CMenu::AppendMenu(MF_STRING | MF_ENABLED, nIDNewItem, menutextbuffer);
MENUITEMINFO info = {0};
info.cbSize = sizeof(info);
info.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_BITMAP;
info.fType = MFT_STRING;
info.wID = (UINT)nIDNewItem;
info.dwTypeData = menutextbuffer;
info.hbmpItem = bitmapUtils.IconToBitmapPARGB32(AfxGetResourceHandle(), uIcon);
icons[nIDNewItem] = uIcon;
return InsertMenuItem((UINT)nIDNewItem, &info);
}
示例15: CreatePopupMenu
void WinGui::Window::CreateMenu(){
menuID = CreatePopupMenu();
MENUITEMINFO mii;
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_STATE | MIIM_TYPE | MIIM_SUBMENU | MIIM_ID;
mii.fType = MFT_STRING;
mii.fState = MFS_ENABLED;
mii.dwTypeData = "Menu Item!";
mii.cch = strlen("Menu Item!");
mii.wID = PMENU;
mii.hSubMenu = NULL;
bool t = InsertMenuItem(menuID, 1, false, &mii);
int xy = GetMessagePos();
TrackPopupMenu(menuID,
TPM_LEFTALIGN | TPM_LEFTBUTTON | TPM_TOPALIGN,
LOWORD(xy), HIWORD(xy),
NULL, hWnd, NULL);
}