ReactOS 0.4.16-dev-319-g6cf4263
dialog.c File Reference
#include "setupapi_private.h"
Include dependency graph for dialog.c:

Go to the source code of this file.

Classes

struct  promptdisk_params
 

Functions

static void promptdisk_init (HWND hwnd, struct promptdisk_params *params)
 
static void promptdisk_ok (HWND hwnd, struct promptdisk_params *params)
 
static void promptdisk_browse (HWND hwnd, struct promptdisk_params *params)
 
static INT_PTR CALLBACK promptdisk_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
UINT WINAPI SetupPromptForDiskA (HWND hwndParent, PCSTR DialogTitle, PCSTR DiskName, PCSTR PathToSource, PCSTR FileSought, PCSTR TagFile, DWORD DiskPromptStyle, PSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize)
 
UINT WINAPI SetupPromptForDiskW (HWND hwndParent, PCWSTR DialogTitle, PCWSTR DiskName, PCWSTR PathToSource, PCWSTR FileSought, PCWSTR TagFile, DWORD DiskPromptStyle, PWSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize)
 

Function Documentation

◆ promptdisk_browse()

static void promptdisk_browse ( HWND  hwnd,
struct promptdisk_params params 
)
static

Definition at line 116 of file dialog.c.

117{
119 ZeroMemory(&ofn, sizeof(ofn));
120
121 ofn.lStructSize = sizeof(ofn);
126 strcpyW(ofn.lpstrFile, params->FileSought);
127
129 {
130 WCHAR* last_slash = strrchrW(ofn.lpstrFile, '\\');
131 if (last_slash) *last_slash = 0;
133 }
135}
#define IDC_PATH
Definition: resource.h:67
#define OFN_EXPLORER
Definition: commdlg.h:104
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4736
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define MAX_PATH
Definition: compat.h:34
#define HeapFree(x, y, z)
Definition: compat.h:735
GLenum const GLfloat * params
Definition: glext.h:5645
#define strrchrW(s, c)
Definition: unicode.h:41
#define strcpyW(d, s)
Definition: unicode.h:35
OPENFILENAME ofn
Definition: sndrec32.cpp:56
HWND hwndOwner
Definition: commdlg.h:330
LPSTR lpstrFile
Definition: commdlg.h:336
DWORD Flags
Definition: commdlg.h:342
DWORD lStructSize
Definition: commdlg.h:329
DWORD nMaxFile
Definition: commdlg.h:337
#define ZeroMemory
Definition: winbase.h:1737
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
BOOL WINAPI SetDlgItemTextW(_In_ HWND, _In_ int, _In_ LPCWSTR)
__wchar_t WCHAR
Definition: xmlstorage.h:180

Referenced by promptdisk_proc().

◆ promptdisk_init()

static void promptdisk_init ( HWND  hwnd,
struct promptdisk_params params 
)
static

Definition at line 37 of file dialog.c.

