1 | /* $Id: loadres.cpp,v 1.1 1999-05-24 20:20:01 ktk Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | *
|
---|
5 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
6 | *
|
---|
7 | */
|
---|
8 | /*
|
---|
9 | * Win32 resource API functions for OS/2
|
---|
10 | *
|
---|
11 | * Copyright 1998 Sander van Leeuwen
|
---|
12 | *
|
---|
13 | */
|
---|
14 | #include <os2win.h>
|
---|
15 | #include "user32.h"
|
---|
16 | #include "resstring.h"
|
---|
17 |
|
---|
18 | //NOTE: HINSTANCE 0xFFFFFFFF == hinstance executable
|
---|
19 | //******************************************************************************
|
---|
20 | //******************************************************************************
|
---|
21 | int WIN32API LoadStringA(HINSTANCE hinst, UINT wID, LPSTR lpBuffer, int cchBuffer)
|
---|
22 | {
|
---|
23 | dprintf(("LoadString from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
|
---|
24 | return OS2LoadStringAscii(hinst, wID, lpBuffer, cchBuffer);
|
---|
25 | }
|
---|
26 | //******************************************************************************
|
---|
27 | //******************************************************************************
|
---|
28 | int WIN32API LoadStringW(HINSTANCE hinst, UINT wID, LPWSTR lpBuffer, int cchBuffer)
|
---|
29 | {
|
---|
30 | dprintf(("LoadStringW %d\n", wID));
|
---|
31 | return OS2LoadStringUnicode(hinst, wID, (WCHAR *)lpBuffer, cchBuffer);
|
---|
32 | }
|
---|
33 | //******************************************************************************
|
---|
34 | //******************************************************************************
|
---|
35 | HICON WIN32API LoadIconA(HINSTANCE hinst, LPCSTR lpszIcon)
|
---|
36 | {
|
---|
37 | HICON rc;
|
---|
38 |
|
---|
39 | if((int)lpszIcon >> 16 != 0) {//convert string name identifier to numeric id
|
---|
40 | dprintf(("LoadIcon %s\n", lpszIcon));
|
---|
41 | lpszIcon = (LPCSTR)ConvertNameId(hinst, (char *)lpszIcon);
|
---|
42 | }
|
---|
43 | else dprintf(("LoadIcon %d\n", (int)lpszIcon));
|
---|
44 |
|
---|
45 | rc = O32_LoadIcon(hinst, lpszIcon);
|
---|
46 |
|
---|
47 | dprintf(("LoadIcon returned %d\n", rc));
|
---|
48 | return(rc);
|
---|
49 | }
|
---|
50 | //******************************************************************************
|
---|
51 | //******************************************************************************
|
---|
52 | HCURSOR WIN32API LoadCursorA(HINSTANCE hinst, LPCSTR lpszCursor)
|
---|
53 | {
|
---|
54 | HCURSOR rc;
|
---|
55 |
|
---|
56 | if((int)lpszCursor >> 16 != 0) {//convert string name identifier to numeric id
|
---|
57 | dprintf(("LoadCursor %s\n", lpszCursor));
|
---|
58 | lpszCursor = (LPCSTR)ConvertNameId(hinst, (char *)lpszCursor);
|
---|
59 | }
|
---|
60 | else dprintf(("LoadCursor %d\n", (int)lpszCursor));
|
---|
61 |
|
---|
62 | rc = O32_LoadCursor(hinst, lpszCursor);
|
---|
63 |
|
---|
64 | dprintf(("LoadCursor from %X returned %d\n", hinst, rc));
|
---|
65 | return(rc);
|
---|
66 | }
|
---|
67 | //******************************************************************************
|
---|
68 | //******************************************************************************
|
---|
69 | HACCEL WIN32API LoadAcceleratorsA(HINSTANCE hinst, LPCSTR lpszAcc)
|
---|
70 | {
|
---|
71 | HACCEL rc;
|
---|
72 |
|
---|
73 | if((int)lpszAcc >> 16 != 0) {//convert string name identifier to numeric id
|
---|
74 | dprintf(("lpszAcc %s\n", lpszAcc));
|
---|
75 | lpszAcc = (LPCSTR)ConvertNameId(hinst, (char *)lpszAcc);
|
---|
76 | }
|
---|
77 | else dprintf(("lpszAcc %d\n", (int)lpszAcc));
|
---|
78 |
|
---|
79 | rc = O32_LoadAccelerators(hinst, lpszAcc);
|
---|
80 |
|
---|
81 | dprintf(("LoadAccelerators returned %d\n", rc));
|
---|
82 | return(rc);
|
---|
83 | }
|
---|
84 | //******************************************************************************
|
---|
85 | //******************************************************************************
|
---|
86 | HBITMAP WIN32API LoadBitmapA(HINSTANCE hinst, LPCSTR lpszBitmap)
|
---|
87 | {
|
---|
88 | HBITMAP rc;
|
---|
89 |
|
---|
90 | if((int)lpszBitmap >> 16 != 0)
|
---|
91 | { //convert string name identifier to numeric id
|
---|
92 | dprintf(("lpszBitmap [%s]\n",
|
---|
93 | lpszBitmap));
|
---|
94 |
|
---|
95 | lpszBitmap = (LPCSTR)ConvertNameId(hinst,
|
---|
96 | (char *)lpszBitmap);
|
---|
97 | }
|
---|
98 | else
|
---|
99 | dprintf(("lpszBitmap %08xh\n",
|
---|
100 | (int)lpszBitmap));
|
---|
101 |
|
---|
102 | rc = O32_LoadBitmap(hinst, lpszBitmap);
|
---|
103 |
|
---|
104 | dprintf(("LoadBitmapA returned %08xh\n",
|
---|
105 | rc));
|
---|
106 |
|
---|
107 | return(rc);
|
---|
108 | }
|
---|
109 |
|
---|
110 | //******************************************************************************
|
---|
111 | //******************************************************************************
|
---|
112 | HACCEL WIN32API LoadAcceleratorsW(HINSTANCE hinst, LPCWSTR lpszAccel)
|
---|
113 | {
|
---|
114 | char *astring = NULL;
|
---|
115 | HACCEL rc;
|
---|
116 |
|
---|
117 | if((int)lpszAccel >> 16 != 0) {//convert string name identifier to numeric id
|
---|
118 | astring = UnicodeToAsciiString((LPWSTR)lpszAccel);
|
---|
119 |
|
---|
120 | dprintf(("lpszAccel %s\n", astring));
|
---|
121 | lpszAccel = (LPWSTR)ConvertNameId(hinst, (char *)astring);
|
---|
122 | }
|
---|
123 | else dprintf(("lpszAccel %d\n", (int)lpszAccel));
|
---|
124 |
|
---|
125 | rc = O32_LoadAccelerators(hinst, (char *)lpszAccel);
|
---|
126 | if(astring)
|
---|
127 | FreeAsciiString(astring);
|
---|
128 |
|
---|
129 | dprintf(("LoadAcceleratorsW returned %d\n", rc));
|
---|
130 | return(rc);
|
---|
131 | }
|
---|
132 | //******************************************************************************
|
---|
133 | //******************************************************************************
|
---|
134 | HBITMAP WIN32API LoadBitmapW(HINSTANCE hinst, LPCWSTR lpszBitmap)
|
---|
135 | {
|
---|
136 | char *astring = NULL;
|
---|
137 | HBITMAP rc;
|
---|
138 |
|
---|
139 | if((int)lpszBitmap >> 16 != 0) {//convert string name identifier to numeric id
|
---|
140 | astring = UnicodeToAsciiString((LPWSTR)lpszBitmap);
|
---|
141 | dprintf(("lpszBitmap %s\n", astring));
|
---|
142 |
|
---|
143 | lpszBitmap = (LPWSTR)ConvertNameId(hinst, (char *)astring);
|
---|
144 | }
|
---|
145 | else dprintf(("lpszBitmap %d\n", (int)lpszBitmap));
|
---|
146 |
|
---|
147 | rc = O32_LoadBitmap(hinst, (char *)lpszBitmap);
|
---|
148 | if(astring)
|
---|
149 | FreeAsciiString(astring);
|
---|
150 |
|
---|
151 | dprintf(("LoadBitmapW returned %d\n", rc));
|
---|
152 | return(rc);
|
---|
153 | }
|
---|
154 | //******************************************************************************
|
---|
155 | //******************************************************************************
|
---|
156 | HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor)
|
---|
157 | {
|
---|
158 | char *astring = NULL;
|
---|
159 | HCURSOR rc;
|
---|
160 |
|
---|
161 | if((int)lpszCursor >> 16 != 0) {//convert string name identifier to numeric id
|
---|
162 | astring = UnicodeToAsciiString((LPWSTR)lpszCursor);
|
---|
163 | dprintf(("lpszCursor %s\n", astring));
|
---|
164 | lpszCursor = (LPWSTR)ConvertNameId(hinst, (char *)astring);
|
---|
165 | }
|
---|
166 | else dprintf(("lpszCursor %d\n", (int)lpszCursor));
|
---|
167 |
|
---|
168 | rc = O32_LoadCursor(hinst, (char *)lpszCursor);
|
---|
169 | if(astring)
|
---|
170 | FreeAsciiString(astring);
|
---|
171 |
|
---|
172 | dprintf(("LoadCursorW returned %d\n", rc));
|
---|
173 | return(rc);
|
---|
174 | }
|
---|
175 | //******************************************************************************
|
---|
176 | //******************************************************************************
|
---|
177 | HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon)
|
---|
178 | {
|
---|
179 | char *astring = NULL;
|
---|
180 | HICON rc;
|
---|
181 |
|
---|
182 | if((int)lpszIcon >> 16 != 0) {//convert string name identifier to numeric id
|
---|
183 | astring = UnicodeToAsciiString((LPWSTR)lpszIcon);
|
---|
184 |
|
---|
185 | dprintf(("lpszIcon %s\n", astring));
|
---|
186 | lpszIcon = (LPWSTR)ConvertNameId(hinst, (char *)astring);
|
---|
187 | }
|
---|
188 | else dprintf(("lpszIcon %d\n", (int)lpszIcon));
|
---|
189 |
|
---|
190 | rc = O32_LoadIcon(hinst, (char *)lpszIcon);
|
---|
191 | if(astring)
|
---|
192 | FreeAsciiString(astring);
|
---|
193 |
|
---|
194 | dprintf(("LoadIconW returned %d\n", rc));
|
---|
195 | return(rc);
|
---|
196 | }
|
---|
197 | //******************************************************************************
|
---|
198 | //******************************************************************************
|
---|
199 | HMENU WIN32API LoadMenuA(HINSTANCE hinst, LPCSTR lpszMenu)
|
---|
200 | {
|
---|
201 | HMENU rc;
|
---|
202 |
|
---|
203 | if((int)lpszMenu >> 16 != 0) {//convert string name identifier to numeric id
|
---|
204 | dprintf(("lpszMenu %s\n", lpszMenu));
|
---|
205 |
|
---|
206 | lpszMenu = (LPCSTR)ConvertNameId(hinst, (char *)lpszMenu);
|
---|
207 | }
|
---|
208 | else dprintf(("lpszMenu %d\n", (int)lpszMenu));
|
---|
209 |
|
---|
210 | rc = O32_LoadMenu(hinst, lpszMenu);
|
---|
211 |
|
---|
212 | dprintf(("LoadMenuA (%X) returned %d\n", hinst, rc));
|
---|
213 | return(rc);
|
---|
214 | }
|
---|
215 | //******************************************************************************
|
---|
216 | //******************************************************************************
|
---|
217 | HMENU WIN32API LoadMenuIndirectA( const MENUITEMTEMPLATEHEADER * arg1)
|
---|
218 | {
|
---|
219 | char *astring = NULL;
|
---|
220 | HMENU rc;
|
---|
221 |
|
---|
222 | dprintf(("OS2LoadMenuIndirectA\n"));
|
---|
223 |
|
---|
224 | rc = O32_LoadMenuIndirect(arg1);
|
---|
225 | if(astring)
|
---|
226 | FreeAsciiString(astring);
|
---|
227 | return(rc);
|
---|
228 | }
|
---|
229 | //******************************************************************************
|
---|
230 | //Won't work...
|
---|
231 | //******************************************************************************
|
---|
232 | HMENU WIN32API LoadMenuIndirectW(const MENUITEMTEMPLATEHEADER * arg1)
|
---|
233 | {
|
---|
234 | dprintf(("OS2LoadMenuIndirectW, improperly implemented!!\n"));
|
---|
235 |
|
---|
236 | return 0;
|
---|
237 | // return O32_LoadMenuIndirect(arg1);
|
---|
238 | }
|
---|
239 | //******************************************************************************
|
---|
240 | //******************************************************************************
|
---|
241 | HMENU WIN32API LoadMenuW(HINSTANCE hinst, LPCWSTR lpszMenu)
|
---|
242 | {
|
---|
243 | char *astring = NULL;
|
---|
244 | HMENU rc;
|
---|
245 |
|
---|
246 | if((int)lpszMenu >> 16 != 0) {//convert string name identifier to numeric id
|
---|
247 | astring = UnicodeToAsciiString((LPWSTR)lpszMenu);
|
---|
248 |
|
---|
249 | dprintf(("lpszMenu %s\n", astring));
|
---|
250 | lpszMenu = (LPWSTR)ConvertNameId(hinst, (char *)astring);
|
---|
251 | }
|
---|
252 | else dprintf(("lpszMenu %d\n", (int)lpszMenu));
|
---|
253 |
|
---|
254 | rc = O32_LoadMenu(hinst, (char *)lpszMenu);
|
---|
255 | if(astring)
|
---|
256 | FreeAsciiString(astring);
|
---|
257 |
|
---|
258 | dprintf(("LoadMenuA (%X) returned %d\n", hinst, rc));
|
---|
259 | return(rc);
|
---|
260 | }
|
---|
261 | //******************************************************************************
|
---|
262 | //TODO: Far from complete, but works for loading resources from exe
|
---|
263 | //fuLoad flag ignored
|
---|
264 | //******************************************************************************
|
---|
265 | HANDLE WIN32API LoadImageA(HINSTANCE hinst, LPCSTR lpszName, UINT uType,
|
---|
266 | int cxDesired, int cyDesired, UINT fuLoad)
|
---|
267 | {
|
---|
268 | HANDLE hRet = 0;
|
---|
269 |
|
---|
270 | dprintf(("OS2LoadImageA NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
|
---|
271 |
|
---|
272 | switch(uType) {
|
---|
273 | case IMAGE_BITMAP:
|
---|
274 | hRet = (HANDLE)LoadBitmapA(hinst, lpszName);
|
---|
275 | break;
|
---|
276 | case IMAGE_CURSOR:
|
---|
277 | hRet = (HANDLE)LoadCursorA(hinst, lpszName);
|
---|
278 | break;
|
---|
279 | case IMAGE_ICON:
|
---|
280 | hRet = (HANDLE)LoadIconA(hinst, lpszName);
|
---|
281 | break;
|
---|
282 | }
|
---|
283 | dprintf(("OS2LoadImageA returned %d\n", (int)hRet));
|
---|
284 |
|
---|
285 | return(hRet);
|
---|
286 | }
|
---|
287 | //******************************************************************************
|
---|
288 | //******************************************************************************
|
---|
289 | HANDLE WIN32API LoadImageW(HINSTANCE hinst, LPCWSTR lpszName, UINT uType,
|
---|
290 | int cxDesired, int cyDesired, UINT fuLoad)
|
---|
291 | {
|
---|
292 | HANDLE hRet = 0;
|
---|
293 |
|
---|
294 | dprintf(("OS2LoadImageW NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
|
---|
295 |
|
---|
296 | switch(uType) {
|
---|
297 | case IMAGE_BITMAP:
|
---|
298 | hRet = (HANDLE)LoadBitmapW(hinst, lpszName);
|
---|
299 | break;
|
---|
300 | case IMAGE_CURSOR:
|
---|
301 | hRet = (HANDLE)LoadCursorW(hinst, lpszName);
|
---|
302 | break;
|
---|
303 | case IMAGE_ICON:
|
---|
304 | hRet = (HANDLE)LoadIconW(hinst, lpszName);
|
---|
305 | break;
|
---|
306 | }
|
---|
307 | dprintf(("OS2LoadImageW returned %d\n", (int)hRet));
|
---|
308 |
|
---|
309 | return(hRet);
|
---|
310 | }
|
---|
311 | //******************************************************************************
|
---|
312 | //******************************************************************************
|
---|