Changeset 9523 for trunk/src/user32/win32class.cpp
- Timestamp:
- Dec 18, 2002, 1:28:08 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/win32class.cpp
r7663 r9523 1 /* $Id: win32class.cpp,v 1. 29 2001-12-20 20:45:55sandervl Exp $ */1 /* $Id: win32class.cpp,v 1.30 2002-12-18 12:28:06 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Class Managment Code for OS/2 4 4 * 5 5 * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl) 6 * 7 * 8 * Parts copied from ReWind (Get/SetClassLong for GCL_WNDPROC) 9 * Copyright 1993, 1996 Alexandre Julliard 10 * 1998 Juergen Schmied (jsch) 6 11 * 7 12 * … … 40 45 //Win32WndClass methods: 41 46 //****************************************************************************** 42 Win32WndClass::Win32WndClass(WNDCLASSEXA *wndclass, BOOL fUnicode)47 Win32WndClass::Win32WndClass(WNDCLASSEXA *wndclass, WNDCLASS_TYPE fClassType) 43 48 : GenericObject(&wndclasses, &critsect) 44 49 { 45 isUnicode = fUnicode;50 this->fClassType = fClassType; 46 51 processId = 0; 47 52 48 if(HIWORD(wndclass->lpszClassName)) { 49 if(isUnicode) { 53 if(HIWORD(wndclass->lpszClassName)) 54 { 55 if(fClassType == WNDCLASS_UNICODE) { 50 56 INT len = lstrlenW((LPWSTR)wndclass->lpszClassName)+1; 51 57 … … 63 69 exit(1); 64 70 } 65 if( isUnicode) {71 if(fClassType == WNDCLASS_UNICODE) { 66 72 lstrcpyW(classNameW, (LPWSTR)wndclass->lpszClassName); 67 73 UnicodeToAscii(classNameW, classNameA); … … 126 132 windowStyle = wndclass->style; 127 133 128 windowProc = 0; 129 WINPROC_SetProc((HWINDOWPROC *)&windowProc, wndclass->lpfnWndProc, (isUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_CLASS); 130 dprintf2(("Window class ptr %x", windowProc)); 134 pfnWindowProcA = 0; 135 pfnWindowProcW = 0; 136 if(fClassType == WNDCLASS_UNICODE) { 137 WINPROC_SetProc((HWINDOWPROC *)&pfnWindowProcW, wndclass->lpfnWndProc, WIN_PROC_32W, WIN_PROC_CLASS); 138 } 139 else { 140 WINPROC_SetProc((HWINDOWPROC *)&pfnWindowProcA, wndclass->lpfnWndProc, WIN_PROC_32A, WIN_PROC_CLASS); 141 } 142 dprintf2(("Window class ptr %x/%x", pfnWindowProcA, pfnWindowProcW)); 131 143 132 144 //User data class words/longs … … 156 168 } 157 169 158 WINPROC_FreeProc(windowProc, WIN_PROC_CLASS); 170 if(pfnWindowProcA) 171 WINPROC_FreeProc(pfnWindowProcA, WIN_PROC_CLASS); 172 if(pfnWindowProcW) 173 WINPROC_FreeProc(pfnWindowProcW, WIN_PROC_CLASS); 159 174 160 175 if(userClassBytes) free(userClassBytes); … … 179 194 { 180 195 if(HIWORD(classname) == 0) { 181 return classAtom == (DWORD)classname;196 return classAtom == (DWORD)classname; 182 197 } 183 198 if(fUnicode) { … … 349 364 //****************************************************************************** 350 365 //****************************************************************************** 366 WNDPROC Win32WndClass::getWindowProc(WNDPROC_TYPE type) 367 { 368 WNDPROC proc; 369 370 if(type == WNDPROC_UNICODE) { 371 proc = (pfnWindowProcW) ? pfnWindowProcW : pfnWindowProcA; 372 } 373 else proc = (pfnWindowProcA) ? pfnWindowProcA : pfnWindowProcW; 374 375 return proc; 376 }; 377 //****************************************************************************** 378 //NOTE: Only to be used when a class has both ascii & unicode window procedures! 379 // Otherwise use SetClassLong GCL_WNDPROC 380 //****************************************************************************** 381 void Win32WndClass::setWindowProc(WNDPROC pfnWindowProc, WNDPROC_TYPE type) 382 { 383 if(type == WNDPROC_UNICODE) { 384 WINPROC_SetProc((HWINDOWPROC *)&pfnWindowProcW, pfnWindowProc, WIN_PROC_32W, WIN_PROC_CLASS); 385 } 386 else WINPROC_SetProc((HWINDOWPROC *)&pfnWindowProcA, pfnWindowProc, WIN_PROC_32A, WIN_PROC_CLASS); 387 } 388 //****************************************************************************** 389 //****************************************************************************** 351 390 void Win32WndClass::setMenuName(LPSTR newMenuName) 352 391 { … … 358 397 } 359 398 if(HIWORD(newMenuName)) { 360 if( isUnicode) {399 if(fClassType == WNDCLASS_UNICODE) { 361 400 menuNameA = (PCHAR)_smalloc(lstrlenW((LPWSTR)newMenuName)+1); 362 401 menuNameW = (WCHAR *)_smalloc((lstrlenW((LPWSTR)newMenuName)+1)*sizeof(WCHAR)); … … 368 407 if(menuNameA == NULL || menuNameW == NULL) { 369 408 dprintf(("Win32Class ctr; menuName/menuNameW == NULL")); 370 exit(1); 371 } 372 if(isUnicode) { 409 DebugInt3(); 410 return; 411 } 412 if(fClassType == WNDCLASS_UNICODE) { 373 413 lstrcpyW(menuNameW, (LPWSTR)newMenuName); 374 414 UnicodeToAscii(menuNameW, menuNameA); … … 405 445 return hInstance; 406 446 case GCL_MENUNAME: 407 return ( isUnicode) ? (ULONG)menuNameW : (ULONG)menuNameA;447 return (fUnicode) ? (ULONG)menuNameW : (ULONG)menuNameA; 408 448 case GCL_STYLE: 409 449 return windowStyle; 410 450 case GCL_WNDPROC: 411 return (ULONG) WINPROC_GetProc(windowProc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A); 451 { 452 WNDPROC pfnWindowProc = pfnWindowProcA; 453 454 if(pfnWindowProcW) 455 { 456 if(!pfnWindowProc || fUnicode) 457 pfnWindowProc = pfnWindowProcW; 458 } 459 return (ULONG) WINPROC_GetProc(pfnWindowProc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A); 460 } 412 461 case GCW_ATOM: //TODO: does this really happen in windows? 413 462 SetLastError(ERROR_INVALID_PARAMETER); … … 493 542 break; 494 543 case GCL_WNDPROC: 544 { 495 545 //Note: Type of SetWindowLong determines new window proc type 496 546 // UNLESS the new window proc has already been registered … … 498 548 // (VERIFIED in NT 4, SP6) 499 549 //TODO: Is that also true for GCL_WNDPROC??????????????? 500 rc = (LONG)WINPROC_GetProc(windowProc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A ); 501 WINPROC_SetProc((HWINDOWPROC *)&windowProc, (WNDPROC)lNewVal, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A, WIN_PROC_CLASS ); 502 break; 550 WNDPROC *proc = &pfnWindowProcA; 551 WINDOWPROCTYPE type = (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A; 552 553 if(pfnWindowProcW) 554 { 555 if(!*proc || fUnicode) 556 proc = &pfnWindowProcW; 557 } 558 rc = (LONG)WINPROC_GetProc(*proc, type ); 559 WINPROC_SetProc((HWINDOWPROC *)proc, (WNDPROC)lNewVal, type, WIN_PROC_CLASS); 560 561 /* now free the one that we didn't set */ 562 if(pfnWindowProcA && pfnWindowProcW) 563 { 564 if (proc == &pfnWindowProcA) 565 { 566 WINPROC_FreeProc( pfnWindowProcW, WIN_PROC_CLASS ); 567 pfnWindowProcW = 0; 568 } 569 else 570 { 571 WINPROC_FreeProc( pfnWindowProcA, WIN_PROC_CLASS ); 572 pfnWindowProcA = 0; 573 } 574 } 575 break; 576 } 503 577 case GCW_ATOM: //TODO: does this really happen in windows? 504 578 SetLastError(ERROR_INVALID_PARAMETER);
Note:
See TracChangeset
for help on using the changeset viewer.