Changeset 596 for trunk/src/user32/new/loadres.cpp
- Timestamp:
- Aug 20, 1999, 1:52:19 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/loadres.cpp
r345 r596 1 /* $Id: loadres.cpp,v 1. 4 1999-07-20 15:46:53sandervl Exp $ */1 /* $Id: loadres.cpp,v 1.5 1999-08-20 11:52:18 sandervl Exp $ */ 2 2 3 /*4 *5 * Project Odin Software License can be found in LICENSE.TXT6 *7 */8 3 /* 9 4 * Win32 resource API functions for OS/2 … … 11 6 * Copyright 1998 Sander van Leeuwen 12 7 * 8 * 9 * Project Odin Software License can be found in LICENSE.TXT 10 * 13 11 */ 14 12 #include <os2win.h> 15 #include "user32.h" 16 #include "resstring.h" 13 #include <string.h> 14 #include <user32.h> 15 #include <winres.h> 16 #include <heapstring.h> 17 17 18 //NOTE: HINSTANCE 0xFFFFFFFF == hinstance executable19 18 //****************************************************************************** 20 19 //****************************************************************************** 21 20 int WIN32API LoadStringA(HINSTANCE hinst, UINT wID, LPSTR lpBuffer, int cchBuffer) 22 21 { 23 dprintf(("LoadString from %X, id %d buffersize %d\n", hinst, wID, cchBuffer)); 24 return OS2LoadStringAscii(hinst, wID, lpBuffer, cchBuffer); 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); 25 43 } 26 44 //****************************************************************************** … … 28 46 int WIN32API LoadStringW(HINSTANCE hinst, UINT wID, LPWSTR lpBuffer, int cchBuffer) 29 47 { 30 dprintf(("LoadStringW %d\n", wID)); 31 return OS2LoadStringUnicode(hinst, wID, (WCHAR *)lpBuffer, cchBuffer); 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); 32 68 } 33 69 //****************************************************************************** 70 //TODO: Standard windows icons! 34 71 //****************************************************************************** 35 72 HICON WIN32API LoadIconA(HINSTANCE hinst, LPCSTR lpszIcon) … … 38 75 39 76 rc = (HICON)FindResourceA(hinst, lpszIcon, RT_ICONA); 77 if(rc == 0) { 78 rc = (HICON)FindResourceA(hinst, lpszIcon, RT_GROUP_ICONA); 79 } 40 80 dprintf(("LoadIconA (%X) returned %d\n", hinst, rc)); 41 81 return(rc); 42 82 } 43 83 //****************************************************************************** 84 //TODO: Standard windows icons! 44 85 //****************************************************************************** 45 86 HICON WIN32API LoadIconW(HINSTANCE hinst, LPCWSTR lpszIcon) … … 48 89 49 90 rc = (HICON)FindResourceW(hinst, lpszIcon, RT_ICONW); 91 if(rc == 0) { 92 rc = (HICON)FindResourceW(hinst, lpszIcon, RT_GROUP_ICONW); 93 } 50 94 dprintf(("LoadIconW (%X) returned %d\n", hinst, rc)); 51 95 return(rc); 52 96 } 53 97 //****************************************************************************** 98 //TODO: Standard windows cursors! 54 99 //****************************************************************************** 55 100 HCURSOR WIN32API LoadCursorA(HINSTANCE hinst, LPCSTR lpszCursor) … … 57 102 HCURSOR rc; 58 103 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); 104 rc = (HCURSOR) FindResourceA(hinst, lpszCursor, RT_CURSORA); 66 105 67 106 dprintf(("LoadCursor from %X returned %d\n", hinst, rc)); … … 69 108 } 70 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! 71 123 //****************************************************************************** 72 124 HBITMAP WIN32API LoadBitmapA(HINSTANCE hinst, LPCSTR lpszBitmap) … … 74 126 HBITMAP rc; 75 127 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)); 128 rc = (HBITMAP) FindResourceA(hinst, lpszBitmap, RT_BITMAPA); 87 129 88 rc = O32_LoadBitmap(hinst, lpszBitmap); 89 90 dprintf(("LoadBitmapA returned %08xh\n", 91 rc)); 92 93 return(rc); 130 dprintf(("LoadBitmapA from %X returned %d\n", hinst, rc)); 131 return(rc); 94 132 } 95 133 //****************************************************************************** 134 //TODO: Standard windows bitmaps! 96 135 //****************************************************************************** 97 136 HBITMAP WIN32API LoadBitmapW(HINSTANCE hinst, LPCWSTR lpszBitmap) 98 137 { 99 char *astring = NULL;100 138 HBITMAP rc; 101 139 102 if((int)lpszBitmap >> 16 != 0) {//convert string name identifier to numeric id 103 astring = UnicodeToAsciiString((LPWSTR)lpszBitmap); 104 dprintf(("lpszBitmap %s\n", astring)); 140 rc = (HBITMAP) FindResourceW(hinst, lpszBitmap, RT_BITMAPW); 105 141 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)); 142 dprintf(("LoadBitmapW from %X returned %d\n", hinst, rc)); 136 143 return(rc); 137 144 }
Note:
See TracChangeset
for help on using the changeset viewer.