From: Vincent Povirk Subject: [6/6] explorer: Add run dialog to start menu. Message-Id: Date: Tue, 10 Dec 2013 15:12:07 -0600 From 319b10e6a899bfb7573181b2817505ec876238b7 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Tue, 10 Dec 2013 14:57:28 -0600 Subject: [PATCH 6/6] explorer: Add run dialog to start menu. --- programs/explorer/explorer.rc | 1 + programs/explorer/resource.h | 1 + programs/explorer/startmenu.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 42 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 5730b39..9275b17 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); @@ -59,6 +60,8 @@ DWORD menu_thread_id; #define WM_POPUP_MENU WM_USER +#define MENU_ID_RUN 1 + static ULONG copy_pidls(struct menu_item* item, LPITEMIDLIST dest) { ULONG item_size; @@ -323,6 +326,27 @@ static void fill_menu(struct menu_item* item) } } +static DWORD CALLBACK do_run_dialog(void* user_data) +{ + 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); + + return 0; +} + +static void run_dialog(void) +{ + CreateThread(NULL, 0, do_run_dialog, NULL, 0, NULL); +} + LRESULT CALLBACK menu_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) @@ -351,11 +375,14 @@ LRESULT CALLBACK 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(); @@ -370,9 +397,11 @@ void popup_startmenu(HWND hwnd) { LPITEMIDLIST pidl; MENUINFO mi; + MENUITEMINFOW mii; RECT rc={0,0,0,0}; TPMPARAMS tpm; WNDCLASSEXW class; + WCHAR run_label[50]; static const WCHAR classname[] = {'W','i','n','e','M','e','n','u','P','a','r','e','n','t',0}; if (!menu_parent_class) @@ -431,6 +460,15 @@ void popup_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