| 1 | /* $Id: wndclass.cpp,v 1.3 1999-09-15 23:20:41 sandervl Exp $ */
|
|---|
| 2 |
|
|---|
| 3 | /*
|
|---|
| 4 | * Win32 Window Class Managment Code for OS/2
|
|---|
| 5 | *
|
|---|
| 6 | * 18-07-1998 SvL: Merged all class code into this file + bug fixes
|
|---|
| 7 | * Register all system classes at dll init
|
|---|
| 8 | * Rewrote incorrect callback code
|
|---|
| 9 | *
|
|---|
| 10 | * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
|
|---|
| 11 | *
|
|---|
| 12 | *
|
|---|
| 13 | * Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 14 | *
|
|---|
| 15 | */
|
|---|
| 16 | #include <os2win.h>
|
|---|
| 17 | #include <stdarg.h>
|
|---|
| 18 | #include <stdio.h>
|
|---|
| 19 | #include <string.h>
|
|---|
| 20 | #include <stdlib.h>
|
|---|
| 21 | #include <assert.h>
|
|---|
| 22 | #include <misc.h>
|
|---|
| 23 | #include <wndproc.h>
|
|---|
| 24 | #include <wndclass.h>
|
|---|
| 25 | #include <nameid.h>
|
|---|
| 26 | #include <spy.h>
|
|---|
| 27 | #include <wprocess.h>
|
|---|
| 28 | #include "hooks.h"
|
|---|
| 29 | #include "wndmsg.h"
|
|---|
| 30 |
|
|---|
| 31 | //default window handlers that are registered by RegisterClass are called
|
|---|
| 32 | //in this callback handler
|
|---|
| 33 | LRESULT EXPENTRY_O32 OS2ToWinCallback(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
|---|
| 34 |
|
|---|
| 35 | DWORD MapOEMToRealKey(DWORD wParam, DWORD lParam);
|
|---|
| 36 |
|
|---|
| 37 | WNDPROC_O32 ButtonHandler = 0;
|
|---|
| 38 | WNDPROC_O32 ListboxHandler = 0;
|
|---|
| 39 | WNDPROC_O32 ComboboxHandler = 0;
|
|---|
| 40 | WNDPROC_O32 EditHandler = 0;
|
|---|
| 41 | WNDPROC_O32 MdiClientHandler = 0;
|
|---|
| 42 | WNDPROC_O32 ScrollbarHandler = 0;
|
|---|
| 43 | WNDPROC_O32 StaticHandler = 0;
|
|---|
| 44 |
|
|---|
| 45 | HWND hwndButton = 0;
|
|---|
| 46 | HWND hwndListbox = 0;
|
|---|
| 47 | HWND hwndEdit = 0;
|
|---|
| 48 | HWND hwndCombobox = 0;
|
|---|
| 49 | HWND hwndScrollbar = 0;
|
|---|
| 50 | HWND hwndMdiClient = 0;
|
|---|
| 51 | HWND hwndStatic = 0;
|
|---|
| 52 |
|
|---|
| 53 | Win32WindowClass *ButtonClass = 0;
|
|---|
| 54 | Win32WindowClass *ListboxClass = 0;
|
|---|
| 55 | Win32WindowClass *EditClass = 0;
|
|---|
| 56 | Win32WindowClass *ComboboxClass = 0;
|
|---|
| 57 | Win32WindowClass *MdiClientClass = 0;
|
|---|
| 58 | Win32WindowClass *ScrollbarClass = 0;
|
|---|
| 59 | Win32WindowClass *StaticClass = 0;
|
|---|
| 60 | //******************************************************************************
|
|---|
| 61 | //******************************************************************************
|
|---|
| 62 | LRESULT WIN32API ButtonCallback(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 63 | {
|
|---|
| 64 | return ButtonHandler(hwnd, Msg, wParam, lParam);
|
|---|
| 65 | }
|
|---|
| 66 | //******************************************************************************
|
|---|
| 67 | //******************************************************************************
|
|---|
| 68 | LRESULT WIN32API ListboxCallback(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 69 | {
|
|---|
| 70 | return ListboxHandler(hwnd, Msg, wParam, lParam);
|
|---|
| 71 | }
|
|---|
| 72 | //******************************************************************************
|
|---|
| 73 | //******************************************************************************
|
|---|
| 74 | LRESULT WIN32API ComboboxCallback(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 75 | {
|
|---|
| 76 | return ComboboxHandler(hwnd, Msg, wParam, lParam);
|
|---|
| 77 | }
|
|---|
| 78 | //******************************************************************************
|
|---|
| 79 | //******************************************************************************
|
|---|
| 80 | LRESULT WIN32API MdiClientCallback(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 81 | {
|
|---|
| 82 | return MdiClientHandler(hwnd, Msg, wParam, lParam);
|
|---|
| 83 | }
|
|---|
| 84 | //******************************************************************************
|
|---|
| 85 | //******************************************************************************
|
|---|
| 86 | LRESULT WIN32API EditCallback(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 87 | {
|
|---|
| 88 | return EditHandler(hwnd, Msg, wParam, lParam);
|
|---|
| 89 | }
|
|---|
| 90 | //******************************************************************************
|
|---|
| 91 | //******************************************************************************
|
|---|
| 92 | LRESULT WIN32API ScrollbarCallback(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 93 | {
|
|---|
| 94 | return ScrollbarHandler(hwnd, Msg, wParam, lParam);
|
|---|
| 95 | }
|
|---|
| 96 | //******************************************************************************
|
|---|
| 97 | //******************************************************************************
|
|---|
| 98 | LRESULT WIN32API StaticCallback(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 99 | {
|
|---|
| 100 | return StaticHandler(hwnd, Msg, wParam, lParam);
|
|---|
| 101 | }
|
|---|
| 102 | //******************************************************************************
|
|---|
| 103 | //SvL: 18-7-'98, Registers system window classes (button, listbox etc etc)
|
|---|
| 104 | //******************************************************************************
|
|---|
| 105 | void RegisterSystemClasses(ULONG hModule)
|
|---|
| 106 | {
|
|---|
| 107 | WNDCLASSA wndclass;
|
|---|
| 108 | HWND hwnd;
|
|---|
| 109 |
|
|---|
| 110 | if(O32_GetClassInfo(NULL, "BUTTON", &wndclass)) {
|
|---|
| 111 | dprintf(("Create BUTTON System class"));
|
|---|
| 112 | ButtonClass = new Win32WindowClass(ButtonCallback, "BUTTON", hModule);
|
|---|
| 113 | ButtonHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
|
|---|
| 114 | hwndButton = O32_CreateWindow("BUTTON", "BUTTON", 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|---|
| 115 | if(hwndButton == 0) {
|
|---|
| 116 | dprintf(("RegisterSystemClasses failed!!"));
|
|---|
| 117 | }
|
|---|
| 118 | O32_SetClassLong(hwndButton, GCL_WNDPROC, (LONG)Win32WindowClass::GetOS2ClassCallback());
|
|---|
| 119 | }
|
|---|
| 120 | if(O32_GetClassInfo(NULL, "LISTBOX", &wndclass)) {
|
|---|
| 121 | dprintf(("Create LISTBOX System class"));
|
|---|
| 122 | ListboxClass = new Win32WindowClass(ListboxCallback, "LISTBOX", hModule);
|
|---|
| 123 | ListboxHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
|
|---|
| 124 | hwndListbox = O32_CreateWindow("LISTBOX", "LISTBOX", 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|---|
| 125 | if(hwndListbox == 0) {
|
|---|
| 126 | dprintf(("RegisterSystemClasses failed!!"));
|
|---|
| 127 | }
|
|---|
| 128 | O32_SetClassLong(hwndListbox, GCL_WNDPROC, (LONG)Win32WindowClass::GetOS2ClassCallback());
|
|---|
| 129 | }
|
|---|
| 130 | if(O32_GetClassInfo(NULL, "COMBOBOX", &wndclass)) {
|
|---|
| 131 | dprintf(("Create COMBOBOX System class"));
|
|---|
| 132 | ComboboxClass = new Win32WindowClass(ComboboxCallback, "COMBOBOX", hModule);
|
|---|
| 133 | ComboboxHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
|
|---|
| 134 | hwndCombobox = O32_CreateWindow("COMBOBOX", "COMBOBOX", 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|---|
| 135 | if(hwndCombobox == 0) {
|
|---|
| 136 | dprintf(("RegisterSystemClasses failed!!"));
|
|---|
| 137 | }
|
|---|
| 138 | O32_SetClassLong(hwndCombobox, GCL_WNDPROC, (LONG)Win32WindowClass::GetOS2ClassCallback());
|
|---|
| 139 | }
|
|---|
| 140 | if(O32_GetClassInfo(NULL, "EDIT", &wndclass)) {
|
|---|
| 141 | dprintf(("Create EDIT System class"));
|
|---|
| 142 | EditClass = new Win32WindowClass(EditCallback, "EDIT", hModule);
|
|---|
| 143 | EditHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
|
|---|
| 144 | hwndEdit = O32_CreateWindow("EDIT", "EDIT", 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|---|
| 145 | if(hwndEdit == 0) {
|
|---|
| 146 | dprintf(("RegisterSystemClasses failed!!"));
|
|---|
| 147 | }
|
|---|
| 148 | O32_SetClassLong(hwndEdit, GCL_WNDPROC, (LONG)Win32WindowClass::GetOS2ClassCallback());
|
|---|
| 149 | }
|
|---|
| 150 | //TODO: This doens't work yet!! (need to create a normal window as parent)
|
|---|
| 151 | if(O32_GetClassInfo(NULL, "MDICLIENT", &wndclass)) {
|
|---|
| 152 | dprintf(("Create MDICLIENT System class"));
|
|---|
| 153 | MdiClientClass = new Win32WindowClass(MdiClientCallback, "MDICLIENT", hModule);
|
|---|
| 154 | MdiClientHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
|
|---|
| 155 | hwndMdiClient = O32_CreateWindow("MDICLIENT", "MDICLIENT", WS_CHILD, 0, 0, 0, 0, hwndListbox, 0, 0, 0);
|
|---|
| 156 | if(hwndMdiClient == 0) {
|
|---|
| 157 | dprintf(("RegisterSystemClasses failed!!"));
|
|---|
| 158 | }
|
|---|
| 159 | O32_SetClassLong(hwndMdiClient, GCL_WNDPROC, (LONG)Win32WindowClass::GetOS2ClassCallback());
|
|---|
| 160 | }
|
|---|
| 161 | if(O32_GetClassInfo(NULL, "SCROLLBAR", &wndclass)) {
|
|---|
| 162 | dprintf(("Create SCROLLBAR System class"));
|
|---|
| 163 | ScrollbarClass = new Win32WindowClass(ScrollbarCallback, "SCROLLBAR", hModule);
|
|---|
| 164 | ScrollbarHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
|
|---|
| 165 | hwndScrollbar = O32_CreateWindow("SCROLLBAR", "SCROLLBAR", 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|---|
| 166 | if(hwndScrollbar == 0) {
|
|---|
| 167 | dprintf(("RegisterSystemClasses failed!!"));
|
|---|
| 168 | }
|
|---|
| 169 | O32_SetClassLong(hwndScrollbar, GCL_WNDPROC, (LONG)Win32WindowClass::GetOS2ClassCallback());
|
|---|
| 170 | }
|
|---|
| 171 | if(O32_GetClassInfo(NULL, "STATIC", &wndclass)) {
|
|---|
| 172 | dprintf(("Create STATIC System class"));
|
|---|
| 173 | StaticClass = new Win32WindowClass(StaticCallback, "STATIC", hModule);
|
|---|
| 174 | StaticHandler = (WNDPROC_O32)wndclass.lpfnWndProc;
|
|---|
| 175 | hwndStatic = O32_CreateWindow("STATIC", "STATIC", 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|---|
| 176 | if(hwndStatic == 0) {
|
|---|
| 177 | dprintf(("RegisterSystemClasses failed!!"));
|
|---|
| 178 | }
|
|---|
| 179 | O32_SetClassLong(hwndStatic, GCL_WNDPROC, (LONG)Win32WindowClass::GetOS2ClassCallback());
|
|---|
| 180 | }
|
|---|
| 181 | //TODO: More standard classes in win95/NT4?
|
|---|
| 182 | }
|
|---|
| 183 | //******************************************************************************
|
|---|
| 184 | //******************************************************************************
|
|---|
| 185 | void UnregisterSystemClasses()
|
|---|
| 186 | {
|
|---|
| 187 | dprintf(("KERNEL32: UnregisterSystemClasses"));
|
|---|
| 188 | if(hwndButton) O32_DestroyWindow(hwndButton);
|
|---|
| 189 | if(hwndListbox) O32_DestroyWindow(hwndListbox);
|
|---|
| 190 | if(hwndCombobox) O32_DestroyWindow(hwndCombobox);
|
|---|
| 191 | if(hwndMdiClient) O32_DestroyWindow(hwndMdiClient);
|
|---|
| 192 | if(hwndEdit) O32_DestroyWindow(hwndEdit);
|
|---|
| 193 | if(hwndScrollbar) O32_DestroyWindow(hwndScrollbar);
|
|---|
| 194 | if(hwndStatic) O32_DestroyWindow(hwndStatic);
|
|---|
| 195 | if(ButtonClass) delete ButtonClass;
|
|---|
| 196 | if(ListboxClass) delete ListboxClass;
|
|---|
| 197 | if(EditClass) delete EditClass;
|
|---|
| 198 | if(ComboboxClass) delete ComboboxClass;
|
|---|
| 199 | if(MdiClientClass) delete MdiClientClass;
|
|---|
| 200 | if(ScrollbarClass) delete ScrollbarClass;
|
|---|
| 201 | if(StaticClass) delete StaticClass;
|
|---|
| 202 | ButtonClass = NULL;
|
|---|
| 203 | EditClass = NULL;
|
|---|
| 204 | ListboxClass = NULL;
|
|---|
| 205 | ComboboxClass = NULL;
|
|---|
| 206 | MdiClientClass = NULL;
|
|---|
| 207 | ScrollbarClass = NULL;
|
|---|
| 208 | StaticClass = NULL;
|
|---|
| 209 | }
|
|---|
| 210 | //******************************************************************************
|
|---|
| 211 | //SvL: 18-7-'98: Moved here from user32.cpp
|
|---|
| 212 | //******************************************************************************
|
|---|
| 213 | ATOM WIN32API RegisterClassA(const WNDCLASSA *lpWndClass)
|
|---|
| 214 | {
|
|---|
| 215 | ATOM rc;
|
|---|
| 216 | WNDCLASSA wc;
|
|---|
| 217 |
|
|---|
| 218 | #ifdef DEBUG
|
|---|
| 219 | WriteLog("USER32: RegisterClassA\n");
|
|---|
| 220 | WriteLog("USER32: lpWndClass->style %X\n", lpWndClass->style);
|
|---|
| 221 | WriteLog("USER32: lpWndClass->lpfnWndProc %X\n", lpWndClass->lpfnWndProc);
|
|---|
| 222 | WriteLog("USER32: lpWndClass->cbClsExtra %X\n", lpWndClass->cbClsExtra);
|
|---|
| 223 | WriteLog("USER32: lpWndClass->cbWndExtra %X\n", lpWndClass->cbWndExtra);
|
|---|
| 224 | WriteLog("USER32: lpWndClass->hInstance %X\n", lpWndClass->hInstance);
|
|---|
| 225 | WriteLog("USER32: lpWndClass->hIcon %X\n", lpWndClass->hIcon);
|
|---|
| 226 | WriteLog("USER32: lpWndClass->hCursor %X\n", lpWndClass->hCursor);
|
|---|
| 227 | WriteLog("USER32: lpWndClass->hbrBackground %X\n", lpWndClass->hbrBackground);
|
|---|
| 228 | WriteLog("USER32: lpWndClass->lpszMenuName %X\n", lpWndClass->lpszMenuName);
|
|---|
| 229 | if((int)lpWndClass->lpszClassName >> 16 == 0)
|
|---|
| 230 | WriteLog("USER32: lpWndClass->lpszClassName %X\n", lpWndClass->lpszClassName);
|
|---|
| 231 | else WriteLog("USER32: lpWndClass->lpszClassName %s\n", lpWndClass->lpszClassName);
|
|---|
| 232 | #endif
|
|---|
| 233 | memcpy(&wc, lpWndClass, sizeof(WNDCLASSA));
|
|---|
| 234 |
|
|---|
| 235 | if((int)wc.lpszMenuName >> 16 != 0) {//convert string name identifier to numeric id
|
|---|
| 236 | dprintf(("USER32: lpszMenuName %s\n", wc.lpszMenuName));
|
|---|
| 237 | *(int *)&wc.lpszMenuName = ConvertNameId(0, (char *)wc.lpszMenuName);
|
|---|
| 238 | dprintf(("USER32: Menu id = %d\n", (int)wc.lpszMenuName));
|
|---|
| 239 | }
|
|---|
| 240 | #ifdef DEBUG
|
|---|
| 241 | if(wc.style & (CS_PARENTDC | CS_CLASSDC)) {
|
|---|
| 242 | dprintf(("USER32: Class uses an unsupported style!!!\n"));
|
|---|
| 243 | }
|
|---|
| 244 | #endif
|
|---|
| 245 | //These are not supported by Open32
|
|---|
| 246 | wc.style &= ~(CS_PARENTDC | CS_CLASSDC);
|
|---|
| 247 |
|
|---|
| 248 | wc.lpfnWndProc = (WNDPROC)Win32WindowClass::GetOS2ClassCallback();
|
|---|
| 249 | rc = O32_RegisterClass(&wc);
|
|---|
| 250 | if(rc) {
|
|---|
| 251 | Win32WindowClass *wndclass = new Win32WindowClass((WNDPROC)lpWndClass->lpfnWndProc, (LPSTR)wc.lpszClassName, wc.hInstance);
|
|---|
| 252 | }
|
|---|
| 253 | dprintf(("USER32: RegisterClass returned %d (%d)\n", rc, GetLastError()));
|
|---|
| 254 | return(rc);
|
|---|
| 255 | }
|
|---|
| 256 | //******************************************************************************
|
|---|
| 257 | //SvL: 18-7-'98: Moved here from user32.cpp
|
|---|
| 258 | //******************************************************************************
|
|---|
| 259 | ATOM WIN32API RegisterClassExA(const WNDCLASSEXA *lpWndClass)
|
|---|
| 260 | {
|
|---|
| 261 | ATOM rc;
|
|---|
| 262 | WNDCLASSEXA wc;
|
|---|
| 263 |
|
|---|
| 264 | #ifdef DEBUG
|
|---|
| 265 | WriteLog("USER32: lpWndClass->cbSize %X\n", lpWndClass->cbSize);
|
|---|
| 266 | WriteLog("USER32: lpWndClass->style %X\n", lpWndClass->style);
|
|---|
| 267 | WriteLog("USER32: lpWndClass->lpfnWndProc %X\n", lpWndClass->lpfnWndProc);
|
|---|
| 268 | WriteLog("USER32: lpWndClass->cbClsExtra %X\n", lpWndClass->cbClsExtra);
|
|---|
| 269 | WriteLog("USER32: lpWndClass->cbWndExtra %X\n", lpWndClass->cbWndExtra);
|
|---|
| 270 | WriteLog("USER32: lpWndClass->hInstance %X\n", lpWndClass->hInstance);
|
|---|
| 271 | WriteLog("USER32: lpWndClass->hIcon %X\n", lpWndClass->hIcon);
|
|---|
| 272 | WriteLog("USER32: lpWndClass->hCursor %X\n", lpWndClass->hCursor);
|
|---|
| 273 | WriteLog("USER32: lpWndClass->hbrBackground %X\n", lpWndClass->hbrBackground);
|
|---|
| 274 | WriteLog("USER32: lpWndClass->lpszMenuName %X\n", lpWndClass->lpszMenuName);
|
|---|
| 275 | if((int)lpWndClass->lpszClassName >> 16 == 0)
|
|---|
| 276 | WriteLog("USER32: lpWndClass->lpszClassName %X\n", lpWndClass->lpszClassName);
|
|---|
| 277 | else WriteLog("USER32: lpWndClass->lpszClassName %s\n", lpWndClass->lpszClassName);
|
|---|
| 278 | #endif
|
|---|
| 279 | memcpy(&wc, lpWndClass, sizeof(WNDCLASSEXA));
|
|---|
| 280 |
|
|---|
| 281 | if((int)wc.lpszMenuName >> 16 != 0) {//convert string name identifier to numeric id
|
|---|
| 282 | dprintf(("USER32: lpszMenuName %s\n", wc.lpszMenuName));
|
|---|
| 283 | *(int *)&wc.lpszMenuName = ConvertNameId(0, (char *)wc.lpszMenuName);
|
|---|
| 284 | dprintf(("USER32: Menu id = %d\n", (int)wc.lpszMenuName));
|
|---|
| 285 | }
|
|---|
| 286 | if(wc.cbSize != sizeof(WNDCLASSEXA))
|
|---|
| 287 | return(0);
|
|---|
| 288 |
|
|---|
| 289 | #ifdef DEBUG
|
|---|
| 290 | if(wc.style & (CS_PARENTDC | CS_CLASSDC)) {
|
|---|
| 291 | dprintf(("USER32: Class uses an unsupported style!!!\n"));
|
|---|
| 292 | }
|
|---|
| 293 | #endif
|
|---|
| 294 | //These are not supported by Open32
|
|---|
| 295 | wc.style &= ~(CS_PARENTDC | CS_CLASSDC);
|
|---|
| 296 |
|
|---|
| 297 | wc.lpfnWndProc = (WNDPROC)Win32WindowClass::GetOS2ClassCallback();
|
|---|
| 298 |
|
|---|
| 299 | rc = O32_RegisterClass((WNDCLASSA *)&wc.style);
|
|---|
| 300 | if(rc) {
|
|---|
| 301 | Win32WindowClass *wndclass = new Win32WindowClass((WNDPROC)lpWndClass->lpfnWndProc, (LPSTR)wc.lpszClassName, wc.hInstance);
|
|---|
| 302 | }
|
|---|
| 303 | #ifdef DEBUG
|
|---|
| 304 | WriteLog("USER32: RegisterClassExA, not completely supported, returned %d\n", rc);
|
|---|
| 305 | if(rc == 0)
|
|---|
| 306 | WriteLog("USER32: GetLastError returned %X\n", GetLastError());
|
|---|
| 307 |
|
|---|
| 308 | #endif
|
|---|
| 309 | return(rc);
|
|---|
| 310 | }
|
|---|
| 311 | //******************************************************************************
|
|---|
| 312 | //******************************************************************************
|
|---|
| 313 | WORD WIN32API RegisterClassW(const WNDCLASSW *lpwc)
|
|---|
| 314 | {
|
|---|
| 315 | ATOM rc;
|
|---|
| 316 | WNDCLASSA wclass;
|
|---|
| 317 |
|
|---|
| 318 | dprintf(("RegisterClassW\n"));
|
|---|
| 319 | memcpy(&wclass, lpwc, sizeof(WNDCLASSA));
|
|---|
| 320 | if(wclass.lpszMenuName && ((int)wclass.lpszMenuName >> 16 != 0)) {
|
|---|
| 321 | wclass.lpszMenuName = UnicodeToAsciiString((LPWSTR)lpwc->lpszMenuName);
|
|---|
| 322 | }
|
|---|
| 323 | if(wclass.lpszClassName && ((int)wclass.lpszClassName >> 16 != 0)) {
|
|---|
| 324 | wclass.lpszClassName = UnicodeToAsciiString((LPWSTR)lpwc->lpszClassName);
|
|---|
| 325 | }
|
|---|
| 326 |
|
|---|
| 327 | rc = RegisterClassA(&wclass);
|
|---|
| 328 |
|
|---|
| 329 | //TODO: Assuming RegisterClass doesn't mess up our structure
|
|---|
| 330 | if(lpwc->lpszMenuName && ((int)lpwc->lpszMenuName >> 16 != 0)) {
|
|---|
| 331 | FreeAsciiString((char *)wclass.lpszMenuName);
|
|---|
| 332 | }
|
|---|
| 333 | if(lpwc->lpszClassName && ((int)lpwc->lpszClassName >> 16 != 0)) {
|
|---|
| 334 | FreeAsciiString((char *)wclass.lpszClassName);
|
|---|
| 335 | }
|
|---|
| 336 | return(rc);
|
|---|
| 337 | }
|
|---|
| 338 | //******************************************************************************
|
|---|
| 339 | //******************************************************************************
|
|---|
| 340 | ATOM WIN32API RegisterClassExW(CONST WNDCLASSEXW *lpwc)
|
|---|
| 341 | {
|
|---|
| 342 | ATOM rc;
|
|---|
| 343 | WNDCLASSEXA wclass;
|
|---|
| 344 |
|
|---|
| 345 | dprintf(("RegisterClassExW\n"));
|
|---|
| 346 | memcpy(&wclass, lpwc, sizeof(WNDCLASSEXA));
|
|---|
| 347 | if(wclass.lpszMenuName && ((int)wclass.lpszMenuName >> 16 != 0)) {
|
|---|
| 348 | wclass.lpszMenuName = UnicodeToAsciiString((LPWSTR)lpwc->lpszMenuName);
|
|---|
| 349 | }
|
|---|
| 350 | if(wclass.lpszClassName && ((int)wclass.lpszClassName >> 16 != 0)) {
|
|---|
| 351 | wclass.lpszClassName = UnicodeToAsciiString((LPWSTR)lpwc->lpszClassName);
|
|---|
| 352 | }
|
|---|
| 353 |
|
|---|
| 354 | rc = RegisterClassExA(&wclass);
|
|---|
| 355 |
|
|---|
| 356 | //TODO: Assuming RegisterClassEx doesn't mess up our structure
|
|---|
| 357 | if(lpwc->lpszMenuName && ((int)lpwc->lpszMenuName >> 16 != 0)) {
|
|---|
| 358 | FreeAsciiString((char *)wclass.lpszMenuName);
|
|---|
| 359 | }
|
|---|
| 360 | if(lpwc->lpszClassName && ((int)lpwc->lpszClassName >> 16 != 0)) {
|
|---|
| 361 | FreeAsciiString((char *)wclass.lpszClassName);
|
|---|
| 362 | }
|
|---|
| 363 | return(rc);
|
|---|
| 364 | }
|
|---|
| 365 | //******************************************************************************
|
|---|
| 366 | //******************************************************************************
|
|---|
| 367 | BOOL WIN32API UnregisterClassA(LPCSTR lpszClassName, HINSTANCE hinst)
|
|---|
| 368 | {
|
|---|
| 369 | BOOL rc;
|
|---|
| 370 |
|
|---|
| 371 | Win32WindowClass::UnregisterClass(hinst, (LPSTR)lpszClassName);
|
|---|
| 372 | rc = O32_UnregisterClass(lpszClassName, hinst);
|
|---|
| 373 | dprintf(("USER32: OS2UnregisterClassA returned %d\n", rc));
|
|---|
| 374 |
|
|---|
| 375 | //Spintest returns FALSE in dll termination, so pretend it succeeded
|
|---|
| 376 | return(TRUE);
|
|---|
| 377 | }
|
|---|
| 378 | //******************************************************************************
|
|---|
| 379 | //******************************************************************************
|
|---|
| 380 | BOOL WIN32API UnregisterClassW(LPCWSTR lpszClassName, HINSTANCE hinst)
|
|---|
| 381 | {
|
|---|
| 382 | char *astring = NULL;
|
|---|
| 383 | BOOL rc;
|
|---|
| 384 |
|
|---|
| 385 | dprintf(("USER32: OS2UnregisterClassW\n"));
|
|---|
| 386 | if((int)lpszClassName >> 16 != 0) {
|
|---|
| 387 | astring = UnicodeToAsciiString((LPWSTR)lpszClassName);
|
|---|
| 388 | }
|
|---|
| 389 | else astring = (char *)lpszClassName;
|
|---|
| 390 |
|
|---|
| 391 | Win32WindowClass::UnregisterClass(hinst, (LPSTR)astring);
|
|---|
| 392 | rc = O32_UnregisterClass(astring, hinst);
|
|---|
| 393 | if((int)astring >> 16 != 0) {
|
|---|
| 394 | FreeAsciiString(astring);
|
|---|
| 395 | }
|
|---|
| 396 | //Spintest returns FALSE in dll termination, so pretend it succeeded
|
|---|
| 397 | return(TRUE);
|
|---|
| 398 | }
|
|---|
| 399 | //******************************************************************************
|
|---|
| 400 | //******************************************************************************
|
|---|
| 401 | BOOL WIN32API GetClassInfoA(HINSTANCE arg1, LPCSTR arg2, WNDCLASSA * arg3)
|
|---|
| 402 | {
|
|---|
| 403 | BOOL rc;
|
|---|
| 404 |
|
|---|
| 405 | dprintf(("USER32: OS2GetClassInfoA\n"));
|
|---|
| 406 | rc = O32_GetClassInfo(arg1, arg2, (WNDCLASSA *)arg3);
|
|---|
| 407 | if(rc == TRUE) {
|
|---|
| 408 | arg3->lpfnWndProc = (WNDPROC)Win32WindowClass::GetClassCallback((LPSTR)arg2);
|
|---|
| 409 | }
|
|---|
| 410 | return(rc);
|
|---|
| 411 | }
|
|---|
| 412 | //******************************************************************************
|
|---|
| 413 | //******************************************************************************
|
|---|
| 414 | BOOL WIN32API GetClassInfoW(HINSTANCE hinst,
|
|---|
| 415 | LPCWSTR lpszClass,
|
|---|
| 416 | WNDCLASSW *lpwc)
|
|---|
| 417 | {
|
|---|
| 418 | WNDCLASSA wclass;
|
|---|
| 419 | BOOL rc;
|
|---|
| 420 | char *szClass = NULL;
|
|---|
| 421 |
|
|---|
| 422 | dprintf(("USER32: OS2GetClassInfoW\n"));
|
|---|
| 423 | if((int)lpszClass >> 16 != 0) {
|
|---|
| 424 | szClass = UnicodeToAsciiString((LPWSTR)lpszClass);
|
|---|
| 425 | dprintf(("USER32: OS2GetClassInfoW %s\n", szClass));
|
|---|
| 426 | }
|
|---|
| 427 | else szClass = (char *)lpszClass;
|
|---|
| 428 |
|
|---|
| 429 | rc = GetClassInfoA(hinst, szClass, &wclass);
|
|---|
| 430 | if(rc == TRUE) {
|
|---|
| 431 | memcpy(lpwc, &wclass, sizeof(WNDCLASSA));
|
|---|
| 432 | //TODO: Memory leak (create class object at RegisterClass and delete it at UnregisterClass)
|
|---|
| 433 | if(lpwc->lpszMenuName && ((int)lpwc->lpszMenuName >> 16 != 0)) {
|
|---|
| 434 | lpwc->lpszMenuName = (LPCWSTR)malloc(strlen(wclass.lpszMenuName)*sizeof(WCHAR)+2);
|
|---|
| 435 | AsciiToUnicode((char *)wclass.lpszMenuName, (LPWSTR)lpwc->lpszMenuName);
|
|---|
| 436 | }
|
|---|
| 437 | if(lpwc->lpszClassName && ((int)lpwc->lpszClassName >> 16 != 0)) {
|
|---|
| 438 | lpwc->lpszClassName = (LPCWSTR)malloc(strlen(wclass.lpszClassName)*sizeof(WCHAR)+2);
|
|---|
| 439 | AsciiToUnicode((char *)wclass.lpszClassName, (LPWSTR)lpwc->lpszClassName);
|
|---|
| 440 | }
|
|---|
| 441 | }
|
|---|
| 442 | dprintf(("USER32: OS2GetClassInfoW returned %d\n", rc));
|
|---|
| 443 | return(rc);
|
|---|
| 444 | }
|
|---|
| 445 | /****************************************************************************
|
|---|
| 446 | * Name : BOOL WIN32API GetClassInfoExA
|
|---|
| 447 | * Purpose : The GetClassInfoEx function retrieves information about a window
|
|---|
| 448 | * class, including the handle of the small icon associated with the
|
|---|
| 449 | * window class. GetClassInfo does not retrieve the handle of the small icon.
|
|---|
| 450 | * Parameters: HINSTANCE hinst handle of application instance
|
|---|
| 451 | * LPCTSTR lpszClass address of class name string
|
|---|
| 452 | * LPWNDCLASSEX lpwcx address of structure for class data
|
|---|
| 453 | * Variables :
|
|---|
| 454 | * Result : If the function finds a matching class and successfully copies
|
|---|
| 455 | * the data, the return value is TRUE;
|
|---|
| 456 | * otherwise, it is FALSE.
|
|---|
| 457 | * To get extended error information, call GetLastError.
|
|---|
| 458 | * Remark : PH: does not obtain handle of the small icon
|
|---|
| 459 | * Status : UNTESTED STUB
|
|---|
| 460 | *
|
|---|
| 461 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 462 | *****************************************************************************/
|
|---|
| 463 | BOOL WIN32API GetClassInfoExA(HINSTANCE hInstance,
|
|---|
| 464 | LPCTSTR lpszClass,
|
|---|
| 465 | LPWNDCLASSEXA lpwcx)
|
|---|
| 466 | {
|
|---|
| 467 | WNDCLASSA WndClass; /* structure for data transformation */
|
|---|
| 468 | BOOL bResult; /* result of subsequent function calls */
|
|---|
| 469 |
|
|---|
| 470 | dprintf(("USER32:GetClassInfoExA (%08xh,%s,%08x).\n",
|
|---|
| 471 | hInstance,
|
|---|
| 472 | lpszClass,
|
|---|
| 473 | lpwcx));
|
|---|
| 474 |
|
|---|
| 475 | /* convert the structures */
|
|---|
| 476 | memcpy((PVOID)&WndClass,
|
|---|
| 477 | (PVOID)&lpwcx->style,
|
|---|
| 478 | sizeof(WndClass) );
|
|---|
| 479 |
|
|---|
| 480 | bResult = GetClassInfoA(hInstance,
|
|---|
| 481 | lpszClass,
|
|---|
| 482 | (WNDCLASSA *)&WndClass);
|
|---|
| 483 | if (bResult == TRUE)
|
|---|
| 484 | {
|
|---|
| 485 | /* convert data back to original structure */
|
|---|
| 486 | memcpy((PVOID)&lpwcx->style,
|
|---|
| 487 | (PVOID)&WndClass,
|
|---|
| 488 | sizeof(WndClass) );
|
|---|
| 489 | lpwcx->cbSize = sizeof(WNDCLASSEXA);
|
|---|
| 490 | lpwcx->hIconSm = 0;
|
|---|
| 491 | }
|
|---|
| 492 |
|
|---|
| 493 | return (bResult);
|
|---|
| 494 | }
|
|---|
| 495 | /*****************************************************************************
|
|---|
| 496 | * Name : BOOL WIN32API GetClassInfoExW
|
|---|
| 497 | * Purpose : The GetClassInfoEx function retrieves information about a window
|
|---|
| 498 | * class, including the handle of the small icon associated with the
|
|---|
| 499 | * window class. GetClassInfo does not retrieve the handle of the small icon.
|
|---|
| 500 | * Parameters: HINSTANCE hinst handle of application instance
|
|---|
| 501 | * LPCWSTR lpszClass address of class name string
|
|---|
| 502 | * LPWNDCLASSEX lpwcx address of structure for class data
|
|---|
| 503 | * Variables :
|
|---|
| 504 | * Result : If the function finds a matching class and successfully copies
|
|---|
| 505 | * the data, the return value is TRUE;
|
|---|
| 506 | * otherwise, it is FALSE.
|
|---|
| 507 | * To get extended error information, call GetLastError.
|
|---|
| 508 | * Remark : does not obtain handle of the small icon
|
|---|
| 509 | * Status : UNTESTED STUB
|
|---|
| 510 | *
|
|---|
| 511 | * Author : Patrick Haller [Thu, 1998/02/26 11:55]
|
|---|
| 512 | *****************************************************************************/
|
|---|
| 513 | BOOL WIN32API GetClassInfoExW(HINSTANCE hInstance,
|
|---|
| 514 | LPCWSTR lpszClass,
|
|---|
| 515 | LPWNDCLASSEXW lpwcx)
|
|---|
| 516 | {
|
|---|
| 517 | WNDCLASSW WndClass; /* structure for data transformation */
|
|---|
| 518 | BOOL bResult; /* result of subsequent function calls */
|
|---|
| 519 |
|
|---|
| 520 | dprintf(("USER32:GetClassInfoExW (%08xh,%s,%08x).\n",
|
|---|
| 521 | hInstance,
|
|---|
| 522 | lpszClass,
|
|---|
| 523 | lpwcx));
|
|---|
| 524 |
|
|---|
| 525 | /* convert the structures */
|
|---|
| 526 | memcpy((PVOID)&WndClass,
|
|---|
| 527 | (PVOID)&lpwcx->style,
|
|---|
| 528 | sizeof(WndClass) );
|
|---|
| 529 |
|
|---|
| 530 | bResult = GetClassInfoW(hInstance,
|
|---|
| 531 | (LPWSTR)lpszClass,
|
|---|
| 532 | (WNDCLASSW *)&WndClass);
|
|---|
| 533 | if (bResult == TRUE)
|
|---|
| 534 | {
|
|---|
| 535 | /* convert data back to original structure */
|
|---|
| 536 | memcpy((PVOID)&lpwcx->style,
|
|---|
| 537 | (PVOID)&WndClass,
|
|---|
| 538 | sizeof(WndClass) );
|
|---|
| 539 | lpwcx->cbSize = sizeof(WNDCLASSEXW);
|
|---|
| 540 | lpwcx->hIconSm = 0;
|
|---|
| 541 | }
|
|---|
| 542 |
|
|---|
| 543 | return (bResult);
|
|---|
| 544 | }
|
|---|
| 545 | //******************************************************************************
|
|---|
| 546 | //TODO: Not complete (unsupported extension in WNDCLASSEXA/W, unsupported styles etc)
|
|---|
| 547 | //******************************************************************************
|
|---|
| 548 | LONG WIN32API GetClassLongA(HWND hwnd, int nIndex)
|
|---|
| 549 | {
|
|---|
| 550 | DWORD rc;
|
|---|
| 551 |
|
|---|
| 552 | dprintf(("USER32: OS2GetClassLongA\n"));
|
|---|
| 553 | rc = O32_GetClassLong(hwnd, nIndex);
|
|---|
| 554 | if(nIndex == GCL_WNDPROC)
|
|---|
| 555 | {
|
|---|
| 556 | char szClass[128];
|
|---|
| 557 | Win32WindowClass *wclass;
|
|---|
| 558 |
|
|---|
| 559 | if(GetClassNameA(hwnd, szClass, sizeof(szClass))) {
|
|---|
| 560 | wclass = Win32WindowClass::FindClass(szClass);
|
|---|
| 561 | if(wclass) {
|
|---|
| 562 | return (LONG)wclass->GetWinCallback();
|
|---|
| 563 | }
|
|---|
| 564 | }
|
|---|
| 565 | dprintf(("GetClassLongA, class of window %X not found\n", hwnd));
|
|---|
| 566 | return 0; //TODO: set last error
|
|---|
| 567 | }
|
|---|
| 568 | return rc;
|
|---|
| 569 | }
|
|---|
| 570 | //******************************************************************************
|
|---|
| 571 | //******************************************************************************
|
|---|
| 572 | LONG WIN32API GetClassLongW(HWND hwnd, int nIndex)
|
|---|
| 573 | {
|
|---|
| 574 | dprintf(("USER32: OS2GetClassLongW\n"));
|
|---|
| 575 | if(nIndex == GCL_MENUNAME) { //TODO
|
|---|
| 576 | dprintf(("USER32: Class Menu name not implemented yet\n"));
|
|---|
| 577 | }
|
|---|
| 578 | // NOTE: This will not work as is (needs UNICODE support)
|
|---|
| 579 | return GetClassLongA(hwnd, nIndex);
|
|---|
| 580 | }
|
|---|
| 581 | //******************************************************************************
|
|---|
| 582 | //******************************************************************************
|
|---|
| 583 | int WIN32API GetClassNameA( HWND arg1, LPSTR arg2, int arg3)
|
|---|
| 584 | {
|
|---|
| 585 | dprintf(("USER32: OS2GetClassNameA\n"));
|
|---|
| 586 | return O32_GetClassName(arg1, arg2, arg3);
|
|---|
| 587 | }
|
|---|
| 588 | //******************************************************************************
|
|---|
| 589 | //******************************************************************************
|
|---|
| 590 | int WIN32API GetClassNameW(HWND hwnd, LPWSTR lpClassName, int nMaxCount)
|
|---|
| 591 | {
|
|---|
| 592 | char *astring = (char *)malloc(nMaxCount);
|
|---|
| 593 | int rc;
|
|---|
| 594 |
|
|---|
| 595 | dprintf(("USER32: OS2GetClassNameW\n"));
|
|---|
| 596 | rc = GetClassNameA(hwnd, astring, nMaxCount);
|
|---|
| 597 | AsciiToUnicode(astring, lpClassName);
|
|---|
| 598 | free(astring);
|
|---|
| 599 | return(rc);
|
|---|
| 600 | }
|
|---|
| 601 | //******************************************************************************
|
|---|
| 602 | //******************************************************************************
|
|---|
| 603 | WORD WIN32API GetClassWord( HWND arg1, int arg2)
|
|---|
| 604 | {
|
|---|
| 605 | dprintf(("USER32: OS2GetClassWord\n"));
|
|---|
| 606 | return O32_GetClassWord(arg1, arg2);
|
|---|
| 607 | }
|
|---|
| 608 | //******************************************************************************
|
|---|
| 609 | //******************************************************************************
|
|---|
| 610 | LONG WIN32API SetClassLongA(HWND hwnd, int nIndex, LONG lNewVal)
|
|---|
| 611 | {
|
|---|
| 612 | DWORD rc;
|
|---|
| 613 |
|
|---|
| 614 | dprintf(("USER32: OS2SetClassLongA\n"));
|
|---|
| 615 | if(nIndex == GCL_WNDPROC) {
|
|---|
| 616 | char szClass[128];
|
|---|
| 617 | Win32WindowClass *wclass;
|
|---|
| 618 |
|
|---|
| 619 | if(GetClassNameA(hwnd, szClass, sizeof(szClass))) {
|
|---|
| 620 | wclass = Win32WindowClass::FindClass(szClass);
|
|---|
| 621 | if(wclass) {
|
|---|
| 622 | rc = (DWORD)wclass->GetWinCallback();
|
|---|
| 623 | wclass->SetWinCallback((WNDPROC)lNewVal);
|
|---|
| 624 | return rc;
|
|---|
| 625 | }
|
|---|
| 626 | }
|
|---|
| 627 | dprintf(("SetClassLongA, class of window %X not found\n", hwnd));
|
|---|
| 628 | return 0; //TODO: set last error
|
|---|
| 629 | }
|
|---|
| 630 | return O32_SetClassLong(hwnd, nIndex, lNewVal);
|
|---|
| 631 | }
|
|---|
| 632 | //******************************************************************************
|
|---|
| 633 | //******************************************************************************
|
|---|
| 634 | LONG WIN32API SetClassLongW( HWND arg1, int arg2, LONG arg3)
|
|---|
| 635 | {
|
|---|
| 636 | dprintf(("USER32: OS2SetClassLongW\n"));
|
|---|
| 637 | // NOTE: This will not work as is (needs UNICODE support)
|
|---|
| 638 | return O32_SetClassLong(arg1, arg2, arg3);
|
|---|
| 639 | }
|
|---|
| 640 | //******************************************************************************
|
|---|
| 641 | //******************************************************************************
|
|---|
| 642 | WORD WIN32API SetClassWord( HWND arg1, int arg2, WORD arg3)
|
|---|
| 643 | {
|
|---|
| 644 | dprintf(("USER32: OS2SetClassWord\n"));
|
|---|
| 645 | return O32_SetClassWord(arg1, arg2, arg3);
|
|---|
| 646 | }
|
|---|
| 647 | //******************************************************************************
|
|---|
| 648 | //Win32WindowClass methods:
|
|---|
| 649 | //******************************************************************************
|
|---|
| 650 | Win32WindowClass::Win32WindowClass(WNDPROC pUserCallback, LPSTR id, HINSTANCE hinst)
|
|---|
| 651 | {
|
|---|
| 652 | //Insert it in front of the rest
|
|---|
| 653 | next = wndclasses;
|
|---|
| 654 | wndclasses = this;
|
|---|
| 655 | if((int)id >> 16 != 0) {
|
|---|
| 656 | strcpy(className, id);
|
|---|
| 657 | classAtom = 0;
|
|---|
| 658 | }
|
|---|
| 659 | else {
|
|---|
| 660 | className[0] = 0;
|
|---|
| 661 | classAtom = (DWORD)id;
|
|---|
| 662 | }
|
|---|
| 663 | this->hinst = hinst;
|
|---|
| 664 |
|
|---|
| 665 | pWinCallback = pUserCallback;
|
|---|
| 666 | dprintf(("Win32WindowClass::Win32WindowClass %d\n", id));
|
|---|
| 667 | }
|
|---|
| 668 | //******************************************************************************
|
|---|
| 669 | //******************************************************************************
|
|---|
| 670 | Win32WindowClass::~Win32WindowClass()
|
|---|
| 671 | {
|
|---|
| 672 | Win32WindowClass *wndclass = Win32WindowClass::wndclasses;
|
|---|
| 673 |
|
|---|
| 674 | if(wndclass == this) {
|
|---|
| 675 | wndclasses = next;
|
|---|
| 676 | }
|
|---|
| 677 | else {
|
|---|
| 678 | while(wndclass->next != NULL) {
|
|---|
| 679 | if(wndclass->next == this) {
|
|---|
| 680 | wndclass->next = next;
|
|---|
| 681 | break;
|
|---|
| 682 | }
|
|---|
| 683 | wndclass = wndclass->next;
|
|---|
| 684 | }
|
|---|
| 685 | }
|
|---|
| 686 | }
|
|---|
| 687 | //******************************************************************************
|
|---|
| 688 | //******************************************************************************
|
|---|
| 689 | Win32WindowClass *Win32WindowClass::FindClass(LPSTR id)
|
|---|
| 690 | {
|
|---|
| 691 | Win32WindowClass *wndclass = wndclasses;
|
|---|
| 692 |
|
|---|
| 693 | if(wndclass == NULL) return(NULL);
|
|---|
| 694 |
|
|---|
| 695 | if((int)id >> 16 != 0) {
|
|---|
| 696 | if(stricmp(wndclass->className, id) == 0) {
|
|---|
| 697 | return(wndclass);
|
|---|
| 698 | }
|
|---|
| 699 | else {
|
|---|
| 700 | wndclass = wndclass->next;
|
|---|
| 701 | while(wndclass != NULL) {
|
|---|
| 702 | if(stricmp(wndclass->className, id) == 0) {
|
|---|
| 703 | return(wndclass);
|
|---|
| 704 | }
|
|---|
| 705 | wndclass = wndclass->next;
|
|---|
| 706 | }
|
|---|
| 707 | }
|
|---|
| 708 | }
|
|---|
| 709 | else {
|
|---|
| 710 | if(wndclass->classAtom == (DWORD)id) {
|
|---|
| 711 | return(wndclass);
|
|---|
| 712 | }
|
|---|
| 713 | else {
|
|---|
| 714 | wndclass = wndclass->next;
|
|---|
| 715 | while(wndclass != NULL) {
|
|---|
| 716 | if(wndclass->classAtom == (DWORD)id) {
|
|---|
| 717 | return(wndclass);
|
|---|
| 718 | }
|
|---|
| 719 | wndclass = wndclass->next;
|
|---|
| 720 | }
|
|---|
| 721 | }
|
|---|
| 722 | }
|
|---|
| 723 | return(NULL);
|
|---|
| 724 | }
|
|---|
| 725 | //******************************************************************************
|
|---|
| 726 | //******************************************************************************
|
|---|
| 727 | void Win32WindowClass::UnregisterClass(HINSTANCE hinst, LPSTR id)
|
|---|
| 728 | {
|
|---|
| 729 | Win32WindowClass *wndclass;
|
|---|
| 730 |
|
|---|
| 731 | dprintf(("::UnregisterClass, destroy class %X!!\n", id));
|
|---|
| 732 | wndclass = FindClass(id);
|
|---|
| 733 | if(wndclass && wndclass->hinst == hinst) {
|
|---|
| 734 | delete wndclass;
|
|---|
| 735 | return;
|
|---|
| 736 | }
|
|---|
| 737 | dprintf(("::UnregisterClass, couldn't find class %X!!\n", id));
|
|---|
| 738 | }
|
|---|
| 739 | //******************************************************************************
|
|---|
| 740 | //******************************************************************************
|
|---|
| 741 | WNDPROC Win32WindowClass::GetClassCallback(HINSTANCE hinst, LPSTR id)
|
|---|
| 742 | {
|
|---|
| 743 | Win32WindowClass *wndclass;
|
|---|
| 744 |
|
|---|
| 745 | wndclass = FindClass(id);
|
|---|
| 746 | if(wndclass && wndclass->hinst == hinst) {
|
|---|
| 747 | return wndclass->pWinCallback;
|
|---|
| 748 | }
|
|---|
| 749 | dprintf(("::GetClassCallback, couldn't find class %X!!\n", id));
|
|---|
| 750 | return(NULL);
|
|---|
| 751 | }
|
|---|
| 752 | //******************************************************************************
|
|---|
| 753 | //******************************************************************************
|
|---|
| 754 | WNDPROC Win32WindowClass::GetClassCallback(LPSTR id)
|
|---|
| 755 | {
|
|---|
| 756 | Win32WindowClass *wndclass;
|
|---|
| 757 |
|
|---|
| 758 | wndclass = FindClass(id);
|
|---|
| 759 | if(wndclass) {
|
|---|
| 760 | return wndclass->pWinCallback;
|
|---|
| 761 | }
|
|---|
| 762 | dprintf(("::GetClassCallback2, couldn't find class %X!!\n", id));
|
|---|
| 763 | return(NULL);
|
|---|
| 764 | }
|
|---|
| 765 | //******************************************************************************
|
|---|
| 766 | //******************************************************************************
|
|---|
| 767 | WNDPROC_O32 Win32WindowClass::GetOS2ClassCallback()
|
|---|
| 768 | {
|
|---|
| 769 | return OS2ToWinCallback;
|
|---|
| 770 | }
|
|---|
| 771 | //******************************************************************************
|
|---|
| 772 | //******************************************************************************
|
|---|
| 773 | LRESULT EXPENTRY_O32 OS2ToWinCallback(HWND hwnd, UINT Msg, WPARAM wParam, LPARAM lParam)
|
|---|
| 774 | {
|
|---|
| 775 | char szClass[128];
|
|---|
| 776 | Win32WindowClass *wclass;
|
|---|
| 777 | LRESULT rc;
|
|---|
| 778 | DWORD dwStyle, dwExStyle;
|
|---|
| 779 | HWND parentHwnd;
|
|---|
| 780 | Win32WindowProc *window;
|
|---|
| 781 |
|
|---|
| 782 | //Restore our FS selector
|
|---|
| 783 | SetWin32TIB();
|
|---|
| 784 |
|
|---|
| 785 | if(Msg == WM_MOUSEACTIVATE)
|
|---|
| 786 | {
|
|---|
| 787 | //Open32 sends an OS/2 window message for a button click
|
|---|
| 788 | if(HIWORD(lParam) == 0x71) //WM_BUTTONCLICKFIRST
|
|---|
| 789 | {
|
|---|
| 790 | lParam = (WM_LBUTTONDOWN << 16) | LOWORD(lParam);
|
|---|
| 791 | }
|
|---|
| 792 | }
|
|---|
| 793 | if(PostSpyMessage(hwnd, Msg, wParam, lParam) == FALSE)
|
|---|
| 794 | dprintf(("OS2ToWinCallback %s for %x %x %x", GetMsgText(Msg), hwnd, wParam, lParam));
|
|---|
| 795 |
|
|---|
| 796 | if(HkCBT::OS2HkCBTProc(hwnd, Msg, wParam, lParam) == TRUE) {//hook swallowed msg
|
|---|
| 797 | RestoreOS2TIB();
|
|---|
| 798 | return(0);
|
|---|
| 799 | }
|
|---|
| 800 |
|
|---|
| 801 | if(O32_GetClassName(hwnd, szClass, sizeof(szClass))) {
|
|---|
| 802 | wclass = Win32WindowClass::FindClass(szClass);
|
|---|
| 803 | if(wclass) {
|
|---|
| 804 | switch(Msg)
|
|---|
| 805 | {
|
|---|
| 806 | case WM_CREATE://Open32 isn't sending WM_NCCREATE messages!!
|
|---|
| 807 | window = Win32WindowProc::FindProc(hwnd, GetCurrentThreadId());
|
|---|
| 808 | if(window) {
|
|---|
| 809 | dprintf(("OS2ToWinCallback (class): New window object!"));
|
|---|
| 810 | window->SetWindowHandle(hwnd);
|
|---|
| 811 | }
|
|---|
| 812 |
|
|---|
| 813 | if(wclass->GetWinCallback()(hwnd, WM_NCCREATE, 0, lParam) == 0) {
|
|---|
| 814 | dprintf(("WM_NCCREATE returned FALSE\n"));
|
|---|
| 815 | return(-1); //don't create window
|
|---|
| 816 | }
|
|---|
| 817 | //Send WM_CREATE message before notifying parent
|
|---|
| 818 | rc = wclass->GetWinCallback()(hwnd, Msg, wParam, lParam);
|
|---|
| 819 |
|
|---|
| 820 | NotifyParent(hwnd, WM_CREATE, wParam, lParam);
|
|---|
| 821 | RestoreOS2TIB();
|
|---|
| 822 | return(rc);
|
|---|
| 823 |
|
|---|
| 824 | case WM_DESTROY: //nofity parent
|
|---|
| 825 | case WM_LBUTTONDOWN:
|
|---|
| 826 | case WM_MBUTTONDOWN:
|
|---|
| 827 | case WM_RBUTTONDOWN:
|
|---|
| 828 | NotifyParent(hwnd, Msg, wParam, lParam);
|
|---|
| 829 | break;
|
|---|
| 830 |
|
|---|
| 831 | case WM_KEYDOWN:
|
|---|
| 832 | case WM_KEYUP:
|
|---|
| 833 | case WM_CHAR: //SvL: Correct Open32 key mapping bug
|
|---|
| 834 | //TODO: Not good enough, look at Wine
|
|---|
| 835 | lParam = MapOEMToRealKey(wParam, lParam);
|
|---|
| 836 | break;
|
|---|
| 837 |
|
|---|
| 838 | case WM_ACTIVATE:
|
|---|
| 839 | if(LOWORD(wParam) != WA_INACTIVE)
|
|---|
| 840 | {
|
|---|
| 841 | //EB: I think the problem is not a missing wm_erasebkgnd.
|
|---|
| 842 | //Maybe some wrong flags in open32 during async repainting.
|
|---|
| 843 | RECT rect;
|
|---|
| 844 | HRGN hrgn;
|
|---|
| 845 | HDC hdc = GetDC(hwnd);
|
|---|
| 846 |
|
|---|
| 847 | // erase the dirty rect
|
|---|
| 848 | GetUpdateRect(hwnd, &rect, TRUE);
|
|---|
| 849 | hrgn = CreateRectRgnIndirect(&rect);
|
|---|
| 850 | SelectClipRgn (hdc, hrgn);
|
|---|
| 851 | DeleteObject (hrgn);
|
|---|
| 852 | wclass->GetWinCallback()(hwnd, WM_ERASEBKGND, hdc, (LPARAM)&rect);
|
|---|
| 853 | SelectClipRgn (hdc, NULL);
|
|---|
| 854 | ReleaseDC(hwnd, hdc);
|
|---|
| 855 | }
|
|---|
| 856 | break;
|
|---|
| 857 | }
|
|---|
| 858 | rc = wclass->GetWinCallback()(hwnd, Msg, wParam, lParam);
|
|---|
| 859 | RestoreOS2TIB();
|
|---|
| 860 | return rc;
|
|---|
| 861 | }
|
|---|
| 862 | }
|
|---|
| 863 | dprintf(("OS2ToWinCallback: couldn't find class procedure of window %X\n", hwnd));
|
|---|
| 864 | RestoreOS2TIB();
|
|---|
| 865 | return(0);
|
|---|
| 866 | }
|
|---|
| 867 | //******************************************************************************
|
|---|
| 868 | //******************************************************************************
|
|---|
| 869 | Win32WindowClass *Win32WindowClass::wndclasses = NULL;
|
|---|