Пример #1
0
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
0
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
0
bool
MenuOperator::add_item(const MenuItem& item)
{
	MENUITEMINFO menu_item_info;
	menu_item_info.cbSize			= sizeof(MENUITEMINFO);

	menu_item_info.fMask			= MIIM_ID | MIIM_TYPE;
	menu_item_info.fType			= MFT_STRING;

	menu_item_info.wID				= item.id();
	menu_item_info.dwTypeData	= const_cast<char*>(item.label().c_str());
	menu_item_info.cch				= item.label().length();

	InsertMenuItem(handle(), 0xffff, TRUE, &menu_item_info);

	return true;
}
Пример #4
0
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);
			}
		}
	}
}
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);
	}
}
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;
}
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);
}
Пример #8
0
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;
}
Пример #9
0
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);
}
Пример #10
0
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;
}
Пример #11
0
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*/);
}
Пример #12
0
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);
}
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;
}
Пример #14
0
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);
}
Пример #15
0
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);
}
Пример #16
0
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);

}
STDMETHODIMP CGitExtensionsShellEx::QueryContextMenu  (
    HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd,
    UINT uidLastCmd, UINT uFlags )
{
    // If the flags include CMF_DEFAULTONLY then we shouldn't do anything.
    if ( uFlags & CMF_DEFAULTONLY )
        return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 0 );

    //InsertMenu (hmenu, uMenuIndex, MF_BYPOSITION, uidFirstCmd, _T("GitEx") );

    int id = 0;

    CString szCascadeContextMenu = GetRegistryValue(HKEY_CURRENT_USER, "SOFTWARE\\GitExtensions\\GitExtensions", "ShellCascadeContextMenu");

    CascadeContextMenu = !(szCascadeContextMenu == "False");

    if (CascadeContextMenu)
    {
        // show context menu cascaded in submenu
        HMENU popupMenu = CreateMenu();

        id = PopulateMenu(popupMenu, uidFirstCmd + id, true);

        //InsertMenu(hmenu, uMenuIndex++, MF_STRING | MF_BYPOSITION | MF_POPUP, (int)popupMenu, "Git Extensions");
        MENUITEMINFO info;

        info.cbSize = sizeof( MENUITEMINFO );
        info.fMask = MIIM_ID | MIIM_TYPE | MIIM_SUBMENU;
        info.fType = MFT_STRING;
        info.wID = uidFirstCmd + 1;
        info.dwTypeData = _T("Git Extensions");
        info.hSubMenu = popupMenu;
        InsertMenuItem(hmenu, 0, true, &info);
    }
    else
    {
        // show menu items directly
        id = PopulateMenu(hmenu, uidFirstCmd + id, false);
    }

    return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, id-uidFirstCmd );
}
Пример #18
0
bool VirtualDimension::CreateLangMenu()
{
	LocalesIterator it;
	int count = 0;
	// languageCode from registry
	int currentLanguageCode = Locale::GetInstance().GetLanguage();

	//Create the menu
	m_pLangMenu = CreatePopupMenu();

	//Add the entries
	while(m_pLangMenu && it.GetNext())
	{
		String name;
		HICON hicon;
		name = it.GetLanguage(&hicon, NULL);
		if (!name.empty())
		{
			MENUITEMINFO iteminfo;
			int code = it.GetLanguageCode();

			count++;

			iteminfo.cbSize = sizeof(MENUITEMINFO);
			iteminfo.fMask = MIIM_DATA|MIIM_STRING|MIIM_FTYPE|MIIM_BITMAP|MIIM_ID;
			iteminfo.dwTypeData = (LPTSTR)name.c_str();
			iteminfo.fType = MFT_STRING;
			iteminfo.dwItemData = (ULONG_PTR)hicon;
			iteminfo.hbmpItem = HBMMENU_CALLBACK;
			iteminfo.wID = WM_VD_LANGUAGE+code; // in order to get WM_COMMAND msg
			InsertMenuItem(m_pLangMenu, WM_VD_LANGUAGE+code, FALSE, &iteminfo);
			if (code == currentLanguageCode)
				 CheckMenuItem(m_pLangMenu,(UINT)code+WM_VD_LANGUAGE,MF_BYCOMMAND|MF_CHECKED);

			// then we connect any menu to the window proc
			SetCommandHandler(WM_VD_LANGUAGE+code, this, &VirtualDimension::OnCmdLanguageChange);
			SetSysCommandHandler(WM_VD_LANGUAGE+code, this, &VirtualDimension::OnCmdLanguageChange);
		}
	}

	return count > 1;
}
Пример #19
0
/*static*/
void MenuWin::InsertItemIntoNativeMenu(
    MenuItemWin* item, HMENU nativeMenu, bool registerNative, int position)
{
    
    // A -1 value means to stick the new item at the end
    if (position == -1) {
        position = GetMenuItemCount(nativeMenu);
        if (position == 0) position = 1;
    }

    MENUITEMINFO itemInfo;
    item->CreateNative(&itemInfo, nativeMenu, registerNative);
    BOOL success = InsertMenuItem(nativeMenu, position, TRUE, &itemInfo);

    if (!success) {
        string error = Win32Utils::QuickFormatMessage(GetLastError());
        throw ValueException::FromString("Could not insert native item: " + error);
    }

}
Пример #20
0
void ShowContextMenu(HWND hWnd)
{
	MENUITEMINFO separatorBtn = {0};
	separatorBtn.cbSize = sizeof(MENUITEMINFO);
	separatorBtn.fMask = MIIM_FTYPE;
	separatorBtn.fType = MFT_SEPARATOR;
	HMENU hMenu = CreatePopupMenu();
	if(hMenu != NULL)
	{
		InsertMenu(hMenu, -1, MF_BYPOSITION, ID_FILE_OPTIONS, GString(IDS_MENU_OPTIONS).c_str());
		InsertMenuItem(hMenu, -1, FALSE, &separatorBtn);
		InsertMenu(hMenu, -1, MF_BYPOSITION, IDM_EXIT, GString(IDS_MENU_EXIT).c_str());
		POINT pt;
		GetCursorPos(&pt);
		SetForegroundWindow(hWnd);
		TrackPopupMenu(hMenu, TPM_RIGHTBUTTON, pt.x, pt.y, 0, hWnd, NULL);
		DestroyMenu(hMenu);
		PostMessage(hWnd, WM_NULL, 0, 0);
	}
}
Пример #21
0
void OMenu::InsertSeparator(UINT uItem, BOOL byPosition, const tstring& caption, bool accels /*= false*/) {
	OMenuItem* mi = new OMenuItem();
	mi->text = caption;
	tstring::size_type i = 0;
	if (!accels)
		while ((i = mi->text.find('&')) != tstring::npos)
			mi->text.erase(i, i+1);

	if(mi->text.length() > 25) {
                // mi->text = mi->text.substr(0, 25) + _T("..."); // !SMT!-UI
	}
	mi->parent = this;
	items.push_back(mi);
	MENUITEMINFO mii = {0};
	mii.cbSize = sizeof(MENUITEMINFO);
	mii.fMask = MIIM_FTYPE | MIIM_DATA;
	mii.fType = MFT_OWNERDRAW | MFT_SEPARATOR;
	mii.dwItemData = (ULONG_PTR)mi;
	InsertMenuItem(uItem, byPosition, &mii);
}
Пример #22
0
void Menu_InsertMenuItem(HMENU hMenu, UINT uID, BOOL fByPosition, LPMENUITEMEX lpmix)
{
    MENUITEMINFO mii;
    LPMENUITEMEX lpmixSet = (LPMENUITEMEX)Mem_Alloc(sizeof(MENUITEMEX));

    *lpmixSet = *lpmix;
    lpmixSet->pszText = String_Duplicate(lpmix->pszText);

    INITSTRUCT(mii, TRUE);
    mii.fMask       = MIIM_TYPE | MIIM_DATA | MIIM_ID;
    mii.fType       = MFT_OWNERDRAW; // | lpmix->fType;
    mii.dwItemData  = (DWORD)lpmixSet;
    mii.wID         = lpmix->wID;

    if (lpmix->iImageIndex == IDP_TOOLBAR)
        if (Menu_GetIconFromProcess != NULL)
            Menu_GetIconFromProcess(lpmix->wID);

    InsertMenuItem(hMenu, uID, fByPosition, &mii);
}
Пример #23
0
HMENU ProcessSubMenu(iteminfo *info, UINT idCmdFirst)
{
	HMENU hSubmenu = CreatePopupMenu();

	int i = 0;
	while (info[i].id != -1)
	{
		MENUITEMINFO mii = { sizeof(MENUITEMINFO) };
		mii.fMask = MIIM_STRING | MIIM_ID;
		mii.wID = info[i].id + idCmdFirst;
		mii.dwTypeData = info[i].text;
		if (info[i].subitems != nullptr)
		{
			mii.fMask |= MIIM_SUBMENU;
			mii.hSubMenu = ProcessSubMenu(info[i].subitems, idCmdFirst);
		}
		InsertMenuItem(hSubmenu, i++, TRUE, &mii);
	}
	return hSubmenu;
}
STDMETHODIMP CGitExtensionsShellEx::QueryContextMenu  (
    HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd,
    UINT uidLastCmd, UINT uFlags )
{
    // If the flags include CMF_DEFAULTONLY then we shouldn't do anything.
    if ( uFlags & CMF_DEFAULTONLY )
        return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, 0 );

    int id = 0;

    CString szCascadeContextMenu = GetRegistryValue(HKEY_CURRENT_USER, "SOFTWARE\\GitExtensions\\GitExtensions", "ShellCascadeContextMenu");

    CascadeContextMenu = !(szCascadeContextMenu == "False");

    if (CascadeContextMenu)
    {
        // show context menu cascaded in submenu
        HMENU popupMenu = CreateMenu();

        id = PopulateMenu(popupMenu, uidFirstCmd, id, true);

        MENUITEMINFO info;

        info.cbSize = sizeof( MENUITEMINFO );
        info.fMask = MIIM_STRING | MIIM_ID | MIIM_BITMAP | MIIM_SUBMENU;
        info.wID = uidFirstCmd + 1;
        info.hbmpItem = IsVistaOrLater() ? IconToBitmapPARGB32(IDI_GITEXTENSIONS) : HBMMENU_CALLBACK;
        myIDMap[1] = IDI_GITEXTENSIONS;
        myIDMap[uidFirstCmd + 1] = IDI_GITEXTENSIONS;
        info.dwTypeData = _T("Git Extensions");
        info.hSubMenu = popupMenu;
        InsertMenuItem(hmenu, 0, true, &info);
    }
    else
    {
        // show menu items directly
        id = PopulateMenu(hmenu, uidFirstCmd, id, false);
    }

    return MAKE_HRESULT ( SEVERITY_SUCCESS, FACILITY_NULL, id );
}
Пример #25
0
LRESULT CALLBACK winproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
	sprintf(tmp, "%d (%d, %d)", uMsg, wParam, lParam);
	//logger.Debug("winproc()", message);

	// Make sure we are dealing with the correct menu.
	// We do this by checking the first menu item in the menu.
	// If it is a well-known one we go further. Otherwise we skip.
	if (uMsg == WM_INITMENUPOPUP) {
		MENUITEMINFO mii;
		mii.cbSize = sizeof(MENUITEMINFO);
		mii.fMask = MIIM_ID;
		GetMenuItemInfo((HMENU) wParam, 0, TRUE, &mii);
		if (mii.wID == kMLMenuFirstItem) {
			sprintf(tmp, "adding menu item: %s", kMLOrgMenuText);
		    logger.Debug("ml_org::winproc()", tmp);

    	    // Delete the menu item first (the call is ignored if it does not exist)
	        DeleteMenu((HMENU) wParam, kMLOrgMenuID, MF_BYCOMMAND);

        	// Create a menu item in the Library button popupmenu
	        mii.cbSize = sizeof(MENUITEMINFO);
        	mii.fMask = MIIM_TYPE|MIIM_ID;
	        mii.wID = kMLOrgMenuID;
	        mii.fType = MFT_STRING;
	        mii.dwTypeData = kMLOrgMenuText;

	        // Make the actual call to insert it
	        InsertMenuItem((HMENU) wParam, 0, FALSE, &mii);
		}
	}

	// Catch click on menu item here
	if ((uMsg == WM_COMMAND)
	 && (HIWORD(wParam) == 0)
	 && (LOWORD(wParam) == kMLOrgMenuID)) {
		organizeML();
	}

	// Call the default window proc to handle the message as well.
	return CallWindowProc(mlWndproc, hwnd, uMsg, wParam, lParam);
} 
Пример #26
0
IFACEMETHODIMP CContextMenu::QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags)
{
	// If uFlags include CMF_DEFAULTONLY then we should not do anything.
	if (CMF_DEFAULTONLY & uFlags)
		return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(0));

	MENUITEMINFO mii = { sizeof(mii) };
	mii.fMask = MIIM_STRING | MIIM_ID | MIIM_SUBMENU;
	mii.wID = idCmdFirst + curid;
	mii.dwTypeData = L"KENSSharp";
	mii.hSubMenu = ProcessSubMenu(rootmenu, idCmdFirst);
	if (!InsertMenuItem(hMenu, indexMenu, TRUE, &mii))
	{
		return HRESULT_FROM_WIN32(GetLastError());
	}

	// Return an HRESULT value with the severity set to SEVERITY_SUCCESS. 
	// Set the code value to the offset of the largest command identifier 
	// that was assigned, plus one (1).
	return MAKE_HRESULT(SEVERITY_SUCCESS, 0, USHORT(curid + 1));
}
Пример #27
0
bool ContextMenuExt::MenuItemInitDelete(UINT pos, UINT cmdId)
{
	MENUITEMINFO mii = { sizeof(mii) };
	mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_STATE;
	mii.fType = MFT_STRING;
	mii.fState = MFS_GRAYED;
	// need folders or files
	if (m_selectionHasFiles || m_selectionHasFolders) {
		mii.fState = MFS_ENABLED;
	}
	mii.wID = cmdId;
	mii.dwTypeData = &commandInfoMap[CMD_DELETE].menuText[0];
	LoadAndSetBitmapByIcon(&mii, CMD_DELETE);

	if (!InsertMenuItem(m_hSubMenu, pos, TRUE, &mii))
	{
		return false;
	}
	m_cmdIdToCommand[cmdId] = CommandId::CMD_DELETE;
	return true;
}
Пример #28
0
bool ContextMenuExt::MenuItemInitShare(UINT pos, UINT cmdId)
{
	MENUITEMINFO mii = { sizeof(mii) };
	mii.fMask = MIIM_STRING | MIIM_FTYPE | MIIM_ID | MIIM_STATE;
	mii.fType = MFT_STRING;
	mii.fState = MFS_GRAYED;
	// enable only for single folder
	if (m_selectionOnlyOne && m_selectionHasFolders && !m_selectionHasFiles) {
		mii.fState = MFS_ENABLED;
	}
	mii.wID = cmdId;
	mii.dwTypeData = &commandInfoMap[CMD_SHARE].menuText[0];
	LoadAndSetBitmapByIcon(&mii, CMD_SHARE);

	if (!InsertMenuItem(m_hSubMenu, pos, TRUE, &mii))
	{
		return false;
	}
	m_cmdIdToCommand[cmdId] = CommandId::CMD_SHARE;
	return true;
}
Пример #29
0
void SWELL_InsertMenu(HMENU menu, int pos, int flag, UINT_PTR idx, const char *str)
{
  MENUITEMINFO mi={sizeof(mi),MIIM_ID|MIIM_STATE|MIIM_TYPE,MFT_STRING,
    (flag & ~MF_BYPOSITION),(flag&MF_POPUP) ? 0 : (int)idx,NULL,NULL,NULL,0,(char *)str};
  
  if (flag&MF_POPUP) 
  {
    mi.hSubMenu = (HMENU)idx;
    mi.fMask |= MIIM_SUBMENU;
    mi.fState &= ~MF_POPUP;
  }
  
  if (flag&MF_SEPARATOR)
  {
    mi.fMask=MIIM_TYPE;
    mi.fType=MFT_SEPARATOR;
    mi.fState &= ~MF_SEPARATOR;
  }
    
  InsertMenuItem(menu,pos,(flag&MF_BYPOSITION) ?  TRUE : FALSE, &mi);
}
Пример #30
0
// copied from swell-menu.mm, can have a common impl someday
int SWELL_GenerateMenuFromList(HMENU hMenu, const void *_list, int listsz)
{
  SWELL_MenuGen_Entry *list = (SWELL_MenuGen_Entry *)_list;
  const int l1=strlen(SWELL_MENUGEN_POPUP_PREFIX);
  while (listsz>0)
  {
    int cnt=1;
    if (!list->name) SWELL_Menu_AddMenuItem(hMenu,NULL,-1,0);
    else if (!strcmp(list->name,SWELL_MENUGEN_ENDPOPUP)) return list + 1 - (SWELL_MenuGen_Entry *)_list;
    else if (!strncmp(list->name,SWELL_MENUGEN_POPUP_PREFIX,l1)) 
    { 
      MENUITEMINFO mi={sizeof(mi),MIIM_SUBMENU|MIIM_STATE|MIIM_TYPE,MFT_STRING,0,0,CreatePopupMenuEx(list->name+l1),NULL,NULL,0,(char *)list->name+l1};
      cnt += SWELL_GenerateMenuFromList(mi.hSubMenu,list+1,listsz-1);
      InsertMenuItem(hMenu,GetMenuItemCount(hMenu),TRUE,&mi);
    }
    else SWELL_Menu_AddMenuItem(hMenu,list->name,list->idx,list->flags);

    list+=cnt;
    listsz -= cnt;
  }
}