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

Last change on this file since 1417 was 1417, checked in by cbratschi, 26 years ago

partial fix for NT's clock.exe: ChooseFont

File size: 24.2 KB
Line 
1/* $Id: comdlg32.cpp,v 1.14 1999-10-23 16:43:50 cbratschi 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#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 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
101ODINFUNCTION1(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
124ODINFUNCTION3(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
147ODINFUNCTION1(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
171ODINFUNCTION1(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
214ODINFUNCTION1(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
238ODINFUNCTION1(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 if (!lpcf)
251 {
252 SetLastError(ERROR_INVALID_PARAMETER);
253
254 return FALSE;
255 }
256
257 // convert to ASCII string
258 memcpy(&asciicf, // make binary copy of CHOOSEFONTW
259 lpcf, // to save the flags
260 sizeof(asciicf));
261
262 memcpy (&asciilf,
263 lpcf->lpLogFont,
264 sizeof(LOGFONTA));
265
266 asciicf.lpLogFont = &asciilf; // update pointer
267
268 // lpTemplatenName bug in open32 ? This doesn't work.
269 // TODO: CF_ENABLETEMPLATEHANDLE
270 if (lpcf->Flags & CF_ENABLETEMPLATE)
271 if((int)asciicf.lpTemplateName >> 16 != 0)
272 asciicf.lpTemplateName = UnicodeToAsciiString((LPWSTR)lpcf->lpTemplateName);
273
274 if (lpcf->lpszStyle)
275 {
276 //CB: NT's clock.exe sets this pointer, don't know why
277 // it's not a pointer to a string!
278 if ((UINT)lpcf->lpszStyle == 0xAAAAAAAA)
279 asciicf.lpszStyle = NULL;
280 else
281 {
282 UnicodeToAsciiN(lpcf->lpszStyle,
283 szAsciiStyle,
284 sizeof(szAsciiStyle));
285
286 asciicf.lpszStyle = szAsciiStyle;
287 }
288 };
289
290 UnicodeToAsciiN(lpcf->lpLogFont->lfFaceName,
291 asciilf.lfFaceName,
292 LF_FACESIZE-1);
293
294 // LPCFHOOKPROC != WNDPROC ?
295 COMDLG32_CHECKHOOK((&asciicf), CF_ENABLEHOOK, WNDPROC)
296
297 // switch strings
298 bResult = O32_ChooseFont((LPCHOOSEFONTA)&asciicf); // call ASCII version
299
300 if (bResult)
301 {
302 // transfer BACK resulting strings !!!
303 AsciiToUnicodeN(asciicf.lpLogFont->lfFaceName,
304 lpcf->lpLogFont->lfFaceName,
305 LF_FACESIZE-1);
306
307 if (lpcf->lpszStyle) AsciiToUnicode(asciicf.lpszStyle,lpcf->lpszStyle);
308 }
309
310 if (lpcf->Flags & CF_ENABLETEMPLATE)
311 if((int)asciicf.lpTemplateName >> 16 != 0)
312 FreeAsciiString((char*)asciicf.lpTemplateName);
313
314 // copy back fields
315 lpcf->Flags = asciicf.Flags;
316
317 return bResult;
318}
319
320
321/*****************************************************************************
322 * Name :
323 * Purpose :
324 * Parameters:
325 * Variables :
326 * Result :
327 * Remark :
328 * Status :
329 *
330 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
331 *****************************************************************************/
332
333ODINFUNCTION0(DWORD, CommDlgExtendedError)
334{
335 return O32_CommDlgExtendedError();
336}
337
338
339/*****************************************************************************
340 * Name :
341 * Purpose :
342 * Parameters:
343 * Variables :
344 * Result :
345 * Remark :
346 * Status :
347 *
348 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
349 *****************************************************************************/
350
351ODINFUNCTION1(HWND, FindTextA,
352 LPFINDREPLACEA, lpfr)
353{
354 Win32WindowProc *wndproc;
355
356 COMDLG32_CHECKHOOK(lpfr, FR_ENABLEHOOK, WNDPROC)
357
358 return O32_FindText(lpfr);
359}
360
361
362/*****************************************************************************
363 * Name :
364 * Purpose :
365 * Parameters:
366 * Variables :
367 * Result :
368 * Remark :
369 * Status :
370 *
371 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
372 *****************************************************************************/
373
374ODINFUNCTION1(HWND, FindTextW,
375 LPFINDREPLACEW, lpfr)
376{
377 Win32WindowProc *wndproc;
378 BOOL bResult;
379 FINDREPLACEA fr;
380
381 memcpy(&fr, // make binary copy first to save all the fields
382 lpfr,
383 sizeof(fr));
384
385 // convert to ASCII string
386 if ((lpfr->Flags & FR_ENABLETEMPLATE) &&
387 (lpfr->lpTemplateName != NULL))
388 fr.lpTemplateName = UnicodeToAsciiString((WCHAR*)lpfr->lpTemplateName);
389 else
390 fr.lpTemplateName = NULL;
391
392 if (lpfr->lpstrFindWhat != NULL)
393 fr.lpstrFindWhat = UnicodeToAsciiString((WCHAR*)lpfr->lpstrFindWhat);
394
395 if (lpfr->lpstrReplaceWith != NULL)
396 fr.lpstrReplaceWith = UnicodeToAsciiString((WCHAR*)lpfr->lpstrReplaceWith);
397
398
399 COMDLG32_CHECKHOOK((&fr), FR_ENABLEHOOK, WNDPROC)
400
401 bResult = O32_FindText(&fr); // call ASCII version
402
403 // @@@PH: Note -- we might have to transfer BACK resulting strings !!!
404 // free temporary ASCII string and restore UNICODE string
405 if (fr.lpTemplateName != NULL)
406 FreeAsciiString((char*)fr.lpTemplateName);
407
408 // free temporary ASCII string and restore UNICODE string
409 if (fr.lpstrFindWhat != NULL)
410 {
411 AsciiToUnicode(fr.lpstrFindWhat,
412 lpfr->lpstrFindWhat);
413
414 FreeAsciiString((char*)fr.lpstrFindWhat);
415 }
416
417 if (fr.lpstrReplaceWith != NULL)
418 {
419 AsciiToUnicode(fr.lpstrReplaceWith,
420 lpfr->lpstrReplaceWith);
421
422 FreeAsciiString((char*)fr.lpstrReplaceWith);
423 }
424
425 // copy back fields
426 lpfr->Flags = fr.Flags;
427
428 return bResult;
429}
430
431
432/*****************************************************************************
433 * Name :
434 * Purpose :
435 * Parameters:
436 * Variables :
437 * Result :
438 * Remark :
439 * Status :
440 *
441 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
442 *****************************************************************************/
443
444ODINFUNCTION3(INT16, GetFileTitleW,
445 LPCWSTR, lpFile,
446 LPWSTR, lpTitle,
447 UINT, cbBuf)
448{
449 LPSTR lpFileBackup;
450 char szTitle[256];
451 INT16 iResult;
452
453 lpFileBackup = UnicodeToAsciiString((LPWSTR)lpFile);
454 iResult = O32_GetFileTitle(lpFileBackup,
455 szTitle,
456 cbBuf);
457
458 FreeAsciiString(lpFileBackup);
459
460 // transform result into Unicode
461 AsciiToUnicode(szTitle,
462 lpTitle);
463
464 return iResult;
465}
466
467
468/*****************************************************************************
469 * Name :
470 * Purpose :
471 * Parameters:
472 * Variables :
473 * Result :
474 * Remark :
475 * Status :
476 *
477 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
478 *****************************************************************************/
479
480ODINFUNCTION1(BOOL, GetOpenFileNameW,
481 LPOPENFILENAMEW, lpofn)
482{
483 Win32WindowProc *wndproc;
484 OPENFILENAMEA ofn;
485 char* szFile;
486 char* szFileTitle;
487 char* szCustFilter;
488 BOOL bResult;
489
490 memcpy(&ofn, // make binary copy first to save all the fields
491 lpofn,
492 sizeof(ofn));
493
494 // convert to ASCII string
495 if ((lpofn->Flags && OFN_ENABLETEMPLATE) &&
496 (lpofn->lpTemplateName != NULL))
497 ofn.lpTemplateName = UnicodeToAsciiString((WCHAR*)lpofn->lpTemplateName);
498 else
499 ofn.lpTemplateName = NULL;
500
501 if (lpofn->lpstrFilter != NULL)
502 ofn.lpstrFilter = UnicodeToAsciiString((WCHAR*)lpofn->lpstrFilter);
503
504 if (lpofn->lpstrInitialDir != NULL)
505 ofn.lpstrInitialDir = UnicodeToAsciiString((WCHAR*)lpofn->lpstrInitialDir);
506
507 if (lpofn->lpstrTitle != NULL)
508 ofn.lpstrTitle = UnicodeToAsciiString((WCHAR*)lpofn->lpstrTitle);
509
510 if (lpofn->lpstrDefExt != NULL)
511 ofn.lpstrDefExt = UnicodeToAsciiString((WCHAR*)lpofn->lpstrDefExt);
512
513 szFile = (char*)malloc(lpofn->nMaxFile);
514 szFile[0] = 0;
515
516 if (*lpofn->lpstrFile != 0)
517 UnicodeToAscii(lpofn->lpstrFile,
518 szFile);
519
520 if (lpofn->lpstrFileTitle != NULL)
521 {
522 szFileTitle = (char*)malloc(lpofn->nMaxFileTitle);
523 szFileTitle[0] = 0;
524
525 if (*lpofn->lpstrFileTitle != 0)
526 UnicodeToAscii(lpofn->lpstrFileTitle,
527 szFileTitle);
528 }
529 else
530 szFileTitle = NULL;
531
532 if (lpofn->lpstrCustomFilter != NULL)
533 {
534 szCustFilter = (char*)malloc(lpofn->nMaxCustFilter);
535 szCustFilter[0] = 0;
536
537
538 if (*lpofn->lpstrCustomFilter != 0)
539 UnicodeToAscii(lpofn->lpstrCustomFilter,
540 szCustFilter);
541 }
542 else
543 szCustFilter = NULL;
544
545 ofn.lpstrFile = szFile;
546 ofn.lpstrFileTitle = szFileTitle;
547 ofn.lpstrCustomFilter = szCustFilter;
548
549 COMDLG32_CHECKHOOK((&ofn), OFN_ENABLEHOOK, WNDPROC)
550
551 bResult = O32_GetOpenFileName(&ofn);
552
553 if (ofn.lpTemplateName != NULL) FreeAsciiString((char*)ofn.lpTemplateName);
554 if (ofn.lpstrFilter != NULL) FreeAsciiString((char*)ofn.lpstrFilter);
555 if (ofn.lpstrInitialDir != NULL) FreeAsciiString((char*)ofn.lpstrInitialDir);
556 if (ofn.lpstrTitle != NULL) FreeAsciiString((char*)ofn.lpstrTitle);
557 if (ofn.lpstrDefExt != NULL) FreeAsciiString((char*)ofn.lpstrDefExt);
558
559 // transform back the result
560 AsciiToUnicode(ofn.lpstrFile,
561 lpofn->lpstrFile);
562 free(szFile);
563
564 if (lpofn->lpstrFileTitle != NULL)
565 {
566 AsciiToUnicode(ofn.lpstrFileTitle,
567 lpofn->lpstrFileTitle);
568 free(szFileTitle);
569 }
570
571 if (lpofn->lpstrCustomFilter != NULL)
572 {
573 AsciiToUnicode(ofn.lpstrCustomFilter,
574 lpofn->lpstrCustomFilter);
575 free(szCustFilter);
576 }
577
578 // copy over some altered flags
579 lpofn->nFilterIndex = ofn.nFilterIndex;
580 lpofn->Flags = ofn.Flags;
581 lpofn->nFileOffset = ofn.nFileOffset;
582 lpofn->nFileExtension = ofn.nFileExtension;
583
584 return bResult;
585}
586
587
588/*****************************************************************************
589 * Name :
590 * Purpose :
591 * Parameters:
592 * Variables :
593 * Result :
594 * Remark :
595 * Status :
596 *
597 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
598 *****************************************************************************/
599
600ODINFUNCTION1(BOOL, GetSaveFileNameW,
601 LPOPENFILENAMEW, lpofn)
602{
603 Win32WindowProc *wndproc;
604 OPENFILENAMEA ofn;
605 char* szFile;
606 char* szFileTitle;
607 char* szCustFilter;
608 BOOL bResult;
609
610 memcpy(&ofn, // make binary copy first to save all the fields
611 lpofn,
612 sizeof(ofn));
613
614 // convert to ASCII string
615 if ((lpofn->Flags && OFN_ENABLETEMPLATE) &&
616 (lpofn->lpTemplateName != NULL))
617 ofn.lpTemplateName = UnicodeToAsciiString((WCHAR*)lpofn->lpTemplateName);
618 else
619 ofn.lpTemplateName = NULL;
620
621 if (lpofn->lpstrFilter != NULL)
622 ofn.lpstrFilter = UnicodeToAsciiString((WCHAR*)lpofn->lpstrFilter);
623
624 if (lpofn->lpstrInitialDir != NULL)
625 ofn.lpstrInitialDir = UnicodeToAsciiString((WCHAR*)lpofn->lpstrInitialDir);
626
627 if (lpofn->lpstrTitle != NULL)
628 ofn.lpstrTitle = UnicodeToAsciiString((WCHAR*)lpofn->lpstrTitle);
629
630 if (lpofn->lpstrDefExt != NULL)
631 ofn.lpstrDefExt = UnicodeToAsciiString((WCHAR*)lpofn->lpstrDefExt);
632
633 szFile = (char*)malloc(lpofn->nMaxFile);
634 szFile[0] = 0;
635
636 if (*lpofn->lpstrFile != 0)
637 UnicodeToAscii(lpofn->lpstrFile,
638 szFile);
639
640 if (lpofn->lpstrFileTitle != NULL)
641 {
642 szFileTitle = (char*)malloc(lpofn->nMaxFileTitle);
643 szFileTitle[0] = 0;
644
645 if (*lpofn->lpstrFileTitle != 0)
646 UnicodeToAscii(lpofn->lpstrFileTitle,
647 szFileTitle);
648 }
649 else
650 szFileTitle = NULL;
651
652 if (lpofn->lpstrCustomFilter != NULL)
653 {
654 szCustFilter = (char*)malloc(lpofn->nMaxCustFilter);
655 szCustFilter[0] = 0;
656
657
658 if (*lpofn->lpstrCustomFilter != 0)
659 UnicodeToAscii(lpofn->lpstrCustomFilter,
660 szCustFilter);
661 }
662 else
663 szCustFilter = NULL;
664
665 ofn.lpstrFile = szFile;
666 ofn.lpstrFileTitle = szFileTitle;
667 ofn.lpstrCustomFilter = szCustFilter;
668
669 COMDLG32_CHECKHOOK((&ofn), OFN_ENABLEHOOK, WNDPROC)
670
671 bResult = O32_GetSaveFileName(&ofn);
672
673 if (ofn.lpTemplateName != NULL) FreeAsciiString((char*)ofn.lpTemplateName);
674 if (ofn.lpstrFilter != NULL) FreeAsciiString((char*)ofn.lpstrFilter);
675 if (ofn.lpstrInitialDir != NULL) FreeAsciiString((char*)ofn.lpstrInitialDir);
676 if (ofn.lpstrTitle != NULL) FreeAsciiString((char*)ofn.lpstrTitle);
677 if (ofn.lpstrDefExt != NULL) FreeAsciiString((char*)ofn.lpstrDefExt);
678
679 // transform back the result
680 AsciiToUnicode(ofn.lpstrFile,
681 lpofn->lpstrFile);
682 free(szFile);
683
684 if (lpofn->lpstrFileTitle != NULL)
685 {
686 AsciiToUnicode(ofn.lpstrFileTitle,
687 lpofn->lpstrFileTitle);
688 free(szFileTitle);
689 }
690
691 if (lpofn->lpstrCustomFilter != NULL)
692 {
693 AsciiToUnicode(ofn.lpstrCustomFilter,
694 lpofn->lpstrCustomFilter);
695 free(szCustFilter);
696 }
697
698 // copy over some altered flags
699 lpofn->nFilterIndex = ofn.nFilterIndex;
700 lpofn->Flags = ofn.Flags;
701 lpofn->nFileOffset = ofn.nFileOffset;
702 lpofn->nFileExtension = ofn.nFileExtension;
703
704 return bResult;
705}
706
707
708/*****************************************************************************
709 * Name :
710 * Purpose :
711 * Parameters:
712 * Variables :
713 * Result :
714 * Remark :
715 * Status :
716 *
717 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
718 *****************************************************************************/
719
720ODINFUNCTION1(BOOL, PrintDlgA,
721 LPPRINTDLGA, lppd)
722{
723 Win32WindowProc *wndproc;
724
725 COMDLG32_CHECKHOOK2(lppd, PD_ENABLEPRINTHOOK, LPPRINTHOOKPROC,lpfnPrintHook)
726 COMDLG32_CHECKHOOK2(lppd, PD_ENABLESETUPHOOK, LPSETUPHOOKPROC,lpfnSetupHook)
727
728 return O32_PrintDlg(lppd);
729}
730
731
732/*****************************************************************************
733 * Name :
734 * Purpose :
735 * Parameters:
736 * Variables :
737 * Result :
738 * Remark :
739 * Status :
740 *
741 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
742 *****************************************************************************/
743
744ODINFUNCTION1(BOOL, PrintDlgW,
745 LPPRINTDLGW, lppd)
746{
747 Win32WindowProc *wndproc;
748
749 PRINTDLGA pd;
750 BOOL bResult;
751
752 memcpy(&pd, // make binary copy first to save all the fields
753 lppd,
754 sizeof(pd));
755
756 // convert to ASCII string
757 if ((lppd->Flags & PD_ENABLEPRINTTEMPLATE) &&
758 (lppd->lpPrintTemplateName != NULL))
759 pd.lpPrintTemplateName = UnicodeToAsciiString((WCHAR*)lppd->lpPrintTemplateName);
760 else
761 pd.lpPrintTemplateName = NULL;
762
763 if ((lppd->Flags & PD_ENABLESETUPTEMPLATE) &&
764 (lppd->lpSetupTemplateName != NULL))
765 pd.lpSetupTemplateName = UnicodeToAsciiString((WCHAR*)lppd->lpSetupTemplateName);
766 else
767 pd.lpSetupTemplateName = NULL;
768
769 COMDLG32_CHECKHOOK2((&pd), PD_ENABLEPRINTHOOK, LPPRINTHOOKPROC,lpfnPrintHook)
770 COMDLG32_CHECKHOOK2((&pd), PD_ENABLESETUPHOOK, LPSETUPHOOKPROC,lpfnSetupHook)
771
772 bResult = O32_PrintDlg(&pd); // call ASCII API
773
774 if (pd.lpPrintTemplateName != NULL) FreeAsciiString((char*)pd.lpPrintTemplateName);
775 if (pd.lpSetupTemplateName != NULL) FreeAsciiString((char*)pd.lpSetupTemplateName);
776
777 // copy back result
778 lppd->Flags = pd.Flags;
779 lppd->nFromPage = pd.nFromPage;
780 lppd->nToPage = pd.nToPage;
781 lppd->nMinPage = pd.nMinPage;
782 lppd->nMaxPage = pd.nMaxPage;
783 lppd->nCopies = pd.nCopies;
784 //@@@PH: all pass-back fields ?
785
786 return bResult;
787}
788
789
790/*****************************************************************************
791 * Name :
792 * Purpose :
793 * Parameters:
794 * Variables :
795 * Result :
796 * Remark :
797 * Status :
798 *
799 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
800 *****************************************************************************/
801
802ODINFUNCTION1(HWND, ReplaceTextA,
803 LPFINDREPLACEA, lpfr)
804{
805 Win32WindowProc *wndproc;
806
807 COMDLG32_CHECKHOOK(lpfr, FR_ENABLEHOOK, WNDPROC)
808
809 return O32_ReplaceText(lpfr);
810}
811
812
813/*****************************************************************************
814 * Name :
815 * Purpose :
816 * Parameters:
817 * Variables :
818 * Result :
819 * Remark :
820 * Status :
821 *
822 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
823 *****************************************************************************/
824
825ODINFUNCTION1(HWND, ReplaceTextW,
826 LPFINDREPLACEW, lpfr)
827{
828 Win32WindowProc *wndproc;
829 BOOL bResult;
830 FINDREPLACEA fr;
831
832 dprintf(("COMDLG32: ReplaceTextW(%08xh)\n",
833 lpfr));
834
835 memcpy(&fr, // make binary copy first to save all the fields
836 lpfr,
837 sizeof(fr));
838
839 // convert to ASCII string
840 if ((lpfr->Flags & FR_ENABLETEMPLATE) &&
841 (lpfr->lpTemplateName != NULL))
842 fr.lpTemplateName = UnicodeToAsciiString((WCHAR*)lpfr->lpTemplateName);
843 else
844 fr.lpTemplateName = NULL;
845
846 if (lpfr->lpstrFindWhat != NULL)
847 fr.lpstrFindWhat = UnicodeToAsciiString((WCHAR*)lpfr->lpstrFindWhat);
848
849 if (lpfr->lpstrReplaceWith != NULL)
850 fr.lpstrReplaceWith = UnicodeToAsciiString((WCHAR*)lpfr->lpstrReplaceWith);
851
852
853 COMDLG32_CHECKHOOK((&fr), FR_ENABLEHOOK, WNDPROC)
854
855 bResult = O32_ReplaceText(&fr); // call ASCII version
856
857 // @@@PH: Note -- we might have to transfer BACK resulting strings !!!
858 // free temporary ASCII string and restore UNICODE string
859 if (fr.lpTemplateName != NULL)
860 FreeAsciiString((char*)fr.lpTemplateName);
861
862 // free temporary ASCII string and restore UNICODE string
863 if (fr.lpstrFindWhat != NULL)
864 {
865 AsciiToUnicode(fr.lpstrFindWhat,
866 lpfr->lpstrFindWhat);
867
868 FreeAsciiString((char*)fr.lpstrFindWhat);
869 }
870
871 if (fr.lpstrReplaceWith != NULL)
872 {
873 AsciiToUnicode(fr.lpstrReplaceWith,
874 lpfr->lpstrReplaceWith);
875
876 FreeAsciiString((char*)fr.lpstrReplaceWith);
877 }
878
879 // copy back fields
880 lpfr->Flags = fr.Flags;
881
882 return bResult;
883}
884
885
886/*****************************************************************************
887 * Name :
888 * Purpose :
889 * Parameters:
890 * Variables :
891 * Result :
892 * Remark :
893 * Status :
894 *
895 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
896 *****************************************************************************/
897
898ODINFUNCTION1(BOOL, PageSetupDlgA,
899 LPPAGESETUPDLGA, lppsd)
900{
901 Win32WindowProc *wndproc;
902
903 dprintf(("COMDLG32: PageSetupDlgA not implemented.\n"));
904
905 //COMDLG32_CHECKHOOK2(lppsd, PSD_ENABLESETUPHOOK, LPPAGESETUPHOOK, lpfnPageSetupHook)
906
907 return(FALSE);
908}
909
910
911/*****************************************************************************
912 * Name :
913 * Purpose :
914 * Parameters:
915 * Variables :
916 * Result :
917 * Remark :
918 * Status :
919 *
920 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
921 *****************************************************************************/
922
923ODINFUNCTION1(BOOL, PageSetupDlgW,
924 LPPAGESETUPDLGW, lppsd)
925{
926 Win32WindowProc *wndproc;
927
928 dprintf(("COMDLG32: PageSetupDlgW(%08xh) not implemented.\n"));
929
930 //COMDLG32_CHECKHOOK2(lppsd, PSD_ENABLESETUPHOOK, LPPAGESETUPHOOK, lpfnPageSetupHook)
931
932 return(FALSE);
933}
934
Note: See TracBrowser for help on using the repository browser.