Permalink
Browse files

If shift is held down when right-clicking the project pane, tell Wind…

…ows to show the 'extended verbs'. Among other things, this enables 'Open in Command Prompt' in Vista and later. Requested in the forums.
  • Loading branch information...
adamv committed Jul 27, 2009
1 parent 7f8d343 commit d876a8d92dcf3066642c05ef5ba38cdef5f32ad8
Showing with 11 additions and 9 deletions.
  1. +3 −1 src/ProjectPane.cpp
  2. +7 −7 src/ShellContextMenu.cpp
  3. +1 −1 src/ShellContextMenu.h
View
@@ -1206,6 +1206,8 @@ void ProjectPane::OnTreeContextMenu(wxTreeEvent& event) {
wxTreeItemId item = event.GetItem();
if (!item) return;
+ bool showExtendedItems = wxGetKeyState(WXK_SHIFT);
+
// Get the path of the item clicked
const DirItemData *data = (DirItemData*)m_prjTree->GetItemData(item);
const wxString& path = data->m_path;
@@ -1284,7 +1286,7 @@ void ProjectPane::OnTreeContextMenu(wxTreeEvent& event) {
#ifdef __WXMSW__
m_contextMenu = new ShellContextMenu();
m_contextMenu->SetObjects(paths);
- m_contextMenu->ShowContextMenu(this, screenPoint);
+ m_contextMenu->ShowContextMenu(this, screenPoint, showExtendedItems);
delete m_contextMenu;
m_contextMenu = NULL;
#endif
View
@@ -43,7 +43,7 @@ ShellContextMenu::~ShellContextMenu()
delete m_Menu;
}
-UINT ShellContextMenu::ShowContextMenu(wxWindow* pWnd, wxPoint pt)
+UINT ShellContextMenu::ShowContextMenu(wxWindow* pWnd, wxPoint pt, bool showExtendedItems)
{
int iMenuType = 0; // to know which version of IContextMenu is supported
LPCONTEXTMENU pContextMenu; // common pointer to IContextMenu and higher version interface
@@ -52,12 +52,14 @@ UINT ShellContextMenu::ShowContextMenu(wxWindow* pWnd, wxPoint pt)
return (0); // something went wrong
if (!m_Menu)
- {
m_Menu = new wxMenu;
- }
- // lets fill the our popupmenu
- pContextMenu->QueryContextMenu(GetHmenuOf(m_Menu), m_Menu->GetMenuItemCount(), MIN_ID, MAX_ID, CMF_NORMAL | CMF_EXPLORE);
+ // lets fill the our popupmenu
+ UINT flags = CMF_NORMAL | CMF_EXPLORE;
+ if (showExtendedItems)
+ flags |= CMF_EXTENDEDVERBS;
+
+ pContextMenu->QueryContextMenu(GetHmenuOf(m_Menu), m_Menu->GetMenuItemCount(), MIN_ID, MAX_ID, flags);
// set context menu
if (iMenuType > 1) // only subclass if its version 2 or 3
@@ -134,7 +136,6 @@ void ShellContextMenu::SetObjects(const wxArrayString &strArray)
free (pidlItem);
if (lpMalloc) lpMalloc->Free(pidl); // free pidl allocated by ParseDisplayName
if (psfFolder) psfFolder->Release();
-
}
lpMalloc->Release ();
psfDesktop->Release ();
@@ -148,7 +149,6 @@ void ShellContextMenu::FreePIDLArray(LPITEMIDLIST *pidlArray)
return;
int iSize = _msize (pidlArray) / sizeof (LPITEMIDLIST);
-
for (int i = 0; i < iSize; i++)
free (pidlArray[i]);
free (pidlArray);
View
@@ -23,7 +23,7 @@ class ShellContextMenu {
virtual ~ShellContextMenu();
void SetObjects(const wxArrayString& strArray);
- UINT ShowContextMenu(wxWindow* pWnd, wxPoint pt);
+ UINT ShowContextMenu(wxWindow* pWnd, wxPoint pt, bool showExtendedItems = false);
bool HookWndProc(UINT message, WPARAM wParam, LPARAM lParam, LRESULT& res);

0 comments on commit d876a8d

Please sign in to comment.