| 1 | /* $Id: loadres.cpp,v 1.4 1999-07-20 15:46:53 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 | rc = (HICON)FindResourceA(hinst, lpszIcon, RT_ICONA);
|
|---|
| 40 | dprintf(("LoadIconA (%X) returned %d\n", hinst, rc));
|
|---|
| 41 | return(rc);
|
|---|
| 42 | }
|
|---|
| 43 | //******************************************************************************
|
|---|
| 44 | //******************************************************************************
|
|---|
| 45 | HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon)
|
|---|
| 46 | {
|
|---|
| 47 | HICON rc;
|
|---|
| 48 |
|
|---|
| 49 | rc = (HICON)FindResourceW(hinst, lpszIcon, RT_ICONW);
|
|---|
| 50 | dprintf(("LoadIconW (%X) returned %d\n", hinst, rc));
|
|---|
| 51 | return(rc);
|
|---|
| 52 | }
|
|---|
| 53 | //******************************************************************************
|
|---|
| 54 | //******************************************************************************
|
|---|
| 55 | HCURSOR WIN32API LoadCursorA(HINSTANCE hinst, LPCSTR lpszCursor)
|
|---|
| 56 | {
|
|---|
| 57 | HCURSOR rc;
|
|---|
| 58 |
|
|---|
| 59 | if((int)lpszCursor >> 16 != 0) {//convert string name identifier to numeric id
|
|---|
| 60 | dprintf(("LoadCursor %s\n", lpszCursor));
|
|---|
| 61 | lpszCursor = (LPCSTR)ConvertNameId(hinst, (char *)lpszCursor);
|
|---|
| 62 | }
|
|---|
| 63 | else dprintf(("LoadCursor %d\n", (int)lpszCursor));
|
|---|
| 64 |
|
|---|
| 65 | rc = O32_LoadCursor(hinst, lpszCursor);
|
|---|
| 66 |
|
|---|
| 67 | dprintf(("LoadCursor from %X returned %d\n", hinst, rc));
|
|---|
| 68 | return(rc);
|
|---|
| 69 | }
|
|---|
| 70 | //******************************************************************************
|
|---|
| 71 | //******************************************************************************
|
|---|
| 72 | HBITMAP WIN32API LoadBitmapA(HINSTANCE hinst, LPCSTR lpszBitmap)
|
|---|
| 73 | {
|
|---|
| 74 | HBITMAP rc;
|
|---|
| 75 |
|
|---|
| 76 | if((int)lpszBitmap >> 16 != 0)
|
|---|
| 77 | { //convert string name identifier to numeric id
|
|---|
| 78 | dprintf(("lpszBitmap [%s]\n",
|
|---|
| 79 | lpszBitmap));
|
|---|
| 80 |
|
|---|
| 81 | lpszBitmap = (LPCSTR)ConvertNameId(hinst,
|
|---|
| 82 | (char *)lpszBitmap);
|
|---|
| 83 | }
|
|---|
| 84 | else
|
|---|
| 85 | dprintf(("lpszBitmap %08xh\n",
|
|---|
| 86 | (int)lpszBitmap));
|
|---|
| 87 |
|
|---|
| 88 | rc = O32_LoadBitmap(hinst, lpszBitmap);
|
|---|
| 89 |
|
|---|
| 90 | dprintf(("LoadBitmapA returned %08xh\n",
|
|---|
| 91 | rc));
|
|---|
| 92 |
|
|---|
| 93 | return(rc);
|
|---|
| 94 | }
|
|---|
| 95 | //******************************************************************************
|
|---|
| 96 | //******************************************************************************
|
|---|
| 97 | HBITMAP WIN32API LoadBitmapW(HINSTANCE hinst, LPCWSTR lpszBitmap)
|
|---|
| 98 | {
|
|---|
| 99 | char *astring = NULL;
|
|---|
| 100 | HBITMAP rc;
|
|---|
| 101 |
|
|---|
| 102 | if((int)lpszBitmap >> 16 != 0) {//convert string name identifier to numeric id
|
|---|
| 103 | astring = UnicodeToAsciiString((LPWSTR)lpszBitmap);
|
|---|
| 104 | dprintf(("lpszBitmap %s\n", astring));
|
|---|
| 105 |
|
|---|
| 106 | lpszBitmap = (LPWSTR)ConvertNameId(hinst, (char *)astring);
|
|---|
| 107 | }
|
|---|
| 108 | else dprintf(("lpszBitmap %d\n", (int)lpszBitmap));
|
|---|
| 109 |
|
|---|
| 110 | rc = O32_LoadBitmap(hinst, (char *)lpszBitmap);
|
|---|
| 111 | if(astring)
|
|---|
| 112 | FreeAsciiString(astring);
|
|---|
| 113 |
|
|---|
| 114 | dprintf(("LoadBitmapW returned %d\n", rc));
|
|---|
| 115 | return(rc);
|
|---|
| 116 | }
|
|---|
| 117 | //******************************************************************************
|
|---|
| 118 | //******************************************************************************
|
|---|
| 119 | HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor)
|
|---|
| 120 | {
|
|---|
| 121 | char *astring = NULL;
|
|---|
| 122 | HCURSOR rc;
|
|---|
| 123 |
|
|---|
| 124 | if((int)lpszCursor >> 16 != 0) {//convert string name identifier to numeric id
|
|---|
| 125 | astring = UnicodeToAsciiString((LPWSTR)lpszCursor);
|
|---|
| 126 | dprintf(("lpszCursor %s\n", astring));
|
|---|
| 127 | lpszCursor = (LPWSTR)ConvertNameId(hinst, (char *)astring);
|
|---|
| 128 | }
|
|---|
| 129 | else dprintf(("lpszCursor %d\n", (int)lpszCursor));
|
|---|
| 130 |
|
|---|
| 131 | rc = O32_LoadCursor(hinst, (char *)lpszCursor);
|
|---|
| 132 | if(astring)
|
|---|
| 133 | FreeAsciiString(astring);
|
|---|
| 134 |
|
|---|
| 135 | dprintf(("LoadCursorW returned %d\n", rc));
|
|---|
| 136 | return(rc);
|
|---|
| 137 | }
|
|---|
| 138 | //******************************************************************************
|
|---|
| 139 | //TODO: Far from complete, but works for loading resources from exe
|
|---|
| 140 | //fuLoad flag ignored
|
|---|
| 141 | //******************************************************************************
|
|---|
| 142 | HANDLE WIN32API LoadImageA(HINSTANCE hinst, LPCSTR lpszName, UINT uType,
|
|---|
| 143 | int cxDesired, int cyDesired, UINT fuLoad)
|
|---|
| 144 | {
|
|---|
| 145 | HANDLE hRet = 0;
|
|---|
| 146 |
|
|---|
| 147 | dprintf(("OS2LoadImageA NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
|
|---|
| 148 |
|
|---|
| 149 | switch(uType) {
|
|---|
| 150 | case IMAGE_BITMAP:
|
|---|
| 151 | hRet = (HANDLE)LoadBitmapA(hinst, lpszName);
|
|---|
| 152 | break;
|
|---|
| 153 | case IMAGE_CURSOR:
|
|---|
| 154 | hRet = (HANDLE)LoadCursorA(hinst, lpszName);
|
|---|
| 155 | break;
|
|---|
| 156 | case IMAGE_ICON:
|
|---|
| 157 | hRet = (HANDLE)LoadIconA(hinst, lpszName);
|
|---|
| 158 | break;
|
|---|
| 159 | }
|
|---|
| 160 | dprintf(("OS2LoadImageA returned %d\n", (int)hRet));
|
|---|
| 161 |
|
|---|
| 162 | return(hRet);
|
|---|
| 163 | }
|
|---|
| 164 | //******************************************************************************
|
|---|
| 165 | //******************************************************************************
|
|---|
| 166 | HANDLE WIN32API LoadImageW(HINSTANCE hinst, LPCWSTR lpszName, UINT uType,
|
|---|
| 167 | int cxDesired, int cyDesired, UINT fuLoad)
|
|---|
| 168 | {
|
|---|
| 169 | HANDLE hRet = 0;
|
|---|
| 170 |
|
|---|
| 171 | dprintf(("OS2LoadImageW NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
|
|---|
| 172 |
|
|---|
| 173 | switch(uType) {
|
|---|
| 174 | case IMAGE_BITMAP:
|
|---|
| 175 | hRet = (HANDLE)LoadBitmapW(hinst, lpszName);
|
|---|
| 176 | break;
|
|---|
| 177 | case IMAGE_CURSOR:
|
|---|
| 178 | hRet = (HANDLE)LoadCursorW(hinst, lpszName);
|
|---|
| 179 | break;
|
|---|
| 180 | case IMAGE_ICON:
|
|---|
| 181 | hRet = (HANDLE)LoadIconW(hinst, lpszName);
|
|---|
| 182 | break;
|
|---|
| 183 | }
|
|---|
| 184 | dprintf(("OS2LoadImageW returned %d\n", (int)hRet));
|
|---|
| 185 |
|
|---|
| 186 | return(hRet);
|
|---|
| 187 | }
|
|---|
| 188 | //******************************************************************************
|
|---|
| 189 | //******************************************************************************
|
|---|