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