ReactOS  0.4.14-dev-52-g6116262
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);
123  ofn.hwndOwner = hwnd;
126  strcpyW(ofn.lpstrFile, params->FileSought);
127 
128  if(GetOpenFileNameW(&ofn))
129  {
130  WCHAR* last_slash = strrchrW(ofn.lpstrFile, '\\');
131  if (last_slash) *last_slash = 0;
133  }
135 }
#define OFN_FILEMUSTEXIST
Definition: commdlg.h:106
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
HWND hwndOwner
Definition: commdlg.h:330
OPENFILENAME ofn
Definition: main.cpp:37
#define IDC_PATH
Definition: resource.h:65
#define ZeroMemory
Definition: winbase.h:1635
DWORD nMaxFile
Definition: commdlg.h:337
GLenum const GLfloat * params
Definition: glext.h:5645
BOOL WINAPI GetOpenFileNameW(OPENFILENAMEW *ofn)
Definition: filedlg.c:4564
BOOL WINAPI SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString)
Definition: dialog.c:2769
#define OFN_PATHMUSTEXIST
Definition: commdlg.h:117
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
DWORD lStructSize
Definition: commdlg.h:329
#define OFN_HIDEREADONLY
Definition: commdlg.h:107
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
static HWND hwnd[MAXHWNDS]
Definition: dialog.c:47
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
LPSTR lpstrFile
Definition: commdlg.h:336
#define HeapFree(x, y, z)
Definition: compat.h:394
DWORD Flags
Definition: commdlg.h:342

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]));
62  args[1] = (DWORD_PTR)unknown;
63  }
65  format, 0, 0, message, sizeof(message)/sizeof(*message),
66  (__ms_va_list*)args);
68 
70  sizeof(message)/sizeof(message[0]));
73  sizeof(message)/sizeof(message[0]));
75  }
76  if(params->DiskPromptStyle & IDF_NOBROWSE)
78 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
Definition: tftpd.h:59
static const char __ms_va_list
Definition: printf.c:70
#define IDF_NOBROWSE
Definition: setupapi.h:418
#define IDC_INFO
Definition: resource.h:4
#define IDF_OEMDISK
Definition: setupapi.h:426
#define DWORD_PTR
Definition: treelist.c:76
#define SW_HIDE
Definition: winuser.h:762
#define FORMAT_MESSAGE_ARGUMENT_ARRAY
Definition: winbase.h:405
#define FORMAT_MESSAGE_FROM_STRING
Definition: winbase.h:402
#define IDC_PATH
Definition: resource.h:65
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
DWORD WINAPI FormatMessageW(DWORD dwFlags, LPCVOID lpSource, DWORD dwMessageId, DWORD dwLanguageId, LPWSTR lpBuffer, DWORD nSize, __ms_va_list *args)
Definition: format_msg.c:583
Definition: match.c:390
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
#define IDS_PROMPTDISK
Definition: resource.h:9
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
HINSTANCE hInstance
Definition: charmap.c:20
GLenum const GLfloat * params
Definition: glext.h:5645
#define IDC_COPYFROM
Definition: resource.h:5
BOOL WINAPI SetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPCWSTR lpString)
Definition: dialog.c:2769
#define IDS_UNKNOWN
Definition: resource.h:7
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
Definition: id3.c:18
#define IDS_COPYFROM
Definition: resource.h:11
#define DWLP_USER
Definition: winuser.h:866
uint32_t DWORD_PTR
Definition: typedefs.h:63
#define IDC_FILENEEDED
Definition: resource.h:3
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define IDS_INFO
Definition: resource.h:53
#define IDC_RUNDLG_BROWSE
Definition: resource.h:7
HWND WINAPI GetDlgItem(HWND hDlg, int nIDDlgItem)
Definition: dialog.c:2126
#define SetWindowLongPtrW
Definition: winuser.h:5247

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 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define IDC_PATH
Definition: resource.h:65
#define NO_ERROR
Definition: dderror.h:5
GLenum const GLfloat * params
Definition: glext.h:5645
#define debugstr_w
Definition: kernel32.h:32
#define DPROMPT_SUCCESS
Definition: setupapi.h:269
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
BOOL WINAPI EndDialog(HWND hwnd, INT_PTR retval)
Definition: dialog.c:2028
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1408
#define DPROMPT_BUFFERTOOSMALL
Definition: setupapi.h:272
static const WCHAR aux[]
HWND WINAPI GetDlgItem(HWND hDlg, int nIDDlgItem)
Definition: dialog.c:2126

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;
159  case IDC_RUNDLG_BROWSE:
160  {
161  struct promptdisk_params *params =
164  return TRUE;
165  }
166  }
167  }
168  return FALSE;
169 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
#define GetWindowLongPtrW
Definition: winuser.h:4730
WPARAM wParam
Definition: combotst.c:138
GLenum const GLfloat * params
Definition: glext.h:5645
static void promptdisk_ok(HWND hwnd, struct promptdisk_params *params)
Definition: dialog.c:86
static void promptdisk_browse(HWND hwnd, struct promptdisk_params *params)
Definition: dialog.c:116
#define DWLP_USER
Definition: winuser.h:866
#define WM_COMMAND
Definition: winuser.h:1722
static void promptdisk_init(HWND hwnd, struct promptdisk_params *params)
Definition: dialog.c:37
BOOL WINAPI EndDialog(HWND hwnd, INT_PTR retval)
Definition: dialog.c:2028
#define msg(x)
Definition: auth_time.c:54
#define IDC_RUNDLG_BROWSE
Definition: resource.h:7
#define IDCANCEL
Definition: winuser.h:825
#define DPROMPT_CANCEL
Definition: setupapi.h:270
#define WM_INITDIALOG
Definition: winuser.h:1721
LPARAM lParam
Definition: combotst.c:139

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),
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);
206  if(PathBuffer)
207  {
208  if(length > PathBufferSize)
209  return DPROMPT_BUFFERTOOSMALL;
210  WideCharToMultiByte(CP_ACP, 0, PathBufferW, -1, PathBuffer, length, NULL, NULL);
211  }
212  }
213  return ret;
214 }
PCWSTR DialogTitle
Definition: dialog.c:24
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
#define DPROMPT_SUCCESS
Definition: setupapi.h:269
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define debugstr_a
Definition: kernel32.h:31
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
PCWSTR DiskName
Definition: dialog.c:25
#define MAX_PATH
Definition: compat.h:26
PCWSTR FileSought
Definition: dialog.c:27
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
DWORD DiskPromptStyle
Definition: dialog.c:29
PCWSTR TagFile
Definition: dialog.c:28
int ret
PWSTR PathBuffer
Definition: dialog.c:30
#define DPROMPT_BUFFERTOOSMALL
Definition: setupapi.h:272
unsigned int UINT
Definition: ndis.h:50
PDWORD PathRequiredSize
Definition: dialog.c:32
PCWSTR PathToSource
Definition: dialog.c:26
DWORD PathBufferSize
Definition: dialog.c:31
#define HeapFree(x, y, z)
Definition: compat.h:394
static WCHAR * strdupAtoW(const char *str)
Definition: main.c:67

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 {
223  struct promptdisk_params params;
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  {
248  if (PathRequiredSize)
250 
251  if (!PathBuffer)
252  return DPROMPT_SUCCESS;
253 
254  if (PathBufferSize >= strlenW(PathToSource) + 1)
255  {
257  return DPROMPT_SUCCESS;
258  }
259  else
260  return DPROMPT_BUFFERTOOSMALL;
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:91
#define IDPROMPTFORDISK
Definition: resource.h:23
PCWSTR DialogTitle
Definition: dialog.c:24
#define snprintfW
Definition: unicode.h:60
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define IDF_CHECKFIRST
Definition: setupapi.h:422
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
HINSTANCE hInstance
Definition: charmap.c:20
GLenum const GLfloat * params
Definition: glext.h:5645
DWORD WINAPI GetFileAttributesW(LPCWSTR lpFileName)
Definition: fileinfo.c:802
#define debugstr_w
Definition: kernel32.h:32
static HWND hwndParent
Definition: cryptui.c:300
LONG_PTR LPARAM
Definition: windef.h:208
#define DPROMPT_SUCCESS
Definition: setupapi.h:269
#define TRACE(s)
Definition: solgame.cpp:4
__wchar_t WCHAR
Definition: xmlstorage.h:180
static INT_PTR CALLBACK promptdisk_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: dialog.c:139
PCWSTR DiskName
Definition: dialog.c:25
#define MAX_PATH
Definition: compat.h:26
PCWSTR FileSought
Definition: dialog.c:27
DWORD DiskPromptStyle
Definition: dialog.c:29
#define SetLastError(x)
Definition: compat.h:409
#define INVALID_FILE_ATTRIBUTES
Definition: vfdcmd.c:23
PCWSTR TagFile
Definition: dialog.c:28
int ret
PWSTR PathBuffer
Definition: dialog.c:30
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
#define ERROR_CANCELLED
Definition: winerror.h:726
#define DPROMPT_BUFFERTOOSMALL
Definition: setupapi.h:272
unsigned int UINT
Definition: ndis.h:50
PDWORD PathRequiredSize
Definition: dialog.c:32
PCWSTR PathToSource
Definition: dialog.c:26
DWORD PathBufferSize
Definition: dialog.c:31
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
#define DPROMPT_CANCEL
Definition: setupapi.h:270
INT_PTR WINAPI DialogBoxParamW(HINSTANCE hInstance, LPCWSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam)
Definition: dialog.c:1871

Referenced by SetupPromptForDiskA(), and test_SetupPromptForDiskW().