//Warning: You should create only one shell menu for a window at a time. CShellMenu *CShellContextMenu::OpenShellMenu(HWND hWnd, UINT uIdMin, UINT uIdMax) { ASSERT(uIdMin < uIdMax); ASSERT(hWnd); int iMenuType = 0; // to know which version of IContextMenu is supported LPCONTEXTMENU pContextMenu; if (!GetContextMenu ((void**) &pContextMenu, iMenuType)) return NULL; CShellMenu *pShellMenu = new CShellMenu(hWnd, uIdMin, uIdMax); pShellMenu->m_ContextMenu.iMenuVer = iMenuType; pShellMenu->m_ContextMenu.pContextMenu = pContextMenu; pShellMenu->m_hMenu = CreatePopupMenu(); // lets fill the our popupmenu pShellMenu->m_ContextMenu.pContextMenu->QueryContextMenu(pShellMenu->m_hMenu, GetMenuItemCount(pShellMenu->m_hMenu), pShellMenu->m_uIdMin, pShellMenu->m_uIdMax, CMF_NORMAL | CMF_EXPLORE); // subclass window to handle menurelated messages in CShellContextMenu if (iMenuType > 1) // only subclass if its version 2 or 3 { pShellMenu->m_WndProc = (WNDPROC) SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) HookWndProc); SetProp(hWnd, S_OLDPROC, (HANDLE) pShellMenu->m_WndProc); SetProp(hWnd, S_CONTEXTMENU, (HANDLE) &pShellMenu->m_ContextMenu); } return pShellMenu; }
void EC_MediaPlayer::EntityClicked(Entity *entity, Qt::MouseButton button, RaycastResult *raycastResult) { if (!getinteractive() || !ParentEntity()) return; // We are only interested in left clicks on our entity. if (!raycastResult) return; if (button != Qt::LeftButton) return; if (entity == ParentEntity()) { // We are only interested in clicks to our target submesh index. if (raycastResult->submesh != (unsigned)getrenderSubmeshIndex()) return; // Entities have EC_Highlight if it is being manipulated. // At this situation we don't want to show any ui. if (entity->GetComponent("EC_Highlight")) return; QMenu *popupInteract = GetContextMenu(); if (!popupInteract->actions().empty()) popupInteract->exec(QCursor::pos()); } }
UINT CShellContextMenu::ShowContextMenu(QWidget * pParentWidget, QPoint pt, QMenu* pMenu ) { HWND hWnd = pParentWidget->winId(); int iMenuType = 0; // to know which version of IContextMenu is supported LPCONTEXTMENU pContextMenu; // common pointer to IContextMenu and higher version interface if (!GetContextMenu ((void**) &pContextMenu, iMenuType)) return (0); // something went wrong if (!m_hMenu) { DestroyMenu( m_hMenu ); m_hMenu = CreatePopupMenu (); } int i; QList<QAction*> actionList = pMenu->actions(); for( i=0; i<actionList.count(); ++i ) { QString s = actionList.at(i)->text(); if (!s.isEmpty()) AppendMenuW( m_hMenu, MF_STRING, i+1, (LPCWSTR)s.utf16() ); } AppendMenuW( m_hMenu, MF_SEPARATOR, i+1, L"" ); // lets fill the our popupmenu pContextMenu->QueryContextMenu (m_hMenu, GetMenuItemCount (m_hMenu), MIN_ID, MAX_ID, CMF_NORMAL | CMF_EXPLORE); // subclass window to handle menurelated messages in CShellContextMenu WNDPROC OldWndProc; if (iMenuType > 1) // only subclass if its version 2 or 3 { OldWndProc = (WNDPROC) SetWindowLongPtr (hWnd, GWLP_WNDPROC, (LONG_PTR) HookWndProc); if (iMenuType == 2) g_IContext2 = (LPCONTEXTMENU2) pContextMenu; else // version 3 g_IContext3 = (LPCONTEXTMENU3) pContextMenu; } else OldWndProc = NULL; UINT idCommand = TrackPopupMenu (m_hMenu,TPM_RETURNCMD | TPM_LEFTALIGN, pt.x(), pt.y(), 0, pParentWidget->winId(), 0); if (OldWndProc) // unsubclass SetWindowLongPtr (hWnd, GWLP_WNDPROC, (LONG_PTR) OldWndProc); if (idCommand >= MIN_ID && idCommand <= MAX_ID) // see if returned idCommand belongs to shell menu entries { InvokeCommand (pContextMenu, idCommand - MIN_ID); // execute related command idCommand = 0; } pContextMenu->Release(); g_IContext2 = NULL; g_IContext3 = NULL; return (idCommand); }
void MenuItem::ShowContextMenu(const TCHAR *path, const struct _ITEMIDLIST *pidl) { struct _ITEMIDLIST *new_pidl = NULL; if (NULL == pidl && path) pidl = new_pidl = sh_getpidl(NULL, path); Menu *pSub = GetContextMenu(pidl); if (new_pidl) m_free(new_pidl); if (pSub) { m_pMenu->HideChild(); LinkSubmenu(pSub); ShowSubMenu(); } }
UINT CShellContextMenu::ShowContextMenu(HWND hWnd, CPoint pt) { int iMenuType = 0; // to know which version of IContextMenu is supported LPCONTEXTMENU pContextMenu; // common pointer to IContextMenu and higher version interface if(!GetContextMenu((LPVOID*)&pContextMenu, iMenuType)) return 0; // something went wrong if(!m_Menu) { delete m_Menu; m_Menu = NULL; m_Menu = new CMenu; m_Menu->CreatePopupMenu(); } // lets fill the popupmenu pContextMenu->QueryContextMenu(m_Menu->m_hMenu, m_Menu->GetMenuItemCount(), ID_SHELLCONTEXTMENU_MIN, ID_SHELLCONTEXTMENU_MAX, CMF_NORMAL | CMF_EXPLORE); // subclass window to handle menurelated messages in CShellContextMenu WNDPROC OldWndProc; if(iMenuType > 1) // only subclass if its version 2 or 3 { OldWndProc = (WNDPROC) SetWindowLong(hWnd, GWL_WNDPROC, (DWORD) HookWndProc); if(iMenuType == 2) g_IContext2 = (LPCONTEXTMENU2) pContextMenu; else // version 3 g_IContext3 = (LPCONTEXTMENU3) pContextMenu; } else OldWndProc = NULL; UINT idCommand = m_Menu->TrackPopupMenu(TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, hWnd); if(OldWndProc) // unsubclass SetWindowLong(hWnd, GWL_WNDPROC, (DWORD) OldWndProc); if(idCommand >= ID_SHELLCONTEXTMENU_MIN && idCommand <= ID_SHELLCONTEXTMENU_MAX) { InvokeCommand(pContextMenu, idCommand - ID_SHELLCONTEXTMENU_MIN); idCommand = 0; } pContextMenu->Release(); g_IContext2 = NULL; g_IContext3 = NULL; return idCommand; }
UINT CShellContextMenu::ShowContextMenu(HWND hWnd, const POINT &pt, UINT uIdMin, UINT uIdMax) { ASSERT(hWnd); ASSERT(uIdMin < uIdMax); SCONTEXTMENU SContextMenu; if (!GetContextMenu((void**) &SContextMenu.pContextMenu, SContextMenu.iMenuVer)) return 0; // something went wrong if (!m_hMenu) { DestroyMenu(m_hMenu); m_hMenu = CreatePopupMenu(); } // lets fill the our popupmenu SContextMenu.pContextMenu->QueryContextMenu(m_hMenu, GetMenuItemCount(m_hMenu), uIdMin, uIdMax, CMF_NORMAL | CMF_EXPLORE); // subclass window to handle menurelated messages in CShellContextMenu WNDPROC OldWndProc; if (SContextMenu.iMenuVer > 1) // only subclass if its version 2 or 3 { OldWndProc = (WNDPROC) SetWindowLongPtr (hWnd, GWLP_WNDPROC, (LONG_PTR) HookWndProc); SetProp(hWnd, S_OLDPROC, (HANDLE) OldWndProc); SetProp(hWnd, S_CONTEXTMENU, (HANDLE) &SContextMenu); } else OldWndProc = NULL; UINT idCommand = ::TrackPopupMenu(m_hMenu, TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, 0, hWnd, NULL); if (OldWndProc) {// unsubclass SetWindowLongPtr(hWnd, GWLP_WNDPROC, (LONG_PTR) OldWndProc); RemoveProp(hWnd, S_OLDPROC); RemoveProp(hWnd, S_CONTEXTMENU); } if (idCommand >= uIdMin && idCommand <= uIdMax) // see if returned idCommand belongs to shell menu entries { InvokeCommand(SContextMenu.pContextMenu, idCommand - uIdMin); // execute related command idCommand = 0; } SContextMenu.pContextMenu->Release(); return idCommand; }
UINT CShellContextMenu::ShowContextMenu(CWnd *pWnd, CPoint pt) { int iMenuType = 0; // to know which version of IContextMenu is supported LPCONTEXTMENU pContextMenu; // common pointer to IContextMenu and higher version interface if (!GetContextMenu ((void**) &pContextMenu, iMenuType)) return (0); // something went wrong if (m_Menu) { delete m_Menu; m_Menu = NULL; } m_Menu = new CMenu; m_Menu->CreatePopupMenu (); // lets fill the our popupmenu pContextMenu->QueryContextMenu (m_Menu->m_hMenu, m_Menu->GetMenuItemCount (), MIN_ID, MAX_ID, CMF_NORMAL | CMF_EXPLORE); // subclass window to handle menurelated messages in CShellContextMenu WNDPROC OldWndProc; if (iMenuType > 1) // only subclass if its version 2 or 3 { OldWndProc = (WNDPROC) SetWindowLong (pWnd->m_hWnd, GWL_WNDPROC, (DWORD) HookWndProc); if (iMenuType == 2) g_IContext2 = (LPCONTEXTMENU2) pContextMenu; else // version 3 g_IContext3 = (LPCONTEXTMENU3) pContextMenu; } else OldWndProc = NULL; UINT idCommand = m_Menu->TrackPopupMenu (TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, pWnd); if (OldWndProc) // unsubclass SetWindowLong (pWnd->m_hWnd, GWL_WNDPROC, (DWORD) OldWndProc); if (idCommand >= MIN_ID && idCommand <= MAX_ID) // see if returned idCommand belongs to shell menu entries { InvokeCommand (pContextMenu, idCommand - MIN_ID); // execute related command idCommand = 0; } pContextMenu->Release(); g_IContext2 = NULL; g_IContext3 = NULL; return (idCommand); }
UINT CShellContextMenu::ShowContextMenu(CWnd *pWnd, POINT pt) { int iMenuType = 0; // to know which version of IContextMenu is supported LPCONTEXTMENU pContextMenu; // common pointer to IContextMenu and higher version interface if (!GetContextMenu ((void**) &pContextMenu, iMenuType)) return (0); // something went wrong if (!m_Menu) { delete m_Menu; m_Menu = NULL; m_Menu = new CMenu; m_Menu->CreatePopupMenu (); m_Menu->AppendMenu(MF_STRING, WM_MENU_FILE,_T("打开文件所在目录")); // lets fill the our popupmenu pContextMenu->QueryContextMenu(m_Menu->m_hMenu, m_Menu->GetMenuItemCount(), MIN_ID, MAX_ID, CMF_NORMAL | CMF_EXPLORE); } if (iMenuType > 1) // only subclass if its version 2 or 3 { if (iMenuType == 2) g_IContext2 = (LPCONTEXTMENU2) pContextMenu; else // version 3 g_IContext3 = (LPCONTEXTMENU3) pContextMenu; } UINT idCommand = m_Menu->TrackPopupMenu (TPM_RETURNCMD | TPM_LEFTALIGN, pt.x, pt.y, pWnd); if (idCommand >= MIN_ID && idCommand <= MAX_ID) // see if returned idCommand belongs to shell menu entries { InvokeCommand (pContextMenu, idCommand - MIN_ID); // execute related command idCommand = 0; } pContextMenu->Release(); g_IContext2 = NULL; g_IContext3 = NULL; return (idCommand); }
void ecConflictListCtrl::OnRightClick(wxMouseEvent& event) { int flags = 0; long item = HitTest(wxPoint(event.GetX(), event.GetY()), flags); if (item >= 0 && !GetParent ()->IsKindOf (CLASSINFO(wxDialog))) // this menu for conflicts view only { m_contextItem = item; // Find which column we're on m_contextCol = wxListCtrlFindColumn(*this, 3, event.GetX()); // GetContextMenu()->SetClientData((void*) TRUE); PopupMenu(GetContextMenu(), event.GetX(), event.GetY()); } else { m_contextItem = -1; PopupMenu(wxGetApp().GetWhatsThisMenu(), event.GetX(), event.GetY()); } }
void IconPanel::OnRightDown(wxMouseEvent& evt) { wxMenu* menu = GetContextMenu(); PopupMenu(menu, wxDefaultPosition); wxDELETE(menu); }