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

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

compile fix

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