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

Last change on this file since 4858 was 4858, checked in by sandervl, 25 years ago

update

File size: 17.0 KB
Line 
1/* $Id: comdlg32.cpp,v 1.27 2000-12-30 13:43:57 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 <winuser32.h>
25
26ODINDEBUGCHANNEL(COMDLG32-COMDLG32)
27
28
29#define COMDLG32_CHECKHOOK(a,b,c) \
30 if(a->Flags & b) \
31 { \
32 a->lpfnHook = 0; \
33 } \
34 a->hwndOwner = Win32ToOS2Handle(a->hwndOwner);
35
36#define COMDLG32_CHECKHOOK2(a,b,c,d) \
37 if(a->Flags & b) \
38 { \
39 a->d = 0; \
40 } \
41 a->hwndOwner = Win32ToOS2Handle(a->hwndOwner);
42
43/*****************************************************************************
44 * Name :
45 * Purpose :
46 * Parameters:
47 * Variables :
48 * Result :
49 * Remark :
50 * Status :
51 *
52 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
53 *****************************************************************************/
54
55ODINFUNCTION1(BOOL, GetSaveFileNameA,
56 LPOPENFILENAMEA, lpofn)
57{
58 return GetFileDialog95A(lpofn, SAVE_DIALOG);
59}
60
61
62/*****************************************************************************
63 * Name :
64 * Purpose :
65 * Parameters:
66 * Variables :
67 * Result :
68 * Remark :
69 * Status :
70 *
71 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
72 *****************************************************************************/
73
74ODINFUNCTION1(BOOL, GetSaveFileNameW,
75 LPOPENFILENAMEW, lpofn)
76{
77 return GetFileDialog95W(lpofn, SAVE_DIALOG);
78}
79
80/*****************************************************************************
81 * Name :
82 * Purpose :
83 * Parameters:
84 * Variables :
85 * Result :
86 * Remark :
87 * Status :
88 *
89 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
90 *****************************************************************************/
91
92ODINFUNCTION1(BOOL, GetOpenFileNameA,
93 LPOPENFILENAMEA, lpofn)
94{
95 return GetFileDialog95A(lpofn, OPEN_DIALOG);
96}
97
98/*****************************************************************************
99 * Name :
100 * Purpose :
101 * Parameters:
102 * Variables :
103 * Result :
104 * Remark :
105 * Status :
106 *
107 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
108 *****************************************************************************/
109
110ODINFUNCTION1(BOOL, GetOpenFileNameW,
111 LPOPENFILENAMEW, lpofn)
112{
113 return GetFileDialog95W(lpofn, OPEN_DIALOG);
114}
115
116#if 0
117/*****************************************************************************
118 * Name :
119 * Purpose :
120 * Parameters:
121 * Variables :
122 * Result :
123 * Remark :
124 * Status :
125 *
126 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
127 *****************************************************************************/
128
129ODINFUNCTION3(INT16, GetFileTitleA32,
130 LPCSTR, lpFile,
131 LPSTR, lpTitle,
132 UINT, cbBuf)
133{
134 return O32_GetFileTitle(lpFile,
135 lpTitle,
136 cbBuf);
137}
138
139
140/*****************************************************************************
141 * Name :
142 * Purpose :
143 * Parameters:
144 * Variables :
145 * Result :
146 * Remark :
147 * Status :
148 *
149 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
150 *****************************************************************************/
151
152ODINFUNCTION1(BOOL, ChooseColorA,
153 LPCHOOSECOLORA, lpcc)
154{
155
156 COMDLG32_CHECKHOOK(lpcc, CC_ENABLEHOOK, LPCCHOOKPROC)
157
158 return O32_ChooseColor(lpcc);
159}
160
161
162/*****************************************************************************
163 * Name :
164 * Purpose :
165 * Parameters:
166 * Variables :
167 * Result :
168 * Remark : casting is a little hot, should work however
169 * assuming lpcc->lpTemplateName is READONLY pointer!
170 * Status :
171 *
172 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
173 *****************************************************************************/
174
175ODINFUNCTION1(BOOL, ChooseColorW,
176 LPCHOOSECOLORW, lpcc)
177{
178 BOOL bResult;
179 LPCWSTR lpTemplateNameBackup = lpcc->lpTemplateName;
180
181 // if no template is to convert, we can take this shortcut
182 if (!(lpcc->Flags & CC_ENABLETEMPLATE))
183 return O32_ChooseColor( (LPCHOOSECOLORA)lpcc );
184
185
186 // convert to ASCII string
187 if (lpcc->lpTemplateName != NULL)
188 lpcc->lpTemplateName = (LPCWSTR)UnicodeToAsciiString((WCHAR*)lpcc->lpTemplateName);
189
190 COMDLG32_CHECKHOOK(lpcc, CC_ENABLEHOOK, LPCCHOOKPROC)
191
192 bResult = O32_ChooseColor((LPCHOOSECOLORA)lpcc); // call ASCII version
193
194 // free temporary ASCII string and restore UNICODE string
195 if (lpcc->lpTemplateName != NULL)
196 {
197 FreeAsciiString((char*)lpcc->lpTemplateName);
198 lpcc->lpTemplateName = lpTemplateNameBackup;
199 }
200
201 return bResult;
202}
203
204
205/*****************************************************************************
206 * Name :
207 * Purpose :
208 * Parameters:
209 * Variables :
210 * Result :
211 * Remark :
212 * Status :
213 *
214 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
215 *****************************************************************************/
216
217ODINFUNCTION1(BOOL, ChooseFontA,
218 LPCHOOSEFONTA, lpcf)
219{
220
221 COMDLG32_CHECKHOOK(lpcf, CF_ENABLEHOOK, WNDPROC)
222
223 return O32_ChooseFont(lpcf);
224}
225
226
227/*****************************************************************************
228 * Name :
229 * Purpose :
230 * Parameters:
231 * Variables :
232 * Result :
233 * Remark : unknown yet, what is INPUT and what is OUTPUT string
234 * Status :
235 *
236 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
237 * Edgar Buerkle [Mon, 1999/06/28 19:35]
238 *****************************************************************************/
239
240ODINFUNCTION1(BOOL, ChooseFontW,
241 LPCHOOSEFONTW, lpcf)
242{
243 BOOL bResult;
244 CHOOSEFONTA asciicf;
245 LOGFONTA asciilf;
246 char szAsciiStyle[64];
247
248 // NOTE: LOGFONTW/A is NOT converted !
249 dprintf(("COMDLG32: ChooseFontW not correctly implemented.\n"));
250
251 if (!lpcf)
252 {
253 SetLastError(ERROR_INVALID_PARAMETER);
254
255 return FALSE;
256 }
257
258 // convert to ASCII string
259 memcpy(&asciicf, // make binary copy of CHOOSEFONTW
260 lpcf, // to save the flags
261 sizeof(asciicf));
262
263 memcpy (&asciilf,
264 lpcf->lpLogFont,
265 sizeof(LOGFONTA));
266
267 asciicf.lpLogFont = &asciilf; // update pointer
268
269 // lpTemplatenName bug in open32 ? This doesn't work.
270 // TODO: CF_ENABLETEMPLATEHANDLE
271 if (lpcf->Flags & CF_ENABLETEMPLATE)
272 if((int)asciicf.lpTemplateName >> 16 != 0)
273 asciicf.lpTemplateName = UnicodeToAsciiString((LPWSTR)lpcf->lpTemplateName);
274
275 //CB: NT's clock.exe traps here!
276 if (lpcf->lpszStyle)
277 {
278 UnicodeToAsciiN(lpcf->lpszStyle,
279 szAsciiStyle,
280 sizeof(szAsciiStyle));
281
282 asciicf.lpszStyle = szAsciiStyle;
283 }
284
285 UnicodeToAsciiN(lpcf->lpLogFont->lfFaceName,
286 asciilf.lfFaceName,
287 LF_FACESIZE-1);
288
289 // LPCFHOOKPROC != WNDPROC ?
290 COMDLG32_CHECKHOOK((&asciicf), CF_ENABLEHOOK, WNDPROC)
291
292 // switch strings
293 bResult = O32_ChooseFont((LPCHOOSEFONTA)&asciicf); // call ASCII version
294
295 if (bResult)
296 {
297 // transfer BACK resulting strings !!!
298 AsciiToUnicodeN(asciicf.lpLogFont->lfFaceName,
299 lpcf->lpLogFont->lfFaceName,
300 LF_FACESIZE-1);
301
302 if (lpcf->lpszStyle) AsciiToUnicode(asciicf.lpszStyle,lpcf->lpszStyle);
303 }
304
305 if (lpcf->Flags & CF_ENABLETEMPLATE)
306 if((int)asciicf.lpTemplateName >> 16 != 0)
307 FreeAsciiString((char*)asciicf.lpTemplateName);
308
309 // copy back fields
310 lpcf->Flags = asciicf.Flags;
311
312 return bResult;
313}
314
315
316/*****************************************************************************
317 * Name :
318 * Purpose :
319 * Parameters:
320 * Variables :
321 * Result :
322 * Remark :
323 * Status :
324 *
325 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
326 *****************************************************************************/
327
328ODINFUNCTION0(DWORD, CommDlgExtendedError32)
329{
330 return O32_CommDlgExtendedError();
331}
332
333/*****************************************************************************
334 * Name :
335 * Purpose :
336 * Parameters:
337 * Variables :
338 * Result :
339 * Remark :
340 * Status :
341 *
342 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
343 *****************************************************************************/
344
345ODINFUNCTION1(HWND, FindTextA32,
346 LPFINDREPLACEA, lpfr)
347{
348
349 COMDLG32_CHECKHOOK(lpfr, FR_ENABLEHOOK, WNDPROC)
350
351 return O32_FindText(lpfr);
352}
353
354
355/*****************************************************************************
356 * Name :
357 * Purpose :
358 * Parameters:
359 * Variables :
360 * Result :
361 * Remark :
362 * Status :
363 *
364 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
365 *****************************************************************************/
366
367ODINFUNCTION1(HWND, FindTextW32,
368 LPFINDREPLACEW, lpfr)
369{
370 BOOL bResult;
371 FINDREPLACEA fr;
372
373 memcpy(&fr, // make binary copy first to save all the fields
374 lpfr,
375 sizeof(fr));
376
377 // convert to ASCII string
378 if ((lpfr->Flags & FR_ENABLETEMPLATE) &&
379 (lpfr->lpTemplateName != NULL))
380 fr.lpTemplateName = UnicodeToAsciiString((WCHAR*)lpfr->lpTemplateName);
381 else
382 fr.lpTemplateName = NULL;
383
384 if (lpfr->lpstrFindWhat != NULL)
385 fr.lpstrFindWhat = UnicodeToAsciiString((WCHAR*)lpfr->lpstrFindWhat);
386
387 if (lpfr->lpstrReplaceWith != NULL)
388 fr.lpstrReplaceWith = UnicodeToAsciiString((WCHAR*)lpfr->lpstrReplaceWith);
389
390
391 COMDLG32_CHECKHOOK((&fr), FR_ENABLEHOOK, WNDPROC)
392
393 bResult = O32_FindText(&fr); // call ASCII version
394
395 // @@@PH: Note -- we might have to transfer BACK resulting strings !!!
396 // free temporary ASCII string and restore UNICODE string
397 if (fr.lpTemplateName != NULL)
398 FreeAsciiString((char*)fr.lpTemplateName);
399
400 // free temporary ASCII string and restore UNICODE string
401 if (fr.lpstrFindWhat != NULL)
402 {
403 AsciiToUnicode(fr.lpstrFindWhat,
404 lpfr->lpstrFindWhat);
405
406 FreeAsciiString((char*)fr.lpstrFindWhat);
407 }
408
409 if (fr.lpstrReplaceWith != NULL)
410 {
411 AsciiToUnicode(fr.lpstrReplaceWith,
412 lpfr->lpstrReplaceWith);
413
414 FreeAsciiString((char*)fr.lpstrReplaceWith);
415 }
416
417 // copy back fields
418 lpfr->Flags = fr.Flags;
419
420 return bResult;
421}
422
423
424/*****************************************************************************
425 * Name :
426 * Purpose :
427 * Parameters:
428 * Variables :
429 * Result :
430 * Remark :
431 * Status :
432 *
433 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
434 *****************************************************************************/
435
436ODINFUNCTION3(INT16, GetFileTitleW32,
437 LPCWSTR, lpFile,
438 LPWSTR, lpTitle,
439 UINT, cbBuf)
440{
441 LPSTR lpFileBackup;
442 char szTitle[256];
443 INT16 iResult;
444
445 lpFileBackup = UnicodeToAsciiString((LPWSTR)lpFile);
446 iResult = O32_GetFileTitle(lpFileBackup,
447 szTitle,
448 cbBuf);
449
450 FreeAsciiString(lpFileBackup);
451
452 // transform result into Unicode
453 AsciiToUnicode(szTitle,
454 lpTitle);
455
456 return iResult;
457}
458#endif
459
460/*****************************************************************************
461 * Name :
462 * Purpose :
463 * Parameters:
464 * Variables :
465 * Result :
466 * Remark :
467 * Status :
468 *
469 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
470 *****************************************************************************/
471
472ODINFUNCTION1(BOOL, PrintDlgA,
473 LPPRINTDLGA, lppd)
474{
475
476 COMDLG32_CHECKHOOK2(lppd, PD_ENABLEPRINTHOOK, LPPRINTHOOKPROC,lpfnPrintHook)
477 COMDLG32_CHECKHOOK2(lppd, PD_ENABLESETUPHOOK, LPSETUPHOOKPROC,lpfnSetupHook)
478
479 return O32_PrintDlg(lppd);
480}
481
482
483/*****************************************************************************
484 * Name :
485 * Purpose :
486 * Parameters:
487 * Variables :
488 * Result :
489 * Remark :
490 * Status :
491 *
492 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
493 *****************************************************************************/
494
495ODINFUNCTION1(BOOL, PrintDlgW,
496 LPPRINTDLGW, lppd)
497{
498
499 PRINTDLGA pd;
500 BOOL bResult;
501
502 memcpy(&pd, // make binary copy first to save all the fields
503 lppd,
504 sizeof(pd));
505
506 // convert to ASCII string
507 if ((lppd->Flags & PD_ENABLEPRINTTEMPLATE) &&
508 (lppd->lpPrintTemplateName != NULL))
509 pd.lpPrintTemplateName = UnicodeToAsciiString((WCHAR*)lppd->lpPrintTemplateName);
510 else
511 pd.lpPrintTemplateName = NULL;
512
513 if ((lppd->Flags & PD_ENABLESETUPTEMPLATE) &&
514 (lppd->lpSetupTemplateName != NULL))
515 pd.lpSetupTemplateName = UnicodeToAsciiString((WCHAR*)lppd->lpSetupTemplateName);
516 else
517 pd.lpSetupTemplateName = NULL;
518
519 COMDLG32_CHECKHOOK2((&pd), PD_ENABLEPRINTHOOK, LPPRINTHOOKPROC,lpfnPrintHook)
520 COMDLG32_CHECKHOOK2((&pd), PD_ENABLESETUPHOOK, LPSETUPHOOKPROC,lpfnSetupHook)
521
522 bResult = O32_PrintDlg(&pd); // call ASCII API
523
524 if (pd.lpPrintTemplateName != NULL) FreeAsciiString((char*)pd.lpPrintTemplateName);
525 if (pd.lpSetupTemplateName != NULL) FreeAsciiString((char*)pd.lpSetupTemplateName);
526
527 // copy back result
528 lppd->Flags = pd.Flags;
529 lppd->nFromPage = pd.nFromPage;
530 lppd->nToPage = pd.nToPage;
531 lppd->nMinPage = pd.nMinPage;
532 lppd->nMaxPage = pd.nMaxPage;
533 lppd->nCopies = pd.nCopies;
534 //@@@PH: all pass-back fields ?
535
536 return bResult;
537}
538
539
540#if 0
541/*****************************************************************************
542 * Name :
543 * Purpose :
544 * Parameters:
545 * Variables :
546 * Result :
547 * Remark :
548 * Status :
549 *
550 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
551 *****************************************************************************/
552
553ODINFUNCTION1(HWND, ReplaceTextA32,
554 LPFINDREPLACEA, lpfr)
555{
556
557 COMDLG32_CHECKHOOK(lpfr, FR_ENABLEHOOK, WNDPROC)
558
559 return O32_ReplaceText(lpfr);
560}
561
562
563/*****************************************************************************
564 * Name :
565 * Purpose :
566 * Parameters:
567 * Variables :
568 * Result :
569 * Remark :
570 * Status :
571 *
572 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
573 *****************************************************************************/
574
575ODINFUNCTION1(HWND, ReplaceTextW32,
576 LPFINDREPLACEW, lpfr)
577{
578 BOOL bResult;
579 FINDREPLACEA fr;
580
581 dprintf(("COMDLG32: ReplaceTextW(%08xh)\n",
582 lpfr));
583
584 memcpy(&fr, // make binary copy first to save all the fields
585 lpfr,
586 sizeof(fr));
587
588 // convert to ASCII string
589 if ((lpfr->Flags & FR_ENABLETEMPLATE) &&
590 (lpfr->lpTemplateName != NULL))
591 fr.lpTemplateName = UnicodeToAsciiString((WCHAR*)lpfr->lpTemplateName);
592 else
593 fr.lpTemplateName = NULL;
594
595 if (lpfr->lpstrFindWhat != NULL)
596 fr.lpstrFindWhat = UnicodeToAsciiString((WCHAR*)lpfr->lpstrFindWhat);
597
598 if (lpfr->lpstrReplaceWith != NULL)
599 fr.lpstrReplaceWith = UnicodeToAsciiString((WCHAR*)lpfr->lpstrReplaceWith);
600
601
602 COMDLG32_CHECKHOOK((&fr), FR_ENABLEHOOK, WNDPROC)
603
604 bResult = O32_ReplaceText(&fr); // call ASCII version
605
606 // @@@PH: Note -- we might have to transfer BACK resulting strings !!!
607 // free temporary ASCII string and restore UNICODE string
608 if (fr.lpTemplateName != NULL)
609 FreeAsciiString((char*)fr.lpTemplateName);
610
611 // free temporary ASCII string and restore UNICODE string
612 if (fr.lpstrFindWhat != NULL)
613 {
614 AsciiToUnicode(fr.lpstrFindWhat,
615 lpfr->lpstrFindWhat);
616
617 FreeAsciiString((char*)fr.lpstrFindWhat);
618 }
619
620 if (fr.lpstrReplaceWith != NULL)
621 {
622 AsciiToUnicode(fr.lpstrReplaceWith,
623 lpfr->lpstrReplaceWith);
624
625 FreeAsciiString((char*)fr.lpstrReplaceWith);
626 }
627
628 // copy back fields
629 lpfr->Flags = fr.Flags;
630
631 return bResult;
632}
633#endif
634
635/*****************************************************************************
636 * Name :
637 * Purpose :
638 * Parameters:
639 * Variables :
640 * Result :
641 * Remark :
642 * Status :
643 *
644 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
645 *****************************************************************************/
646
647ODINFUNCTION1(BOOL, PageSetupDlgA,
648 LPPAGESETUPDLGA, lppsd)
649{
650
651 dprintf(("COMDLG32: PageSetupDlgA not implemented.\n"));
652
653 //COMDLG32_CHECKHOOK2(lppsd, PSD_ENABLESETUPHOOK, LPPAGESETUPHOOK, lpfnPageSetupHook)
654
655 return(FALSE);
656}
657
658
659/*****************************************************************************
660 * Name :
661 * Purpose :
662 * Parameters:
663 * Variables :
664 * Result :
665 * Remark :
666 * Status :
667 *
668 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
669 *****************************************************************************/
670
671ODINFUNCTION1(BOOL, PageSetupDlgW,
672 LPPAGESETUPDLGW, lppsd)
673{
674
675 dprintf(("COMDLG32: PageSetupDlgW(%08xh) not implemented.\n"));
676
677 //COMDLG32_CHECKHOOK2(lppsd, PSD_ENABLESETUPHOOK, LPPAGESETUPHOOK, lpfnPageSetupHook)
678
679 return(FALSE);
680}
681
Note: See TracBrowser for help on using the repository browser.