[3/5] explorer: Add run dialog to start menu.

Vincent Povirk madewokherd at gmail.com
Tue Jan 7 16:37:20 CST 2014


-------------- next part --------------
From fe6c3626b2f8dc843044e5a994bac76ea4d3c48c Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Tue, 10 Dec 2013 14:57:28 -0600
Subject: [PATCH 3/5] explorer: Add run dialog to start menu.

---
 programs/explorer/explorer.rc |  1 +
 programs/explorer/resource.h  |  1 +
 programs/explorer/startmenu.c | 35 +++++++++++++++++++++++++++++++++--
 3 files changed, 35 insertions(+), 2 deletions(-)

diff --git a/programs/explorer/explorer.rc b/programs/explorer/explorer.rc
index 86ec4e3..349d2a7 100644
--- a/programs/explorer/explorer.rc
+++ b/programs/explorer/explorer.rc
@@ -30,6 +30,7 @@ STRINGTABLE
     IDS_EXPLORER_TITLE  "Wine Explorer"
     IDS_PATHBOX_LABEL   "Location:"
     IDS_START_LABEL     "Start"
+    IDS_RUN             "Run..."
 }
 
 #define WINE_FILEDESCRIPTION_STR "Wine Explorer"
diff --git a/programs/explorer/resource.h b/programs/explorer/resource.h
index a7f3f3a..747dd03 100644
--- a/programs/explorer/resource.h
+++ b/programs/explorer/resource.h
@@ -24,5 +24,6 @@
 #define IDS_EXPLORER_TITLE 1
 #define IDS_PATHBOX_LABEL 2
 #define IDS_START_LABEL 3
+#define IDS_RUN 4
 
 #endif
diff --git a/programs/explorer/startmenu.c b/programs/explorer/startmenu.c
index 1968c97..19df514 100644
--- a/programs/explorer/startmenu.c
+++ b/programs/explorer/startmenu.c
@@ -27,6 +27,7 @@
 #include "wine/debug.h"
 #include "wine/list.h"
 #include "explorer_private.h"
+#include "resource.h"
 
 WINE_DEFAULT_DEBUG_CHANNEL(explorer);
 
@@ -52,6 +53,8 @@ static struct menu_item root_menu = {{0}};
 static struct menu_item public_startmenu = {{0}};
 static struct menu_item user_startmenu = {{0}};
 
+#define MENU_ID_RUN 1
+
 static ULONG copy_pidls(struct menu_item* item, LPITEMIDLIST dest)
 {
     ULONG item_size;
@@ -314,6 +317,20 @@ static void fill_menu(struct menu_item* item)
     }
 }
 
+static void run_dialog(void)
+{
+    void WINAPI (*pRunFileDlg)(HWND hWndOwner, HICON hIcon, LPCSTR lpszDir,
+                               LPCSTR lpszTitle, LPCSTR lpszDesc, DWORD dwFlags);
+    HMODULE hShell32;
+
+    hShell32 = LoadLibraryA("shell32");
+    pRunFileDlg = (void*)GetProcAddress(hShell32, (LPCSTR)61);
+
+    pRunFileDlg(NULL, NULL, NULL, NULL, NULL, 0);
+
+    FreeLibrary(hShell32);
+}
+
 LRESULT menu_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 {
     switch (msg)
@@ -342,11 +359,14 @@ LRESULT menu_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
             MENUITEMINFOW mii;
 
             mii.cbSize = sizeof(mii);
-            mii.fMask = MIIM_DATA;
+            mii.fMask = MIIM_DATA|MIIM_ID;
             GetMenuItemInfoW(hmenu, wparam, TRUE, &mii);
             item = (struct menu_item*)mii.dwItemData;
 
-            exec_item(item);
+            if (item)
+                exec_item(item);
+            else if (mii.wID == MENU_ID_RUN)
+                run_dialog();
 
             destroy_menus();
 
@@ -361,8 +381,10 @@ void do_startmenu(HWND hwnd)
 {
     LPITEMIDLIST pidl;
     MENUINFO mi;
+    MENUITEMINFOW mii;
     RECT rc={0,0,0,0};
     TPMPARAMS tpm;
+    WCHAR run_label[50];
 
     destroy_menus();
 
@@ -397,6 +419,15 @@ void do_startmenu(HWND hwnd)
     if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_CONTROLS, &pidl)))
         add_shell_item(&root_menu, pidl);
 
+    LoadStringW(NULL, IDS_RUN, run_label, sizeof(run_label)/sizeof(run_label[0]));
+
+    mii.cbSize = sizeof(mii);
+    mii.fMask = MIIM_STRING|MIIM_ID;
+    mii.dwTypeData = run_label;
+    mii.wID = MENU_ID_RUN;
+
+    InsertMenuItemW(root_menu.menuhandle, -1, TRUE, &mii);
+
     mi.cbSize = sizeof(mi);
     mi.fMask = MIM_STYLE;
     mi.dwStyle = MNS_NOTIFYBYPOS;
-- 
1.8.1.2



More information about the wine-patches mailing list