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

Last change on this file since 1036 was 1026, checked in by sandervl, 26 years ago

Bugfix for all common dialogs

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