1 | /* $Id: dialog.cpp,v 1.5 1999-06-26 13:46:21 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 | BOOL WIN32API DialogBoxIndirectParamA(HINSTANCE hinst,
|
---|
131 | DLGTEMPLATE *dlgtemplate,
|
---|
132 | HWND hwndParent, DLGPROC dlgproc,
|
---|
133 | LPARAM lParamInit)
|
---|
134 | {
|
---|
135 | BOOL rc;
|
---|
136 | DLGTEMPLATE *os2dlg;
|
---|
137 |
|
---|
138 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
---|
139 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
---|
140 |
|
---|
141 | rc = O32_DialogBoxIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
142 | //dialog already destroyed when this returns
|
---|
143 | dprintf(("OS2DialogBoxIndirectParamA returned %X\n", rc));
|
---|
144 | return(rc);
|
---|
145 | }
|
---|
146 | //******************************************************************************
|
---|
147 | //******************************************************************************
|
---|
148 | BOOL WIN32API DialogBoxIndirectParamW(HINSTANCE hinst,
|
---|
149 | DLGTEMPLATE *dlgtemplate,
|
---|
150 | HWND hwndParent, DLGPROC dlgproc,
|
---|
151 | LPARAM lParamInit)
|
---|
152 | {
|
---|
153 | BOOL rc;
|
---|
154 | DLGTEMPLATE *os2dlg;
|
---|
155 |
|
---|
156 | os2dlg = ConvertWin32DlgTemplate(dlgtemplate);
|
---|
157 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgproc, os2dlg);
|
---|
158 |
|
---|
159 | rc = O32_DialogBoxIndirectParam(hinst, os2dlg, hwndParent, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
160 | //dialog already destroyed when this returns
|
---|
161 | dprintf(("OS2DialogBoxIndirectParamW returned %d\n", rc));
|
---|
162 | return(rc);
|
---|
163 | }
|
---|
164 | //******************************************************************************
|
---|
165 | //******************************************************************************
|
---|
166 | int WIN32API DialogBoxParamA(HINSTANCE hinst, LPCSTR lpszTemplate, HWND hwndOwner,
|
---|
167 | DLGPROC dlgprc, LPARAM lParamInit)
|
---|
168 | {
|
---|
169 | int rc;
|
---|
170 |
|
---|
171 | if((int)lpszTemplate >> 16 != 0) {//convert string name identifier to numeric id
|
---|
172 | dprintf(("DialogBoxParam %s\n", lpszTemplate));
|
---|
173 | lpszTemplate = (LPCSTR)ConvertNameId(hinst, (char *)lpszTemplate);
|
---|
174 | }
|
---|
175 | else {
|
---|
176 | dprintf(("DialogBoxParam %d\n", (int)lpszTemplate));
|
---|
177 | }
|
---|
178 |
|
---|
179 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)dlgprc);
|
---|
180 | rc = O32_DialogBoxParam(hinst, lpszTemplate, hwndOwner, (DLGPROC_O32)dialog->GetOS2Callback(), lParamInit);
|
---|
181 |
|
---|
182 | dprintf(("DialogBoxParam returned %d\n", rc));
|
---|
183 | return(rc);
|
---|
184 | }
|
---|
185 | //******************************************************************************
|
---|
186 | //******************************************************************************
|
---|
187 | int WIN32API DialogBoxParamW(HINSTANCE arg1, LPCWSTR arg2, HWND arg3,
|
---|
188 | DLGPROC arg4, LPARAM arg5)
|
---|
189 | {
|
---|
190 | int rc;
|
---|
191 | char *astring = NULL;
|
---|
192 |
|
---|
193 |
|
---|
194 | if((int)arg2 >> 16 != 0) {
|
---|
195 | astring = UnicodeToAsciiString((LPWSTR)arg2);
|
---|
196 | }
|
---|
197 | else astring = (char *)arg2;
|
---|
198 | dprintf(("OS2DialogBoxParamW\n"));
|
---|
199 |
|
---|
200 | Win32WindowProc *dialog = new Win32WindowProc((WNDPROC)arg4);
|
---|
201 | rc = DialogBoxParamA(arg1, astring, arg3, arg4, arg5);
|
---|
202 |
|
---|
203 | if((int)astring >> 16 != 0) FreeAsciiString(astring);
|
---|
204 |
|
---|
205 | dprintf(("OS2DialogBoxIndirectParamA returned %d\n", rc));
|
---|
206 |
|
---|
207 | return(rc);
|
---|
208 | }
|
---|
209 | //******************************************************************************
|
---|
210 | //******************************************************************************
|
---|
211 |
|
---|