source: trunk/src/comdlg32/comdlg32.cpp@ 1677

Last change on this file since 1677 was 1677, checked in by phaller, 26 years ago

Fix: fixes in file open dialogs

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