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

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

merged with latest wine code

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