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