1 | /* $Id: loadres.cpp,v 1.5 1999-08-20 11:52:18 sandervl Exp $ */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Win32 resource API functions for OS/2
|
---|
5 | *
|
---|
6 | * Copyright 1998 Sander van Leeuwen
|
---|
7 | *
|
---|
8 | *
|
---|
9 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
10 | *
|
---|
11 | */
|
---|
12 | #include <os2win.h>
|
---|
13 | #include <string.h>
|
---|
14 | #include <user32.h>
|
---|
15 | #include <winres.h>
|
---|
16 | #include <heapstring.h>
|
---|
17 |
|
---|
18 | //******************************************************************************
|
---|
19 | //******************************************************************************
|
---|
20 | int WIN32API LoadStringA(HINSTANCE hinst, UINT wID, LPSTR lpBuffer, int cchBuffer)
|
---|
21 | {
|
---|
22 | Win32Resource *winres;
|
---|
23 | LPWSTR resstring;
|
---|
24 | int resstrlen = 0;
|
---|
25 |
|
---|
26 | winres = (Win32Resource *)FindResourceA(hinst, (LPSTR)wID, RT_STRINGA);
|
---|
27 | if(winres == NULL) {
|
---|
28 | dprintf(("LoadStringA NOT FOUND from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
|
---|
29 | return 0;
|
---|
30 | }
|
---|
31 |
|
---|
32 | resstring = (LPWSTR)winres->lockResource();
|
---|
33 | if(resstring) {
|
---|
34 | resstrlen = min(lstrlenW(resstring)+1, cchBuffer);
|
---|
35 | lstrcpynWtoA(lpBuffer, resstring, resstrlen);
|
---|
36 | lpBuffer[cchBuffer-1] = 0;
|
---|
37 | dprintf(("LoadStringA %s", lpBuffer));
|
---|
38 | }
|
---|
39 | delete winres;
|
---|
40 |
|
---|
41 | dprintf(("LoadStringA from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
|
---|
42 | return(resstrlen);
|
---|
43 | }
|
---|
44 | //******************************************************************************
|
---|
45 | //******************************************************************************
|
---|
46 | int WIN32API LoadStringW(HINSTANCE hinst, UINT wID, LPWSTR lpBuffer, int cchBuffer)
|
---|
47 | {
|
---|
48 | Win32Resource *winres;
|
---|
49 | LPWSTR resstring;
|
---|
50 | int resstrlen = 0;
|
---|
51 |
|
---|
52 | winres = (Win32Resource *)FindResourceW(hinst, (LPWSTR)wID, RT_STRINGW);
|
---|
53 | if(winres == NULL) {
|
---|
54 | dprintf(("LoadStringW NOT FOUND from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
|
---|
55 | return 0;
|
---|
56 | }
|
---|
57 |
|
---|
58 | resstring = (LPWSTR)winres->lockResource();
|
---|
59 | if(resstring) {
|
---|
60 | resstrlen = min(lstrlenW(resstring)+1, cchBuffer);
|
---|
61 | lstrcpynW(lpBuffer, resstring, resstrlen);
|
---|
62 | lpBuffer[cchBuffer-1] = 0;
|
---|
63 | }
|
---|
64 | delete winres;
|
---|
65 |
|
---|
66 | dprintf(("LoadStringW from %X, id %d buffersize %d\n", hinst, wID, cchBuffer));
|
---|
67 | return(resstrlen);
|
---|
68 | }
|
---|
69 | //******************************************************************************
|
---|
70 | //TODO: Standard windows icons!
|
---|
71 | //******************************************************************************
|
---|
72 | HICON WIN32API LoadIconA(HINSTANCE hinst, LPCSTR lpszIcon)
|
---|
73 | {
|
---|
74 | HICON rc;
|
---|
75 |
|
---|
76 | rc = (HICON)FindResourceA(hinst, lpszIcon, RT_ICONA);
|
---|
77 | if(rc == 0) {
|
---|
78 | rc = (HICON)FindResourceA(hinst, lpszIcon, RT_GROUP_ICONA);
|
---|
79 | }
|
---|
80 | dprintf(("LoadIconA (%X) returned %d\n", hinst, rc));
|
---|
81 | return(rc);
|
---|
82 | }
|
---|
83 | //******************************************************************************
|
---|
84 | //TODO: Standard windows icons!
|
---|
85 | //******************************************************************************
|
---|
86 | HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon)
|
---|
87 | {
|
---|
88 | HICON rc;
|
---|
89 |
|
---|
90 | rc = (HICON)FindResourceW(hinst, lpszIcon, RT_ICONW);
|
---|
91 | if(rc == 0) {
|
---|
92 | rc = (HICON)FindResourceW(hinst, lpszIcon, RT_GROUP_ICONW);
|
---|
93 | }
|
---|
94 | dprintf(("LoadIconW (%X) returned %d\n", hinst, rc));
|
---|
95 | return(rc);
|
---|
96 | }
|
---|
97 | //******************************************************************************
|
---|
98 | //TODO: Standard windows cursors!
|
---|
99 | //******************************************************************************
|
---|
100 | HCURSOR WIN32API LoadCursorA(HINSTANCE hinst, LPCSTR lpszCursor)
|
---|
101 | {
|
---|
102 | HCURSOR rc;
|
---|
103 |
|
---|
104 | rc = (HCURSOR) FindResourceA(hinst, lpszCursor, RT_CURSORA);
|
---|
105 |
|
---|
106 | dprintf(("LoadCursor from %X returned %d\n", hinst, rc));
|
---|
107 | return(rc);
|
---|
108 | }
|
---|
109 | //******************************************************************************
|
---|
110 | //TODO: Standard windows cursors!
|
---|
111 | //******************************************************************************
|
---|
112 | HCURSOR WIN32API LoadCursorW(HINSTANCE hinst, LPCWSTR lpszCursor)
|
---|
113 | {
|
---|
114 | HCURSOR rc;
|
---|
115 |
|
---|
116 | rc = (HCURSOR) FindResourceW(hinst, lpszCursor, RT_CURSORW);
|
---|
117 |
|
---|
118 | dprintf(("LoadCursorW from %X returned %d\n", hinst, rc));
|
---|
119 | return(rc);
|
---|
120 | }
|
---|
121 | //******************************************************************************
|
---|
122 | //TODO: Standard windows bitmaps!
|
---|
123 | //******************************************************************************
|
---|
124 | HBITMAP WIN32API LoadBitmapA(HINSTANCE hinst, LPCSTR lpszBitmap)
|
---|
125 | {
|
---|
126 | HBITMAP rc;
|
---|
127 |
|
---|
128 | rc = (HBITMAP) FindResourceA(hinst, lpszBitmap, RT_BITMAPA);
|
---|
129 |
|
---|
130 | dprintf(("LoadBitmapA from %X returned %d\n", hinst, rc));
|
---|
131 | return(rc);
|
---|
132 | }
|
---|
133 | //******************************************************************************
|
---|
134 | //TODO: Standard windows bitmaps!
|
---|
135 | //******************************************************************************
|
---|
136 | HBITMAP WIN32API LoadBitmapW(HINSTANCE hinst, LPCWSTR lpszBitmap)
|
---|
137 | {
|
---|
138 | HBITMAP rc;
|
---|
139 |
|
---|
140 | rc = (HBITMAP) FindResourceW(hinst, lpszBitmap, RT_BITMAPW);
|
---|
141 |
|
---|
142 | dprintf(("LoadBitmapW from %X returned %d\n", hinst, rc));
|
---|
143 | return(rc);
|
---|
144 | }
|
---|
145 | //******************************************************************************
|
---|
146 | //TODO: Far from complete, but works for loading resources from exe
|
---|
147 | //fuLoad flag ignored
|
---|
148 | //******************************************************************************
|
---|
149 | HANDLE WIN32API LoadImageA(HINSTANCE hinst, LPCSTR lpszName, UINT uType,
|
---|
150 | int cxDesired, int cyDesired, UINT fuLoad)
|
---|
151 | {
|
---|
152 | HANDLE hRet = 0;
|
---|
153 |
|
---|
154 | dprintf(("OS2LoadImageA NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
|
---|
155 |
|
---|
156 | switch(uType) {
|
---|
157 | case IMAGE_BITMAP:
|
---|
158 | hRet = (HANDLE)LoadBitmapA(hinst, lpszName);
|
---|
159 | break;
|
---|
160 | case IMAGE_CURSOR:
|
---|
161 | hRet = (HANDLE)LoadCursorA(hinst, lpszName);
|
---|
162 | break;
|
---|
163 | case IMAGE_ICON:
|
---|
164 | hRet = (HANDLE)LoadIconA(hinst, lpszName);
|
---|
165 | break;
|
---|
166 | }
|
---|
167 | dprintf(("OS2LoadImageA returned %d\n", (int)hRet));
|
---|
168 |
|
---|
169 | return(hRet);
|
---|
170 | }
|
---|
171 | //******************************************************************************
|
---|
172 | //******************************************************************************
|
---|
173 | HANDLE WIN32API LoadImageW(HINSTANCE hinst, LPCWSTR lpszName, UINT uType,
|
---|
174 | int cxDesired, int cyDesired, UINT fuLoad)
|
---|
175 | {
|
---|
176 | HANDLE hRet = 0;
|
---|
177 |
|
---|
178 | dprintf(("OS2LoadImageW NOT COMPLETE (%d,%d)\n", cxDesired, cyDesired));
|
---|
179 |
|
---|
180 | switch(uType) {
|
---|
181 | case IMAGE_BITMAP:
|
---|
182 | hRet = (HANDLE)LoadBitmapW(hinst, lpszName);
|
---|
183 | break;
|
---|
184 | case IMAGE_CURSOR:
|
---|
185 | hRet = (HANDLE)LoadCursorW(hinst, lpszName);
|
---|
186 | break;
|
---|
187 | case IMAGE_ICON:
|
---|
188 | hRet = (HANDLE)LoadIconW(hinst, lpszName);
|
---|
189 | break;
|
---|
190 | }
|
---|
191 | dprintf(("OS2LoadImageW returned %d\n", (int)hRet));
|
---|
192 |
|
---|
193 | return(hRet);
|
---|
194 | }
|
---|
195 | //******************************************************************************
|
---|
196 | //******************************************************************************
|
---|