2 * SetupAPI dialog functions
4 * Copyright 2009 Ricardo Filipe
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include "wine/debug.h"
32 #include "setupapi_private.h"
34 #include "wine/unicode.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(setupapi);
38 struct promptdisk_params {
44 DWORD DiskPromptStyle;
47 PDWORD PathRequiredSize;
50 /* initiates the fields of the SetupPromptForDisk dialog according to the parameters
52 static void promptdisk_init(HWND hwnd, struct promptdisk_params *params)
57 SetWindowLongPtrW(hwnd, DWLP_USER, (LONG_PTR)params);
59 if(params->DialogTitle)
60 SetWindowTextW(hwnd, params->DialogTitle);
61 if(params->PathToSource)
62 SetDlgItemTextW(hwnd, IDC_PATH, params->PathToSource);
64 if(!(params->DiskPromptStyle & IDF_OEMDISK))
66 LoadStringW(SETUPAPI_hInstance, IDS_PROMPTDISK, format,
67 sizeof(format)/sizeof(format[0]));
70 snprintfW(message, sizeof(message)/sizeof(message[0]), format,
71 params->FileSought, params->DiskName);
75 LoadStringW(SETUPAPI_hInstance, IDS_UNKNOWN, unknown,
76 sizeof(unknown)/sizeof(unknown[0]));
77 snprintfW(message, sizeof(message)/sizeof(message[0]), format,
78 params->FileSought, unknown);
80 SetDlgItemTextW(hwnd, IDC_FILENEEDED, message);
82 LoadStringW(SETUPAPI_hInstance, IDS_INFO, message,
83 sizeof(message)/sizeof(message[0]));
84 SetDlgItemTextW(hwnd, IDC_INFO, message);
85 LoadStringW(SETUPAPI_hInstance, IDS_COPYFROM, message,
86 sizeof(message)/sizeof(message[0]));
87 SetDlgItemTextW(hwnd, IDC_COPYFROM, message);
89 if(params->DiskPromptStyle & IDF_NOBROWSE)
90 ShowWindow(GetDlgItem(hwnd, IDC_RUNDLG_BROWSE), SW_HIDE);
93 /* Handles the messages sent to the SetupPromptForDisk dialog
95 static INT_PTR CALLBACK promptdisk_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
100 promptdisk_init(hwnd, (struct promptdisk_params *)lParam);
106 EndDialog(hwnd, DPROMPT_CANCEL);
113 /***********************************************************************
114 * SetupPromptForDiskW (SETUPAPI.@)
116 UINT WINAPI SetupPromptForDiskW(HWND hwndParent, PCWSTR DialogTitle, PCWSTR DiskName,
117 PCWSTR PathToSource, PCWSTR FileSought, PCWSTR TagFile, DWORD DiskPromptStyle,
118 PWSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize)
120 struct promptdisk_params params;
123 TRACE("%p, %s, %s, %s, %s, %s, 0x%08x, %p, %d, %p\n", hwndParent, debugstr_w(DialogTitle),
124 debugstr_w(DiskName), debugstr_w(PathToSource), debugstr_w(FileSought),
125 debugstr_w(TagFile), DiskPromptStyle, PathBuffer, PathBufferSize,
130 SetLastError(ERROR_INVALID_PARAMETER);
131 return DPROMPT_CANCEL;
133 params.DialogTitle = DialogTitle;
134 params.DiskName = DiskName;
135 params.PathToSource = PathToSource;
136 params.FileSought = FileSought;
137 params.TagFile = TagFile;
138 params.DiskPromptStyle = DiskPromptStyle;
139 params.PathBuffer = PathBuffer;
140 params.PathBufferSize = PathBufferSize;
141 params.PathRequiredSize = PathRequiredSize;
143 ret = DialogBoxParamW(SETUPAPI_hInstance, MAKEINTRESOURCEW(IDPROMPTFORDISK),
144 hwndParent, promptdisk_proc, (LPARAM)¶ms);
146 if(ret == DPROMPT_CANCEL)
147 SetLastError(ERROR_CANCELLED);