| 1 | /* $Id: loadres.cpp,v 1.3 1999-07-20 07:42:35 sandervl 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 | HBITMAP WIN32API LoadBitmapA(HINSTANCE hinst, LPCSTR lpszBitmap)
|
|---|
| 70 | {
|
|---|
| 71 | HBITMAP rc;
|
|---|
| 72 |
|
|---|
| 73 | if((int)lpszBitmap >> 16 != 0)
|
|---|
| 74 | { //convert string name identifier to numeric id
|
|---|
| 75 | dprintf(("lpszBitmap [%s]\n",
|
|---|
| 76 | lpszBitmap));
|
|---|
| 77 |
|
|---|
| 78 | lpszBitmap = (LPCSTR)ConvertNameId(hinst,
|
|---|
| 79 | (char *)lpszBitmap);
|
|---|
| 80 | }
|
|---|
| 81 | else
|
|---|
| 82 | dprintf(("lpszBitmap %08xh\n",
|
|---|
| 83 | (int)lpszBitmap));
|
|---|
| 84 |
|
|---|
| 85 | rc = O32_LoadBitmap(hinst, lpszBitmap);
|
|---|
| 86 |
|
|---|
| 87 | dprintf(("LoadBitmapA returned %08xh\n",
|
|---|
| 88 | rc));
|
|---|
| 89 |
|
|---|
| 90 | return(rc);
|
|---|
| 91 | }
|
|---|
| 92 | //******************************************************************************
|
|---|
| 93 | //******************************************************************************
|
|---|
| 94 | HBITMAP WIN32API LoadBitmapW(HINSTANCE hinst, LPCWSTR lpszBitmap)
|
|---|
| 95 | {
|
|---|
| 96 | char *astring = NULL;
|
|---|
| 97 | HBITMAP rc;
|
|---|
| 98 |
|
|---|
| 99 | if((int)lpszBitmap >> 16 != 0) {//convert string name identifier to numeric id
|
|---|
| 100 | astring = UnicodeToAsciiString((LPWSTR)lpszBitmap);
|
|---|
| 101 | dprintf(("lpszBitmap %s\n", astring));
|
|---|
| 102 |
|
|---|
| 103 | lpszBitmap = (LPWSTR)ConvertNameId(hinst, (char *)astring);
|
|---|
| 104 | }
|
|---|
| 105 | else dprintf(("lpszBitmap %d\n", (int)lpszBitmap));
|
|---|
| 106 |
|
|---|
| 107 | rc = O32_LoadBitmap(hinst, (char *)lpszBitmap);
|
|---|
| 108 | if(astring)
|
|---|
| 109 | FreeAsciiString(astring);
|
|---|
| 110 |
|
|---|
| 111 | dprintf(("LoadBitmapW returned %d\n", rc));
|
|---|
| 112 | return(rc);
|
|---|
| 113 | }
|
|---|
| 114 | //******************************************************************************
|
|---|
| 115 | //******************************************************************************
|
|---|
| 116 | HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor)
|
|---|
| 117 | {
|
|---|
| 118 | char *astring = NULL;
|
|---|
| 119 | HCURSOR rc;
|
|---|
| 120 |
|
|---|
| 121 | if((int)lpszCursor >> 16 != 0) {//convert string name identifier to numeric id
|
|---|
| 122 | astring = UnicodeToAsciiString((LPWSTR)lpszCursor);
|
|---|
| 123 | dprintf(("lpszCursor %s\n", astring));
|
|---|
| 124 | lpszCursor = (LPWSTR)ConvertNameId(hinst, (char *)astring);
|
|---|
| 125 | }
|
|---|
| 126 | else dprintf(("lpszCursor %d\n", (int)lpszCursor));
|
|---|
| 127 |
|
|---|
| 128 | rc = O32_LoadCursor(hinst, (char *)lpszCursor);
|
|---|
| 129 | if(astring)
|
|---|
| 130 | FreeAsciiString(astring);
|
|---|
| 131 |
|
|---|
| 132 | dprintf(("LoadCursorW returned %d\n", rc));
|
|---|
| 133 | return(rc);
|
|---|
| 134 | }
|
|---|
| 135 | //******************************************************************************
|
|---|
| 136 | //******************************************************************************
|
|---|
| 137 | HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon)
|
|---|
| 138 | {
|
|---|
| 139 | char *astring = NULL;
|
|---|
| 140 | HICON rc;
|
|---|
| 141 |
|
|---|
| 142 | if((int)lpszIcon >> 16 != 0) {//convert string name identifier to numeric id
|
|---|
| 143 | astring = UnicodeToAsciiString((LPWSTR)lpszIcon);
|
|---|
| 144 |
|
|---|
| 145 | dprintf(("lpszIcon %s\n", astring));
|
|---|
| 146 | lpszIcon = (LPWSTR)ConvertNameId(hinst, (char *)astring);
|
|---|
| 147 | }
|
|---|
| 148 | else dprintf(("lpszIcon %d\n", (int)lpszIcon));
|
|---|
| 149 |
|
|---|
| 150 | rc = O32_LoadIcon(hinst, (char *)lpszIcon);
|
|---|
| 151 | if(astring)
|
|---|
| 152 | FreeAsciiString(astring);
|
|---|
| 153 |
|
|---|
| 154 | dprintf(("LoadIconW returned %d\n", rc));
|
|---|
| 155 | return(rc);
|
|---|
| 156 | }
|
|---|
| 157 | //******************************************************************************
|
|---|
| 158 | //******************************************************************************
|
|---|
| 159 | //******************************************************************************
|
|---|
| 160 | //TODO: Far from complete, but works for loading resources from exe
|
|---|
| 161 | //fuLoad flag ignored
|
|---|
| 162 | //******************************************************************************
|
|---|
| 163 | HANDLE WIN32API LoadImageA(HINSTANCE hinst, LPCSTR lpszName, UINT uType,
|
|---|
| 164 | int cxDesired, int cyDesired, UINT fuLoad)
|
|---|
| 165 | {
|
|---|
| 166 | HANDLE hRet = 0;
|
|---|
| 167 |
|
|---|
| 168 | dprintf(("OS2LoadImageA NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
|
|---|
| 169 |
|
|---|
| 170 | switch(uType) {
|
|---|
| 171 | case IMAGE_BITMAP:
|
|---|
| 172 | hRet = (HANDLE)LoadBitmapA(hinst, lpszName);
|
|---|
| 173 | break;
|
|---|
| 174 | case IMAGE_CURSOR:
|
|---|
| 175 | hRet = (HANDLE)LoadCursorA(hinst, lpszName);
|
|---|
| 176 | break;
|
|---|
| 177 | case IMAGE_ICON:
|
|---|
| 178 | hRet = (HANDLE)LoadIconA(hinst, lpszName);
|
|---|
| 179 | break;
|
|---|
| 180 | }
|
|---|
| 181 | dprintf(("OS2LoadImageA returned %d\n", (int)hRet));
|
|---|
| 182 |
|
|---|
| 183 | return(hRet);
|
|---|
| 184 | }
|
|---|
| 185 | //******************************************************************************
|
|---|
| 186 | //******************************************************************************
|
|---|
| 187 | HANDLE WIN32API LoadImageW(HINSTANCE hinst, LPCWSTR lpszName, UINT uType,
|
|---|
| 188 | int cxDesired, int cyDesired, UINT fuLoad)
|
|---|
| 189 | {
|
|---|
| 190 | HANDLE hRet = 0;
|
|---|
| 191 |
|
|---|
| 192 | dprintf(("OS2LoadImageW NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
|
|---|
| 193 |
|
|---|
| 194 | switch(uType) {
|
|---|
| 195 | case IMAGE_BITMAP:
|
|---|
| 196 | hRet = (HANDLE)LoadBitmapW(hinst, lpszName);
|
|---|
| 197 | break;
|
|---|
| 198 | case IMAGE_CURSOR:
|
|---|
| 199 | hRet = (HANDLE)LoadCursorW(hinst, lpszName);
|
|---|
| 200 | break;
|
|---|
| 201 | case IMAGE_ICON:
|
|---|
| 202 | hRet = (HANDLE)LoadIconW(hinst, lpszName);
|
|---|
| 203 | break;
|
|---|
| 204 | }
|
|---|
| 205 | dprintf(("OS2LoadImageW returned %d\n", (int)hRet));
|
|---|
| 206 |
|
|---|
| 207 | return(hRet);
|
|---|
| 208 | }
|
|---|
| 209 | //******************************************************************************
|
|---|
| 210 | //******************************************************************************
|
|---|