| 1 | /* $Id: windowclass.cpp,v 1.9 2000-02-16 14:28:26 sandervl Exp $ */ | 
|---|
| 2 | /* | 
|---|
| 3 | * Win32 Window Class Code for OS/2 | 
|---|
| 4 | * | 
|---|
| 5 | * | 
|---|
| 6 | * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl) | 
|---|
| 7 | * | 
|---|
| 8 | * | 
|---|
| 9 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 10 | * | 
|---|
| 11 | */ | 
|---|
| 12 | #include <os2win.h> | 
|---|
| 13 | #include <stdio.h> | 
|---|
| 14 | #include <stdlib.h> | 
|---|
| 15 | #include <string.h> | 
|---|
| 16 | #include <stdarg.h> | 
|---|
| 17 | #include <assert.h> | 
|---|
| 18 | #include <misc.h> | 
|---|
| 19 | #include <win32class.h> | 
|---|
| 20 | #include <win32wbase.h> | 
|---|
| 21 | #include <controls.h> | 
|---|
| 22 |  | 
|---|
| 23 | #define DBG_LOCALLOG    DBG_windowclass | 
|---|
| 24 | #include "dbglocal.h" | 
|---|
| 25 |  | 
|---|
| 26 | //****************************************************************************** | 
|---|
| 27 | //****************************************************************************** | 
|---|
| 28 | void RegisterSystemClasses(ULONG hModule) | 
|---|
| 29 | { | 
|---|
| 30 | dprintf(("RegisterSystemClasses\n")); | 
|---|
| 31 | CONTROLS_Register(); | 
|---|
| 32 | } | 
|---|
| 33 | //****************************************************************************** | 
|---|
| 34 | //****************************************************************************** | 
|---|
| 35 | void UnregisterSystemClasses() | 
|---|
| 36 | { | 
|---|
| 37 | dprintf(("UnregisterSystemClasses\n")); | 
|---|
| 38 | CONTROLS_Unregister(); | 
|---|
| 39 | } | 
|---|
| 40 | //****************************************************************************** | 
|---|
| 41 | //****************************************************************************** | 
|---|
| 42 | ATOM WIN32API RegisterClassA(CONST WNDCLASSA *lpWndClass) | 
|---|
| 43 | { | 
|---|
| 44 | WNDCLASSEXA wc; | 
|---|
| 45 | Win32WndClass *wclass; | 
|---|
| 46 |  | 
|---|
| 47 | dprintf(("RegisterClassA\n")); | 
|---|
| 48 | //CB: size new in ex structure | 
|---|
| 49 | wc.cbSize = sizeof(wc); | 
|---|
| 50 | memcpy(&wc.style, lpWndClass, sizeof(WNDCLASSA)); | 
|---|
| 51 | wc.hIconSm = 0; | 
|---|
| 52 |  | 
|---|
| 53 | wclass = new Win32WndClass(&wc,FALSE); | 
|---|
| 54 | if(wclass == NULL) { | 
|---|
| 55 | dprintf(("RegisterClassA wclass == NULL!")); | 
|---|
| 56 | return(0); | 
|---|
| 57 | } | 
|---|
| 58 | return(wclass->getAtom()); | 
|---|
| 59 | } | 
|---|
| 60 | //****************************************************************************** | 
|---|
| 61 | //****************************************************************************** | 
|---|
| 62 | ATOM WIN32API RegisterClassExA(CONST WNDCLASSEXA *lpWndClass) | 
|---|
| 63 | { | 
|---|
| 64 | Win32WndClass *wclass; | 
|---|
| 65 |  | 
|---|
| 66 | dprintf(("RegisterClassExA\n")); | 
|---|
| 67 | wclass = new Win32WndClass((WNDCLASSEXA *)lpWndClass,FALSE); | 
|---|
| 68 | if(wclass == NULL) { | 
|---|
| 69 | dprintf(("RegisterClassExA wclass == NULL!")); | 
|---|
| 70 | return(0); | 
|---|
| 71 | } | 
|---|
| 72 | return(wclass->getAtom()); | 
|---|
| 73 | } | 
|---|
| 74 | //****************************************************************************** | 
|---|
| 75 | //****************************************************************************** | 
|---|
| 76 | WORD WIN32API RegisterClassW(CONST WNDCLASSW *lpwc) | 
|---|
| 77 | { | 
|---|
| 78 | ATOM rc; | 
|---|
| 79 | WNDCLASSEXA wclass; | 
|---|
| 80 | Win32WndClass *winclass; | 
|---|
| 81 |  | 
|---|
| 82 | dprintf(("RegisterClassW\n")); | 
|---|
| 83 | //CB: size new in ex structure | 
|---|
| 84 | wclass.cbSize = sizeof(wclass); | 
|---|
| 85 | memcpy(&wclass.style, lpwc, sizeof(WNDCLASSA)); | 
|---|
| 86 |  | 
|---|
| 87 | winclass = new Win32WndClass((WNDCLASSEXA *)&wclass, TRUE); | 
|---|
| 88 | if(winclass == NULL) { | 
|---|
| 89 | dprintf(("RegisterClassW wclass == NULL!")); | 
|---|
| 90 | return(0); | 
|---|
| 91 | } | 
|---|
| 92 | rc = winclass->getAtom(); | 
|---|
| 93 |  | 
|---|
| 94 | return(rc); | 
|---|
| 95 | } | 
|---|
| 96 | //****************************************************************************** | 
|---|
| 97 | //****************************************************************************** | 
|---|
| 98 | ATOM WIN32API RegisterClassExW(CONST WNDCLASSEXW *lpwc) | 
|---|
| 99 | { | 
|---|
| 100 | ATOM rc; | 
|---|
| 101 | WNDCLASSEXA wclass; | 
|---|
| 102 | Win32WndClass *winclass; | 
|---|
| 103 |  | 
|---|
| 104 | dprintf(("RegisterClassExW\n")); | 
|---|
| 105 | memcpy(&wclass, lpwc, sizeof(WNDCLASSEXA)); | 
|---|
| 106 |  | 
|---|
| 107 | winclass = new Win32WndClass((WNDCLASSEXA *)&wclass, TRUE); | 
|---|
| 108 | if(winclass == NULL) { | 
|---|
| 109 | dprintf(("RegisterClassExW wclass == NULL!")); | 
|---|
| 110 | return(0); | 
|---|
| 111 | } | 
|---|
| 112 | rc = winclass->getAtom(); | 
|---|
| 113 |  | 
|---|
| 114 | return(rc); | 
|---|
| 115 | } | 
|---|
| 116 | //****************************************************************************** | 
|---|
| 117 | //****************************************************************************** | 
|---|
| 118 | BOOL WIN32API UnregisterClassA(LPCSTR lpszClassName, HINSTANCE hinst) | 
|---|
| 119 | { | 
|---|
| 120 | Win32WndClass::UnregisterClassA(hinst, (LPSTR)lpszClassName); | 
|---|
| 121 |  | 
|---|
| 122 | //Spintest returns FALSE in dll termination, so pretend it succeeded | 
|---|
| 123 | return(TRUE); | 
|---|
| 124 | } | 
|---|
| 125 | //****************************************************************************** | 
|---|
| 126 | //****************************************************************************** | 
|---|
| 127 | BOOL WIN32API UnregisterClassW(LPCWSTR lpszClassName, HINSTANCE hinst) | 
|---|
| 128 | { | 
|---|
| 129 | char *astring = NULL; | 
|---|
| 130 |  | 
|---|
| 131 | dprintf(("USER32:  UnregisterClassW\n")); | 
|---|
| 132 | if(HIWORD(lpszClassName) != 0) { | 
|---|
| 133 | astring = UnicodeToAsciiString((LPWSTR)lpszClassName); | 
|---|
| 134 | } | 
|---|
| 135 | else  astring = (char *)lpszClassName; | 
|---|
| 136 |  | 
|---|
| 137 | Win32WndClass::UnregisterClassA(hinst, (LPSTR)astring); | 
|---|
| 138 | if(HIWORD(astring) != 0) | 
|---|
| 139 | FreeAsciiString((char *)astring); | 
|---|
| 140 |  | 
|---|
| 141 | //Spintest returns FALSE in dll termination, so pretend it succeeded | 
|---|
| 142 | return(TRUE); | 
|---|
| 143 | } | 
|---|
| 144 | //****************************************************************************** | 
|---|
| 145 | //****************************************************************************** | 
|---|
| 146 | BOOL WIN32API GetClassInfoA(HINSTANCE hInstance, LPCSTR lpszClass, WNDCLASSA *lpwc) | 
|---|
| 147 | { | 
|---|
| 148 | WNDCLASSEXA    wc; | 
|---|
| 149 | BOOL           rc; | 
|---|
| 150 | Win32WndClass *wndclass; | 
|---|
| 151 |  | 
|---|
| 152 | dprintf(("USER32:  GetClassInfoA\n")); | 
|---|
| 153 |  | 
|---|
| 154 | wndclass = Win32WndClass::FindClass(hInstance, (LPSTR)lpszClass); | 
|---|
| 155 | if(wndclass) { | 
|---|
| 156 | wndclass->getClassInfo(&wc); | 
|---|
| 157 | memcpy(lpwc, &wc.style, sizeof(WNDCLASSA)); | 
|---|
| 158 | return(TRUE); | 
|---|
| 159 | } | 
|---|
| 160 | return(FALSE); | 
|---|
| 161 | } | 
|---|
| 162 | //****************************************************************************** | 
|---|
| 163 | //****************************************************************************** | 
|---|
| 164 | BOOL WIN32API GetClassInfoW(HINSTANCE  hinst, LPCWSTR lpszClass, WNDCLASSW *lpwc) | 
|---|
| 165 | { | 
|---|
| 166 | WNDCLASSEXW    wc; | 
|---|
| 167 | BOOL           rc; | 
|---|
| 168 | Win32WndClass *wndclass; | 
|---|
| 169 | char          *astring = NULL; | 
|---|
| 170 |  | 
|---|
| 171 | dprintf(("USER32:  GetClassInfoW\n")); | 
|---|
| 172 |  | 
|---|
| 173 | if(HIWORD(lpszClass) != 0) { | 
|---|
| 174 | astring = UnicodeToAsciiString((LPWSTR)lpszClass); | 
|---|
| 175 | } | 
|---|
| 176 | else  astring = (char *)lpszClass; | 
|---|
| 177 |  | 
|---|
| 178 | wndclass = Win32WndClass::FindClass(hinst, astring); | 
|---|
| 179 | if(HIWORD(astring) != 0) | 
|---|
| 180 | FreeAsciiString((char *)astring); | 
|---|
| 181 |  | 
|---|
| 182 | if(wndclass) { | 
|---|
| 183 | wndclass->getClassInfo(&wc); | 
|---|
| 184 | memcpy(lpwc, &wc.style, sizeof(WNDCLASSW)); | 
|---|
| 185 | return(TRUE); | 
|---|
| 186 | } | 
|---|
| 187 | return(FALSE); | 
|---|
| 188 | } | 
|---|
| 189 | /**************************************************************************** | 
|---|
| 190 | * Name      : BOOL WIN32API GetClassInfoExA | 
|---|
| 191 | * Purpose   : The GetClassInfoEx function retrieves information about a window | 
|---|
| 192 | *             class, including the handle of the small icon associated with the | 
|---|
| 193 | *             window class. GetClassInfo does not retrieve the handle of the small icon. | 
|---|
| 194 | * Parameters: HINSTANCE    hinst     handle of application instance | 
|---|
| 195 | *             LPCTSTR      lpszClass address of class name string | 
|---|
| 196 | *             LPWNDCLASSEX lpwcx     address of structure for class data | 
|---|
| 197 | * Variables : | 
|---|
| 198 | * Result    : If the function finds a matching class and successfully copies | 
|---|
| 199 | *               the data, the return value is TRUE; | 
|---|
| 200 | *             otherwise, it is FALSE. | 
|---|
| 201 | *             To get extended error information, call GetLastError. | 
|---|
| 202 | * Remark    : PH: does not obtain handle of the small icon | 
|---|
| 203 | *****************************************************************************/ | 
|---|
| 204 | BOOL WIN32API GetClassInfoExA(HINSTANCE     hInstance, | 
|---|
| 205 | LPCTSTR       lpszClass, | 
|---|
| 206 | LPWNDCLASSEXA lpwcx) | 
|---|
| 207 | { | 
|---|
| 208 | BOOL           rc; | 
|---|
| 209 | Win32WndClass *wndclass; | 
|---|
| 210 |  | 
|---|
| 211 | dprintf(("USER32:GetClassInfoExA (%08xh,%x,%08x).\n", | 
|---|
| 212 | hInstance, | 
|---|
| 213 | lpszClass, | 
|---|
| 214 | lpwcx)); | 
|---|
| 215 |  | 
|---|
| 216 | wndclass = Win32WndClass::FindClass(hInstance, (LPSTR)lpszClass); | 
|---|
| 217 | if(wndclass) { | 
|---|
| 218 | wndclass->getClassInfo(lpwcx); | 
|---|
| 219 | lpwcx->cbSize = sizeof(WNDCLASSEXA); | 
|---|
| 220 | return(TRUE); | 
|---|
| 221 | } | 
|---|
| 222 | return(FALSE); | 
|---|
| 223 | } | 
|---|
| 224 | /***************************************************************************** | 
|---|
| 225 | * Name      : BOOL WIN32API GetClassInfoExW | 
|---|
| 226 | * Purpose   : The GetClassInfoEx function retrieves information about a window | 
|---|
| 227 | *             class, including the handle of the small icon associated with the | 
|---|
| 228 | *             window class. GetClassInfo does not retrieve the handle of the small icon. | 
|---|
| 229 | * Parameters: HINSTANCE    hinst     handle of application instance | 
|---|
| 230 | *             LPCWSTR      lpszClass address of class name string | 
|---|
| 231 | *             LPWNDCLASSEX lpwcx     address of structure for class data | 
|---|
| 232 | * Variables : | 
|---|
| 233 | * Result    : If the function finds a matching class and successfully copies | 
|---|
| 234 | *               the data, the return value is TRUE; | 
|---|
| 235 | *             otherwise, it is FALSE. | 
|---|
| 236 | *             To get extended error information, call GetLastError. | 
|---|
| 237 | * Remark    : does not obtain handle of the small icon | 
|---|
| 238 | * | 
|---|
| 239 | *****************************************************************************/ | 
|---|
| 240 | BOOL WIN32API GetClassInfoExW(HINSTANCE     hInstance, | 
|---|
| 241 | LPCWSTR       lpszClass, | 
|---|
| 242 | LPWNDCLASSEXW lpwcx) | 
|---|
| 243 | { | 
|---|
| 244 | BOOL           rc; | 
|---|
| 245 | Win32WndClass *wndclass; | 
|---|
| 246 | char          *astring = NULL; | 
|---|
| 247 |  | 
|---|
| 248 | dprintf(("USER32: GetClassInfoExW\n")); | 
|---|
| 249 |  | 
|---|
| 250 | if(HIWORD(lpszClass) != 0) { | 
|---|
| 251 | astring = UnicodeToAsciiString((LPWSTR)lpszClass); | 
|---|
| 252 | } | 
|---|
| 253 | else  astring = (char *)lpszClass; | 
|---|
| 254 |  | 
|---|
| 255 | wndclass = Win32WndClass::FindClass(hInstance, astring); | 
|---|
| 256 | if(HIWORD(astring) != 0) | 
|---|
| 257 | FreeAsciiString((char *)astring); | 
|---|
| 258 |  | 
|---|
| 259 | if(wndclass) { | 
|---|
| 260 | wndclass->getClassInfo(lpwcx); | 
|---|
| 261 | lpwcx->cbSize = sizeof(WNDCLASSEXW); | 
|---|
| 262 | return(TRUE); | 
|---|
| 263 | } | 
|---|
| 264 | return(FALSE); | 
|---|
| 265 | } | 
|---|
| 266 | //****************************************************************************** | 
|---|
| 267 | //****************************************************************************** | 
|---|
| 268 | int WIN32API GetClassNameA(HWND hwnd, LPSTR lpszClassName, int cchClassName) | 
|---|
| 269 | { | 
|---|
| 270 | Win32BaseWindow *wnd; | 
|---|
| 271 | int rc; | 
|---|
| 272 |  | 
|---|
| 273 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 274 | if(!wnd) { | 
|---|
| 275 | dprintf(("GetClassNameA wnd == NULL")); | 
|---|
| 276 | return(0); | 
|---|
| 277 | } | 
|---|
| 278 | *lpszClassName = 0; | 
|---|
| 279 | rc = (wnd->getClass())->getClassName(lpszClassName, cchClassName); | 
|---|
| 280 | dprintf(("USER32: GetClassNameA %x %s (%d)", hwnd, lpszClassName, rc)); | 
|---|
| 281 | return rc; | 
|---|
| 282 | } | 
|---|
| 283 | //****************************************************************************** | 
|---|
| 284 | //****************************************************************************** | 
|---|
| 285 | int WIN32API GetClassNameW(HWND hwnd, LPWSTR lpszClassName, int cchClassName) | 
|---|
| 286 | { | 
|---|
| 287 | Win32BaseWindow *wnd; | 
|---|
| 288 |  | 
|---|
| 289 | dprintf(("USER32: GetClassNameW\n")); | 
|---|
| 290 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 291 | if(!wnd) { | 
|---|
| 292 | dprintf(("GetClassNameA wnd == NULL")); | 
|---|
| 293 | return(0); | 
|---|
| 294 | } | 
|---|
| 295 | return (wnd->getClass())->getClassName(lpszClassName, cchClassName); | 
|---|
| 296 | } | 
|---|
| 297 | //****************************************************************************** | 
|---|
| 298 | //****************************************************************************** | 
|---|
| 299 | LONG WIN32API SetClassLongA(HWND hwnd, int nIndex, LONG lNewVal) | 
|---|
| 300 | { | 
|---|
| 301 | Win32BaseWindow *wnd; | 
|---|
| 302 |  | 
|---|
| 303 | dprintf(("USER32: SetClassLongA %x %d %x", hwnd, nIndex, lNewVal)); | 
|---|
| 304 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 305 | if(!wnd) { | 
|---|
| 306 | dprintf(("SetClassLongA wnd == NULL")); | 
|---|
| 307 | return(0); | 
|---|
| 308 | } | 
|---|
| 309 | return (wnd->getClass())->setClassLongA(nIndex, lNewVal); | 
|---|
| 310 | } | 
|---|
| 311 | //****************************************************************************** | 
|---|
| 312 | //****************************************************************************** | 
|---|
| 313 | LONG WIN32API SetClassLongW(HWND hwnd, int nIndex, LONG lNewVal) | 
|---|
| 314 | { | 
|---|
| 315 | Win32BaseWindow *wnd; | 
|---|
| 316 |  | 
|---|
| 317 | dprintf(("USER32: SetClassLongW\n")); | 
|---|
| 318 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 319 | if(!wnd) { | 
|---|
| 320 | dprintf(("SetClassLongW wnd == NULL")); | 
|---|
| 321 | return(0); | 
|---|
| 322 | } | 
|---|
| 323 | return (wnd->getClass())->setClassLongW(nIndex, lNewVal); | 
|---|
| 324 | } | 
|---|
| 325 | //****************************************************************************** | 
|---|
| 326 | //****************************************************************************** | 
|---|
| 327 | WORD WIN32API SetClassWord(HWND hwnd, int nIndex, WORD  wNewVal) | 
|---|
| 328 | { | 
|---|
| 329 | Win32BaseWindow *wnd; | 
|---|
| 330 |  | 
|---|
| 331 | dprintf(("USER32: SetClassWordA\n")); | 
|---|
| 332 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 333 | if(!wnd) { | 
|---|
| 334 | dprintf(("SetClassWordA wnd == NULL")); | 
|---|
| 335 | return(0); | 
|---|
| 336 | } | 
|---|
| 337 | return (wnd->getClass())->setClassWord(nIndex, wNewVal); | 
|---|
| 338 | } | 
|---|
| 339 | //****************************************************************************** | 
|---|
| 340 | //****************************************************************************** | 
|---|
| 341 | WORD WIN32API GetClassWord(HWND hwnd, int nIndex) | 
|---|
| 342 | { | 
|---|
| 343 | Win32BaseWindow *wnd; | 
|---|
| 344 |  | 
|---|
| 345 | dprintf(("USER32: GetClassWordA\n")); | 
|---|
| 346 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 347 | if(!wnd) { | 
|---|
| 348 | dprintf(("GetClassWordA wnd == NULL")); | 
|---|
| 349 | return(0); | 
|---|
| 350 | } | 
|---|
| 351 | return (wnd->getClass())->getClassWord(nIndex); | 
|---|
| 352 | } | 
|---|
| 353 | //****************************************************************************** | 
|---|
| 354 | //****************************************************************************** | 
|---|
| 355 | LONG WIN32API GetClassLongA(HWND hwnd, int nIndex) | 
|---|
| 356 | { | 
|---|
| 357 | Win32BaseWindow *wnd; | 
|---|
| 358 |  | 
|---|
| 359 | dprintf(("USER32: GetClassLongA %x %d", hwnd, nIndex)); | 
|---|
| 360 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 361 | if(!wnd) { | 
|---|
| 362 | dprintf(("GetClassLongA wnd == NULL")); | 
|---|
| 363 | return(0); | 
|---|
| 364 | } | 
|---|
| 365 | return (wnd->getClass())->getClassLongA(nIndex); | 
|---|
| 366 | } | 
|---|
| 367 | //****************************************************************************** | 
|---|
| 368 | //****************************************************************************** | 
|---|
| 369 | LONG WIN32API GetClassLongW(HWND hwnd, int nIndex) | 
|---|
| 370 | { | 
|---|
| 371 | Win32BaseWindow *wnd; | 
|---|
| 372 |  | 
|---|
| 373 | dprintf(("USER32: GetClassLongW\n")); | 
|---|
| 374 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); | 
|---|
| 375 | if(!wnd) { | 
|---|
| 376 | dprintf(("GetClassLongW wnd == NULL")); | 
|---|
| 377 | return(0); | 
|---|
| 378 | } | 
|---|
| 379 | return (wnd->getClass())->getClassLongW(nIndex); | 
|---|
| 380 | } | 
|---|
| 381 | //****************************************************************************** | 
|---|
| 382 | //****************************************************************************** | 
|---|