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

Last change on this file since 3192 was 3192, checked in by cbratschi, 25 years ago

switch for PM <-> WINE file dialogs

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