Changeset 3702 for trunk/src


Ignore:
Timestamp:
Jun 13, 2000, 11:26:30 PM (25 years ago)
Author:
sandervl
Message:

when registering a class, check if it already exists and return error

Location:
trunk/src/user32
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/win32class.cpp

    r3153 r3702  
    1 /* $Id: win32class.cpp,v 1.16 2000-03-18 16:13:37 cbratschi Exp $ */
     1/* $Id: win32class.cpp,v 1.17 2000-06-13 21:26:29 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Managment Code for OS/2
     
    240240  dprintf(("Class %X (inst %X) not found!", id, hInstance));
    241241  return(NULL);
     242}
     243//******************************************************************************
     244//******************************************************************************
     245Win32WndClass *Win32WndClass::FindClass(HINSTANCE hInstance, LPWSTR id)
     246{
     247 LPSTR          lpszClassName;
     248 Win32WndClass *winclass;
     249
     250  if(HIWORD(id)) {
     251        lpszClassName = UnicodeToAsciiString((LPWSTR)id);
     252  }
     253  else  lpszClassName = (LPSTR)id;
     254
     255  winclass = FindClass(hInstance, lpszClassName);
     256
     257  if(HIWORD(id)) {
     258        FreeAsciiString((char *)lpszClassName);
     259  }
     260  return winclass;
    242261}
    243262//******************************************************************************
  • trunk/src/user32/win32class.h

    r3153 r3702  
    1 /* $Id: win32class.h,v 1.11 2000-03-18 16:13:38 cbratschi Exp $ */
     1/* $Id: win32class.h,v 1.12 2000-06-13 21:26:30 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Managment Code for OS/2
     
    6868
    6969 static Win32WndClass *FindClass(HINSTANCE hinst, LPSTR id);
     70 static Win32WndClass *FindClass(HINSTANCE hinst, LPWSTR id);
     71
    7072 static  void   DestroyAll();
    7173
  • trunk/src/user32/windowclass.cpp

    r3625 r3702  
    1 /* $Id: windowclass.cpp,v 1.10 2000-05-28 16:43:48 sandervl Exp $ */
     1/* $Id: windowclass.cpp,v 1.11 2000-06-13 21:26:30 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Code for OS/2
     
    4545 Win32WndClass *wclass;
    4646
    47     dprintf(("RegisterClassA\n"));
     47   dprintf(("RegisterClassA\n"));
    4848   //CB: size new in ex structure
    4949   wc.cbSize = sizeof(wc);
     
    5151   wc.hIconSm = 0;
    5252
     53   if(Win32WndClass::FindClass(wc.hInstance, (LPSTR)wc.lpszClassName)) {
     54        dprintf(("RegisterClassA %x %x already exists", wc.hInstance, wc.lpszClassName));
     55        SetLastError(ERROR_CLASS_ALREADY_EXISTS);
     56        return 0;
     57   }
     58
    5359   wclass = new Win32WndClass(&wc,FALSE);
    5460   if(wclass == NULL) {
    55         dprintf(("RegisterClassA wclass == NULL!"));
     61        dprintf(("ERROR: RegisterClassA winclass == NULL!"));
     62        DebugInt3();
    5663        return(0);
    5764   }
     
    6370{
    6471 Win32WndClass *wclass;
     72
     73   if(Win32WndClass::FindClass(lpWndClass->hInstance, (LPSTR)lpWndClass->lpszClassName)) {
     74        dprintf(("RegisterClassExA %x %x already exists", lpWndClass->hInstance, lpWndClass->lpszClassName));
     75        SetLastError(ERROR_CLASS_ALREADY_EXISTS);
     76        return 0;
     77   }
    6578
    6679   dprintf(("RegisterClassExA\n"));
    6780   wclass = new Win32WndClass((WNDCLASSEXA *)lpWndClass,FALSE);
    6881   if(wclass == NULL) {
    69         dprintf(("RegisterClassExA wclass == NULL!"));
     82        dprintf(("ERROR: RegisterClassExA winclass == NULL!"));
     83        DebugInt3();
    7084        return(0);
    7185   }
     
    7791{
    7892 ATOM rc;
    79  WNDCLASSEXA wclass;
     93 WNDCLASSEXA wc;
    8094 Win32WndClass *winclass;
    8195
    8296    dprintf(("RegisterClassW\n"));
    8397    //CB: size new in ex structure
    84     wclass.cbSize = sizeof(wclass);
    85     memcpy(&wclass.style, lpwc, sizeof(WNDCLASSA));
    86 
    87     winclass = new Win32WndClass((WNDCLASSEXA *)&wclass, TRUE);
     98    wc.cbSize = sizeof(wc);
     99    memcpy(&wc.style, lpwc, sizeof(WNDCLASSA));
     100
     101    if(Win32WndClass::FindClass(wc.hInstance, (LPWSTR)wc.lpszClassName)) {
     102        dprintf(("RegisterClassW %x %x already exists", wc.hInstance, wc.lpszClassName));
     103        SetLastError(ERROR_CLASS_ALREADY_EXISTS);
     104        return 0;
     105    }
     106
     107    winclass = new Win32WndClass((WNDCLASSEXA *)&wc, TRUE);
    88108    if(winclass == NULL) {
    89         dprintf(("RegisterClassW wclass == NULL!"));
    90         return(0);
     109        dprintf(("ERROR: RegisterClassW winclass == NULL!"));
     110        DebugInt3();
     111        return 0;
    91112    }
    92113    rc = winclass->getAtom();
     
    99120{
    100121 ATOM rc;
    101  WNDCLASSEXA wclass;
     122 WNDCLASSEXA wc;
    102123 Win32WndClass *winclass;
    103124
    104125    dprintf(("RegisterClassExW\n"));
    105     memcpy(&wclass, lpwc, sizeof(WNDCLASSEXA));
    106 
    107     winclass = new Win32WndClass((WNDCLASSEXA *)&wclass, TRUE);
     126    memcpy(&wc, lpwc, sizeof(WNDCLASSEXA));
     127
     128    if(Win32WndClass::FindClass(wc.hInstance, (LPWSTR)wc.lpszClassName)) {
     129        dprintf(("RegisterClassW %x %x already exists", wc.hInstance, wc.lpszClassName));
     130        SetLastError(ERROR_CLASS_ALREADY_EXISTS);
     131        return 0;
     132    }
     133
     134    winclass = new Win32WndClass((WNDCLASSEXA *)&wc, TRUE);
    108135    if(winclass == NULL) {
    109         dprintf(("RegisterClassExW wclass == NULL!"));
     136        dprintf(("ERROR: RegisterClassExW winclass == NULL!"));
     137        DebugInt3();
    110138        return(0);
    111139    }
Note: See TracChangeset for help on using the changeset viewer.