1 | /* $Id: comdlg32.cpp,v 1.8 1999-06-29 16:24:17 achimha Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * COMDLG32 implementation
|
---|
5 | *
|
---|
6 | * Copyright 1998 Sander van Leeuwen
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 | #include <os2win.h>
|
---|
13 | #include <stdarg.h>
|
---|
14 | #include <stdlib.h>
|
---|
15 | #include <string.h>
|
---|
16 | #include <misc.h>
|
---|
17 | #include <wndproc.h>
|
---|
18 |
|
---|
19 |
|
---|
20 | #define COMDLG32_CHECKHOOK(a,b,c) \
|
---|
21 | if(a->Flags & b) \
|
---|
22 | { \
|
---|
23 | wndproc = CreateWindowProc((WNDPROC)a->lpfnHook);\
|
---|
24 | if(wndproc == NULL) \
|
---|
25 | return(FALSE); \
|
---|
26 | \
|
---|
27 | a->lpfnHook = (c)Win32WindowProc::GetOS2Callback();\
|
---|
28 | }
|
---|
29 |
|
---|
30 | #define COMDLG32_CHECKHOOK2(a,b,c,d) \
|
---|
31 | if(a->Flags & b) \
|
---|
32 | { \
|
---|
33 | wndproc = CreateWindowProc((WNDPROC)a->d);\
|
---|
34 | if(wndproc == NULL) \
|
---|
35 | return(FALSE); \
|
---|
36 | \
|
---|
37 | a->d = (c)Win32WindowProc::GetOS2Callback();\
|
---|
38 | }
|
---|
39 |
|
---|
40 |
|
---|
41 | /*****************************************************************************
|
---|
42 | * Name :
|
---|
43 | * Purpose :
|
---|
44 | * Parameters:
|
---|
45 | * Variables :
|
---|
46 | * Result :
|
---|
47 | * Remark :
|
---|
48 | * Status :
|
---|
49 | *
|
---|
50 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
51 | *****************************************************************************/
|
---|
52 |
|
---|
53 | BOOL WIN32API GetSaveFileNameA(LPOPENFILENAMEA lpofn)
|
---|
54 | {
|
---|
55 | Win32WindowProc *wndproc;
|
---|
56 |
|
---|
57 | dprintf(("COMDLG32: GetSaveFileNameA(%08xh)\n",
|
---|
58 | lpofn));
|
---|
59 |
|
---|
60 | COMDLG32_CHECKHOOK(lpofn, OFN_ENABLEHOOK, WNDPROC)
|
---|
61 |
|
---|
62 | return(O32_GetSaveFileName(lpofn));
|
---|
63 | }
|
---|
64 |
|
---|
65 |
|
---|
66 | /*****************************************************************************
|
---|
67 | * Name :
|
---|
68 | * Purpose :
|
---|
69 | * Parameters:
|
---|
70 | * Variables :
|
---|
71 | * Result :
|
---|
72 | * Remark :
|
---|
73 | * Status :
|
---|
74 | *
|
---|
75 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
76 | *****************************************************************************/
|
---|
77 |
|
---|
78 | BOOL WIN32API GetOpenFileNameA(LPOPENFILENAMEA lpofn)
|
---|
79 | {
|
---|
80 | Win32WindowProc *wndproc;
|
---|
81 |
|
---|
82 | dprintf(("COMDLG32: GetOpenFileNameA(%08xh)\n",
|
---|
83 | lpofn));
|
---|
84 |
|
---|
85 | COMDLG32_CHECKHOOK(lpofn, OFN_ENABLEHOOK, WNDPROC)
|
---|
86 |
|
---|
87 | return(O32_GetOpenFileName(lpofn));
|
---|
88 | }
|
---|
89 |
|
---|
90 |
|
---|
91 | /*****************************************************************************
|
---|
92 | * Name :
|
---|
93 | * Purpose :
|
---|
94 | * Parameters:
|
---|
95 | * Variables :
|
---|
96 | * Result :
|
---|
97 | * Remark :
|
---|
98 | * Status :
|
---|
99 | *
|
---|
100 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
101 | *****************************************************************************/
|
---|
102 |
|
---|
103 | INT16 WIN32API GetFileTitleA(LPCSTR lpFile,
|
---|
104 | LPSTR lpTitle,
|
---|
105 | UINT cbBuf)
|
---|
106 | {
|
---|
107 | dprintf(("COMDLG32: GetFileTitleA(%s,%08xh,%08xh)\n",
|
---|
108 | lpFile,
|
---|
109 | lpTitle,
|
---|
110 | cbBuf));
|
---|
111 |
|
---|
112 | return O32_GetFileTitle(lpFile,
|
---|
113 | lpTitle,
|
---|
114 | cbBuf);
|
---|
115 | }
|
---|
116 |
|
---|
117 |
|
---|
118 | /*****************************************************************************
|
---|
119 | * Name :
|
---|
120 | * Purpose :
|
---|
121 | * Parameters:
|
---|
122 | * Variables :
|
---|
123 | * Result :
|
---|
124 | * Remark :
|
---|
125 | * Status :
|
---|
126 | *
|
---|
127 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
128 | *****************************************************************************/
|
---|
129 |
|
---|
130 | BOOL WIN32API ChooseColorA(LPCHOOSECOLORA lpcc)
|
---|
131 | {
|
---|
132 | Win32WindowProc *wndproc;
|
---|
133 |
|
---|
134 | dprintf(("COMDLG32: ChooseColorA(%08xh)\n",
|
---|
135 | lpcc));
|
---|
136 |
|
---|
137 | COMDLG32_CHECKHOOK(lpcc, CC_ENABLEHOOK, LPCCHOOKPROC)
|
---|
138 |
|
---|
139 | return O32_ChooseColor(lpcc);
|
---|
140 | }
|
---|
141 |
|
---|
142 |
|
---|
143 | /*****************************************************************************
|
---|
144 | * Name :
|
---|
145 | * Purpose :
|
---|
146 | * Parameters:
|
---|
147 | * Variables :
|
---|
148 | * Result :
|
---|
149 | * Remark : casting is a little hot, should work however
|
---|
150 | * assuming lpcc->lpTemplateName is READONLY pointer!
|
---|
151 | * Status :
|
---|
152 | *
|
---|
153 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
154 | *****************************************************************************/
|
---|
155 |
|
---|
156 | BOOL WIN32API ChooseColorW(LPCHOOSECOLORW lpcc)
|
---|
157 | {
|
---|
158 | Win32WindowProc *wndproc;
|
---|
159 | BOOL bResult;
|
---|
160 | LPCWSTR lpTemplateNameBackup = lpcc->lpTemplateName;
|
---|
161 |
|
---|
162 | dprintf(("COMDLG32: ChooseColorW(%08xh).\n",
|
---|
163 | lpcc));
|
---|
164 |
|
---|
165 | // if no template is to convert, we can take this shortcut
|
---|
166 | if (!(lpcc->Flags & CC_ENABLETEMPLATE))
|
---|
167 | return O32_ChooseColor( (LPCHOOSECOLORA)lpcc );
|
---|
168 |
|
---|
169 |
|
---|
170 | // convert to ASCII string
|
---|
171 | if (lpcc->lpTemplateName != NULL)
|
---|
172 | lpcc->lpTemplateName = (LPCWSTR)UnicodeToAsciiString((WCHAR*)lpcc->lpTemplateName);
|
---|
173 |
|
---|
174 | COMDLG32_CHECKHOOK(lpcc, CC_ENABLEHOOK, LPCCHOOKPROC)
|
---|
175 |
|
---|
176 | bResult = O32_ChooseColor((LPCHOOSECOLORA)lpcc); // call ASCII version
|
---|
177 |
|
---|
178 | // free temporary ASCII string and restore UNICODE string
|
---|
179 | if (lpcc->lpTemplateName != NULL)
|
---|
180 | {
|
---|
181 | FreeAsciiString((char*)lpcc->lpTemplateName);
|
---|
182 | lpcc->lpTemplateName = lpTemplateNameBackup;
|
---|
183 | }
|
---|
184 |
|
---|
185 | return bResult;
|
---|
186 | }
|
---|
187 |
|
---|
188 |
|
---|
189 | /*****************************************************************************
|
---|
190 | * Name :
|
---|
191 | * Purpose :
|
---|
192 | * Parameters:
|
---|
193 | * Variables :
|
---|
194 | * Result :
|
---|
195 | * Remark :
|
---|
196 | * Status :
|
---|
197 | *
|
---|
198 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
199 | *****************************************************************************/
|
---|
200 |
|
---|
201 | BOOL WIN32API ChooseFontA(LPCHOOSEFONTA lpcf)
|
---|
202 | {
|
---|
203 | Win32WindowProc *wndproc;
|
---|
204 |
|
---|
205 | dprintf(("COMDLG32: ChooseFontA(%08xh).\n",
|
---|
206 | lpcf));
|
---|
207 |
|
---|
208 | COMDLG32_CHECKHOOK(lpcf, CF_ENABLEHOOK, WNDPROC)
|
---|
209 |
|
---|
210 | return O32_ChooseFont(lpcf);
|
---|
211 | }
|
---|
212 |
|
---|
213 |
|
---|
214 | /*****************************************************************************
|
---|
215 | * Name :
|
---|
216 | * Purpose :
|
---|
217 | * Parameters:
|
---|
218 | * Variables :
|
---|
219 | * Result :
|
---|
220 | * Remark : unknown yet, what is INPUT and what is OUTPUT string
|
---|
221 | * Status :
|
---|
222 | *
|
---|
223 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
224 | * Edgar Buerkle [Mon, 1999/06/28 19:35]
|
---|
225 | *****************************************************************************/
|
---|
226 |
|
---|
227 | BOOL WIN32API ChooseFontW(LPCHOOSEFONTW lpcf)
|
---|
228 | {
|
---|
229 | Win32WindowProc *wndproc;
|
---|
230 | BOOL bResult;
|
---|
231 | CHOOSEFONTA asciicf;
|
---|
232 | LOGFONTA asciilf;
|
---|
233 | char szAsciiStyle[64];
|
---|
234 |
|
---|
235 | // NOTE: LOGFONTW/A is NOT converted !
|
---|
236 | dprintf(("COMDLG32: ChooseFontW(%08xh) not correctly implemented.\n",
|
---|
237 | lpcf));
|
---|
238 |
|
---|
239 | // convert to ASCII string
|
---|
240 | memcpy(&asciicf, // make binary copy of CHOOSEFONTW
|
---|
241 | lpcf, // to save the flags
|
---|
242 | sizeof(asciicf));
|
---|
243 |
|
---|
244 | memcpy (&asciilf,
|
---|
245 | lpcf->lpLogFont,
|
---|
246 | sizeof(LOGFONTA));
|
---|
247 |
|
---|
248 | asciicf.lpLogFont = &asciilf; // update pointer
|
---|
249 |
|
---|
250 | // lpTemplatenName bug in open32 ? This doesn't work.
|
---|
251 | // TODO: CF_ENABLETEMPLATEHANDLE
|
---|
252 | if (lpcf->Flags & CF_ENABLETEMPLATE)
|
---|
253 | if((int)asciicf.lpTemplateName >> 16 != 0)
|
---|
254 | asciicf.lpTemplateName = UnicodeToAsciiString((LPWSTR)lpcf->lpTemplateName);
|
---|
255 |
|
---|
256 | UnicodeToAsciiN(lpcf->lpszStyle,
|
---|
257 | szAsciiStyle,
|
---|
258 | sizeof(szAsciiStyle) - 1);
|
---|
259 | asciicf.lpszStyle = szAsciiStyle;
|
---|
260 |
|
---|
261 | UnicodeToAsciiN(lpcf->lpLogFont->lfFaceName,
|
---|
262 | asciilf.lfFaceName,
|
---|
263 | LF_FACESIZE-1);
|
---|
264 |
|
---|
265 | // LPCFHOOKPROC != WNDPROC ?
|
---|
266 | COMDLG32_CHECKHOOK(lpcf, CF_ENABLEHOOK, WNDPROC)
|
---|
267 |
|
---|
268 | // switch strings
|
---|
269 | bResult = O32_ChooseFont((LPCHOOSEFONTA)&asciicf); // call ASCII version
|
---|
270 |
|
---|
271 | // transfer BACK resulting strings !!!
|
---|
272 | AsciiToUnicodeN(asciicf.lpLogFont->lfFaceName,
|
---|
273 | lpcf->lpLogFont->lfFaceName,
|
---|
274 | LF_FACESIZE-1);
|
---|
275 |
|
---|
276 | AsciiToUnicode(asciicf.lpszStyle,
|
---|
277 | lpcf->lpszStyle);
|
---|
278 |
|
---|
279 | if (lpcf->Flags & CF_ENABLETEMPLATE)
|
---|
280 | if((int)asciicf.lpTemplateName >> 16 != 0)
|
---|
281 | FreeAsciiString((char*)asciicf.lpTemplateName);
|
---|
282 |
|
---|
283 | // copy back fields
|
---|
284 | lpcf->Flags = asciicf.Flags;
|
---|
285 |
|
---|
286 | return bResult;
|
---|
287 | }
|
---|
288 |
|
---|
289 |
|
---|
290 | /*****************************************************************************
|
---|
291 | * Name :
|
---|
292 | * Purpose :
|
---|
293 | * Parameters:
|
---|
294 | * Variables :
|
---|
295 | * Result :
|
---|
296 | * Remark :
|
---|
297 | * Status :
|
---|
298 | *
|
---|
299 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
300 | *****************************************************************************/
|
---|
301 |
|
---|
302 | DWORD WIN32API CommDlgExtendedError(void)
|
---|
303 | {
|
---|
304 | dprintf(("COMDLG32: ComDlgExtendedError()\n"));
|
---|
305 |
|
---|
306 | return O32_CommDlgExtendedError();
|
---|
307 | }
|
---|
308 |
|
---|
309 |
|
---|
310 | /*****************************************************************************
|
---|
311 | * Name :
|
---|
312 | * Purpose :
|
---|
313 | * Parameters:
|
---|
314 | * Variables :
|
---|
315 | * Result :
|
---|
316 | * Remark :
|
---|
317 | * Status :
|
---|
318 | *
|
---|
319 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
320 | *****************************************************************************/
|
---|
321 |
|
---|
322 | HWND WIN32API FindTextA(LPFINDREPLACEA lpfr)
|
---|
323 | {
|
---|
324 | Win32WindowProc *wndproc;
|
---|
325 |
|
---|
326 | dprintf(("COMDLG32: FindTextA(%08xh).\n",
|
---|
327 | lpfr));
|
---|
328 |
|
---|
329 | COMDLG32_CHECKHOOK(lpfr, FR_ENABLEHOOK, WNDPROC)
|
---|
330 |
|
---|
331 | return O32_FindText(lpfr);
|
---|
332 | }
|
---|
333 |
|
---|
334 |
|
---|
335 | /*****************************************************************************
|
---|
336 | * Name :
|
---|
337 | * Purpose :
|
---|
338 | * Parameters:
|
---|
339 | * Variables :
|
---|
340 | * Result :
|
---|
341 | * Remark :
|
---|
342 | * Status :
|
---|
343 | *
|
---|
344 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
345 | *****************************************************************************/
|
---|
346 |
|
---|
347 | HWND WIN32API FindTextW(LPFINDREPLACEW lpfr)
|
---|
348 | {
|
---|
349 | Win32WindowProc *wndproc;
|
---|
350 | BOOL bResult;
|
---|
351 | FINDREPLACEA fr;
|
---|
352 |
|
---|
353 | dprintf(("COMDLG32: FindTextW(%08xh)\n",
|
---|
354 | lpfr));
|
---|
355 |
|
---|
356 | memcpy(&fr, // make binary copy first to save all the fields
|
---|
357 | lpfr,
|
---|
358 | sizeof(fr));
|
---|
359 |
|
---|
360 | // convert to ASCII string
|
---|
361 | if ((lpfr->Flags & FR_ENABLETEMPLATE) &&
|
---|
362 | (lpfr->lpTemplateName != NULL))
|
---|
363 | fr.lpTemplateName = UnicodeToAsciiString((WCHAR*)lpfr->lpTemplateName);
|
---|
364 | else
|
---|
365 | fr.lpTemplateName = NULL;
|
---|
366 |
|
---|
367 | if (lpfr->lpstrFindWhat != NULL)
|
---|
368 | fr.lpstrFindWhat = UnicodeToAsciiString((WCHAR*)lpfr->lpstrFindWhat);
|
---|
369 |
|
---|
370 | if (lpfr->lpstrReplaceWith != NULL)
|
---|
371 | fr.lpstrReplaceWith = UnicodeToAsciiString((WCHAR*)lpfr->lpstrReplaceWith);
|
---|
372 |
|
---|
373 |
|
---|
374 | COMDLG32_CHECKHOOK(lpfr, FR_ENABLEHOOK, WNDPROC)
|
---|
375 |
|
---|
376 | bResult = O32_FindText(&fr); // call ASCII version
|
---|
377 |
|
---|
378 | // @@@PH: Note -- we might have to transfer BACK resulting strings !!!
|
---|
379 | // free temporary ASCII string and restore UNICODE string
|
---|
380 | if (fr.lpTemplateName != NULL)
|
---|
381 | FreeAsciiString((char*)fr.lpTemplateName);
|
---|
382 |
|
---|
383 | // free temporary ASCII string and restore UNICODE string
|
---|
384 | if (fr.lpstrFindWhat != NULL)
|
---|
385 | {
|
---|
386 | AsciiToUnicode(fr.lpstrFindWhat,
|
---|
387 | lpfr->lpstrFindWhat);
|
---|
388 |
|
---|
389 | FreeAsciiString((char*)fr.lpstrFindWhat);
|
---|
390 | }
|
---|
391 |
|
---|
392 | if (fr.lpstrReplaceWith != NULL)
|
---|
393 | {
|
---|
394 | AsciiToUnicode(fr.lpstrReplaceWith,
|
---|
395 | lpfr->lpstrReplaceWith);
|
---|
396 |
|
---|
397 | FreeAsciiString((char*)fr.lpstrReplaceWith);
|
---|
398 | }
|
---|
399 |
|
---|
400 | // copy back fields
|
---|
401 | lpfr->Flags = fr.Flags;
|
---|
402 |
|
---|
403 | return bResult;
|
---|
404 | }
|
---|
405 |
|
---|
406 |
|
---|
407 | /*****************************************************************************
|
---|
408 | * Name :
|
---|
409 | * Purpose :
|
---|
410 | * Parameters:
|
---|
411 | * Variables :
|
---|
412 | * Result :
|
---|
413 | * Remark :
|
---|
414 | * Status :
|
---|
415 | *
|
---|
416 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
417 | *****************************************************************************/
|
---|
418 |
|
---|
419 | INT16 WIN32API GetFileTitleW(LPCWSTR lpFile,
|
---|
420 | LPWSTR lpTitle,
|
---|
421 | UINT cbBuf)
|
---|
422 | {
|
---|
423 | LPSTR lpFileBackup;
|
---|
424 | char szTitle[256];
|
---|
425 | INT16 iResult;
|
---|
426 |
|
---|
427 | dprintf(("COMDLG32: GetFileTitleW(%08xh,%08xh,%08xh).\n",
|
---|
428 | lpFile,
|
---|
429 | lpTitle,
|
---|
430 | cbBuf));
|
---|
431 |
|
---|
432 | lpFileBackup = UnicodeToAsciiString((LPWSTR)lpFile);
|
---|
433 | iResult = O32_GetFileTitle(lpFileBackup,
|
---|
434 | szTitle,
|
---|
435 | cbBuf);
|
---|
436 |
|
---|
437 | FreeAsciiString(lpFileBackup);
|
---|
438 |
|
---|
439 | // transform result into Unicode
|
---|
440 | AsciiToUnicode(szTitle,
|
---|
441 | lpTitle);
|
---|
442 |
|
---|
443 | return iResult;
|
---|
444 | }
|
---|
445 |
|
---|
446 |
|
---|
447 | /*****************************************************************************
|
---|
448 | * Name :
|
---|
449 | * Purpose :
|
---|
450 | * Parameters:
|
---|
451 | * Variables :
|
---|
452 | * Result :
|
---|
453 | * Remark :
|
---|
454 | * Status :
|
---|
455 | *
|
---|
456 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
457 | *****************************************************************************/
|
---|
458 |
|
---|
459 | BOOL WIN32API GetOpenFileNameW(LPOPENFILENAMEW lpofn)
|
---|
460 | {
|
---|
461 | Win32WindowProc *wndproc;
|
---|
462 | OPENFILENAMEA ofn;
|
---|
463 | char* szFile;
|
---|
464 | char* szFileTitle;
|
---|
465 | char* szCustFilter;
|
---|
466 | BOOL bResult;
|
---|
467 |
|
---|
468 | dprintf(("COMDLG32: GetOpenFileNameW(%08xh)\n",
|
---|
469 | lpofn));
|
---|
470 |
|
---|
471 | memcpy(&ofn, // make binary copy first to save all the fields
|
---|
472 | lpofn,
|
---|
473 | sizeof(ofn));
|
---|
474 |
|
---|
475 | // convert to ASCII string
|
---|
476 | if ((lpofn->Flags && OFN_ENABLETEMPLATE) &&
|
---|
477 | (lpofn->lpTemplateName != NULL))
|
---|
478 | ofn.lpTemplateName = UnicodeToAsciiString((WCHAR*)lpofn->lpTemplateName);
|
---|
479 | else
|
---|
480 | ofn.lpTemplateName = NULL;
|
---|
481 |
|
---|
482 | if (lpofn->lpstrFilter != NULL)
|
---|
483 | ofn.lpstrFilter = UnicodeToAsciiString((WCHAR*)lpofn->lpstrFilter);
|
---|
484 |
|
---|
485 | if (lpofn->lpstrInitialDir != NULL)
|
---|
486 | ofn.lpstrInitialDir = UnicodeToAsciiString((WCHAR*)lpofn->lpstrInitialDir);
|
---|
487 |
|
---|
488 | if (lpofn->lpstrTitle != NULL)
|
---|
489 | ofn.lpstrTitle = UnicodeToAsciiString((WCHAR*)lpofn->lpstrTitle);
|
---|
490 |
|
---|
491 | if (lpofn->lpstrDefExt != NULL)
|
---|
492 | ofn.lpstrDefExt = UnicodeToAsciiString((WCHAR*)lpofn->lpstrDefExt);
|
---|
493 |
|
---|
494 | szFile = (char*)malloc(lpofn->nMaxFile);
|
---|
495 | szFile[0] = 0;
|
---|
496 |
|
---|
497 | if (*lpofn->lpstrFile != 0)
|
---|
498 | UnicodeToAscii(lpofn->lpstrFile,
|
---|
499 | szFile);
|
---|
500 |
|
---|
501 | if (lpofn->lpstrFileTitle != NULL)
|
---|
502 | {
|
---|
503 | szFileTitle = (char*)malloc(lpofn->nMaxFileTitle);
|
---|
504 | szFileTitle[0] = 0;
|
---|
505 |
|
---|
506 | if (*lpofn->lpstrFileTitle != 0)
|
---|
507 | UnicodeToAscii(lpofn->lpstrFileTitle,
|
---|
508 | szFileTitle);
|
---|
509 | }
|
---|
510 | else
|
---|
511 | szFileTitle = NULL;
|
---|
512 |
|
---|
513 | if (lpofn->lpstrCustomFilter != NULL)
|
---|
514 | {
|
---|
515 | szCustFilter = (char*)malloc(lpofn->nMaxCustFilter);
|
---|
516 | szCustFilter[0] = 0;
|
---|
517 |
|
---|
518 |
|
---|
519 | if (*lpofn->lpstrCustomFilter != 0)
|
---|
520 | UnicodeToAscii(lpofn->lpstrCustomFilter,
|
---|
521 | szCustFilter);
|
---|
522 | }
|
---|
523 | else
|
---|
524 | szCustFilter = NULL;
|
---|
525 |
|
---|
526 | ofn.lpstrFile = szFile;
|
---|
527 | ofn.lpstrFileTitle = szFileTitle;
|
---|
528 | ofn.lpstrCustomFilter = szCustFilter;
|
---|
529 |
|
---|
530 | COMDLG32_CHECKHOOK(lpofn, OFN_ENABLEHOOK, WNDPROC)
|
---|
531 |
|
---|
532 | bResult = O32_GetOpenFileName(&ofn);
|
---|
533 |
|
---|
534 | if (ofn.lpTemplateName != NULL) FreeAsciiString((char*)ofn.lpTemplateName);
|
---|
535 | if (ofn.lpstrFilter != NULL) FreeAsciiString((char*)ofn.lpstrFilter);
|
---|
536 | if (ofn.lpstrInitialDir != NULL) FreeAsciiString((char*)ofn.lpstrInitialDir);
|
---|
537 | if (ofn.lpstrTitle != NULL) FreeAsciiString((char*)ofn.lpstrTitle);
|
---|
538 | if (ofn.lpstrDefExt != NULL) FreeAsciiString((char*)ofn.lpstrDefExt);
|
---|
539 |
|
---|
540 | // transform back the result
|
---|
541 | AsciiToUnicode(ofn.lpstrFile,
|
---|
542 | lpofn->lpstrFile);
|
---|
543 | free(szFile);
|
---|
544 |
|
---|
545 | if (lpofn->lpstrFileTitle != NULL)
|
---|
546 | {
|
---|
547 | AsciiToUnicode(ofn.lpstrFileTitle,
|
---|
548 | lpofn->lpstrFileTitle);
|
---|
549 | free(szFileTitle);
|
---|
550 | }
|
---|
551 |
|
---|
552 | if (lpofn->lpstrCustomFilter != NULL)
|
---|
553 | {
|
---|
554 | AsciiToUnicode(ofn.lpstrCustomFilter,
|
---|
555 | lpofn->lpstrCustomFilter);
|
---|
556 | free(szCustFilter);
|
---|
557 | }
|
---|
558 |
|
---|
559 | // copy over some altered flags
|
---|
560 | lpofn->nFilterIndex = ofn.nFilterIndex;
|
---|
561 | lpofn->Flags = ofn.Flags;
|
---|
562 | lpofn->nFileOffset = ofn.nFileOffset;
|
---|
563 | lpofn->nFileExtension = ofn.nFileExtension;
|
---|
564 |
|
---|
565 | return bResult;
|
---|
566 | }
|
---|
567 |
|
---|
568 |
|
---|
569 | /*****************************************************************************
|
---|
570 | * Name :
|
---|
571 | * Purpose :
|
---|
572 | * Parameters:
|
---|
573 | * Variables :
|
---|
574 | * Result :
|
---|
575 | * Remark :
|
---|
576 | * Status :
|
---|
577 | *
|
---|
578 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
579 | *****************************************************************************/
|
---|
580 |
|
---|
581 | BOOL WIN32API GetSaveFileNameW(LPOPENFILENAMEW lpofn)
|
---|
582 | {
|
---|
583 | Win32WindowProc *wndproc;
|
---|
584 | OPENFILENAMEA ofn;
|
---|
585 | char* szFile;
|
---|
586 | char* szFileTitle;
|
---|
587 | char* szCustFilter;
|
---|
588 | BOOL bResult;
|
---|
589 |
|
---|
590 | dprintf(("COMDLG32: GetSaveFileNameW(%08xh)\n",
|
---|
591 | lpofn));
|
---|
592 |
|
---|
593 | memcpy(&ofn, // make binary copy first to save all the fields
|
---|
594 | lpofn,
|
---|
595 | sizeof(ofn));
|
---|
596 |
|
---|
597 | // convert to ASCII string
|
---|
598 | if ((lpofn->Flags && OFN_ENABLETEMPLATE) &&
|
---|
599 | (lpofn->lpTemplateName != NULL))
|
---|
600 | ofn.lpTemplateName = UnicodeToAsciiString((WCHAR*)lpofn->lpTemplateName);
|
---|
601 | else
|
---|
602 | ofn.lpTemplateName = NULL;
|
---|
603 |
|
---|
604 | if (lpofn->lpstrFilter != NULL)
|
---|
605 | ofn.lpstrFilter = UnicodeToAsciiString((WCHAR*)lpofn->lpstrFilter);
|
---|
606 |
|
---|
607 | if (lpofn->lpstrInitialDir != NULL)
|
---|
608 | ofn.lpstrInitialDir = UnicodeToAsciiString((WCHAR*)lpofn->lpstrInitialDir);
|
---|
609 |
|
---|
610 | if (lpofn->lpstrTitle != NULL)
|
---|
611 | ofn.lpstrTitle = UnicodeToAsciiString((WCHAR*)lpofn->lpstrTitle);
|
---|
612 |
|
---|
613 | if (lpofn->lpstrDefExt != NULL)
|
---|
614 | ofn.lpstrDefExt = UnicodeToAsciiString((WCHAR*)lpofn->lpstrDefExt);
|
---|
615 |
|
---|
616 | szFile = (char*)malloc(lpofn->nMaxFile);
|
---|
617 | szFile[0] = 0;
|
---|
618 |
|
---|
619 | if (*lpofn->lpstrFile != 0)
|
---|
620 | UnicodeToAscii(lpofn->lpstrFile,
|
---|
621 | szFile);
|
---|
622 |
|
---|
623 | if (lpofn->lpstrFileTitle != NULL)
|
---|
624 | {
|
---|
625 | szFileTitle = (char*)malloc(lpofn->nMaxFileTitle);
|
---|
626 | szFileTitle[0] = 0;
|
---|
627 |
|
---|
628 | if (*lpofn->lpstrFileTitle != 0)
|
---|
629 | UnicodeToAscii(lpofn->lpstrFileTitle,
|
---|
630 | szFileTitle);
|
---|
631 | }
|
---|
632 | else
|
---|
633 | szFileTitle = NULL;
|
---|
634 |
|
---|
635 | if (lpofn->lpstrCustomFilter != NULL)
|
---|
636 | {
|
---|
637 | szCustFilter = (char*)malloc(lpofn->nMaxCustFilter);
|
---|
638 | szCustFilter[0] = 0;
|
---|
639 |
|
---|
640 |
|
---|
641 | if (*lpofn->lpstrCustomFilter != 0)
|
---|
642 | UnicodeToAscii(lpofn->lpstrCustomFilter,
|
---|
643 | szCustFilter);
|
---|
644 | }
|
---|
645 | else
|
---|
646 | szCustFilter = NULL;
|
---|
647 |
|
---|
648 | ofn.lpstrFile = szFile;
|
---|
649 | ofn.lpstrFileTitle = szFileTitle;
|
---|
650 | ofn.lpstrCustomFilter = szCustFilter;
|
---|
651 |
|
---|
652 | COMDLG32_CHECKHOOK(lpofn, OFN_ENABLEHOOK, WNDPROC)
|
---|
653 |
|
---|
654 | bResult = O32_GetSaveFileName(&ofn);
|
---|
655 |
|
---|
656 | if (ofn.lpTemplateName != NULL) FreeAsciiString((char*)ofn.lpTemplateName);
|
---|
657 | if (ofn.lpstrFilter != NULL) FreeAsciiString((char*)ofn.lpstrFilter);
|
---|
658 | if (ofn.lpstrInitialDir != NULL) FreeAsciiString((char*)ofn.lpstrInitialDir);
|
---|
659 | if (ofn.lpstrTitle != NULL) FreeAsciiString((char*)ofn.lpstrTitle);
|
---|
660 | if (ofn.lpstrDefExt != NULL) FreeAsciiString((char*)ofn.lpstrDefExt);
|
---|
661 |
|
---|
662 | // transform back the result
|
---|
663 | AsciiToUnicode(ofn.lpstrFile,
|
---|
664 | lpofn->lpstrFile);
|
---|
665 | free(szFile);
|
---|
666 |
|
---|
667 | if (lpofn->lpstrFileTitle != NULL)
|
---|
668 | {
|
---|
669 | AsciiToUnicode(ofn.lpstrFileTitle,
|
---|
670 | lpofn->lpstrFileTitle);
|
---|
671 | free(szFileTitle);
|
---|
672 | }
|
---|
673 |
|
---|
674 | if (lpofn->lpstrCustomFilter != NULL)
|
---|
675 | {
|
---|
676 | AsciiToUnicode(ofn.lpstrCustomFilter,
|
---|
677 | lpofn->lpstrCustomFilter);
|
---|
678 | free(szCustFilter);
|
---|
679 | }
|
---|
680 |
|
---|
681 | // copy over some altered flags
|
---|
682 | lpofn->nFilterIndex = ofn.nFilterIndex;
|
---|
683 | lpofn->Flags = ofn.Flags;
|
---|
684 | lpofn->nFileOffset = ofn.nFileOffset;
|
---|
685 | lpofn->nFileExtension = ofn.nFileExtension;
|
---|
686 |
|
---|
687 | return bResult;
|
---|
688 | }
|
---|
689 |
|
---|
690 |
|
---|
691 | /*****************************************************************************
|
---|
692 | * Name :
|
---|
693 | * Purpose :
|
---|
694 | * Parameters:
|
---|
695 | * Variables :
|
---|
696 | * Result :
|
---|
697 | * Remark :
|
---|
698 | * Status :
|
---|
699 | *
|
---|
700 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
701 | *****************************************************************************/
|
---|
702 |
|
---|
703 | BOOL WIN32API PrintDlgA(LPPRINTDLGA lppd)
|
---|
704 | {
|
---|
705 | Win32WindowProc *wndproc;
|
---|
706 |
|
---|
707 | dprintf(("COMDLG32: PrintDlgA(%08xh)\n",
|
---|
708 | lppd));
|
---|
709 |
|
---|
710 | COMDLG32_CHECKHOOK2(lppd, PD_ENABLEPRINTHOOK, LPPRINTHOOKPROC,lpfnPrintHook)
|
---|
711 | COMDLG32_CHECKHOOK2(lppd, PD_ENABLESETUPHOOK, LPSETUPHOOKPROC,lpfnSetupHook)
|
---|
712 |
|
---|
713 | return O32_PrintDlg(lppd);
|
---|
714 | }
|
---|
715 |
|
---|
716 |
|
---|
717 | /*****************************************************************************
|
---|
718 | * Name :
|
---|
719 | * Purpose :
|
---|
720 | * Parameters:
|
---|
721 | * Variables :
|
---|
722 | * Result :
|
---|
723 | * Remark :
|
---|
724 | * Status :
|
---|
725 | *
|
---|
726 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
727 | *****************************************************************************/
|
---|
728 |
|
---|
729 | BOOL WIN32API PrintDlgW(LPPRINTDLGW lppd)
|
---|
730 | {
|
---|
731 | Win32WindowProc *wndproc;
|
---|
732 |
|
---|
733 | PRINTDLGA pd;
|
---|
734 | BOOL bResult;
|
---|
735 |
|
---|
736 | dprintf(("COMDLG32: PrintDlgW(%08xh)\n",
|
---|
737 | lppd));
|
---|
738 |
|
---|
739 | memcpy(&pd, // make binary copy first to save all the fields
|
---|
740 | lppd,
|
---|
741 | sizeof(pd));
|
---|
742 |
|
---|
743 | // convert to ASCII string
|
---|
744 | if ((lppd->Flags & PD_ENABLEPRINTTEMPLATE) &&
|
---|
745 | (lppd->lpPrintTemplateName != NULL))
|
---|
746 | pd.lpPrintTemplateName = UnicodeToAsciiString((WCHAR*)lppd->lpPrintTemplateName);
|
---|
747 | else
|
---|
748 | pd.lpPrintTemplateName = NULL;
|
---|
749 |
|
---|
750 | if ((lppd->Flags & PD_ENABLESETUPTEMPLATE) &&
|
---|
751 | (lppd->lpSetupTemplateName != NULL))
|
---|
752 | pd.lpSetupTemplateName = UnicodeToAsciiString((WCHAR*)lppd->lpSetupTemplateName);
|
---|
753 | else
|
---|
754 | pd.lpSetupTemplateName = NULL;
|
---|
755 |
|
---|
756 | COMDLG32_CHECKHOOK2(lppd, PD_ENABLEPRINTHOOK, LPPRINTHOOKPROC,lpfnPrintHook)
|
---|
757 | COMDLG32_CHECKHOOK2(lppd, PD_ENABLESETUPHOOK, LPSETUPHOOKPROC,lpfnSetupHook)
|
---|
758 |
|
---|
759 | bResult = O32_PrintDlg(&pd); // call ASCII API
|
---|
760 |
|
---|
761 | if (pd.lpPrintTemplateName != NULL) FreeAsciiString((char*)pd.lpPrintTemplateName);
|
---|
762 | if (pd.lpSetupTemplateName != NULL) FreeAsciiString((char*)pd.lpSetupTemplateName);
|
---|
763 |
|
---|
764 | // copy back result
|
---|
765 | lppd->Flags = pd.Flags;
|
---|
766 | lppd->nFromPage = pd.nFromPage;
|
---|
767 | lppd->nToPage = pd.nToPage;
|
---|
768 | lppd->nMinPage = pd.nMinPage;
|
---|
769 | lppd->nMaxPage = pd.nMaxPage;
|
---|
770 | lppd->nCopies = pd.nCopies;
|
---|
771 | //@@@PH: all pass-back fields ?
|
---|
772 |
|
---|
773 | return bResult;
|
---|
774 | }
|
---|
775 |
|
---|
776 |
|
---|
777 | /*****************************************************************************
|
---|
778 | * Name :
|
---|
779 | * Purpose :
|
---|
780 | * Parameters:
|
---|
781 | * Variables :
|
---|
782 | * Result :
|
---|
783 | * Remark :
|
---|
784 | * Status :
|
---|
785 | *
|
---|
786 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
787 | *****************************************************************************/
|
---|
788 |
|
---|
789 | HWND WIN32API ReplaceTextA(LPFINDREPLACEA lpfr)
|
---|
790 | {
|
---|
791 | Win32WindowProc *wndproc;
|
---|
792 |
|
---|
793 | dprintf(("COMDLG32: ReplaceTextA(%08xh).\n",
|
---|
794 | lpfr));
|
---|
795 |
|
---|
796 | COMDLG32_CHECKHOOK(lpfr, FR_ENABLEHOOK, WNDPROC)
|
---|
797 |
|
---|
798 | return O32_ReplaceText(lpfr);
|
---|
799 | }
|
---|
800 |
|
---|
801 |
|
---|
802 | /*****************************************************************************
|
---|
803 | * Name :
|
---|
804 | * Purpose :
|
---|
805 | * Parameters:
|
---|
806 | * Variables :
|
---|
807 | * Result :
|
---|
808 | * Remark :
|
---|
809 | * Status :
|
---|
810 | *
|
---|
811 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
812 | *****************************************************************************/
|
---|
813 |
|
---|
814 | HWND WIN32API ReplaceTextW(LPFINDREPLACEW lpfr)
|
---|
815 | {
|
---|
816 | Win32WindowProc *wndproc;
|
---|
817 | BOOL bResult;
|
---|
818 | FINDREPLACEA fr;
|
---|
819 |
|
---|
820 | dprintf(("COMDLG32: ReplaceTextW(%08xh)\n",
|
---|
821 | lpfr));
|
---|
822 |
|
---|
823 | memcpy(&fr, // make binary copy first to save all the fields
|
---|
824 | lpfr,
|
---|
825 | sizeof(fr));
|
---|
826 |
|
---|
827 | // convert to ASCII string
|
---|
828 | if ((lpfr->Flags & FR_ENABLETEMPLATE) &&
|
---|
829 | (lpfr->lpTemplateName != NULL))
|
---|
830 | fr.lpTemplateName = UnicodeToAsciiString((WCHAR*)lpfr->lpTemplateName);
|
---|
831 | else
|
---|
832 | fr.lpTemplateName = NULL;
|
---|
833 |
|
---|
834 | if (lpfr->lpstrFindWhat != NULL)
|
---|
835 | fr.lpstrFindWhat = UnicodeToAsciiString((WCHAR*)lpfr->lpstrFindWhat);
|
---|
836 |
|
---|
837 | if (lpfr->lpstrReplaceWith != NULL)
|
---|
838 | fr.lpstrReplaceWith = UnicodeToAsciiString((WCHAR*)lpfr->lpstrReplaceWith);
|
---|
839 |
|
---|
840 |
|
---|
841 | COMDLG32_CHECKHOOK(lpfr, FR_ENABLEHOOK, WNDPROC)
|
---|
842 |
|
---|
843 | bResult = O32_ReplaceText(&fr); // call ASCII version
|
---|
844 |
|
---|
845 | // @@@PH: Note -- we might have to transfer BACK resulting strings !!!
|
---|
846 | // free temporary ASCII string and restore UNICODE string
|
---|
847 | if (fr.lpTemplateName != NULL)
|
---|
848 | FreeAsciiString((char*)fr.lpTemplateName);
|
---|
849 |
|
---|
850 | // free temporary ASCII string and restore UNICODE string
|
---|
851 | if (fr.lpstrFindWhat != NULL)
|
---|
852 | {
|
---|
853 | AsciiToUnicode(fr.lpstrFindWhat,
|
---|
854 | lpfr->lpstrFindWhat);
|
---|
855 |
|
---|
856 | FreeAsciiString((char*)fr.lpstrFindWhat);
|
---|
857 | }
|
---|
858 |
|
---|
859 | if (fr.lpstrReplaceWith != NULL)
|
---|
860 | {
|
---|
861 | AsciiToUnicode(fr.lpstrReplaceWith,
|
---|
862 | lpfr->lpstrReplaceWith);
|
---|
863 |
|
---|
864 | FreeAsciiString((char*)fr.lpstrReplaceWith);
|
---|
865 | }
|
---|
866 |
|
---|
867 | // copy back fields
|
---|
868 | lpfr->Flags = fr.Flags;
|
---|
869 |
|
---|
870 | return bResult;
|
---|
871 | }
|
---|
872 |
|
---|
873 |
|
---|
874 | /*****************************************************************************
|
---|
875 | * Name :
|
---|
876 | * Purpose :
|
---|
877 | * Parameters:
|
---|
878 | * Variables :
|
---|
879 | * Result :
|
---|
880 | * Remark :
|
---|
881 | * Status :
|
---|
882 | *
|
---|
883 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
884 | *****************************************************************************/
|
---|
885 |
|
---|
886 | BOOL WIN32API PageSetupDlgA(LPPAGESETUPDLGA lppsd)
|
---|
887 | {
|
---|
888 | Win32WindowProc *wndproc;
|
---|
889 |
|
---|
890 | dprintf(("COMDLG32: PageSetupDlgA(%08xh) not implemented.\n",
|
---|
891 | lppsd));
|
---|
892 |
|
---|
893 | //COMDLG32_CHECKHOOK2(lppsd, PSD_ENABLESETUPHOOK, LPPAGESETUPHOOK, lpfnPageSetupHook)
|
---|
894 |
|
---|
895 | return(FALSE);
|
---|
896 | }
|
---|
897 |
|
---|
898 |
|
---|
899 | /*****************************************************************************
|
---|
900 | * Name :
|
---|
901 | * Purpose :
|
---|
902 | * Parameters:
|
---|
903 | * Variables :
|
---|
904 | * Result :
|
---|
905 | * Remark :
|
---|
906 | * Status :
|
---|
907 | *
|
---|
908 | * Author : Patrick Haller [Tue, 1998/02/10 01:55]
|
---|
909 | *****************************************************************************/
|
---|
910 |
|
---|
911 | BOOL WIN32API PageSetupDlgW(LPPAGESETUPDLGW lppsd)
|
---|
912 | {
|
---|
913 | Win32WindowProc *wndproc;
|
---|
914 |
|
---|
915 | dprintf(("COMDLG32: PageSetupDlgW(%08xh) not implemented.\n",
|
---|
916 | lppsd));
|
---|
917 |
|
---|
918 | //COMDLG32_CHECKHOOK2(lppsd, PSD_ENABLESETUPHOOK, LPPAGESETUPHOOK, lpfnPageSetupHook)
|
---|
919 |
|
---|
920 | return(FALSE);
|
---|
921 | }
|
---|