[4/7] setupapi: enable Browse action on SetupPromptForDisk dialog

Ricardo Filipe ricardo_barbano at hotmail.com
Sun Feb 22 18:33:33 CST 2009


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winehq.org/pipermail/wine-patches/attachments/20090223/88a79e24/attachment.htm 
-------------- next part --------------
From 809ba14439191a16edb3581aee686eb83e832be3 Mon Sep 17 00:00:00 2001
From: Ricardo Filipe <ricardo_barbano at hotmail.com>
Date: Wed, 18 Feb 2009 03:40:15 +0000
Subject: setupapi: enable Browse action on SetupPromptForDisk dialog

---
 dlls/setupapi/dialog.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/dlls/setupapi/dialog.c b/dlls/setupapi/dialog.c
index 3f31bd1..124c7c7 100644
--- a/dlls/setupapi/dialog.c
+++ b/dlls/setupapi/dialog.c
@@ -92,6 +92,32 @@ static void promptdisk_init(HWND hwnd, struct promptdisk_params *params)
         ShowWindow(GetDlgItem(hwnd, IDC_RUNDLG_BROWSE), SW_HIDE);
 }
 
+/* When the user clicks the browse button in SetupPromptForDisk dialog
+ * it copies the path of the selected file to the dialog path field
+ */
+static void promptdisk_browse(HWND hwnd, struct promptdisk_params *params)
+{
+    OPENFILENAMEW ofn;
+    ZeroMemory(&ofn, sizeof(ofn));
+
+    ofn.lStructSize = sizeof(ofn);
+    ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST;
+    ofn.hwndOwner = hwnd;
+    ofn.nMaxFile = MAX_PATH;
+    ofn.lpstrFile = HeapAlloc(GetProcessHeap(), 0, MAX_PATH*sizeof(WCHAR));
+    strcpyW(ofn.lpstrFile, params->FileSought);
+
+    if(GetOpenFileNameW(&ofn))
+    {
+        WCHAR* last_slash = strrchrW(ofn.lpstrFile, '\\');
+        WCHAR path[MAX_PATH];
+        *last_slash = 0;
+        strcpyW(path, ofn.lpstrFile);
+        SetDlgItemTextW(hwnd, IDC_PATH, path);
+    }
+    HeapFree(GetProcessHeap(), 0, ofn.lpstrFile);
+}
+
 /* Handles the messages sent to the SetupPromptForDisk dialog
 */
 static INT_PTR CALLBACK promptdisk_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -107,6 +133,13 @@ static INT_PTR CALLBACK promptdisk_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
                 case IDCANCEL:
                     EndDialog(hwnd, DPROMPT_CANCEL);
                     return TRUE;
+                case IDC_RUNDLG_BROWSE:
+                {
+                    struct promptdisk_params *params =
+                        (struct promptdisk_params *)GetWindowLongPtrW(hwnd, DWLP_USER);
+                    promptdisk_browse(hwnd, params);
+                    return TRUE;
+                }
             }
     }
     return FALSE;
-- 
1.5.6.3


More information about the wine-patches mailing list