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