1 | /* $Id: dialog.cpp,v 1.3 1999-09-15 23:20:38 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 dialog API functions for OS/2
|
---|
5 | *
|
---|
6 | * Copyright 1998 Sander van Leeuwen
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 | #include <os2win.h>
|
---|
13 | #include <nameid.h>
|
---|
14 | #include "user32.h"
|
---|
15 | #include "wndproc.h"
|
---|
16 | #include "wndclass.h"
|
---|
17 | #include "dlgconvert.h"
|
---|
18 |
|
---|
19 | //TODO: dlgproc == NULL
|
---|
20 | //******************************************************************************
|
---|
21 | //******************************************************************************
|
---|
22 | HWND WIN32API CreateDialogParamA(HINSTANCE hinst, LPCSTR lpszTemplate,
|
---|
23 | HWND hwndOwner, DLGPROC dlgproc,
|
---|
24 | LPARAM lParamInit)
|
---|
25 | {
|
---|
26 | HWND rc;
|
---|
27 | Win32WindowProc *dialog = NULL;
|
---|
28 |
|
---|
29 | if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
|
---|
30 | #ifdef DEBUG
|
---|
31 | WriteLog("OS2CreateDialogParamA %s\n", lpszTemplate);
|
---|
32 | #endif
|
---|
33 | lpszTemplate = (LPCSTR)ConvertNameId(hinst, (char *)lpszTemplate);
|
---|
34 | }
|
---|
35 | #ifdef DEBUG
|
---|
36 | else WriteLog("OS2CreateDialogParamA %d\n", (int)lpszTemplate);
|
---|
37 | #endif
|
---|
38 |
|
---|
39 | if(dlgproc) {
|
---|
40 | dialog = new Win32WindowProc((WNDPROC)dlgproc);
|
---|
41 | rc = O32_CreateDialogParam(hinst, lpszTemplate, hwndOwner, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
42 | }
|
---|
43 | else rc = O32_CreateDialogParam(hinst, lpszTemplate, hwndOwner, (DLGPROC_O32)O32_DefDlgProc, lParamInit);
|
---|
44 |
|
---|
45 | if(rc == 0 && dialog) {
|
---|
46 | delete(dialog);
|
---|
47 | }
|
---|
48 |
|
---|
49 | #ifdef DEBUG
|
---|
50 | WriteLog("CreateDialogParamA %X %X %d returned %X (%d)\n", hinst, hwndOwner, lParamInit, rc, GetLastError());
|
---|
51 | #endif
|
---|
52 | return(rc);
|
---|
53 | }
|
---|
54 | //******************************************************************************
|
---|
55 | //******************************************************************************
|
---|
56 | HWND WIN32API CreateDialogParamW(HINSTANCE hinst, LPCWSTR lpszTemplate,
|
---|
57 | HWND hwndOwner, DLGPROC dlgproc,
|
---|
58 | LPARAM lParamInit)
|
---|
59 | {
|
---|
60 | HWND rc;
|
---|
61 |
|
---|
62 | if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
|
---|
63 | char *astring = UnicodeToAsciiString((LPWSTR)lpszTemplate);
|
---|
64 | #ifdef DEBUG
|
---|
65 | WriteLog("OS2CreateDialogParamW %s\n", astring);
|
---|
66 | #endif
|
---|
67 | lpszTemplate = (LPWSTR)ConvertNameId(hinst, astring);
|
---|
68 | FreeAsciiString(astring);
|
---|
69 | }
|
---|
70 | #ifdef DEBUG
|
---|
71 | else WriteLog("OS2CreateDialogParamW %d\n", (int)lpszTemplate);
|
---|
72 | #endif
|
---|
73 |
|
---|
74 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc);
|
---|
75 |
|
---|
76 | rc = O32_CreateDialogParam(hinst, (LPCSTR)lpszTemplate, hwndOwner, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
77 | if(rc == 0) {
|
---|
78 | delete(dialog);
|
---|
79 | }
|
---|
80 |
|
---|
81 | #ifdef DEBUG
|
---|
82 | WriteLog("CreateDialogParamW returned %X\n", rc);
|
---|
83 | #endif
|
---|
84 | return(rc);
|
---|
85 | }
|
---|
86 | //******************************************************************************
|
---|
87 | //******************************************************************************
|
---|
88 | HWND WIN32API CreateDialogIndirectParamA(HINSTANCE hinst,
|
---|
89 | DLGTEMPLATE *dlgtemplate,
|
---|
90 | HWND hwndParent, DLGPROC dlgproc,
|
---|
91 | LPARAM lParamInit)
|
---|
92 | {
|
---|
93 | HWND hwnd;
|
---|
94 | DLGTEMPLATE *os2dlg;
|
---|
95 |
|
---|
96 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
---|
97 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
---|
98 |
|
---|
99 | hwnd = O32_CreateDialogIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
100 | if(hwnd == 0) {
|
---|
101 | delete(dialog);
|
---|
102 | }
|
---|
103 | #ifdef DEBUG
|
---|
104 | WriteLog("CreateDialogIndirectParamA returned %X\n", hwnd);
|
---|
105 | #endif
|
---|
106 | return(hwnd);
|
---|
107 | }
|
---|
108 | //******************************************************************************
|
---|
109 | //******************************************************************************
|
---|
110 | HWND WIN32API CreateDialogIndirectParamW(HINSTANCE hinst,
|
---|
111 | DLGTEMPLATE *dlgtemplate,
|
---|
112 | HWND hwndParent, DLGPROC dlgproc,
|
---|
113 | LPARAM lParamInit)
|
---|
114 | {
|
---|
115 | HWND hwnd;
|
---|
116 | DLGTEMPLATE *os2dlg;
|
---|
117 |
|
---|
118 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
---|
119 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
---|
120 |
|
---|
121 | hwnd = O32_CreateDialogIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
122 | if(hwnd == 0) {
|
---|
123 | delete(dialog);
|
---|
124 | }
|
---|
125 | dprintf(("CreateDialogIndirectParamW returned %X\n", hwnd));
|
---|
126 | return(hwnd);
|
---|
127 | }
|
---|
128 | //******************************************************************************
|
---|
129 | //******************************************************************************
|
---|
130 | INT WIN32API DialogBoxIndirectParamA(HINSTANCE hinst,
|
---|
131 | DLGTEMPLATE *dlgtemplate,
|
---|
132 | HWND hwndParent, DLGPROC dlgproc,
|
---|
133 | LPARAM lParamInit)
|
---|
134 | {
|
---|
135 | INT rc;
|
---|
136 | DLGTEMPLATE *os2dlg;
|
---|
137 |
|
---|
138 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
---|
139 |
|
---|
140 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
---|
141 |
|
---|
142 | rc = O32_DialogBoxIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
143 | //dialog already destroyed when this returns
|
---|
144 | dprintf(("OS2DialogBoxIndirectParamA returned %X\n", rc));
|
---|
145 | return(rc);
|
---|
146 | }
|
---|
147 | //******************************************************************************
|
---|
148 | //******************************************************************************
|
---|
149 | INT WIN32API DialogBoxIndirectParamW(HINSTANCE hinst,
|
---|
150 | DLGTEMPLATE *dlgtemplate,
|
---|
151 | HWND hwndParent, DLGPROC dlgproc,
|
---|
152 | LPARAM lParamInit)
|
---|
153 | {
|
---|
154 | INT rc;
|
---|
155 | DLGTEMPLATE *os2dlg;
|
---|
156 |
|
---|
157 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
---|
158 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
---|
159 |
|
---|
160 | rc = O32_DialogBoxIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
161 | //dialog already destroyed when this returns
|
---|
162 | dprintf(("OS2DialogBoxIndirectParamW returned %d\n", rc));
|
---|
163 | return(rc);
|
---|
164 | }
|
---|
165 | //******************************************************************************
|
---|
166 | //******************************************************************************
|
---|
167 | int WIN32API DialogBoxParamA(HINSTANCE hinst, LPCSTR lpszTemplate, HWND hwndOwner,
|
---|
168 | DLGPROC dlgprc, LPARAM lParamInit)
|
---|
169 | {
|
---|
170 | int rc;
|
---|
171 |
|
---|
172 | if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
|
---|
173 | dprintf(("DialogBoxParam %s\n", lpszTemplate));
|
---|
174 | lpszTemplate = (LPCSTR)ConvertNameId(hinst, (char *)lpszTemplate);
|
---|
175 | }
|
---|
176 | else {
|
---|
177 | dprintf(("DialogBoxParam %d\n", (int)lpszTemplate));
|
---|
178 | }
|
---|
179 |
|
---|
180 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgprc);
|
---|
181 | rc = O32_DialogBoxParam(hinst, lpszTemplate, hwndOwner, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
182 |
|
---|
183 | dprintf(("DialogBoxParam returned %d\n", rc));
|
---|
184 | return(rc);
|
---|
185 | }
|
---|
186 | //******************************************************************************
|
---|
187 | //******************************************************************************
|
---|
188 | int WIN32API DialogBoxParamW(HINSTANCE arg1, LPCWSTR arg2, HWND arg3,
|
---|
189 | DLGPROC arg4, LPARAM arg5)
|
---|
190 | {
|
---|
191 | int rc;
|
---|
192 | char *astring = NULL;
|
---|
193 |
|
---|
194 |
|
---|
195 | if((int)arg2 >> 16 != 0) {
|
---|
196 | astring = UnicodeToAsciiString((LPWSTR)arg2);
|
---|
197 | }
|
---|
198 | else astring = (char *)arg2;
|
---|
199 | dprintf(("OS2DialogBoxParamW\n"));
|
---|
200 |
|
---|
201 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)arg4);
|
---|
202 | rc = DialogBoxParamA(arg1, astring, arg3, arg4, arg5);
|
---|
203 |
|
---|
204 | if((int)astring >> 16 != 0) FreeAsciiString(astring);
|
---|
205 |
|
---|
206 | dprintf(("OS2DialogBoxIndirectParamA returned %d\n", rc));
|
---|
207 |
|
---|
208 | return(rc);
|
---|
209 | }
|
---|
210 | //******************************************************************************
|
---|
211 | // CB: Loads and starts a native OS/2 dialog with Win32 DlgProc
|
---|
212 | // (used in COMCTL32)
|
---|
213 | // full name: NativeDialogBoxIndirectParam
|
---|
214 | //******************************************************************************
|
---|
215 | INT WINAPI NativeDlgBoxIP(HMODULE hmodule,
|
---|
216 | HINSTANCE hinst, LPCSTR lpszName,
|
---|
217 | HWND hwndParent, DLGPROC dlgproc,
|
---|
218 | LPARAM lParamInit)
|
---|
219 | {
|
---|
220 | BOOL rc;
|
---|
221 | DLGTEMPLATE *os2dlg;
|
---|
222 | HRSRC hRes;
|
---|
223 |
|
---|
224 | dprintf(("NativeDlgBoxIP"));
|
---|
225 |
|
---|
226 | hRes = O32_FindResource(hmodule,lpszName,RT_DIALOGA);
|
---|
227 | if (hRes == 0) return (INT)-1;
|
---|
228 |
|
---|
229 | dprintf((" hRes = %d",hRes));
|
---|
230 |
|
---|
231 | os2dlg = (DLGTEMPLATE*)O32_LoadResource(hmodule,hRes);
|
---|
232 | if (os2dlg == NULL) return (INT)-1;
|
---|
233 |
|
---|
234 | dprintf((" os2dlg = %d",os2dlg));
|
---|
235 |
|
---|
236 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc,os2dlg);
|
---|
237 | rc = O32_DialogBoxIndirectParam(hinst,os2dlg,hwndParent,(DLGPROC_O32)dialog->GetOS2Callback(),lParamInit);
|
---|
238 | //dialog already destroyed when this returns
|
---|
239 | dprintf(("NativeDlgBoxIP returned %X\n", rc));
|
---|
240 |
|
---|
241 | return rc;
|
---|
242 | }
|
---|
243 | //******************************************************************************
|
---|
244 | //******************************************************************************
|
---|
245 | //******************************************************************************
|
---|
246 | // CB: Loads and starts a native OS/2 dialog with Win32 DlgProc
|
---|
247 | // (used in COMCTL32)
|
---|
248 | // full name: NativeCreateDialogIndirectParam
|
---|
249 | //******************************************************************************
|
---|
250 | INT WINAPI NativeCreateDlgIP(HMODULE hmodule,
|
---|
251 | HINSTANCE hinst, LPCSTR lpszName,
|
---|
252 | HWND hwndParent, DLGPROC dlgproc,
|
---|
253 | LPARAM lParamInit)
|
---|
254 | {
|
---|
255 | BOOL rc;
|
---|
256 | DLGTEMPLATE *os2dlg;
|
---|
257 | HRSRC hRes;
|
---|
258 |
|
---|
259 | dprintf(("NativeCreateDlgBoxIP"));
|
---|
260 |
|
---|
261 | hRes = O32_FindResource(hmodule,lpszName,RT_DIALOGA);
|
---|
262 | if (hRes == 0) return (INT)-1;
|
---|
263 |
|
---|
264 | dprintf((" hRes = %d",hRes));
|
---|
265 |
|
---|
266 | os2dlg = (DLGTEMPLATE*)O32_LoadResource(hmodule,hRes);
|
---|
267 | if (os2dlg == NULL) return (INT)-1;
|
---|
268 |
|
---|
269 | dprintf((" os2dlg = %d",os2dlg));
|
---|
270 |
|
---|
271 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc,os2dlg);
|
---|
272 | rc = O32_CreateDialogIndirectParam(hinst,os2dlg,hwndParent,(DLGPROC_O32)dialog->GetOS2Callback(),lParamInit);
|
---|
273 | //dialog already destroyed when this returns
|
---|
274 | dprintf(("NativeDlgBoxIP returned %X\n", rc));
|
---|
275 |
|
---|
276 | return rc;
|
---|
277 | }
|
---|
278 | //******************************************************************************
|
---|
279 | //******************************************************************************
|
---|