[7/9] setupapi: implement Ok button action in SetupPromptForDisk

Ricardo Filipe ricardo_barbano at hotmail.com
Wed Feb 18 17:55:18 CST 2009


activate Ok button and make it return according to MSDN instructions and
visual tests on windows.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winehq.org/pipermail/wine-patches/attachments/20090218/e4a3440d/attachment.htm 
-------------- next part --------------
From 28698cbfc75ca22eba40635954561b0d790b9a5e Mon Sep 17 00:00:00 2001
From: Ricardo Filipe <ricardo_barbano at hotmail.com>
Date: Wed, 18 Feb 2009 03:46:01 +0000
Subject: setupapi: implement Ok button action in SetupPromptForDisk dialog

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

diff --git a/dlls/setupapi/dialog.c b/dlls/setupapi/dialog.c
index 124c7c7..58fc972 100644
--- a/dlls/setupapi/dialog.c
+++ b/dlls/setupapi/dialog.c
@@ -92,6 +92,40 @@ static void promptdisk_init(HWND hwnd, struct promptdisk_params *params)
         ShowWindow(GetDlgItem(hwnd, IDC_RUNDLG_BROWSE), SW_HIDE);
 }
 
+/* When the user clicks in the Ok button in SetupPromptForDisk dialog
+ * if the parameters are good it copies the path from the dialog to the output buffer
+ * saves the required size for the buffer if PathRequiredSize is given
+ * returns NO_ERROR if there is no PathBuffer to copy too
+ * returns DPROMPT_BUFFERTOOSMALL if the path is too big to fit in PathBuffer
+ */
+static void promptdisk_ok(HWND hwnd, struct promptdisk_params *params)
+{
+    int requiredSize;
+    WCHAR aux[MAX_PATH];
+    GetWindowTextW(GetDlgItem(hwnd, IDC_PATH), aux, MAX_PATH);
+    requiredSize = strlenW(aux)+1;
+
+    if(params->PathRequiredSize)
+    {
+        *params->PathRequiredSize = requiredSize;
+        TRACE("returning PathRequiredSize=%d\n",*params->PathRequiredSize);
+    }
+    if(!params->PathBuffer && !params->PathBufferSize)
+    {
+        EndDialog(hwnd, NO_ERROR);
+        return;
+    }
+    if(params->PathBuffer && (requiredSize > params->PathBufferSize
+        || params->PathBufferSize < MAX_PATH))
+    {
+        EndDialog(hwnd, DPROMPT_BUFFERTOOSMALL);
+        return;
+    }
+    strcpyW(params->PathBuffer, aux);
+    TRACE("returning PathBuffer=%s\n", debugstr_w(params->PathBuffer));
+    EndDialog(hwnd, DPROMPT_SUCCESS);
+}
+
 /* When the user clicks the browse button in SetupPromptForDisk dialog
  * it copies the path of the selected file to the dialog path field
  */
@@ -130,6 +164,13 @@ static INT_PTR CALLBACK promptdisk_proc(HWND hwnd, UINT msg, WPARAM wParam, LPAR
         case WM_COMMAND:
             switch(wParam)
             {
+                case IDOK:
+                {
+                    struct promptdisk_params *params =
+                        (struct promptdisk_params *)GetWindowLongPtrW(hwnd, DWLP_USER);
+                    promptdisk_ok(hwnd, params);
+                    return TRUE;
+                }
                 case IDCANCEL:
                     EndDialog(hwnd, DPROMPT_CANCEL);
                     return TRUE;
-- 
1.5.6.3


More information about the wine-patches mailing list