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