Ignore:
Timestamp:
Dec 18, 2002, 1:28:08 PM (23 years ago)
Author:
sandervl
Message:

removed obsolete files

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:55 sandervl Exp $ */
     1/* $Id: win32class.cpp,v 1.30 2002-12-18 12:28:06 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Managment Code for OS/2
    44 *
    55 * 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)
    611 *
    712 *
     
    4045//Win32WndClass methods:
    4146//******************************************************************************
    42 Win32WndClass::Win32WndClass(WNDCLASSEXA *wndclass, BOOL fUnicode)
     47Win32WndClass::Win32WndClass(WNDCLASSEXA *wndclass, WNDCLASS_TYPE fClassType)
    4348                  : GenericObject(&wndclasses, &critsect)
    4449{
    45   isUnicode = fUnicode;
     50  this->fClassType = fClassType;
    4651  processId = 0;
    4752
    48   if(HIWORD(wndclass->lpszClassName)) {
    49         if(isUnicode) {
     53  if(HIWORD(wndclass->lpszClassName))
     54  {
     55        if(fClassType == WNDCLASS_UNICODE) {
    5056                INT len = lstrlenW((LPWSTR)wndclass->lpszClassName)+1;
    5157
     
    6369                exit(1);
    6470        }
    65         if(isUnicode) {
     71        if(fClassType == WNDCLASS_UNICODE) {
    6672                lstrcpyW(classNameW, (LPWSTR)wndclass->lpszClassName);
    6773                UnicodeToAscii(classNameW, classNameA);
     
    126132  windowStyle           = wndclass->style;
    127133
    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));
    131143
    132144  //User data class words/longs
     
    156168  }
    157169
    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);
    159174
    160175  if(userClassBytes)    free(userClassBytes);
     
    179194{
    180195  if(HIWORD(classname) == 0) {
    181     return classAtom == (DWORD)classname;
     196      return classAtom == (DWORD)classname;
    182197  }
    183198  if(fUnicode) {
     
    349364//******************************************************************************
    350365//******************************************************************************
     366WNDPROC 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//******************************************************************************
     381void 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//******************************************************************************
    351390void Win32WndClass::setMenuName(LPSTR newMenuName)
    352391{
     
    358397  }
    359398  if(HIWORD(newMenuName)) {
    360         if(isUnicode) {
     399        if(fClassType == WNDCLASS_UNICODE) {
    361400                menuNameA = (PCHAR)_smalloc(lstrlenW((LPWSTR)newMenuName)+1);
    362401                menuNameW = (WCHAR *)_smalloc((lstrlenW((LPWSTR)newMenuName)+1)*sizeof(WCHAR));
     
    368407        if(menuNameA == NULL || menuNameW == NULL) {
    369408                dprintf(("Win32Class ctr; menuName/menuNameW == NULL"));
    370                 exit(1);
    371         }
    372         if(isUnicode) {
     409                DebugInt3();
     410                return;
     411        }
     412        if(fClassType == WNDCLASS_UNICODE) {
    373413                lstrcpyW(menuNameW, (LPWSTR)newMenuName);
    374414                UnicodeToAscii(menuNameW, menuNameA);
     
    405445                return hInstance;
    406446        case GCL_MENUNAME:
    407                 return (isUnicode) ? (ULONG)menuNameW : (ULONG)menuNameA;
     447                return (fUnicode) ? (ULONG)menuNameW : (ULONG)menuNameA;
    408448        case GCL_STYLE:
    409449                return windowStyle;
    410450        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        }
    412461        case GCW_ATOM: //TODO: does this really happen in windows?
    413462                SetLastError(ERROR_INVALID_PARAMETER);
     
    493542                break;
    494543        case GCL_WNDPROC:
     544        {
    495545                //Note: Type of SetWindowLong determines new window proc type
    496546                //      UNLESS the new window proc has already been registered
     
    498548                //      (VERIFIED in NT 4, SP6)
    499549                //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        }
    503577        case GCW_ATOM: //TODO: does this really happen in windows?
    504578                SetLastError(ERROR_INVALID_PARAMETER);
Note: See TracChangeset for help on using the changeset viewer.