source: trunk/src/kernel32/winres.cpp@ 3830

Last change on this file since 3830 was 3625, checked in by sandervl, 25 years ago

resource handling changes

File size: 4.3 KB
Line 
1/* $Id: winres.cpp,v 1.27 2000-05-28 16:45:14 sandervl Exp $ */
2
3/*
4 * Win32 resource class
5 *
6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 *
9 * Project Odin Software License can be found in LICENSE.TXT
10 *
11 *
12 */
13#define INCL_BASE
14#define INCL_WIN
15#define INCL_GPIBITMAPS
16#define INCL_BITMAPFILEFORMAT
17#define INCL_DOSMODULEMGR
18#include <os2wrap.h> //Odin32 OS/2 api wrappers
19#include <stdarg.h>
20#ifdef __IBMCPP__
21#include <builtin.h>
22#endif
23#include <stdio.h>
24#include <stdlib.h>
25#include <string.h>
26#define INCL_WINRES
27#include <win32type.h>
28#include <win32api.h>
29#include <winconst.h>
30#include <winres.h>
31#include <misc.h>
32#include <winimagebase.h>
33#include <winexebase.h>
34#include <windllbase.h>
35#include "cvtresource.h"
36
37#define DBG_LOCALLOG DBG_winres
38#include "dbglocal.h"
39
40//******************************************************************************
41//******************************************************************************
42PVOID WIN32API ConvertResourceToOS2(HINSTANCE hInstance, LPSTR restype, HRSRC hResource)
43{
44 PIMAGE_RESOURCE_DATA_ENTRY pData = (PIMAGE_RESOURCE_DATA_ENTRY)hResource;
45 Win32ImageBase *module;
46 char *resdata;
47 int ressize, cvtressize;
48
49 if(hInstance == 0 || hInstance == -1 || (WinExe && hInstance == WinExe->getInstanceHandle())) {
50 module = (Win32ImageBase *)WinExe;
51 }
52 else {
53 module = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
54 }
55 resdata = (char *)LockResource(LoadResource(hInstance, hResource));
56 ressize = SizeofResource(hInstance, hResource);
57
58 switch((int)restype) {
59 case NTRT_NEWBITMAP:
60 case NTRT_BITMAP:
61 return ConvertBitmap((WINBITMAPINFOHEADER *)resdata, ressize, (PULONG)&cvtressize);
62
63 case NTRT_CURSOR:
64 return ConvertCursor((CursorComponent *)resdata, ressize, &cvtressize);
65
66 case NTRT_GROUP_CURSOR:
67 return ConvertCursorGroup((CursorHeader *)resdata, ressize, module);
68
69 case NTRT_GROUP_ICON:
70 return ConvertIconGroup((IconHeader *)resdata, ressize, module);
71
72 case NTRT_ICON:
73 return ConvertIcon((WINBITMAPINFOHEADER *)resdata, ressize, &cvtressize);
74
75 case NTRT_ACCELERATORS:
76 return ConvertAccelerator((WINACCEL *)resdata, ressize);
77
78 case NTRT_NEWMENU:
79 case NTRT_MENU:
80 case NTRT_NEWDIALOG:
81 case NTRT_DIALOG:
82 case NTRT_FONTDIR:
83 case NTRT_FONT:
84 case NTRT_MESSAGETABLE:
85 case NTRT_RCDATA:
86 case NTRT_VERSION:
87 case NTRT_STRING:
88 break;
89
90 default:
91 break;
92 }
93 dprintf(("ConvertResourceToOS2: Can't convert resource %x (inst %x)", hResource, hInstance));
94 return 0;
95}
96//******************************************************************************
97//******************************************************************************
98ULONG WIN32API QueryConvertedResourceSize(HINSTANCE hInstance, LPSTR restype, HRSRC hResource)
99{
100 PIMAGE_RESOURCE_DATA_ENTRY pData = (PIMAGE_RESOURCE_DATA_ENTRY)hResource;
101 Win32ImageBase *module;
102 char *resdata;
103 int ressize, cvtressize;
104
105 if(hInstance == 0 || hInstance == -1 || (WinExe && hInstance == WinExe->getInstanceHandle())) {
106 module = (Win32ImageBase *)WinExe;
107 }
108 else {
109 module = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
110 }
111 resdata = (char *)LockResource(LoadResource(hInstance, hResource));
112 ressize = SizeofResource(hInstance, hResource);
113
114 switch((int)restype) {
115 case NTRT_NEWBITMAP:
116 case NTRT_BITMAP:
117 return QueryConvertedBitmapSize((WINBITMAPINFOHEADER *)resdata, ressize);
118
119 case NTRT_CURSOR:
120 return QueryConvertedCursorSize((CursorComponent *)resdata, ressize);
121
122 case NTRT_ICON:
123 return QueryConvertedIconSize((WINBITMAPINFOHEADER *)resdata, ressize);
124
125 case NTRT_GROUP_ICON:
126 case NTRT_GROUP_CURSOR:
127 case NTRT_ACCELERATORS:
128 case NTRT_NEWMENU:
129 case NTRT_MENU:
130 case NTRT_NEWDIALOG:
131 case NTRT_DIALOG:
132 case NTRT_FONTDIR:
133 case NTRT_FONT:
134 case NTRT_MESSAGETABLE:
135 case NTRT_RCDATA:
136 case NTRT_VERSION:
137 case NTRT_STRING:
138 default:
139 dprintf(("Win32Resource::getOS2Size SHOULDN'T BE CALLED for this resource type (%d) (NOT IMPLEMENTED)!!", restype));
140 break;
141 }
142 return 0;
143}
144//******************************************************************************
145//******************************************************************************
Note: See TracBrowser for help on using the repository browser.