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

Last change on this file since 3223 was 3223, checked in by achimha, 25 years ago

fixed dialog invocation

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