1 | /* $Id: winres.cpp,v 1.29 2001-03-13 18:45:34 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 | #include <stdio.h>
|
---|
21 | #include <stdlib.h>
|
---|
22 | #include <string.h>
|
---|
23 | #define INCL_WINRES
|
---|
24 | #include <win32type.h>
|
---|
25 | #include <win32api.h>
|
---|
26 | #include <winconst.h>
|
---|
27 | #include <winres.h>
|
---|
28 | #include <misc.h>
|
---|
29 | #include <winimagebase.h>
|
---|
30 | #include <winexebase.h>
|
---|
31 | #include <windllbase.h>
|
---|
32 | #include "cvtresource.h"
|
---|
33 |
|
---|
34 | #define DBG_LOCALLOG DBG_winres
|
---|
35 | #include "dbglocal.h"
|
---|
36 |
|
---|
37 | //******************************************************************************
|
---|
38 | //******************************************************************************
|
---|
39 | PVOID WIN32API ConvertResourceToOS2(HINSTANCE hInstance, LPSTR restype, HRSRC hResource)
|
---|
40 | {
|
---|
41 | PIMAGE_RESOURCE_DATA_ENTRY pData = (PIMAGE_RESOURCE_DATA_ENTRY)hResource;
|
---|
42 | Win32ImageBase *module;
|
---|
43 | char *resdata;
|
---|
44 | int ressize, cvtressize;
|
---|
45 |
|
---|
46 | if(hInstance == 0 || hInstance == -1 || (WinExe && hInstance == WinExe->getInstanceHandle())) {
|
---|
47 | module = (Win32ImageBase *)WinExe;
|
---|
48 | }
|
---|
49 | else {
|
---|
50 | module = (Win32ImageBase *)Win32DllBase::findModule(hInstance);
|
---|
51 | }
|
---|
52 | resdata = (char *)LockResource(LoadResource(hInstance, hResource));
|
---|
53 | ressize = SizeofResource(hInstance, hResource);
|
---|
54 |
|
---|
55 | switch((int)restype) {
|
---|
56 | case NTRT_CURSOR:
|
---|
57 | return ConvertCursor((CursorComponent *)resdata, ressize, &cvtressize);
|
---|
58 |
|
---|
59 | case NTRT_GROUP_CURSOR:
|
---|
60 | return ConvertCursorGroup((CursorHeader *)resdata, ressize, module);
|
---|
61 |
|
---|
62 | case NTRT_NEWMENU:
|
---|
63 | case NTRT_MENU:
|
---|
64 | case NTRT_NEWDIALOG:
|
---|
65 | case NTRT_DIALOG:
|
---|
66 | case NTRT_FONTDIR:
|
---|
67 | case NTRT_FONT:
|
---|
68 | case NTRT_MESSAGETABLE:
|
---|
69 | case NTRT_RCDATA:
|
---|
70 | case NTRT_VERSION:
|
---|
71 | case NTRT_STRING:
|
---|
72 | break;
|
---|
73 |
|
---|
74 | default:
|
---|
75 | break;
|
---|
76 | }
|
---|
77 | dprintf(("ConvertResourceToOS2: Can't convert resource %x (inst %x)", hResource, hInstance));
|
---|
78 | return 0;
|
---|
79 | }
|
---|
80 | //******************************************************************************
|
---|
81 | //******************************************************************************
|
---|
82 | PVOID WIN32API ConvertCursorToOS2(LPVOID lpWinResData)
|
---|
83 | {
|
---|
84 | int ressize, cvtressize;
|
---|
85 |
|
---|
86 | ressize = QueryConvertedCursorSize((CursorComponent *)lpWinResData, 0);
|
---|
87 |
|
---|
88 | return ConvertCursor((CursorComponent *)lpWinResData, ressize, &cvtressize);
|
---|
89 | }
|
---|
90 | //******************************************************************************
|
---|
91 | //******************************************************************************
|
---|
92 | VOID WIN32API FreeOS2Resource(LPVOID lpResource)
|
---|
93 | {
|
---|
94 | free(lpResource);
|
---|
95 | }
|
---|
96 | //******************************************************************************
|
---|
97 | //******************************************************************************
|
---|
98 | ULONG 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_CURSOR:
|
---|
116 | return QueryConvertedCursorSize((CursorComponent *)resdata, ressize);
|
---|
117 |
|
---|
118 | case NTRT_GROUP_ICON:
|
---|
119 | case NTRT_GROUP_CURSOR:
|
---|
120 | case NTRT_ACCELERATORS:
|
---|
121 | case NTRT_NEWMENU:
|
---|
122 | case NTRT_MENU:
|
---|
123 | case NTRT_NEWDIALOG:
|
---|
124 | case NTRT_DIALOG:
|
---|
125 | case NTRT_FONTDIR:
|
---|
126 | case NTRT_FONT:
|
---|
127 | case NTRT_MESSAGETABLE:
|
---|
128 | case NTRT_RCDATA:
|
---|
129 | case NTRT_VERSION:
|
---|
130 | case NTRT_STRING:
|
---|
131 | default:
|
---|
132 | dprintf(("Win32Resource::getOS2Size SHOULDN'T BE CALLED for this resource type (%d) (NOT IMPLEMENTED)!!", restype));
|
---|
133 | break;
|
---|
134 | }
|
---|
135 | return 0;
|
---|
136 | }
|
---|
137 | //******************************************************************************
|
---|
138 | //******************************************************************************
|
---|