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

Last change on this file since 6208 was 6208, checked in by sandervl, 24 years ago

PrintDlg: open32 <-> kernel32 global memory handle conversion added

File size: 6.8 KB
Line 
1/* $Id: comdlg32.cpp,v 1.30 2001-07-07 19:08: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 <winuser32.h>
25#include <unicode.h>
26
27ODINDEBUGCHANNEL(COMDLG32-COMDLG32)
28
29
30#define COMDLG32_CHECKHOOK(a,b,c) \
31 if(a->Flags & b) \
32 { \
33 a->lpfnHook = 0; \
34 } \
35 a->hwndOwner = Win32ToOS2Handle(a->hwndOwner);
36
37#define COMDLG32_CHECKHOOK2(a,b,c,d) \
38 if(a->Flags & b) \
39 { \
40 a->d = 0; \
41 } \
42 a->hwndOwner = Win32ToOS2Handle(a->hwndOwner);
43
44#ifdef USING_OPEN32
45
46#define FLAG_TO_OPEN32 0
47#define FLAG_FROM_OPEN32 1
48
49//******************************************************************************
50//******************************************************************************
51HGLOBAL GlobalCopy(HGLOBAL hDest, HGLOBAL hSource, BOOL fToOpen32)
52{
53 LPVOID src;
54 LPVOID dest;
55 ULONG size;
56
57 if(fToOpen32 == FLAG_TO_OPEN32) {
58 src = GlobalLock(hSource);
59 if(src) {
60 size = GlobalSize(hSource);
61 if(hDest == NULL) {
62 hDest = O32_GlobalAlloc(GHND, size);
63 }
64 dest = O32_GlobalLock(hDest);
65 memcpy(dest, src, size);
66 O32_GlobalUnlock(hDest);
67 }
68 GlobalUnlock(hSource);
69 }
70 else {
71 src = O32_GlobalLock(hSource);
72 if(src) {
73 size = O32_GlobalSize(hSource);
74 if(hDest == NULL) {
75 hDest = GlobalAlloc(GHND, size);
76 }
77 dest = GlobalLock(hDest);
78 memcpy(dest, src, size);
79 GlobalUnlock(hDest);
80 }
81 O32_GlobalUnlock(hSource);
82 }
83 return hDest;
84}
85#endif
86/*****************************************************************************
87 * Name :
88 * Purpose :
89 * Parameters:
90 * Variables :
91 * Result :
92 * Remark :
93 * Status :
94 *
95 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
96 *****************************************************************************/
97
98ODINFUNCTION1(BOOL, PrintDlgA,
99 LPPRINTDLGA, lppd)
100{
101 BOOL ret;
102#ifdef USING_OPEN32
103 HGLOBAL hDevmode = 0, hDevNames = 0;
104 HGLOBAL hOrgDevmode = 0, hOrgDevNames = 0;
105 DEVMODEA *devmode, *devmodeorg;
106 DEVNAMES *devnames, *devnamesorg;
107 ULONG size;
108#endif
109
110 COMDLG32_CHECKHOOK2(lppd, PD_ENABLEPRINTHOOK, LPPRINTHOOKPROC,lpfnPrintHook)
111 COMDLG32_CHECKHOOK2(lppd, PD_ENABLESETUPHOOK, LPSETUPHOOKPROC,lpfnSetupHook)
112
113#ifdef USING_OPEN32
114 if(lppd->hDevMode) {
115 hOrgDevmode = lppd->hDevMode;
116 lppd->hDevMode = GlobalCopy(NULL, hOrgDevmode, FLAG_TO_OPEN32);
117 }
118 if(lppd->hDevNames) {
119 hOrgDevNames = lppd->hDevNames;
120 lppd->hDevNames = GlobalCopy(NULL, hOrgDevNames, FLAG_TO_OPEN32);
121 }
122#endif
123 HWND hwndOwner = lppd->hwndOwner;
124 if(lppd->hwndOwner) {
125 lppd->hwndOwner = Win32ToOS2Handle(lppd->hwndOwner);
126 }
127 ret = O32_PrintDlg(lppd);
128 lppd->hwndOwner = hwndOwner;
129#ifdef USING_OPEN32
130 if(ret == TRUE) {
131 if(lppd->hDevMode) {
132 hDevmode = lppd->hDevMode;
133 lppd->hDevMode = GlobalCopy(hOrgDevmode, lppd->hDevMode, FLAG_FROM_OPEN32);
134 O32_GlobalFree(hDevmode);
135 }
136 if(lppd->hDevNames) {
137 hDevNames = lppd->hDevNames;
138 lppd->hDevNames = GlobalCopy(hOrgDevNames, lppd->hDevNames, FLAG_FROM_OPEN32);
139 O32_GlobalFree(hDevNames);
140 }
141 }
142#endif
143 return ret;
144}
145
146
147/*****************************************************************************
148 * Name :
149 * Purpose :
150 * Parameters:
151 * Variables :
152 * Result :
153 * Remark :
154 * Status :
155 *
156 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
157 *****************************************************************************/
158
159ODINFUNCTION1(BOOL, PrintDlgW,
160 LPPRINTDLGW, lppd)
161{
162
163 PRINTDLGA pd;
164 BOOL bResult;
165
166 //SvL: TODO: hDevMode & hDevNames
167 dprintf(("PrintDlgW: ERROR NOT COMPLETE (UNICODE TRANSLATION)!!"));
168
169 memcpy(&pd, // make binary copy first to save all the fields
170 lppd,
171 sizeof(pd));
172
173 // convert to ASCII string
174 if ((lppd->Flags & PD_ENABLEPRINTTEMPLATE) &&
175 (lppd->lpPrintTemplateName != NULL))
176 pd.lpPrintTemplateName = UnicodeToAsciiString((WCHAR*)lppd->lpPrintTemplateName);
177 else
178 pd.lpPrintTemplateName = NULL;
179
180 if ((lppd->Flags & PD_ENABLESETUPTEMPLATE) &&
181 (lppd->lpSetupTemplateName != NULL))
182 pd.lpSetupTemplateName = UnicodeToAsciiString((WCHAR*)lppd->lpSetupTemplateName);
183 else
184 pd.lpSetupTemplateName = NULL;
185
186 COMDLG32_CHECKHOOK2((&pd), PD_ENABLEPRINTHOOK, LPPRINTHOOKPROC,lpfnPrintHook)
187 COMDLG32_CHECKHOOK2((&pd), PD_ENABLESETUPHOOK, LPSETUPHOOKPROC,lpfnSetupHook)
188
189 bResult = O32_PrintDlg(&pd); // call ASCII API
190
191 if (pd.lpPrintTemplateName != NULL) FreeAsciiString((char*)pd.lpPrintTemplateName);
192 if (pd.lpSetupTemplateName != NULL) FreeAsciiString((char*)pd.lpSetupTemplateName);
193
194 // copy back result
195 lppd->Flags = pd.Flags;
196 lppd->nFromPage = pd.nFromPage;
197 lppd->nToPage = pd.nToPage;
198 lppd->nMinPage = pd.nMinPage;
199 lppd->nMaxPage = pd.nMaxPage;
200 lppd->nCopies = pd.nCopies;
201 //@@@PH: all pass-back fields ?
202
203 return bResult;
204}
205
206
207/*****************************************************************************
208 * Name :
209 * Purpose :
210 * Parameters:
211 * Variables :
212 * Result :
213 * Remark :
214 * Status :
215 *
216 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
217 *****************************************************************************/
218
219ODINFUNCTION1(BOOL, PageSetupDlgA,
220 LPPAGESETUPDLGA, lppsd)
221{
222
223 dprintf(("COMDLG32: PageSetupDlgA not implemented.\n"));
224
225 //COMDLG32_CHECKHOOK2(lppsd, PSD_ENABLESETUPHOOK, LPPAGESETUPHOOK, lpfnPageSetupHook)
226
227 return(FALSE);
228}
229
230
231/*****************************************************************************
232 * Name :
233 * Purpose :
234 * Parameters:
235 * Variables :
236 * Result :
237 * Remark :
238 * Status :
239 *
240 * Author : Patrick Haller [Tue, 1998/02/10 01:55]
241 *****************************************************************************/
242
243ODINFUNCTION1(BOOL, PageSetupDlgW,
244 LPPAGESETUPDLGW, lppsd)
245{
246
247 dprintf(("COMDLG32: PageSetupDlgW(%08xh) not implemented.\n"));
248
249 //COMDLG32_CHECKHOOK2(lppsd, PSD_ENABLESETUPHOOK, LPPAGESETUPHOOK, lpfnPageSetupHook)
250
251 return(FALSE);
252}
253
Note: See TracBrowser for help on using the repository browser.