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