38{
40
41 if(params->DialogTitle)
42 SetWindowTextW(hwnd, params->DialogTitle);
43 if(params->PathToSource)
44 SetDlgItemTextW(hwnd, IDC_PATH, params->PathToSource);
45
46 if(!(params->DiskPromptStyle & IDF_OEMDISK))
47 {
48 WCHAR message[256+2*MAX_PATH];
49 WCHAR format[256];
50 WCHAR unknown[256];
51 DWORD_PTR args[2];
53 sizeof(format)/sizeof(format[0]));
54
55 args[0] = (DWORD_PTR)params->FileSought;
56 if(params->DiskName)
57 args[1] = (DWORD_PTR)params->DiskName;
58 else
59 {
61 sizeof(unknown)/sizeof(unknown[0]));
63 }
65 format, 0, 0, message, sizeof(message)/sizeof(*message),
68
70 sizeof(message)/sizeof(message[0]));
73 sizeof(message)/sizeof(message[0]));
75 }
76 if(params->DiskPromptStyle & IDF_NOBROWSE)
78}
#define IDS_UNKNOWN
Definition: resource.h:7
#define IDS_INFO
Definition: resource.h:53
HINSTANCE hInstance
Definition: charmap.c:19
static WCHAR unknown[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1605
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
#define IDS_COPYFROM
Definition: resource.h:11
#define IDS_PROMPTDISK
Definition: resource.h:9
#define IDC_COPYFROM
Definition: resource.h:5
#define IDC_RUNDLG_BROWSE
Definition: resource.h:7
#define IDC_INFO
Definition: resource.h:4
#define IDC_FILENEEDED
Definition: resource.h:3
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define IDF_OEMDISK
Definition: setupapi.h:431
#define IDF_NOBROWSE
Definition: setupapi.h:423
Definition: match.c:390
Definition: format.c:58
Definition: tftpd.h:60
#define DWORD_PTR
Definition: treelist.c:76
uint32_t DWORD_PTR
Definition: typedefs.h:65
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:447
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:450
#define __ms_va_list
Definition: windef.h:456
#define SW_HIDE
Definition: winuser.h:771
#define DWLP_USER
Definition: winuser.h:875
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
#define SetWindowLongPtrW
Definition: winuser.h:5358

Referenced by promptdisk_proc().

◆ promptdisk_ok()

static void promptdisk_ok ( HWND  hwnd,
struct promptdisk_params params 
)
static

Definition at line 86 of file dialog.c.

87{
88 int requiredSize;
91 requiredSize = strlenW(aux)+1;
92
93 if(params->PathRequiredSize)
94 {
95 *params->PathRequiredSize = requiredSize;
96 TRACE("returning PathRequiredSize=%d\n",*params->PathRequiredSize);
97 }
98 if(!params->PathBuffer)
99 {
101 return;
102 }
103 if(requiredSize > params->PathBufferSize)
104 {
106 return;
107 }
108 strcpyW(params->PathBuffer, aux);
109 TRACE("returning PathBuffer=%s\n", debugstr_w(params->PathBuffer));
111}
#define NO_ERROR
Definition: dderror.h:5
#define debugstr_w
Definition: kernel32.h:32
static const WCHAR aux[]
#define strlenW(s)
Definition: unicode.h:34
#define DPROMPT_BUFFERTOOSMALL
Definition: setupapi.h:272
#define DPROMPT_SUCCESS
Definition: setupapi.h:269
#define TRACE(s)
Definition: solgame.cpp:4
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1384
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by promptdisk_proc().

◆ promptdisk_proc()

static INT_PTR CALLBACK promptdisk_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 139 of file dialog.c.

140{
141 switch(msg)
142 {
143 case WM_INITDIALOG:
145 return TRUE;
146 case WM_COMMAND:
147 switch(wParam)
148 {
149 case IDOK:
150 {
151 struct promptdisk_params *params =
154 return TRUE;
155 }
156 case IDCANCEL:
158 return TRUE;
160 {
161 struct promptdisk_params *params =
164 return TRUE;
165 }
166 }
167 }
168 return FALSE;
169}
#define msg(x)
Definition: auth_time.c:54
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static void promptdisk_browse(HWND hwnd, struct promptdisk_params *params)
Definition: dialog.c:116
static void promptdisk_ok(HWND hwnd, struct promptdisk_params *params)
Definition: dialog.c:86
static void promptdisk_init(HWND hwnd, struct promptdisk_params *params)
Definition: dialog.c:37
#define DPROMPT_CANCEL
Definition: setupapi.h:270
#define GetWindowLongPtrW
Definition: winuser.h:4832
#define IDCANCEL
Definition: winuser.h:834
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
#define IDOK
Definition: winuser.h:833

Referenced by SetupPromptForDiskW().

◆ SetupPromptForDiskA()

UINT WINAPI SetupPromptForDiskA ( HWND  hwndParent,
PCSTR  DialogTitle,
PCSTR  DiskName,
PCSTR  PathToSource,
PCSTR  FileSought,
PCSTR  TagFile,
DWORD  DiskPromptStyle,
PSTR  PathBuffer,
DWORD  PathBufferSize,
PDWORD  PathRequiredSize 
)

Definition at line 174 of file dialog.c.

177{
178 WCHAR *DialogTitleW, *DiskNameW, *PathToSourceW;
179 WCHAR *FileSoughtW, *TagFileW, PathBufferW[MAX_PATH];
180 UINT ret, length;
181
182 TRACE("%p, %s, %s, %s, %s, %s, 0x%08x, %p, %d, %p\n", hwndParent, debugstr_a(DialogTitle),
183 debugstr_a(DiskName), debugstr_a(PathToSource), debugstr_a(FileSought),
184 debugstr_a(TagFile), DiskPromptStyle, PathBuffer, PathBufferSize,
185 PathRequiredSize);
186
187 DialogTitleW = strdupAtoW(DialogTitle);
188 DiskNameW = strdupAtoW(DiskName);
189 PathToSourceW = strdupAtoW(PathToSource);
190 FileSoughtW = strdupAtoW(FileSought);
191 TagFileW = strdupAtoW(TagFile);
192
193 ret = SetupPromptForDiskW(hwndParent, DialogTitleW, DiskNameW, PathToSourceW,
194 FileSoughtW, TagFileW, DiskPromptStyle, PathBufferW, MAX_PATH, PathRequiredSize);
195
196 HeapFree(GetProcessHeap(), 0, DialogTitleW);
197 HeapFree(GetProcessHeap(), 0, DiskNameW);
198 HeapFree(GetProcessHeap(), 0, PathToSourceW);
199 HeapFree(GetProcessHeap(), 0, FileSoughtW);
200 HeapFree(GetProcessHeap(), 0, TagFileW);
201
202 if(ret == DPROMPT_SUCCESS)
203 {
204 length = WideCharToMultiByte(CP_ACP, 0, PathBufferW, -1, NULL, 0, NULL, NULL);
205 if(PathRequiredSize) *PathRequiredSize = length;
206 if(PathBuffer)
207 {
208 if(length > PathBufferSize)
210 WideCharToMultiByte(CP_ACP, 0, PathBufferW, -1, PathBuffer, length, NULL, NULL);
211 }
212 }
213 return ret;
214}
static HWND hwndParent
Definition: cryptui.c:300
#define NULL
Definition: types.h:112
static WCHAR * strdupAtoW(const char *str)
Definition: main.c:65
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
UINT WINAPI SetupPromptForDiskW(HWND hwndParent, PCWSTR DialogTitle, PCWSTR DiskName, PCWSTR PathToSource, PCWSTR FileSought, PCWSTR TagFile, DWORD DiskPromptStyle, PWSTR PathBuffer, DWORD PathBufferSize, PDWORD PathRequiredSize)
Definition: dialog.c:219
GLuint GLsizei GLsizei * length
Definition: glext.h:6040
#define debugstr_a
Definition: kernel32.h:31
unsigned int UINT
Definition: ndis.h:50
int ret

Referenced by test_SetupPromptForDiskA().

◆ SetupPromptForDiskW()

UINT WINAPI SetupPromptForDiskW ( HWND  hwndParent,
PCWSTR  DialogTitle,
PCWSTR  DiskName,
PCWSTR  PathToSource,
PCWSTR  FileSought,
PCWSTR  TagFile,
DWORD  DiskPromptStyle,
PWSTR  PathBuffer,
DWORD  PathBufferSize,
PDWORD  PathRequiredSize 
)

Definition at line 219 of file dialog.c.

222{
224 UINT ret;
225
226 TRACE("%p, %s, %s, %s, %s, %s, 0x%08x, %p, %d, %p\n", hwndParent, debugstr_w(DialogTitle),
230
231 if(!FileSought)
232 {
234 return DPROMPT_CANCEL;
235 }
236
238 {
239 static const WCHAR format[] = {'%', 's', '\\', '%', 's', '\0'};
240 WCHAR filepath[MAX_PATH];
241
242 if (strlenW(PathToSource) + 1 + strlenW(FileSought) < sizeof(filepath))
243 {
245
247 {
250
251 if (!PathBuffer)
252 return DPROMPT_SUCCESS;
253
255 {
257 return DPROMPT_SUCCESS;
258 }
259 else
261 }
262 }
263 }
264
265 params.DialogTitle = DialogTitle;
266 params.DiskName = DiskName;
267 params.PathToSource = PathToSource;
268 params.FileSought = FileSought;
269 params.TagFile = TagFile;
270 params.DiskPromptStyle = DiskPromptStyle;
271 params.PathBuffer = PathBuffer;
272 params.PathBufferSize = PathBufferSize;
273 params.PathRequiredSize = PathRequiredSize;
274
277
278 if(ret == DPROMPT_CANCEL)
280 return ret;
281}
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define SetLastError(x)
Definition: compat.h:752
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:652
static INT_PTR CALLBACK promptdisk_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:139
#define IDPROMPTFORDISK
Definition: resource.h:23
#define snprintfW
Definition: unicode.h:66
#define IDF_CHECKFIRST
Definition: setupapi.h:427
DWORD DiskPromptStyle
Definition: dialog.c:29
DWORD PathBufferSize
Definition: dialog.c:31
PCWSTR TagFile
Definition: dialog.c:28
PDWORD PathRequiredSize
Definition: dialog.c:32
PCWSTR DialogTitle
Definition: dialog.c:24
PCWSTR FileSought
Definition: dialog.c:27
PCWSTR DiskName
Definition: dialog.c:25
PWSTR PathBuffer
Definition: dialog.c:30
PCWSTR PathToSource
Definition: dialog.c:26
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
LONG_PTR LPARAM
Definition: windef.h:208
#define ERROR_CANCELLED
Definition: winerror.h:726
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
INT_PTR WINAPI DialogBoxParamW(_In_opt_ HINSTANCE, _In_ LPCWSTR, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)

Referenced by SetupPromptForDiskA(), and test_SetupPromptForDiskW().