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