1 | /*
|
---|
2 | * Win32 dialog API functions for OS/2
|
---|
3 | *
|
---|
4 | * Copyright 1998 Sander van Leeuwen
|
---|
5 | *
|
---|
6 | *
|
---|
7 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
8 | *
|
---|
9 | */
|
---|
10 | #include <os2win.h>
|
---|
11 | #include <nameid.h>
|
---|
12 | #include "user32.h"
|
---|
13 | #include "wndproc.h"
|
---|
14 | #include "wndsubproc.h"
|
---|
15 | #include "wndclass.h"
|
---|
16 | #include "dlgconvert.h"
|
---|
17 |
|
---|
18 | //TODO: dlgproc == NULL
|
---|
19 | //******************************************************************************
|
---|
20 | //******************************************************************************
|
---|
21 | HWND WIN32API CreateDialogParamA(HINSTANCE hinst, LPCSTR lpszTemplate,
|
---|
22 | HWND hwndOwner, DLGPROC dlgproc,
|
---|
23 | LPARAM lParamInit)
|
---|
24 | {
|
---|
25 | HWND rc;
|
---|
26 | Win32WindowProc *dialog = NULL;
|
---|
27 |
|
---|
28 | if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
|
---|
29 | #ifdef DEBUG
|
---|
30 | WriteLog("OS2CreateDialogParamA %s\n", lpszTemplate);
|
---|
31 | #endif
|
---|
32 | lpszTemplate = (LPCSTR)ConvertNameId(hinst, (char *)lpszTemplate);
|
---|
33 | }
|
---|
34 | #ifdef DEBUG
|
---|
35 | else WriteLog("OS2CreateDialogParamA %d\n", (int)lpszTemplate);
|
---|
36 | #endif
|
---|
37 |
|
---|
38 | if(dlgproc) {
|
---|
39 | dialog = new Win32WindowProc((WNDPROC)dlgproc);
|
---|
40 | rc = O32_CreateDialogParam(hinst, lpszTemplate, hwndOwner, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
41 | }
|
---|
42 | else rc = O32_CreateDialogParam(hinst, lpszTemplate, hwndOwner, (DLGPROC_O32)O32_DefDlgProc, lParamInit);
|
---|
43 |
|
---|
44 | if(rc == 0 && dialog) {
|
---|
45 | delete(dialog);
|
---|
46 | }
|
---|
47 |
|
---|
48 | #ifdef DEBUG
|
---|
49 | WriteLog("CreateDialogParamA %X %X %d returned %X (%d)\n", hinst, hwndOwner, lParamInit, rc, GetLastError());
|
---|
50 | #endif
|
---|
51 | return(rc);
|
---|
52 | }
|
---|
53 | //******************************************************************************
|
---|
54 | //******************************************************************************
|
---|
55 | HWND WIN32API CreateDialogParamW(HINSTANCE hinst, LPCWSTR lpszTemplate,
|
---|
56 | HWND hwndOwner, DLGPROC dlgproc,
|
---|
57 | LPARAM lParamInit)
|
---|
58 | {
|
---|
59 | HWND rc;
|
---|
60 |
|
---|
61 | if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
|
---|
62 | char *astring = UnicodeToAsciiString((LPWSTR)lpszTemplate);
|
---|
63 | #ifdef DEBUG
|
---|
64 | WriteLog("OS2CreateDialogParamW %s\n", astring);
|
---|
65 | #endif
|
---|
66 | lpszTemplate = (LPWSTR)ConvertNameId(hinst, astring);
|
---|
67 | FreeAsciiString(astring);
|
---|
68 | }
|
---|
69 | #ifdef DEBUG
|
---|
70 | else WriteLog("OS2CreateDialogParamW %d\n", (int)lpszTemplate);
|
---|
71 | #endif
|
---|
72 |
|
---|
73 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc);
|
---|
74 |
|
---|
75 | rc = O32_CreateDialogParam(hinst, (LPCSTR)lpszTemplate, hwndOwner, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
76 | if(rc == 0) {
|
---|
77 | delete(dialog);
|
---|
78 | }
|
---|
79 |
|
---|
80 | #ifdef DEBUG
|
---|
81 | WriteLog("CreateDialogParamW returned %X\n", rc);
|
---|
82 | #endif
|
---|
83 | return(rc);
|
---|
84 | }
|
---|
85 | //******************************************************************************
|
---|
86 | //******************************************************************************
|
---|
87 | HWND WIN32API CreateDialogIndirectParamA(HINSTANCE hinst,
|
---|
88 | DLGTEMPLATE *dlgtemplate,
|
---|
89 | HWND hwndParent, DLGPROC dlgproc,
|
---|
90 | LPARAM lParamInit)
|
---|
91 | {
|
---|
92 | HWND hwnd;
|
---|
93 | DLGTEMPLATE *os2dlg;
|
---|
94 |
|
---|
95 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
---|
96 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
---|
97 |
|
---|
98 | hwnd = O32_CreateDialogIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
99 | if(hwnd == 0) {
|
---|
100 | delete(dialog);
|
---|
101 | }
|
---|
102 | #ifdef DEBUG
|
---|
103 | WriteLog("CreateDialogIndirectParamA returned %X\n", hwnd);
|
---|
104 | #endif
|
---|
105 | return(hwnd);
|
---|
106 | }
|
---|
107 | //******************************************************************************
|
---|
108 | //******************************************************************************
|
---|
109 | HWND WIN32API CreateDialogIndirectParamW(HINSTANCE hinst,
|
---|
110 | DLGTEMPLATE *dlgtemplate,
|
---|
111 | HWND hwndParent, DLGPROC dlgproc,
|
---|
112 | LPARAM lParamInit)
|
---|
113 | {
|
---|
114 | HWND hwnd;
|
---|
115 | DLGTEMPLATE *os2dlg;
|
---|
116 |
|
---|
117 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
---|
118 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
---|
119 |
|
---|
120 | hwnd = O32_CreateDialogIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
121 | if(hwnd == 0) {
|
---|
122 | delete(dialog);
|
---|
123 | }
|
---|
124 | dprintf(("CreateDialogIndirectParamW returned %X\n", hwnd));
|
---|
125 | return(hwnd);
|
---|
126 | }
|
---|
127 | //******************************************************************************
|
---|
128 | //******************************************************************************
|
---|
129 | BOOL WIN32API DialogBoxIndirectParamA(HINSTANCE hinst,
|
---|
130 | DLGTEMPLATE *dlgtemplate,
|
---|
131 | HWND hwndParent, DLGPROC dlgproc,
|
---|
132 | LPARAM lParamInit)
|
---|
133 | {
|
---|
134 | BOOL rc;
|
---|
135 | DLGTEMPLATE *os2dlg;
|
---|
136 |
|
---|
137 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
---|
138 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
---|
139 |
|
---|
140 | rc = O32_DialogBoxIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
141 | //dialog already destroyed when this returns
|
---|
142 | dprintf(("OS2DialogBoxIndirectParamA returned %X\n", rc));
|
---|
143 | return(rc);
|
---|
144 | }
|
---|
145 | //******************************************************************************
|
---|
146 | //******************************************************************************
|
---|
147 | BOOL WIN32API DialogBoxIndirectParamW(HINSTANCE hinst,
|
---|
148 | DLGTEMPLATE *dlgtemplate,
|
---|
149 | HWND hwndParent, DLGPROC dlgproc,
|
---|
150 | LPARAM lParamInit)
|
---|
151 | {
|
---|
152 | BOOL rc;
|
---|
153 | DLGTEMPLATE *os2dlg;
|
---|
154 |
|
---|
155 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
---|
156 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
---|
157 |
|
---|
158 | rc = O32_DialogBoxIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
159 | //dialog already destroyed when this returns
|
---|
160 | dprintf(("OS2DialogBoxIndirectParamW returned %d\n", rc));
|
---|
161 | return(rc);
|
---|
162 | }
|
---|
163 | //******************************************************************************
|
---|
164 | //******************************************************************************
|
---|
165 | int WIN32API DialogBoxParamA(HINSTANCE hinst, LPCSTR lpszTemplate, HWND hwndOwner,
|
---|
166 | DLGPROC dlgprc, LPARAM lParamInit)
|
---|
167 | {
|
---|
168 | int rc;
|
---|
169 |
|
---|
170 | if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
|
---|
171 | dprintf(("DialogBoxParam %s\n", lpszTemplate));
|
---|
172 | lpszTemplate = (LPCSTR)ConvertNameId(hinst, (char *)lpszTemplate);
|
---|
173 | }
|
---|
174 | else {
|
---|
175 | dprintf(("DialogBoxParam %d\n", (int)lpszTemplate));
|
---|
176 | }
|
---|
177 |
|
---|
178 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgprc);
|
---|
179 | rc = O32_DialogBoxParam(hinst, lpszTemplate, hwndOwner, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
180 |
|
---|
181 | dprintf(("DialogBoxParam returned %d\n", rc));
|
---|
182 | return(rc);
|
---|
183 | }
|
---|
184 | //******************************************************************************
|
---|
185 | //******************************************************************************
|
---|
186 | int WIN32API DialogBoxParamW(HINSTANCE arg1, LPCWSTR arg2, HWND arg3,
|
---|
187 | DLGPROC arg4, LPARAM arg5)
|
---|
188 | {
|
---|
189 | int rc;
|
---|
190 | char *astring = NULL;
|
---|
191 |
|
---|
192 |
|
---|
193 | if((int)arg2 >> 16 != 0) {
|
---|
194 | astring = UnicodeToAsciiString((LPWSTR)arg2);
|
---|
195 | }
|
---|
196 | else astring = (char *)arg2;
|
---|
197 | dprintf(("OS2DialogBoxParamW\n"));
|
---|
198 |
|
---|
199 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)arg4);
|
---|
200 | rc = DialogBoxParamA(arg1, astring, arg3, arg4, arg5);
|
---|
201 |
|
---|
202 | if((int)astring >> 16 != 0) FreeAsciiString(astring);
|
---|
203 |
|
---|
204 | dprintf(("OS2DialogBoxIndirectParamA returned %d\n", rc));
|
---|
205 |
|
---|
206 | return(rc);
|
---|
207 | }
|
---|
208 | //******************************************************************************
|
---|
209 | //******************************************************************************
|
---|
210 |
|
---|