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

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

removed old includes

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