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

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

* empty log message *

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