| 1 | /* $Id: windowclass.cpp,v 1.2 1999-10-08 16:28:21 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 | //******************************************************************************
|
|---|
| 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 | dprintf(("USER32: UnregisterClassA\n"));
|
|---|
| 118 | Win32WndClass::UnregisterClassA(hinst, (LPSTR)lpszClassName);
|
|---|
| 119 |
|
|---|
| 120 | //Spintest returns FALSE in dll termination, so pretend it succeeded
|
|---|
| 121 | return(TRUE);
|
|---|
| 122 | }
|
|---|
| 123 | //******************************************************************************
|
|---|
| 124 | //******************************************************************************
|
|---|
| 125 | BOOL WIN32API UnregisterClassW(LPCWSTR lpszClassName, HINSTANCE hinst)
|
|---|
| 126 | {
|
|---|
| 127 | char *astring = NULL;
|
|---|
| 128 |
|
|---|
| 129 | dprintf(("USER32: UnregisterClassW\n"));
|
|---|
| 130 | if(HIWORD(lpszClassName) != 0) {
|
|---|
| 131 | astring = UnicodeToAsciiString((LPWSTR)lpszClassName);
|
|---|
| 132 | }
|
|---|
| 133 | else astring = (char *)lpszClassName;
|
|---|
| 134 |
|
|---|
| 135 | Win32WndClass::UnregisterClassA(hinst, (LPSTR)astring);
|
|---|
| 136 | if(HIWORD(astring) != 0)
|
|---|
| 137 | FreeAsciiString((char *)astring);
|
|---|
| 138 |
|
|---|
| 139 | //Spintest returns FALSE in dll termination, so pretend it succeeded
|
|---|
| 140 | return(TRUE);
|
|---|
| 141 | }
|
|---|
| 142 | //******************************************************************************
|
|---|
| 143 | //******************************************************************************
|
|---|
| 144 | BOOL WIN32API GetClassInfoA(HINSTANCE hInstance, LPCSTR lpszClass, WNDCLASSA *lpwc)
|
|---|
| 145 | {
|
|---|
| 146 | WNDCLASSEXA wc;
|
|---|
| 147 | BOOL rc;
|
|---|
| 148 | Win32WndClass *wndclass;
|
|---|
| 149 |
|
|---|
| 150 | dprintf(("USER32: GetClassInfoA\n"));
|
|---|
| 151 |
|
|---|
| 152 | wndclass = Win32WndClass::FindClass(hInstance, (LPSTR)lpszClass);
|
|---|
| 153 | if(wndclass) {
|
|---|
| 154 | wndclass->getClassInfo(&wc);
|
|---|
| 155 | memcpy(lpwc, &wc.style, sizeof(WNDCLASSA));
|
|---|
| 156 | return(TRUE);
|
|---|
| 157 | }
|
|---|
| 158 | return(FALSE);
|
|---|
| 159 | }
|
|---|
| 160 | //******************************************************************************
|
|---|
| 161 | //******************************************************************************
|
|---|
| 162 | BOOL WIN32API GetClassInfoW(HINSTANCE hinst, LPCWSTR lpszClass, WNDCLASSW *lpwc)
|
|---|
| 163 | {
|
|---|
| 164 | WNDCLASSEXW wc;
|
|---|
| 165 | BOOL rc;
|
|---|
| 166 | Win32WndClass *wndclass;
|
|---|
| 167 | char *astring = NULL;
|
|---|
| 168 |
|
|---|
| 169 | dprintf(("USER32: GetClassInfoW\n"));
|
|---|
| 170 |
|
|---|
| 171 | if(HIWORD(lpszClass) != 0) {
|
|---|
| 172 | astring = UnicodeToAsciiString((LPWSTR)lpszClass);
|
|---|
| 173 | }
|
|---|
| 174 | else astring = (char *)lpszClass;
|
|---|
| 175 |
|
|---|
| 176 | wndclass = Win32WndClass::FindClass(hinst, astring);
|
|---|
| 177 | if(HIWORD(astring) != 0)
|
|---|
| 178 | FreeAsciiString((char *)astring);
|
|---|
| 179 |
|
|---|
| 180 | if(wndclass) {
|
|---|
| 181 | wndclass->getClassInfo(&wc);
|
|---|
| 182 | memcpy(lpwc, &wc.style, sizeof(WNDCLASSW));
|
|---|
| 183 | return(TRUE);
|
|---|
| 184 | }
|
|---|
| 185 | return(FALSE);
|
|---|
| 186 | }
|
|---|
| 187 | /****************************************************************************
|
|---|
| 188 | * Name : BOOL WIN32API GetClassInfoExA
|
|---|
| 189 | * Purpose : The GetClassInfoEx function retrieves information about a window
|
|---|
| 190 | * class, including the handle of the small icon associated with the
|
|---|
| 191 | * window class. GetClassInfo does not retrieve the handle of the small icon.
|
|---|
| 192 | * Parameters: HINSTANCE hinst handle of application instance
|
|---|
| 193 | * LPCTSTR lpszClass address of class name string
|
|---|
| 194 | * LPWNDCLASSEX lpwcx address of structure for class data
|
|---|
| 195 | * Variables :
|
|---|
| 196 | * Result : If the function finds a matching class and successfully copies
|
|---|
| 197 | * the data, the return value is TRUE;
|
|---|
| 198 | * otherwise, it is FALSE.
|
|---|
| 199 | * To get extended error information, call GetLastError.
|
|---|
| 200 | * Remark : PH: does not obtain handle of the small icon
|
|---|
| 201 | *****************************************************************************/
|
|---|
| 202 | BOOL WIN32API GetClassInfoExA(HINSTANCE hInstance,
|
|---|
| 203 | LPCTSTR lpszClass,
|
|---|
| 204 | LPWNDCLASSEXA lpwcx)
|
|---|
| 205 | {
|
|---|
| 206 | BOOL rc;
|
|---|
| 207 | Win32WndClass *wndclass;
|
|---|
| 208 |
|
|---|
| 209 | dprintf(("USER32:GetClassInfoExA (%08xh,%x,%08x).\n",
|
|---|
| 210 | hInstance,
|
|---|
| 211 | lpszClass,
|
|---|
| 212 | lpwcx));
|
|---|
| 213 |
|
|---|
| 214 | wndclass = Win32WndClass::FindClass(hInstance, (LPSTR)lpszClass);
|
|---|
| 215 | if(wndclass) {
|
|---|
| 216 | wndclass->getClassInfo(lpwcx);
|
|---|
| 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 | return(TRUE);
|
|---|
| 259 | }
|
|---|
| 260 | return(FALSE);
|
|---|
| 261 | }
|
|---|
| 262 | //******************************************************************************
|
|---|
| 263 | //******************************************************************************
|
|---|
| 264 | int WIN32API GetClassNameA(HWND hwnd, LPSTR lpszClassName, int cchClassName)
|
|---|
| 265 | {
|
|---|
| 266 | Win32BaseWindow *wnd;
|
|---|
| 267 |
|
|---|
| 268 | dprintf(("USER32: GetClassNameA\n"));
|
|---|
| 269 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 270 | if(!wnd) {
|
|---|
| 271 | dprintf(("GetClassNameA wnd == NULL"));
|
|---|
| 272 | return(0);
|
|---|
| 273 | }
|
|---|
| 274 | return (wnd->getClass())->getClassName(lpszClassName, cchClassName);
|
|---|
| 275 | }
|
|---|
| 276 | //******************************************************************************
|
|---|
| 277 | //******************************************************************************
|
|---|
| 278 | int WIN32API GetClassNameW(HWND hwnd, LPWSTR lpszClassName, int cchClassName)
|
|---|
| 279 | {
|
|---|
| 280 | Win32BaseWindow *wnd;
|
|---|
| 281 |
|
|---|
| 282 | dprintf(("USER32: GetClassNameW\n"));
|
|---|
| 283 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 284 | if(!wnd) {
|
|---|
| 285 | dprintf(("GetClassNameA wnd == NULL"));
|
|---|
| 286 | return(0);
|
|---|
| 287 | }
|
|---|
| 288 | return (wnd->getClass())->getClassName(lpszClassName, cchClassName);
|
|---|
| 289 | }
|
|---|
| 290 | //******************************************************************************
|
|---|
| 291 | //******************************************************************************
|
|---|
| 292 | LONG WIN32API SetClassLongA(HWND hwnd, int nIndex, LONG lNewVal)
|
|---|
| 293 | {
|
|---|
| 294 | Win32BaseWindow *wnd;
|
|---|
| 295 |
|
|---|
| 296 | dprintf(("USER32: SetClassLongA\n"));
|
|---|
| 297 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 298 | if(!wnd) {
|
|---|
| 299 | dprintf(("SetClassLongA wnd == NULL"));
|
|---|
| 300 | return(0);
|
|---|
| 301 | }
|
|---|
| 302 | return (wnd->getClass())->setClassLongA(nIndex, lNewVal);
|
|---|
| 303 | }
|
|---|
| 304 | //******************************************************************************
|
|---|
| 305 | //******************************************************************************
|
|---|
| 306 | LONG WIN32API SetClassLongW(HWND hwnd, int nIndex, LONG lNewVal)
|
|---|
| 307 | {
|
|---|
| 308 | Win32BaseWindow *wnd;
|
|---|
| 309 |
|
|---|
| 310 | dprintf(("USER32: SetClassLongW\n"));
|
|---|
| 311 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 312 | if(!wnd) {
|
|---|
| 313 | dprintf(("SetClassLongW wnd == NULL"));
|
|---|
| 314 | return(0);
|
|---|
| 315 | }
|
|---|
| 316 | return (wnd->getClass())->setClassLongW(nIndex, lNewVal);
|
|---|
| 317 | }
|
|---|
| 318 | //******************************************************************************
|
|---|
| 319 | //******************************************************************************
|
|---|
| 320 | WORD WIN32API SetClassWord(HWND hwnd, int nIndex, WORD wNewVal)
|
|---|
| 321 | {
|
|---|
| 322 | Win32BaseWindow *wnd;
|
|---|
| 323 |
|
|---|
| 324 | dprintf(("USER32: SetClassWordA\n"));
|
|---|
| 325 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 326 | if(!wnd) {
|
|---|
| 327 | dprintf(("SetClassWordA wnd == NULL"));
|
|---|
| 328 | return(0);
|
|---|
| 329 | }
|
|---|
| 330 | return (wnd->getClass())->setClassWord(nIndex, wNewVal);
|
|---|
| 331 | }
|
|---|
| 332 | //******************************************************************************
|
|---|
| 333 | //******************************************************************************
|
|---|
| 334 | WORD WIN32API GetClassWord(HWND hwnd, int nIndex)
|
|---|
| 335 | {
|
|---|
| 336 | Win32BaseWindow *wnd;
|
|---|
| 337 |
|
|---|
| 338 | dprintf(("USER32: GetClassWordA\n"));
|
|---|
| 339 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 340 | if(!wnd) {
|
|---|
| 341 | dprintf(("GetClassWordA wnd == NULL"));
|
|---|
| 342 | return(0);
|
|---|
| 343 | }
|
|---|
| 344 | return (wnd->getClass())->getClassWord(nIndex);
|
|---|
| 345 | }
|
|---|
| 346 | //******************************************************************************
|
|---|
| 347 | //******************************************************************************
|
|---|
| 348 | LONG WIN32API GetClassLongA(HWND hwnd, int nIndex)
|
|---|
| 349 | {
|
|---|
| 350 | Win32BaseWindow *wnd;
|
|---|
| 351 |
|
|---|
| 352 | dprintf(("USER32: GetClassLongA\n"));
|
|---|
| 353 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 354 | if(!wnd) {
|
|---|
| 355 | dprintf(("GetClassLongA wnd == NULL"));
|
|---|
| 356 | return(0);
|
|---|
| 357 | }
|
|---|
| 358 | return (wnd->getClass())->getClassLongA(nIndex);
|
|---|
| 359 | }
|
|---|
| 360 | //******************************************************************************
|
|---|
| 361 | //******************************************************************************
|
|---|
| 362 | LONG WIN32API GetClassLongW(HWND hwnd, int nIndex)
|
|---|
| 363 | {
|
|---|
| 364 | Win32BaseWindow *wnd;
|
|---|
| 365 |
|
|---|
| 366 | dprintf(("USER32: GetClassLongW\n"));
|
|---|
| 367 | wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
|
|---|
| 368 | if(!wnd) {
|
|---|
| 369 | dprintf(("GetClassLongW wnd == NULL"));
|
|---|
| 370 | return(0);
|
|---|
| 371 | }
|
|---|
| 372 | return (wnd->getClass())->getClassLongW(nIndex);
|
|---|
| 373 | }
|
|---|
| 374 | //******************************************************************************
|
|---|
| 375 | //******************************************************************************
|
|---|