Changeset 304 for trunk/src


Ignore:
Timestamp:
Jul 14, 1999, 11:05:59 PM (26 years ago)
Author:
cbratschi
Message:

several bugs fixed, RegisterClass works, CreateWindow on the way

Location:
trunk/src/user32/new
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/new/initterm.cpp

    r300 r304  
    1 /* $Id: initterm.cpp,v 1.1 1999-07-14 08:35:34 sandervl Exp $ */
     1/* $Id: initterm.cpp,v 1.2 1999-07-14 21:05:58 cbratschi Exp $ */
    22
    33/*
     
    2727#define  INCL_DOSMODULEMGR
    2828#define  INCL_DOSPROCESS
    29 #include <os2wrap.h>    //Odin32 OS/2 api wrappers
     29#include <os2wrap.h>    //Odin32 OS/2 api wrappers
    3030#include <stdlib.h>
    3131#include <stdio.h>
     
    9595         if (CRT_init() == -1)
    9696            return 0UL;
    97          _ctordtorInit();
     97         _ctordtorInit();
    9898
    9999         CheckVersionFromHMOD(PE2LX_VERSION, hModule); /*PLF Wed  98-03-18 05:28:48*/
     
    105105         rc = DosExitList(0x0000FF00|EXLST_ADD, cleanup);
    106106         if(rc)
    107                 return 0UL;
     107                return 0UL;
    108108
    109109         rc = DosExitList(0x00008000|EXLST_ADD, cleanupQueue);
    110110         if(rc)
    111                 return 0UL;
     111                return 0UL;
    112112
    113113         //SvL: 18-7-'98, Register system window classes (button, listbox etc etc)
    114          RegisterSystemClasses(hModule);
     114         RegisterSystemClasses(hModule);
    115115
    116         //SvL: Try to start communication with our message spy queue server
    117         InitSpyQueue();
     116        //SvL: Try to start communication with our message spy queue server
     117        InitSpyQueue();
    118118
    119         //SvL: Init win32 PM classes
    120         if(InitPM() == FALSE) {
    121                 return 0UL;
    122         }
     119        //SvL: Init win32 PM classes
     120        if(InitPM() == FALSE) {
     121                return 0UL;
     122        }
    123123         break;
    124124      case 1 :
  • trunk/src/user32/new/menu.cpp

    r300 r304  
    1 /* $Id: menu.cpp,v 1.1 1999-07-14 08:35:35 sandervl Exp $ */
     1/* $Id: menu.cpp,v 1.2 1999-07-14 21:05:58 cbratschi Exp $ */
    22
    33/*
     
    1717 */
    1818#include <os2win.h>
     19#include <stdlib.h>
    1920
    2021//******************************************************************************
     
    8889    free(astring);
    8990    if(rc) {
    90                 dprintf(("USER32: OS2GetMenuStringW %s\n", astring));
    91                 AsciiToUnicode(astring, lpsz);
     91                dprintf(("USER32: OS2GetMenuStringW %s\n", astring));
     92                AsciiToUnicode(astring, lpsz);
    9293    }
    93     else        lpsz[0] = 0;
     94    else        lpsz[0] = 0;
    9495    return(rc);
    9596}
     
    158159#endif
    159160  if(lpPM->cbSize != 0)
    160         rect = &lpPM->rcExclude;
     161        rect = &lpPM->rcExclude;
    161162
    162163  return O32_TrackPopupMenu(hmenu, flags, X, Y, 0, hwnd, rect);
     
    165166//******************************************************************************
    166167BOOL WIN32API AppendMenuA(HMENU hMenu, UINT uFlags, UINT ulDNewItem,
    167                              LPCSTR lpNewItem)
     168                             LPCSTR lpNewItem)
    168169{
    169170#ifdef DEBUG
     
    173174
    174175    if(uFlags & MF_STRING || uFlags == 0)
    175             WriteLog("USER32:  OS2AppendMenuA %s\n", lpNewItem);
     176            WriteLog("USER32:  OS2AppendMenuA %s\n", lpNewItem);
    176177
    177178    rc = O32_AppendMenu(hMenu, uFlags, ulDNewItem, lpNewItem);
     
    358359//******************************************************************************
    359360BOOL WIN32API CheckMenuRadioItem(HMENU hmenu, UINT idFirst, UINT idLast,
    360                                     UINT idCheck, UINT uFlags)
     361                                    UINT idCheck, UINT uFlags)
    361362{
    362363#ifdef DEBUG
     
    407408//******************************************************************************
    408409BOOL WIN32API SetMenuItemInfoA(HMENU hmenu, UINT par1, BOOL par2,
    409                                const MENUITEMINFOA * lpMenuItemInfo)
     410                               const MENUITEMINFOA * lpMenuItemInfo)
    410411{
    411412#ifdef DEBUG
  • trunk/src/user32/new/oslibwin.cpp

    r300 r304  
    1 /* $Id: oslibwin.cpp,v 1.1 1999-07-14 08:35:35 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.2 1999-07-14 21:05:58 cbratschi Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    2424  if(hwndParent == OSLIB_HWND_DESKTOP)
    2525  {
    26         hwndParent = HWND_DESKTOP;
     26        hwndParent = HWND_DESKTOP;
    2727  }
    2828
     
    4040
    4141  if(hwndParent == 0) {
    42         hwndParent = HWND_DESKTOP;
     42        hwndParent = HWND_DESKTOP;
    4343  }
    4444  if(WinQueryWindowRect(hwndParent, &rectl) == 0) {
    45         y = OS2TOWIN32POINT(rectl.yTop - rectl.yBottom, y);
     45        y = OS2TOWIN32POINT(rectl.yTop - rectl.yBottom, y);
    4646  }
    4747  if(dwFrameStyle) {
    48         dwWinStyle &= ~WS_CLIPCHILDREN; //invalid style according to docs
    49         hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
    50                                        &dwFrameStyle, WIN32_STDCLASS,
     48        dwWinStyle &= ~WS_CLIPCHILDREN; //invalid style according to docs
     49        hwndFrame = WinCreateStdWindow(hwndParent, dwWinStyle,
     50                                       &dwFrameStyle, WIN32_STDCLASS,
    5151                                       "", 0, 0, 0, &hwndClient) != 0;
    52         if(hwndFrame) {
    53                 if(pszName) {
    54                         WinSetWindowText(hwndFrame, pszName);
    55                 }
    56                 WinSetWindowPos(hwndFrame, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 
    57                                 x, y, cx, cy, SWP_SIZE | SWP_MOVE);
     52        if(hwndFrame) {
     53                if(pszName) {
     54                        WinSetWindowText(hwndFrame, pszName);
     55                }
     56                WinSetWindowPos(hwndFrame, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP,
     57                                x, y, cx, cy, SWP_SIZE | SWP_MOVE);
    5858
    59                 return hwndFrame;
    60         }
    61         return 0;
     59                return hwndFrame;
     60        }
     61        return 0;
    6262  }
    63   else  return WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, x, y, cx, cy,
     63  else  return WinCreateWindow(hwndParent, WIN32_STDCLASS, pszName, dwWinStyle, x, y, cx, cy,
    6464                               Owner, (fHWND_BOTTOM) ? HWND_BOTTOM :HWND_TOP, 0, NULL,
    6565                               NULL);
     
    7474  /* Window styles */
    7575  if(dwStyle & WINWS_MINIMIZE)
    76         *OSWinStyle |= WS_MINIMIZED;
     76        *OSWinStyle |= WS_MINIMIZED;
    7777  if(dwStyle & WINWS_VISIBLE)
    78         *OSWinStyle |= WS_VISIBLE;
     78        *OSWinStyle |= WS_VISIBLE;
    7979  if(dwStyle & WINWS_DISABLED)
    80         *OSWinStyle |= WS_DISABLED;
     80        *OSWinStyle |= WS_DISABLED;
    8181  if(dwStyle & WINWS_CLIPSIBLINGS)
    82         *OSWinStyle |= WS_CLIPSIBLINGS;
     82        *OSWinStyle |= WS_CLIPSIBLINGS;
    8383  if(dwStyle & WINWS_CLIPCHILDREN)
    84         *OSWinStyle |= WS_CLIPCHILDREN;
     84        *OSWinStyle |= WS_CLIPCHILDREN;
    8585  if(dwStyle & WINWS_MAXIMIZE)
    86         *OSWinStyle |= WS_MAXIMIZED;
     86        *OSWinStyle |= WS_MAXIMIZED;
    8787  if(dwStyle & WINWS_GROUP)
    88         *OSWinStyle |= WS_GROUP;
     88        *OSWinStyle |= WS_GROUP;
    8989  if(dwStyle & WINWS_TABSTOP)
    90         *OSWinStyle |= WS_TABSTOP;
     90        *OSWinStyle |= WS_TABSTOP;
    9191
    9292  if(dwStyle & WINWS_CAPTION)
    93         *OSFrameStyle |= FCF_TITLEBAR;
     93        *OSFrameStyle |= FCF_TITLEBAR;
    9494  if(dwStyle & WINWS_BORDER)
    95         *OSFrameStyle |= FCF_BORDER;
     95        *OSFrameStyle |= FCF_BORDER;
    9696  if(dwStyle & WINWS_DLGFRAME)
    97         *OSFrameStyle |= FCF_DLGBORDER;
     97        *OSFrameStyle |= FCF_DLGBORDER;
    9898  if(dwStyle & WINWS_VSCROLL)
    99         *OSFrameStyle |= FCF_VERTSCROLL;
     99        *OSFrameStyle |= FCF_VERTSCROLL;
    100100  if(dwStyle & WINWS_HSCROLL)
    101         *OSFrameStyle |= FCF_HORZSCROLL;
     101        *OSFrameStyle |= FCF_HORZSCROLL;
    102102  if(dwStyle & WINWS_SYSMENU)
    103         *OSFrameStyle |= FCF_SYSMENU;
     103        *OSFrameStyle |= FCF_SYSMENU;
    104104  if(dwStyle & WINWS_THICKFRAME)
    105         *OSFrameStyle |= FCF_SIZEBORDER;        //??
     105        *OSFrameStyle |= FCF_SIZEBORDER;        //??
    106106  if(dwStyle & WINWS_MINIMIZEBOX)
    107         *OSFrameStyle |= FCF_MINBUTTON;
     107        *OSFrameStyle |= FCF_MINBUTTON;
    108108  if(dwStyle & WINWS_MAXIMIZEBOX)
    109         *OSFrameStyle |= FCF_MAXBUTTON;
     109        *OSFrameStyle |= FCF_MAXBUTTON;
    110110
    111111  return TRUE;
     
    115115BOOL OSLibWinSetWindowULong(HWND hwnd, ULONG offset, ULONG value)
    116116{
    117   return WinSetWindowULong(hwnd, offset, value) == 0;
     117  return WinSetWindowULong(hwnd, offset, value);
    118118}
    119119//******************************************************************************
     
    121121ULONG OSLibWinGetWindowULong(HWND hwnd, ULONG offset)
    122122{
    123   return WinGetWindowULong(hwnd, offset);
     123  return WinQueryWindowULong(hwnd, offset);
    124124}
    125125//******************************************************************************
  • trunk/src/user32/new/pmwindow.cpp

    r300 r304  
    1 /* $Id: pmwindow.cpp,v 1.2 1999-07-14 08:35:35 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.3 1999-07-14 21:05:58 cbratschi Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    3636
    3737  if(!hab || !hmq) {
    38         dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
    39         return(FALSE);
     38        UINT error;
     39
     40        //CB: only fail on real error
     41        error = WinGetLastError(hab) & 0xFFFF; //error code
     42        if (!hab || error != PMERR_MSG_QUEUE_ALREADY_EXISTS)
     43        {
     44          dprintf(("WinInitialize or WinCreateMsgQueue failed %x %x", hab, hmq));
     45          dprintf((" Error = %x",error));
     46          return(FALSE);
     47        } else
     48        {
     49          //CB: get queue handle (todo)
     50        }
    4051  }
    4152
     
    4657     CS_SIZEREDRAW,                     /* Class style                  */
    4758     8)) {
    48         dprintf(("WinRegisterClass Win32Window failed"));
    49         return(FALSE);
     59        dprintf(("WinRegisterClass Win32Window failed"));
     60        return(FALSE);
    5061   }
    5162
     
    6879
    6980  if(msg != WM_CREATE && win32wnd == NULL && magic != WIN32PM_MAGIC) {
    70         dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
    71         goto RunDefWndProc;
     81        dprintf(("Invalid win32wnd pointer for window %x!!", hwnd));
     82        goto RunDefWndProc;
    7283  }
    7384  switch( msg )
    74   {     
     85  {
    7586    case WM_CREATE:
    76         //Processing is done in after WinCreateWindow returns
    77         break;
    78        
     87        //Processing is done in after WinCreateWindow returns
     88        break;
     89
    7990    case WM_QUIT:
    80         if(win32wnd->MsgQuit()) {
    81                 goto RunDefWndProc;
    82         }
    83         break;
    84        
     91        if(win32wnd->MsgQuit()) {
     92                goto RunDefWndProc;
     93        }
     94        break;
     95
    8596    case WM_CLOSE:
    86         if(win32wnd->MsgClose()) {
    87                 goto RunDefWndProc;
    88         }
    89         break;
     97        if(win32wnd->MsgClose()) {
     98                goto RunDefWndProc;
     99        }
     100        break;
    90101
    91102    case WM_DESTROY:
    92         if(win32wnd->MsgDestroy()) {
    93                 goto RunDefWndProc;
    94         }
    95         break;
     103        if(win32wnd->MsgDestroy()) {
     104                goto RunDefWndProc;
     105        }
     106        break;
    96107
    97108    case WM_ENABLE:
    98         if(win32wnd->MsgEnable((ULONG)mp1)) {
    99                 goto RunDefWndProc;
    100         }
    101         break;
     109        if(win32wnd->MsgEnable((ULONG)mp1)) {
     110                goto RunDefWndProc;
     111        }
     112        break;
    102113
    103114    case WM_SHOW:
    104         if(win32wnd->MsgShow((ULONG)mp1)) {
    105                 goto RunDefWndProc;
    106         }
    107         break;
     115        if(win32wnd->MsgShow((ULONG)mp1)) {
     116                goto RunDefWndProc;
     117        }
     118        break;
    108119
    109120    case WM_MOVE:
     
    114125     ULONG  xScreen, yScreen, yParent, xParent;
    115126
    116         rc = WinQueryWindowRect(hwnd, &rectl);
    117         if(rc == TRUE) {
    118                 point.x = rectl.xLeft;
    119                 point.y = rectl.yBottom;
    120 
    121                 //If the window has a parent, calculate position relative to that window
    122                 if((hwndParent = WinQueryWindow(hwnd, QW_PARENT)) != WinQueryDesktopWindow(hab, NULLHANDLE)) {
    123                         rc = WinMapWindowPoints(hwnd, hwndParent, &point, 1);
    124                         if(rc == FALSE) {
    125                                 dprintf(("WM_MOVE: WinMapWindowPoints (parent) failed!"));
    126                                 break;
    127                         }
    128                         rc = WinQueryWindowRect(hwndParent, &rectl2);
    129                         if(rc == FALSE) {
    130                                 dprintf(("WM_MOVE: WinQueryWindowRect(HWND_DESKTOP, &rectl) failed!"));
    131                                 break;
    132                         }
    133                         yParent = point.x;
    134                         yParent = OS2TOWIN32POINT(rectl2.yTop - rectl2.yBottom, point.y);
    135                 }
    136                 else    xParent = yParent = -1;
    137 
    138                 point.x = rectl.xLeft;
    139                 point.y = rectl.yBottom;
    140 
    141                 rc = WinMapWindowPoints(hwnd, HWND_DESKTOP, &point, 1);
    142                 if(rc == FALSE) {
    143                         dprintf(("WM_MOVE: WinMapWindowPoints (desktop) failed!"));
    144                         break;
    145                 }
    146                 rc = WinQueryWindowRect(HWND_DESKTOP, &rectl);
    147                 if(rc == FALSE) {
    148                         dprintf(("WM_MOVE: WinQueryWindowRect(HWND_DESKTOP, &rectl) failed!"));
    149                         break;
    150                 }
    151                 xScreen = point.x;
    152                 yScreen = OS2TOWIN32POINT(rectl.yTop - rectl.yBottom, point.y);
    153 
    154                 if(win32wnd->MsgMove(xScreen, yScreen, xParent, yParent)) {
    155                         goto RunDefWndProc;
    156                 }
    157         }
    158         else {
    159                 dprintf(("WM_MOVE: WinQueryWindowRect failed!"));
    160         }
    161         break;
     127        rc = WinQueryWindowRect(hwnd, &rectl);
     128        if(rc == TRUE) {
     129                point.x = rectl.xLeft;
     130                point.y = rectl.yBottom;
     131
     132                //If the window has a parent, calculate position relative to that window
     133                if((hwndParent = WinQueryWindow(hwnd, QW_PARENT)) != WinQueryDesktopWindow(hab, NULLHANDLE)) {
     134                        rc = WinMapWindowPoints(hwnd, hwndParent, &point, 1);
     135                        if(rc == FALSE) {
     136                                dprintf(("WM_MOVE: WinMapWindowPoints (parent) failed!"));
     137                                break;
     138                        }
     139                        rc = WinQueryWindowRect(hwndParent, &rectl2);
     140                        if(rc == FALSE) {
     141                                dprintf(("WM_MOVE: WinQueryWindowRect(HWND_DESKTOP, &rectl) failed!"));
     142                                break;
     143                        }
     144                        yParent = point.x;
     145                        yParent = OS2TOWIN32POINT(rectl2.yTop - rectl2.yBottom, point.y);
     146                }
     147                else    xParent = yParent = -1;
     148
     149                point.x = rectl.xLeft;
     150                point.y = rectl.yBottom;
     151
     152                rc = WinMapWindowPoints(hwnd, HWND_DESKTOP, &point, 1);
     153                if(rc == FALSE) {
     154                        dprintf(("WM_MOVE: WinMapWindowPoints (desktop) failed!"));
     155                        break;
     156                }
     157                rc = WinQueryWindowRect(HWND_DESKTOP, &rectl);
     158                if(rc == FALSE) {
     159                        dprintf(("WM_MOVE: WinQueryWindowRect(HWND_DESKTOP, &rectl) failed!"));
     160                        break;
     161                }
     162                xScreen = point.x;
     163                yScreen = OS2TOWIN32POINT(rectl.yTop - rectl.yBottom, point.y);
     164
     165                if(win32wnd->MsgMove(xScreen, yScreen, xParent, yParent)) {
     166                        goto RunDefWndProc;
     167                }
     168        }
     169        else {
     170                dprintf(("WM_MOVE: WinQueryWindowRect failed!"));
     171        }
     172        break;
    162173    }
    163174
    164175    case WM_WINDOWPOSCHANGED:
    165176    {
    166         break;
     177        break;
    167178    }
    168179
    169180    case WM_ADJUSTWINDOWPOS:
    170181    {
    171 //      if(win32wnd->MsgWindowPosChanging(0, 0)) {
    172         break;
     182//      if(win32wnd->MsgWindowPosChanging(0, 0)) {
     183        break;
    173184    }
    174185
     
    177188     HPS hps;
    178189
    179         hps = WinGetPS(hwnd);
    180         if(win32wnd->MsgEraseBackGround((ULONG)hps))
     190        hps = WinGetPS(hwnd);
     191        if(win32wnd->MsgEraseBackGround((ULONG)hps))
    181192        {
    182                 /*
    183                  * Return TRUE to request PM to paint the window background
    184                  * in SYSCLR_WINDOW.
    185                  */
    186                 WinReleasePS(hps);
    187                 return (MRESULT)( TRUE );
    188         }
    189         WinReleasePS(hps);
    190         return (MRESULT) FALSE;
     193                /*
     194                 * Return TRUE to request PM to paint the window background
     195                 * in SYSCLR_WINDOW.
     196                 */
     197                WinReleasePS(hps);
     198                return (MRESULT)( TRUE );
     199        }
     200        WinReleasePS(hps);
     201        return (MRESULT) FALSE;
    191202    }
    192203    case WM_SIZE:
     
    194205     SWP swp;
    195206
    196         rc = WinQueryWindowPos(hwnd, &swp);
    197         if(rc == FALSE) {
    198                 dprintf(("WM_SIZE: WinQueryWindowPos failed!"));
    199                 break;
    200         }
    201         if(win32wnd->MsgSize(SHORT1FROMMP(mp2), SHORT2FROMMP(mp2),
    202                                 (swp.fl & SWP_MINIMIZE) != 0,
    203                                 (swp.fl & SWP_MAXIMIZE) != 0)) 
     207        rc = WinQueryWindowPos(hwnd, &swp);
     208        if(rc == FALSE) {
     209                dprintf(("WM_SIZE: WinQueryWindowPos failed!"));
     210                break;
     211        }
     212        if(win32wnd->MsgSize(SHORT1FROMMP(mp2), SHORT2FROMMP(mp2),
     213                                (swp.fl & SWP_MINIMIZE) != 0,
     214                                (swp.fl & SWP_MAXIMIZE) != 0))
    204215        {
    205                 goto RunDefWndProc;
    206         }
    207 
    208         break;
     216                goto RunDefWndProc;
     217        }
     218
     219        break;
    209220    }
    210221
     
    213224      HWND hwndActivate = (HWND)mp1;
    214225
    215         if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
    216                 //another (non-win32) application's window
    217                 //set to NULL (allowed according to win32 SDK) to avoid problems
    218                 hwndActivate = NULL;
    219         }
    220         if(win32wnd->MsgActivate(1, hwndActivate)) {
    221                 goto RunDefWndProc;
    222         }
    223         break;
     226        if(WinQueryWindowULong(hwndActivate, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
     227                //another (non-win32) application's window
     228                //set to NULL (allowed according to win32 SDK) to avoid problems
     229                hwndActivate = NULL;
     230        }
     231        if(win32wnd->MsgActivate(1, hwndActivate)) {
     232                goto RunDefWndProc;
     233        }
     234        break;
    224235    }
    225236    case WM_FOCUSCHANGE:
    226         break;
     237        break;
    227238
    228239    case WM_SETFOCUS:
     
    230241      HWND hwndFocus = (HWND)mp1;
    231242
    232         if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
    233                 //another (non-win32) application's window
    234                 //set to NULL (allowed according to win32 SDK) to avoid problems
    235                 hwndFocus = NULL;
    236         }
    237         if((ULONG)mp2 == TRUE) {
    238                 rc = win32wnd->MsgSetFocus(hwndFocus);
    239         }
    240         else    rc = win32wnd->MsgKillFocus(hwndFocus);
    241         if(rc) {
    242                 goto RunDefWndProc;
    243         }
    244         break;
     243        if(WinQueryWindowULong(hwndFocus, OFFSET_WIN32PM_MAGIC) != WIN32PM_MAGIC) {
     244                //another (non-win32) application's window
     245                //set to NULL (allowed according to win32 SDK) to avoid problems
     246                hwndFocus = NULL;
     247        }
     248        if((ULONG)mp2 == TRUE) {
     249                rc = win32wnd->MsgSetFocus(hwndFocus);
     250        }
     251        else    rc = win32wnd->MsgKillFocus(hwndFocus);
     252        if(rc) {
     253                goto RunDefWndProc;
     254        }
     255        break;
    245256    }
    246257    //**************************************************************************
     
    248259    //**************************************************************************
    249260    case WM_BUTTON1DOWN:
    250         if(win32wnd->MsgButton(BUTTON_LEFTDOWN, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
    251                 goto RunDefWndProc;
    252         }
    253         break;
     261        if(win32wnd->MsgButton(BUTTON_LEFTDOWN, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     262                goto RunDefWndProc;
     263        }
     264        break;
    254265    case WM_BUTTON1UP:
    255         if(win32wnd->MsgButton(BUTTON_LEFTUP, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
    256                 goto RunDefWndProc;
    257         }
    258         break;
     266        if(win32wnd->MsgButton(BUTTON_LEFTUP, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     267                goto RunDefWndProc;
     268        }
     269        break;
    259270    case WM_BUTTON1DBLCLK:
    260         if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
    261                 goto RunDefWndProc;
    262         }
    263         break;
     271        if(win32wnd->MsgButton(BUTTON_LEFTDBLCLICK, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     272                goto RunDefWndProc;
     273        }
     274        break;
    264275    case WM_BUTTON2DOWN:
    265         if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
    266                 goto RunDefWndProc;
    267         }
    268         break;
     276        if(win32wnd->MsgButton(BUTTON_RIGHTDOWN, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     277                goto RunDefWndProc;
     278        }
     279        break;
    269280    case WM_BUTTON2UP:
    270         if(win32wnd->MsgButton(BUTTON_RIGHTUP, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
    271                 goto RunDefWndProc;
    272         }
    273         break;
     281        if(win32wnd->MsgButton(BUTTON_RIGHTUP, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     282                goto RunDefWndProc;
     283        }
     284        break;
    274285    case WM_BUTTON2DBLCLK:
    275         if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
    276                 goto RunDefWndProc;
    277         }
    278         break;
     286        if(win32wnd->MsgButton(BUTTON_RIGHTDBLCLICK, (*(POINTS *)&mp1).x, (*(POINTS *)&mp1).y)) {
     287                goto RunDefWndProc;
     288        }
     289        break;
    279290    case WM_BUTTON2MOTIONSTART:
    280291    case WM_BUTTON2MOTIONEND:
     
    289300    case WM_BUTTON3MOTIONEND:
    290301    case WM_BUTTON3CLICK:
    291         break;
     302        break;
    292303
    293304    case WM_MOUSEMOVE:
    294         break;
     305        break;
    295306
    296307    //**************************************************************************
     
    298309    //**************************************************************************
    299310    case WM_VSCROLL:
    300         break;
     311        break;
    301312    case WM_HSCROLL:
    302         break;
     313        break;
    303314
    304315    case WM_CONTROL:
    305         break;
     316        break;
    306317
    307318    case WM_COMMAND:
    308319    case WM_SYSCOMMAND:
    309         break;
     320        break;
    310321
    311322    case WM_CHAR:
    312         break;
     323        break;
    313324
    314325    case WM_INITMENU:
     
    316327    case WM_MENUEND:
    317328    case WM_NEXTMENU:
    318         break;
     329        break;
    319330
    320331    case WM_TIMER:
    321         break;
     332        break;
    322333
    323334    case WM_PAINT:
    324         if(win32wnd->MsgPaint(0, 0)) {
    325                 goto RunDefWndProc;
    326         }
    327         break;
     335        if(win32wnd->MsgPaint(0, 0)) {
     336                goto RunDefWndProc;
     337        }
     338        break;
    328339
    329340    case WM_SYSCOLORCHANGE:
    330341    case WM_SYSVALUECHANGED:
    331         break;
     342        break;
    332343
    333344    case WM_CALCVALIDRECTS:
     
    353364    case WM_SAVEAPPLICATION:
    354365    case WM_SEMANTICEVENT:
    355         break;
     366        break;
    356367    default:
    357         RestoreOS2TIB();       
    358         return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     368        RestoreOS2TIB();
     369        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    359370  }
    360   RestoreOS2TIB();     
     371  RestoreOS2TIB();
    361372  return (MRESULT)FALSE;
    362373
    363374RunDefWndProc:
    364   RestoreOS2TIB();     
     375  RestoreOS2TIB();
    365376  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    366377} /* End of Win32WindowProc */
  • trunk/src/user32/new/win32class.cpp

    r300 r304  
    1 /* $Id: win32class.cpp,v 1.2 1999-07-14 08:35:36 sandervl Exp $ */
     1/* $Id: win32class.cpp,v 1.3 1999-07-14 21:05:58 cbratschi Exp $ */
    22/*
    33 * Win32 Window Class Managment Code for OS/2
     
    2323{
    2424  if(HIWORD(wndclass->lpszClassName)) {
    25         if(isUnicode) {
    26                 classNameA = (PCHAR)malloc(lstrlenW((LPWSTR)wndclass->lpszClassName)+1);
    27                 classNameW = (WCHAR *)malloc((lstrlenW((LPWSTR)wndclass->lpszClassName)+1)*sizeof(WCHAR));
    28         }
    29         else {
    30                 classNameA = (PCHAR)malloc(strlen(wndclass->lpszClassName)+1);
    31                 classNameW = (WCHAR *)malloc((strlen(wndclass->lpszClassName)+1)*sizeof(WCHAR));
    32         }
    33         if(classNameA == NULL || classNameW == NULL) {
    34                 dprintf(("Win32Class ctr; classNameA/classNameW == NULL"));
    35                 exit(1);
    36         }
    37         if(isUnicode) {
    38                 lstrcpyW(classNameW, (LPWSTR)wndclass->lpszClassName);
    39                 UnicodeToAscii(classNameW, classNameA);
    40         }
    41         else {
    42                 strcpy((char *)classNameA, wndclass->lpszClassName);
    43                 AsciiToUnicode(classNameA, classNameW);
    44         }
    45         classAtom       = GlobalAddAtomA(classNameA);
     25        if(isUnicode) {
     26                INT len = lstrlenW((LPWSTR)wndclass->lpszClassName)+1;
     27
     28                classNameA = (PCHAR)malloc(len);
     29                classNameW = (WCHAR *)malloc(len*sizeof(WCHAR));
     30        }
     31        else {
     32                INT len = strlen(wndclass->lpszClassName)+1;
     33
     34                classNameA = (PCHAR)malloc(len);
     35                classNameW = (WCHAR *)malloc(len*sizeof(WCHAR));
     36        }
     37        if(classNameA == NULL || classNameW == NULL) {
     38                dprintf(("Win32Class ctr; classNameA/classNameW == NULL"));
     39                exit(1);
     40        }
     41        if(isUnicode) {
     42                lstrcpyW(classNameW, (LPWSTR)wndclass->lpszClassName);
     43                UnicodeToAscii(classNameW, classNameA);
     44        }
     45        else {
     46                strcpy((char *)classNameA, wndclass->lpszClassName);
     47                AsciiToUnicode(classNameA, classNameW);
     48        }
     49        classAtom       = GlobalAddAtomA(classNameA);
    4650  }
    4751  else {
    48         classNameA      = NULL;
    49         classNameW      = NULL;
    50         classAtom       = (DWORD)wndclass->lpszClassName;
     52        classNameA      = NULL;
     53        classNameW      = NULL;
     54        classAtom       = (DWORD)wndclass->lpszClassName;
    5155  }
    5256  this->isUnicode       = isUnicode;
     
    6266  dprintf(("USER32:  wndclass->hbrBackground %X\n", wndclass->hbrBackground));
    6367  if(HIWORD(wndclass->lpszClassName))
    64        dprintf(("USER32:  wndclass->lpszClassName %X\n", wndclass->lpszClassName));
    65   else dprintf(("USER32:  wndclass->lpszClassName %s\n", wndclass->lpszClassName));
     68       dprintf(("USER32:  wndclass->lpszClassName %s\n", wndclass->lpszClassName));
     69  else dprintf(("USER32:  wndclass->lpszClassName %X\n", wndclass->lpszClassName));
    6670
    6771  if(HIWORD(wndclass->lpszMenuName)) {//convert string name identifier to numeric id
     
    7074  else dprintf(("USER32:  wndclass->lpszMenuName %X\n", wndclass->lpszMenuName));
    7175
    72   nrExtraClassWords     = wndclass->cbClsExtra;
    73   nrExtraWindowWords    = wndclass->cbWndExtra;
    74   backgroundBrush       = wndclass->hbrBackground;      //TODO: fErase of PAINSTRUCT in WM_PAINT if == NULL
    75   hCursor               = wndclass->hCursor;
    76   hIcon                 = wndclass->hIcon;
    77   hInstance             = wndclass->hInstance;
     76  nrExtraClassWords     = wndclass->cbClsExtra;
     77  nrExtraWindowWords    = wndclass->cbWndExtra;
     78  backgroundBrush       = wndclass->hbrBackground;      //TODO: fErase of PAINSTRUCT in WM_PAINT if == NULL
     79  hCursor               = wndclass->hCursor;
     80  hIcon                 = wndclass->hIcon;
     81  hInstance             = wndclass->hInstance;
    7882
    7983  menuNameA = 0;
     
    8185  setMenuName((LPSTR)wndclass->lpszMenuName);
    8286
    83   windowStyle           = wndclass->style;
    84   windowProc            = wndclass->lpfnWndProc;
     87  windowStyle           = wndclass->style;
     88  windowProc            = wndclass->lpfnWndProc;
    8589
    8690  //User data class words/longs
    8791  if(nrExtraClassWords) {
    88         userClassLong = (ULONG *)malloc(nrExtraClassWords);
    89         if(userClassLong == NULL) {
    90                 dprintf(("Win32Class ctr: userClassLong == NULL!"));
    91                 exit(1);
    92         }
    93         memset(userClassLong, 0, nrExtraClassWords);
    94   }
    95   else  userClassLong = NULL;
     92        userClassLong = (ULONG *)malloc(nrExtraClassWords);
     93        if(userClassLong == NULL) {
     94                dprintf(("Win32Class ctr: userClassLong == NULL!"));
     95                exit(1);
     96        }
     97        memset(userClassLong, 0, nrExtraClassWords);
     98  }
     99  else  userClassLong = NULL;
    96100
    97101  cWindows = 0;
     
    102106Win32WndClass::~Win32WndClass()
    103107{
    104   if(userClassLong)     free(userClassLong);
    105   if(classNameA)        free(classNameA);
    106   if(classNameW)        free(classNameW);
     108  if(userClassLong)     free(userClassLong);
     109  if(classNameA)        free(classNameA);
     110  if(classNameW)        free(classNameW);
    107111  if(menuNameA && HIWORD(menuNameA)) {
    108         free(menuNameA);
    109         assert(menuNameW);
    110         free(menuNameW);
     112        free(menuNameA);
     113        assert(menuNameW);
     114        free(menuNameW);
    111115  }
    112116}
     
    117121  Win32WndClass *wndclass = (Win32WndClass *)wndclasses;
    118122
    119   if(wndclass == NULL)  return(NULL);
     123  if(wndclass == NULL)  return(NULL);
    120124
    121125  if(HIWORD(id) != 0) {
    122         if(stricmp(wndclass->classNameA, id) == 0 && wndclass->hInstance == hInstance) {
    123                 return(wndclass);
    124         }
    125         else {
    126                 wndclass = (Win32WndClass *)wndclass->GetNext();
    127                 while(wndclass != NULL) {
    128                         if(stricmp(wndclass->classNameA, id) == 0 && wndclass->hInstance == hInstance) {
    129                                 return(wndclass);
    130                         }
    131                         wndclass = (Win32WndClass *)wndclass->GetNext();
    132                 }
    133         }
     126        if(stricmp(wndclass->classNameA, id) == 0 && wndclass->hInstance == hInstance) {
     127                return(wndclass);
     128        }
     129        else {
     130                wndclass = (Win32WndClass *)wndclass->GetNext();
     131                while(wndclass != NULL) {
     132                        if(stricmp(wndclass->classNameA, id) == 0 && wndclass->hInstance == hInstance) {
     133                                return(wndclass);
     134                        }
     135                        wndclass = (Win32WndClass *)wndclass->GetNext();
     136                }
     137        }
    134138  }
    135139  else {
    136         if(wndclass->classAtom == (DWORD)id && wndclass->hInstance == hInstance) {
    137                 return(wndclass);
    138         }
    139         else {
    140                 wndclass = (Win32WndClass *)wndclass->GetNext();
    141                 while(wndclass != NULL) {
    142                         if(wndclass->classAtom == (DWORD)id && wndclass->hInstance == hInstance) {
    143                                 return(wndclass);
    144                         }
    145                         wndclass = (Win32WndClass *)wndclass->GetNext();
    146                 }
    147         }
     140        if(wndclass->classAtom == (DWORD)id && wndclass->hInstance == hInstance) {
     141                return(wndclass);
     142        }
     143        else {
     144                wndclass = (Win32WndClass *)wndclass->GetNext();
     145                while(wndclass != NULL) {
     146                        if(wndclass->classAtom == (DWORD)id && wndclass->hInstance == hInstance) {
     147                                return(wndclass);
     148                        }
     149                        wndclass = (Win32WndClass *)wndclass->GetNext();
     150                }
     151        }
    148152  }
    149153  dprintf(("Class %X (inst %X) not found!", id, hInstance));
     
    157161  wndclass->cbWndExtra    = nrExtraWindowWords;
    158162  wndclass->hbrBackground = backgroundBrush;
    159   wndclass->hCursor       = hCursor;
     163  wndclass->hCursor       = hCursor;
    160164  wndclass->hIcon         = hIcon;
    161165  wndclass->hInstance     = hInstance;
    162166  wndclass->lpszMenuName  = (LPCTSTR)menuNameA;
    163167  wndclass->lpszClassName = (classNameA) ? (LPCTSTR)classNameA : (LPCTSTR)classAtom;
    164   wndclass->style         = windowStyle;
    165   wndclass->lpfnWndProc   = windowProc;
    166   wndclass->hIconSm       = hIconSm;
     168  wndclass->style         = windowStyle;
     169  wndclass->lpfnWndProc   = windowProc;
     170  wndclass->hIconSm       = hIconSm;
    167171  return(TRUE);
    168172}
     
    174178  wndclass->cbWndExtra    = nrExtraWindowWords;
    175179  wndclass->hbrBackground = backgroundBrush;
    176   wndclass->hCursor       = hCursor;
     180  wndclass->hCursor       = hCursor;
    177181  wndclass->hIcon         = hIcon;
    178182  wndclass->hInstance     = hInstance;
    179183  wndclass->lpszMenuName  = (LPCWSTR)menuNameW;
    180184  wndclass->lpszClassName = (classNameW) ? (LPCWSTR)classNameW : (LPCWSTR)classAtom;
    181   wndclass->style         = windowStyle;
    182   wndclass->lpfnWndProc   = windowProc;
    183   wndclass->hIconSm       = hIconSm;
     185  wndclass->style         = windowStyle;
     186  wndclass->lpfnWndProc   = windowProc;
     187  wndclass->hIconSm       = hIconSm;
    184188  return(TRUE);
    185189}
     
    189193{
    190194  if(HIWORD(classNameA)) {
    191         strncpy(lpszClassName, classNameA, cchClassName-1);
    192         return strlen(lpszClassName);
     195        strncpy(lpszClassName, classNameA, cchClassName-1);
     196        return strlen(lpszClassName);
    193197  }
    194198  *(ULONG *)lpszClassName = classAtom;
     
    202206
    203207  if(HIWORD(classNameW)) {
    204         lstrcpyW(lpszClassName, classNameW);
    205         return lstrlenW(lpszClassName)*sizeof(WCHAR);
     208        lstrcpyW(lpszClassName, classNameW);
     209        return lstrlenW(lpszClassName)*sizeof(WCHAR);
    206210  }
    207211  *(ULONG *)lpszClassName = classAtom;
     
    213217{
    214218  if(HIWORD(menuNameA)) {
    215         free(menuNameA);
    216         free(menuNameW);
    217         menuNameA = 0;
     219        free(menuNameA);
     220        free(menuNameW);
     221        menuNameA = 0;
    218222        menuNameW = 0;
    219223  }
    220224  if(HIWORD(newMenuName)) {
    221         if(isUnicode) {
    222                 menuNameA = (PCHAR)malloc(lstrlenW((LPWSTR)newMenuName)+1);
    223                 menuNameW = (WCHAR *)malloc((lstrlenW((LPWSTR)newMenuName)+1)*sizeof(WCHAR));
    224         }
    225         else {
    226                 menuNameA = (PCHAR)malloc(strlen(newMenuName)+1);
    227                 menuNameW = (WCHAR *)malloc((strlen(newMenuName)+1)*sizeof(WCHAR));
    228         }
    229         if(menuNameA == NULL || menuNameW == NULL) {
    230                 dprintf(("Win32Class ctr; menuName/menuNameW == NULL"));
    231                 exit(1);
    232         }
    233         if(isUnicode) {
    234                 lstrcpyW(menuNameW, (LPWSTR)newMenuName);
    235                 UnicodeToAscii(menuNameW, menuNameA);
    236         }
    237         else {
    238                 strcpy((char *)menuNameA, newMenuName);
    239                 AsciiToUnicode(menuNameA, menuNameW);
    240         }
     225        if(isUnicode) {
     226                menuNameA = (PCHAR)malloc(lstrlenW((LPWSTR)newMenuName)+1);
     227                menuNameW = (WCHAR *)malloc((lstrlenW((LPWSTR)newMenuName)+1)*sizeof(WCHAR));
     228        }
     229        else {
     230                menuNameA = (PCHAR)malloc(strlen(newMenuName)+1);
     231                menuNameW = (WCHAR *)malloc((strlen(newMenuName)+1)*sizeof(WCHAR));
     232        }
     233        if(menuNameA == NULL || menuNameW == NULL) {
     234                dprintf(("Win32Class ctr; menuName/menuNameW == NULL"));
     235                exit(1);
     236        }
     237        if(isUnicode) {
     238                lstrcpyW(menuNameW, (LPWSTR)newMenuName);
     239                UnicodeToAscii(menuNameW, menuNameA);
     240        }
     241        else {
     242                strcpy((char *)menuNameA, newMenuName);
     243                AsciiToUnicode(menuNameA, menuNameW);
     244        }
    241245  }
    242246  else {//id
    243         menuNameA = (PCHAR)newMenuName;
    244         menuNameW = (WCHAR *)newMenuName;
     247        menuNameA = (PCHAR)newMenuName;
     248        menuNameW = (WCHAR *)newMenuName;
    245249  }
    246250}
     
    250254{
    251255  switch(index) {
    252         case GCL_CBCLSEXTRA:
    253                 return nrExtraClassWords;
    254         case GCL_CBWNDEXTRA:
    255                 return nrExtraWindowWords;
    256         case GCL_HBRBACKGROUND:
    257                 return backgroundBrush;
    258         case GCL_HCURSOR:
    259                 return hCursor;
    260         case GCL_HICON:
    261                 return hIcon;
    262         case GCL_HMODULE:
    263                 return hInstance;
    264         case GCL_MENUNAME:
    265                 return (isUnicode) ? (ULONG)menuNameW : (ULONG)menuNameA;
    266         case GCL_STYLE:
    267                 return windowStyle;
    268         case GCL_WNDPROC:
    269                 return (ULONG)windowProc;
    270         case GCW_ATOM: //TODO: does this really happen in windows?
    271                 SetLastError(ERROR_INVALID_PARAMETER);
    272                 return 0;
    273         default:
    274                 if(index > 0 && index < nrExtraClassWords - sizeof(ULONG)) {
    275                         return userClassLong[index];
    276                 }
    277                 SetLastError(ERROR_INVALID_PARAMETER);
    278                 return 0;
     256        case GCL_CBCLSEXTRA:
     257                return nrExtraClassWords;
     258        case GCL_CBWNDEXTRA:
     259                return nrExtraWindowWords;
     260        case GCL_HBRBACKGROUND:
     261                return backgroundBrush;
     262        case GCL_HCURSOR:
     263                return hCursor;
     264        case GCL_HICON:
     265                return hIcon;
     266        case GCL_HMODULE:
     267                return hInstance;
     268        case GCL_MENUNAME:
     269                return (isUnicode) ? (ULONG)menuNameW : (ULONG)menuNameA;
     270        case GCL_STYLE:
     271                return windowStyle;
     272        case GCL_WNDPROC:
     273                return (ULONG)windowProc;
     274        case GCW_ATOM: //TODO: does this really happen in windows?
     275                SetLastError(ERROR_INVALID_PARAMETER);
     276                return 0;
     277        default:
     278                if(index > 0 && index < nrExtraClassWords - sizeof(ULONG)) {
     279                        return userClassLong[index];
     280                }
     281                SetLastError(ERROR_INVALID_PARAMETER);
     282                return 0;
    279283  }
    280284}
     
    284288{
    285289  switch(index) {
    286         case GCW_ATOM:
    287                 return (WORD)classAtom;
    288         default:
    289                 if(index > 0 && index < nrExtraClassWords - sizeof(WORD)) {
    290                         return ((WORD *)userClassLong)[index];
    291                 }
    292                 SetLastError(ERROR_INVALID_PARAMETER);
    293                 return 0;
     290        case GCW_ATOM:
     291                return (WORD)classAtom;
     292        default:
     293                if(index > 0 && index < nrExtraClassWords - sizeof(WORD)) {
     294                        return ((WORD *)userClassLong)[index];
     295                }
     296                SetLastError(ERROR_INVALID_PARAMETER);
     297                return 0;
    294298  }
    295299}
     
    302306
    303307  switch(index) {
    304         case GCL_CBCLSEXTRA: //TODO (doesn't affect allocated classes, so what does it do?)
    305                 rc = nrExtraClassWords;
    306 //              nrExtraClassWords = lNewVal;
    307                 break;
    308         case GCL_CBWNDEXTRA:
    309                 rc = nrExtraWindowWords;
    310                 nrExtraWindowWords = lNewVal;
    311                 break;
    312         case GCL_HBRBACKGROUND:
    313                 rc = backgroundBrush;
    314                 backgroundBrush = lNewVal;
    315                 break;
    316         case GCL_HCURSOR:
    317                 rc = hCursor;
    318                 hCursor = lNewVal;
    319                 break;
    320         case GCL_HICON:
    321                 rc = hIcon;
    322                 hIcon = lNewVal;
    323                 break;
    324         case GCL_HMODULE:
    325                 rc = hInstance;
    326                 hInstance = lNewVal;
    327                 break;
    328         case GCL_MENUNAME:
    329                 rc = 0; //old value is meaningless (according to Wine)
    330                 setMenuName((LPSTR)lNewVal);
    331                 break;
    332         case GCL_STYLE:
    333                 rc = windowStyle;
    334                 windowStyle = lNewVal;
    335                 break;
    336         case GCL_WNDPROC:
    337                 rc = (ULONG)windowProc;
    338                 windowProc = (WNDPROC)lNewVal;
    339                 break;
    340         case GCW_ATOM: //TODO: does this really happen in windows?
    341                 SetLastError(ERROR_INVALID_PARAMETER);
    342                 return 0;
    343         default:
    344                 if(index > 0 && index < nrExtraClassWords - sizeof(ULONG)) {
    345                         rc = userClassLong[index];
    346                         userClassLong[index] = lNewVal;
    347                         return(rc);
    348                 }
    349                 SetLastError(ERROR_INVALID_PARAMETER);
    350                 return 0;
     308        case GCL_CBCLSEXTRA: //TODO (doesn't affect allocated classes, so what does it do?)
     309                rc = nrExtraClassWords;
     310//              nrExtraClassWords = lNewVal;
     311                break;
     312        case GCL_CBWNDEXTRA:
     313                rc = nrExtraWindowWords;
     314                nrExtraWindowWords = lNewVal;
     315                break;
     316        case GCL_HBRBACKGROUND:
     317                rc = backgroundBrush;
     318                backgroundBrush = lNewVal;
     319                break;
     320        case GCL_HCURSOR:
     321                rc = hCursor;
     322                hCursor = lNewVal;
     323                break;
     324        case GCL_HICON:
     325                rc = hIcon;
     326                hIcon = lNewVal;
     327                break;
     328        case GCL_HMODULE:
     329                rc = hInstance;
     330                hInstance = lNewVal;
     331                break;
     332        case GCL_MENUNAME:
     333                rc = 0; //old value is meaningless (according to Wine)
     334                setMenuName((LPSTR)lNewVal);
     335                break;
     336        case GCL_STYLE:
     337                rc = windowStyle;
     338                windowStyle = lNewVal;
     339                break;
     340        case GCL_WNDPROC:
     341                rc = (ULONG)windowProc;
     342                windowProc = (WNDPROC)lNewVal;
     343                break;
     344        case GCW_ATOM: //TODO: does this really happen in windows?
     345                SetLastError(ERROR_INVALID_PARAMETER);
     346                return 0;
     347        default:
     348                if(index > 0 && index < nrExtraClassWords - sizeof(ULONG)) {
     349                        rc = userClassLong[index];
     350                        userClassLong[index] = lNewVal;
     351                        return(rc);
     352                }
     353                SetLastError(ERROR_INVALID_PARAMETER);
     354                return 0;
    351355  }
    352356  return(rc);
     
    359363
    360364  switch(index) {
    361         case GCW_ATOM:
    362                 rc = (WORD)classAtom;
    363                 classAtom = wNewVal;
    364                 return(rc);
    365         default:
    366                 if(index > 0 && index < nrExtraClassWords - sizeof(WORD)) {
    367                         rc = ((WORD *)userClassLong)[index];
    368                         ((WORD *)userClassLong)[index] = wNewVal;
    369                         return(rc);
    370                 }
    371                 SetLastError(ERROR_INVALID_PARAMETER);
    372                 return 0;
     365        case GCW_ATOM:
     366                rc = (WORD)classAtom;
     367                classAtom = wNewVal;
     368                return(rc);
     369        default:
     370                if(index > 0 && index < nrExtraClassWords - sizeof(WORD)) {
     371                        rc = ((WORD *)userClassLong)[index];
     372                        ((WORD *)userClassLong)[index] = wNewVal;
     373                        return(rc);
     374                }
     375                SetLastError(ERROR_INVALID_PARAMETER);
     376                return 0;
    373377  }
    374378}
     
    383387  wndclass = FindClass(hinst, id);
    384388  if(wndclass) {
    385         delete wndclass;
    386         return;
     389        delete wndclass;
     390        return;
    387391  }
    388392  dprintf(("::UnregisterClass, couldn't find class %X!!\n", id));
  • trunk/src/user32/new/win32wnd.cpp

    r300 r304  
    1 /* $Id: win32wnd.cpp,v 1.1 1999-07-14 08:35:37 sandervl Exp $ */
     1/* $Id: win32wnd.cpp,v 1.2 1999-07-14 21:05:58 cbratschi Exp $ */
    22/*
    33 * Win32 Window Code for OS/2
     
    4545//******************************************************************************
    4646Win32Window::Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
    47                         : GenericObject(&windows, OBJTYPE_WINDOW)
     47                        : GenericObject(&windows, OBJTYPE_WINDOW)
    4848{
    4949  Init();
     
    5757  isUnicode        = FALSE;
    5858
    59   *windowName      = NULL;
     59  windowName       = NULL;
    6060  wndNameLength    = 0;
    6161
    62   *windowText      = NULL;;
     62  windowText       = NULL;;
    6363  wndTextLength    = 0;
    64        
    65   *userWindowLong  = NULL;;
     64
     65  userWindowLong   = NULL;;
    6666  nrUserWindowLong = 0;
    6767
     
    6969  OS2Hwnd          = 0;
    7070  Win32Hwnd        = 0;
    71   if(HMHandleAllocate(&Win32Hwnd, (ULONG)this) != 0)
    72   {
    73         dprintf(("Win32Window::Init HMHandleAllocate failed!!"));
    74         DebugInt3();
     71
     72  //CB: what does this code? Win32Hwnd is always 0!
     73  if(HMHandleAllocate(&Win32Hwnd, (ULONG)this) != 0)
     74  {
     75        dprintf(("Win32Window::Init HMHandleAllocate failed!!"));
     76        DebugInt3();
    7577  }
    7678  posx = posy      = 0;
     
    7880
    7981  dwExStyle        = 0;
    80   dwStyle          = 0;
     82  dwStyle          = 0;
    8183  win32wndproc     = 0;
    8284  hInstance        = 0;
    8385  parent           = 0;
    84   windowId         = 0xFFFFFFFF;        //default = -1
     86  windowId         = 0xFFFFFFFF;        //default = -1
    8587  userData         = 0;
    8688
     
    9597{
    9698  if(Win32Hwnd)
    97         HMHandleFree(Win32Hwnd);
     99        HMHandleFree(Win32Hwnd);
    98100  if(windowName)
    99         free(windowName);
     101        free(windowName);
    100102  if(windowText)
    101         free(windowText);
     103        free(windowText);
    102104  if(userWindowLong)
    103         free(userWindowLong);
     105        free(userWindowLong);
    104106}
    105107//******************************************************************************
     
    109111 char  buffer[256];
    110112 DWORD tmp;
    111  INT   sw = SW_SHOW; 
     113 INT   sw = SW_SHOW;
    112114 POINT maxSize, maxPos, minTrack, maxTrack;
    113115
     
    117119  if (cs->hwndParent)
    118120  {
    119         /* Make sure parent is valid */
     121        /* Make sure parent is valid */
    120122        if (!IsWindow( cs->hwndParent ))
    121123        {
    122                 dprintf(("Bad parent %04x\n", cs->hwndParent ));
    123                 SetLastError(ERROR_INVALID_PARAMETER);
    124                 return FALSE;
    125         }
    126   } 
    127   else 
     124                dprintf(("Bad parent %04x\n", cs->hwndParent ));
     125                SetLastError(ERROR_INVALID_PARAMETER);
     126                return FALSE;
     127        }
     128  }
     129  else
    128130  if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
    129131        dprintf(("No parent for child window\n" ));
    130         SetLastError(ERROR_INVALID_PARAMETER);
     132        SetLastError(ERROR_INVALID_PARAMETER);
    131133        return FALSE;  /* WS_CHILD needs a parent, but WS_POPUP doesn't */
    132134  }
     
    141143  }
    142144
    143   /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX 
    144    * with an atom as the class name, put some programs expect to have a *REAL* string in 
    145    * lpszClass when the CREATESTRUCT is sent with WM_CREATE 
     145  /* Fix the lpszClass field: from existing programs, it seems ok to call a CreateWindowXXX
     146   * with an atom as the class name, put some programs expect to have a *REAL* string in
     147   * lpszClass when the CREATESTRUCT is sent with WM_CREATE
    146148   */
    147   if (!HIWORD(cs->lpszClass) ) {       
     149  if (!HIWORD(cs->lpszClass) ) {
    148150        if (isUnicode) {
    149                 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
    150         }
    151         else {
    152                 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
    153         }
    154         cs->lpszClass = buffer;
     151                GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
     152        }
     153        else {
     154                GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
     155        }
     156        cs->lpszClass = buffer;
    155157  }
    156158
     
    160162//        PDB *pdb = PROCESS_Current();
    161163
    162        /* Never believe Microsoft's documentation... CreateWindowEx doc says 
    163         * that if an overlapped window is created with WS_VISIBLE style bit 
     164       /* Never believe Microsoft's documentation... CreateWindowEx doc says
     165        * that if an overlapped window is created with WS_VISIBLE style bit
    164166        * set and the x parameter is set to CW_USEDEFAULT, the system ignores
    165167        * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
    166168        * reveals that
    167169        *
    168         * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16 
    169         * 2) it does not ignore the y parameter as the docs claim; instead, it 
     170        * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
     171        * 2) it does not ignore the y parameter as the docs claim; instead, it
    170172        *    uses it as second parameter to ShowWindow() unless y is either
    171173        *    CW_USEDEFAULT or CW_USEDEFAULT16.
    172         * 
     174        *
    173175        * The fact that we didn't do 2) caused bogus windows pop up when wine
    174         * was running apps that were using this obscure feature. Example - 
    175         * calc.exe that comes with Win98 (only Win98, it's different from 
     176        * was running apps that were using this obscure feature. Example -
     177        * calc.exe that comes with Win98 (only Win98, it's different from
    176178        * the one that comes with Win95 and NT)
    177179        */
     
    212214  nrUserWindowLong = windowClass->getExtraWndWords();
    213215  if(nrUserWindowLong) {
    214         userWindowLong = (ULONG *)malloc(nrUserWindowLong);
    215         memset(userWindowLong, 0, nrUserWindowLong);
     216        userWindowLong = (ULONG *)malloc(nrUserWindowLong);
     217        memset(userWindowLong, 0, nrUserWindowLong);
    216218  }
    217219
    218220  if ((cs->style & WS_CHILD) && cs->hwndParent)
    219221  {
    220         if(HMHandleTranslateToOS2(cs->hwndParent, &tmp) != NO_ERROR)
    221         {
    222                 dprintf(("HMHandleTranslateToOS2 couldn't find parent window %x!!!", cs->hwndParent));
    223                 return FALSE;
    224         }
    225         parent = (Win32Window *)tmp;
     222        if(HMHandleTranslateToOS2(cs->hwndParent, &tmp) != NO_ERROR)
     223        {
     224                dprintf(("HMHandleTranslateToOS2 couldn't find parent window %x!!!", cs->hwndParent));
     225                return FALSE;
     226        }
     227        parent = (Win32Window *)tmp;
    226228  }
    227229  else
    228230  {
    229         parent = NULL;  //desktop
     231        parent = NULL;  //desktop
    230232        if (!cs->hwndParent) {
    231                 owner = NULL;
    232         }
     233                owner = NULL;
     234        }
    233235        else
    234236        {
    235                 if(HMHandleTranslateToOS2(cs->hwndParent, &tmp) != NO_ERROR)
    236                 {
    237                         dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent));
    238                         return FALSE;
    239                 }
    240                 owner = (Win32Window *)tmp;
    241         }
     237                if(HMHandleTranslateToOS2(cs->hwndParent, &tmp) != NO_ERROR)
     238                {
     239                        dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent));
     240                        return FALSE;
     241                }
     242                owner = (Win32Window *)tmp;
     243        }
    242244  }
    243245
     
    256258  if (!(cs->style & WS_CHILD))
    257259  {
    258         dwStyle |= WS_CLIPSIBLINGS;
    259         if (!(cs->style & WS_POPUP))
    260         {
     260        dwStyle |= WS_CLIPSIBLINGS;
     261        if (!(cs->style & WS_POPUP))
     262        {
    261263            dwStyle |= WS_CAPTION;
    262264            flags |= WIN_NEED_SIZE;
    263         }
     265        }
    264266  }
    265267  if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
     
    300302        else
    301303        {
    302                 if (windowClass->getMenuNameA()) {
    303                         cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
    304                         if (cs->hMenu) SetMenu( getWindowHandle(), cs->hMenu );
    305                 }
    306         }
    307   }
    308   else  windowId = (UINT)cs->hMenu;
     304                if (windowClass->getMenuNameA()) {
     305                        cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
     306                        if (cs->hMenu) SetMenu( getWindowHandle(), cs->hMenu );
     307                }
     308        }
     309  }
     310  else  windowId = (UINT)cs->hMenu;
    309311
    310312  DWORD dwOSWinStyle, dwOSFrameStyle;
     
    314316  OS2Hwnd = OSLibWinCreateWindow((parent) ? parent->getOS2WindowHandle() : 0,
    315317                                 dwOSWinStyle, dwOSFrameStyle, (char *)cs->lpszName,
    316                                  cs->x, cs->y, cs->cx, cs->cy, 
    317                                  (owner) ? owner->getOS2WindowHandle() : 0,
     318                                 cs->x, cs->y, cs->cx, cs->cy,
     319                                 (owner) ? owner->getOS2WindowHandle() : 0,
    318320                                 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE);
    319321
    320322  if(OS2Hwnd == 0) {
    321         dprintf(("Window creation failed!!"));
    322         return FALSE;
     323        dprintf(("Window creation failed!!"));
     324        return FALSE;
    323325  }
    324326  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
    325         dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
    326         return FALSE;
     327        dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
     328        return FALSE;
    327329  }
    328330  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
    329         dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
    330         return FALSE;
    331   }
    332 
     331        dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
     332        return FALSE;
     333  }
     334
     335  return TRUE;
    333336}
    334337/*******************************************************************
     
    338341 */
    339342void Win32Window::GetMinMaxInfo(POINT *maxSize, POINT *maxPos,
    340                                 POINT *minTrack, POINT *maxTrack )
     343                                POINT *minTrack, POINT *maxTrack )
    341344{
    342345    MINMAXINFO MinMax;
     
    378381    lpPos = (LPINTERNALPOS)GetPropA( wndPtr->hwndSelf, atomInternalPos );
    379382    if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
    380         CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
     383        CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
    381384    else
    382385    {
     
    454457{
    455458 WORD fwSizeType = 0;
    456  
     459
    457460  if(fMinimize) {
    458         fwSizeType = SIZE_MINIMIZED;
     461        fwSizeType = SIZE_MINIMIZED;
    459462  }
    460463  else
    461464  if(fMaximize) {
    462         fwSizeType = SIZE_MAXIMIZED;
    463   }
    464   else  fwSizeType = SIZE_RESTORED;
     465        fwSizeType = SIZE_MAXIMIZED;
     466  }
     467  else  fwSizeType = SIZE_RESTORED;
    465468
    466469  return SendMessageA(WM_SIZE, fwSizeType, MAKELONG((USHORT)width, (USHORT)height));
     
    491494
    492495  switch(msg) {
    493         case BUTTON_LEFTDOWN:
    494                 win32msg = WM_LBUTTONDOWN;
    495                 break;
    496         case BUTTON_LEFTUP:
    497                 win32msg = WM_LBUTTONUP;
    498                 break;
    499         case BUTTON_LEFTDBLCLICK:
    500                 win32msg = WM_LBUTTONDBLCLK;
    501                 break;
    502         case BUTTON_RIGHTUP:
    503                 win32msg = WM_RBUTTONUP;
    504                 break;
    505         case BUTTON_RIGHTDOWN:
    506                 win32msg = WM_RBUTTONDOWN;
    507                 break;
    508         case BUTTON_RIGHTDBLCLICK:
    509                 win32msg = WM_RBUTTONDBLCLK;
    510                 break;
    511         default:
    512                 dprintf(("Win32Window::Button: invalid msg!!!!"));
    513                 return 1;
     496        case BUTTON_LEFTDOWN:
     497                win32msg = WM_LBUTTONDOWN;
     498                break;
     499        case BUTTON_LEFTUP:
     500                win32msg = WM_LBUTTONUP;
     501                break;
     502        case BUTTON_LEFTDBLCLICK:
     503                win32msg = WM_LBUTTONDBLCLK;
     504                break;
     505        case BUTTON_RIGHTUP:
     506                win32msg = WM_RBUTTONUP;
     507                break;
     508        case BUTTON_RIGHTDOWN:
     509                win32msg = WM_RBUTTONDOWN;
     510                break;
     511        case BUTTON_RIGHTDBLCLICK:
     512                win32msg = WM_RBUTTONDBLCLK;
     513                break;
     514        default:
     515                dprintf(("Win32Window::Button: invalid msg!!!!"));
     516                return 1;
    514517  }
    515518  return SendMessageA(win32msg, 0, MAKELONG(x, OS2TOWIN32POINT(height, y)));
     
    532535{
    533536  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    534         dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     537        dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    535538
    536539  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
     
    539542  switch(Msg)
    540543  {
    541         case WM_CREATE:
    542         {
     544        case WM_CREATE:
     545        {
    543546                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    544                         dprintf(("WM_NCCREATE returned FALSE\n"));
    545                         return(0); //don't create window
     547                        dprintf(("WM_NCCREATE returned FALSE\n"));
     548                        return(0); //don't create window
    546549                }
    547550                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
    548                         dprintf(("WM_CREATE returned FALSE\n"));
    549                         return(0); //don't create window
    550                 }
    551                 NotifyParent(Msg, wParam, lParam);
    552 
    553                 return(1);
    554         }
    555         case WM_LBUTTONDOWN:
    556         case WM_MBUTTONDOWN:
    557         case WM_RBUTTONDOWN:
    558                 NotifyParent(Msg, wParam, lParam);
    559                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    560 
    561         case WM_DESTROY:
    562                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    563                 NotifyParent(Msg, wParam, lParam);
    564                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    565         default:
    566                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     551                        dprintf(("WM_CREATE returned FALSE\n"));
     552                        return(0); //don't create window
     553                }
     554                NotifyParent(Msg, wParam, lParam);
     555
     556                return(1);
     557        }
     558        case WM_LBUTTONDOWN:
     559        case WM_MBUTTONDOWN:
     560        case WM_RBUTTONDOWN:
     561                NotifyParent(Msg, wParam, lParam);
     562                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     563
     564        case WM_DESTROY:
     565                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     566                NotifyParent(Msg, wParam, lParam);
     567                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     568        default:
     569                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    567570  }
    568571}
     
    574577 Win32Window *parentwindow;
    575578
    576    while(window) 
     579   while(window)
    577580   {
    578         if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
    579         {
    580                 /* Notify the parent window only */
    581                 parentwindow = window->getParent();
    582                 if(parentwindow) {
    583                         if(Msg == WM_CREATE || Msg == WM_DESTROY) {
    584                                 parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
    585                         }
    586                         else    parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
    587                 }
    588         }
    589         else    break;
    590 
    591         window = parentwindow;
     581        if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
     582        {
     583                /* Notify the parent window only */
     584                parentwindow = window->getParent();
     585                if(parentwindow) {
     586                        if(Msg == WM_CREATE || Msg == WM_DESTROY) {
     587                                parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
     588                        }
     589                        else    parentwindow->SendMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
     590                }
     591        }
     592        else    break;
     593
     594        window = parentwindow;
    592595   }
    593596}
     
    599602
    600603   switch(index) {
    601         case GWL_EXSTYLE:
    602                 oldval = dwExStyle;
    603                 dwExStyle = value;
    604                 return oldval;
    605         case GWL_STYLE:
    606                 oldval = dwStyle;
    607                 dwStyle = value;
    608                 return oldval;
    609         case GWL_WNDPROC:
    610                 oldval = (LONG)getWindowProc();
    611                 setWindowProc((WNDPROC)value);
    612                 return oldval;
    613         case GWL_HINSTANCE:
    614                 oldval = hInstance;
    615                 hInstance = value;
    616                 return oldval;
    617         case GWL_HWNDPARENT:
    618         {
    619          ULONG tmp;
    620 
    621                 if(getParent()) {
    622                         oldval = getParent()->getWindowHandle();
    623                 }
    624                 else    oldval = 0;
    625 
    626                 if(value == 0) {//desktop window = parent
    627                         setParent(NULL);
    628                         OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
    629                         return oldval;
    630                 }
    631                 if(HMHandleTranslateToOS2(value, &tmp) == NO_ERROR)
    632                 {
    633                         setParent((Win32Window *)tmp);
    634                         OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
    635                         return oldval;
    636                 }
    637                 SetLastError(ERROR_INVALID_PARAMETER);
    638                 return 0;
    639         }
    640         case GWL_ID:
    641                 oldval = getWindowId();
    642                 setWindowId(value);
    643                 return oldval;
    644         case GWL_USERDATA:
    645                 oldval = userData;
    646                 userData = value;
    647                 return oldval;
    648         default:
    649                 if(index >= 0 && index/4 < nrUserWindowLong)
    650                 {
    651                         oldval = userWindowLong[index/4];
    652                         userWindowLong[index/4] = value;
    653                         return oldval;
    654                 }
    655                 SetLastError(ERROR_INVALID_PARAMETER);
    656                 return 0;
     604        case GWL_EXSTYLE:
     605                oldval = dwExStyle;
     606                dwExStyle = value;
     607                return oldval;
     608        case GWL_STYLE:
     609                oldval = dwStyle;
     610                dwStyle = value;
     611                return oldval;
     612        case GWL_WNDPROC:
     613                oldval = (LONG)getWindowProc();
     614                setWindowProc((WNDPROC)value);
     615                return oldval;
     616        case GWL_HINSTANCE:
     617                oldval = hInstance;
     618                hInstance = value;
     619                return oldval;
     620        case GWL_HWNDPARENT:
     621        {
     622         ULONG tmp;
     623
     624                if(getParent()) {
     625                        oldval = getParent()->getWindowHandle();
     626                }
     627                else    oldval = 0;
     628
     629                if(value == 0) {//desktop window = parent
     630                        setParent(NULL);
     631                        OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
     632                        return oldval;
     633                }
     634                if(HMHandleTranslateToOS2(value, &tmp) == NO_ERROR)
     635                {
     636                        setParent((Win32Window *)tmp);
     637                        OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
     638                        return oldval;
     639                }
     640                SetLastError(ERROR_INVALID_PARAMETER);
     641                return 0;
     642        }
     643        case GWL_ID:
     644                oldval = getWindowId();
     645                setWindowId(value);
     646                return oldval;
     647        case GWL_USERDATA:
     648                oldval = userData;
     649                userData = value;
     650                return oldval;
     651        default:
     652                if(index >= 0 && index/4 < nrUserWindowLong)
     653                {
     654                        oldval = userWindowLong[index/4];
     655                        userWindowLong[index/4] = value;
     656                        return oldval;
     657                }
     658                SetLastError(ERROR_INVALID_PARAMETER);
     659                return 0;
    657660   }
    658661}
     
    662665{
    663666   switch(index) {
    664         case GWL_EXSTYLE:
    665                 return dwExStyle;
    666         case GWL_STYLE:
    667                 return dwStyle;
    668         case GWL_WNDPROC:
    669                 return (ULONG)getWindowProc();
    670         case GWL_HINSTANCE:
    671                 return hInstance;
    672         case GWL_HWNDPARENT:
    673                 if(getParent()) {
    674                         return getParent()->getWindowHandle();
    675                 }
    676                 else    return 0;
    677         case GWL_ID:
    678                 return getWindowId();
    679         case GWL_USERDATA:
    680                 return userData;
    681         default:
    682                 if(index >= 0 && index/4 < nrUserWindowLong)
    683                 {
    684                         return userWindowLong[index/4];
    685                 }
    686                 SetLastError(ERROR_INVALID_PARAMETER);
    687                 return 0;
     667        case GWL_EXSTYLE:
     668                return dwExStyle;
     669        case GWL_STYLE:
     670                return dwStyle;
     671        case GWL_WNDPROC:
     672                return (ULONG)getWindowProc();
     673        case GWL_HINSTANCE:
     674                return hInstance;
     675        case GWL_HWNDPARENT:
     676                if(getParent()) {
     677                        return getParent()->getWindowHandle();
     678                }
     679                else    return 0;
     680        case GWL_ID:
     681                return getWindowId();
     682        case GWL_USERDATA:
     683                return userData;
     684        default:
     685                if(index >= 0 && index/4 < nrUserWindowLong)
     686                {
     687                        return userWindowLong[index/4];
     688                }
     689                SetLastError(ERROR_INVALID_PARAMETER);
     690                return 0;
    688691   }
    689692}
     
    696699   if(index >= 0 && index/4 < nrUserWindowLong)
    697700   {
    698         oldval = ((WORD *)userWindowLong)[index/2];
    699         ((WORD *)userWindowLong)[index/2] = value;
    700         return oldval;
     701        oldval = ((WORD *)userWindowLong)[index/2];
     702        ((WORD *)userWindowLong)[index/2] = value;
     703        return oldval;
    701704   }
    702705   SetLastError(ERROR_INVALID_PARAMETER);
     
    709712   if(index >= 0 && index/4 < nrUserWindowLong)
    710713   {
    711         return ((WORD *)userWindowLong)[index/2];
     714        return ((WORD *)userWindowLong)[index/2];
    712715   }
    713716   SetLastError(ERROR_INVALID_PARAMETER);
  • trunk/src/user32/new/window.cpp

    r300 r304  
    1 /* $Id: window.cpp,v 1.1 1999-07-14 08:35:37 sandervl Exp $ */
     1/* $Id: window.cpp,v 1.2 1999-07-14 21:05:59 cbratschi Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    3737        dprintf(("CreateWindowEx32A: bad class name "));
    3838        if (!HIWORD(className)) {
    39                 dprintf(("CreateWindowEx32A: bad class name %04x\n", LOWORD(className)));
    40         }
    41         else    dprintf(("CreateWindowEx32A: bad class name '%s'\n", className ));
    42         SetLastError(ERROR_INVALID_PARAMETER);
     39                dprintf(("CreateWindowEx32A: bad class name %04x\n", LOWORD(className)));
     40        }
     41        else    dprintf(("CreateWindowEx32A: bad class name '%s'\n", className ));
     42        SetLastError(ERROR_INVALID_PARAMETER);
    4343        return 0;
    4444    }
     
    5858    cs.dwExStyle      = exStyle;
    5959    window = new Win32Window( &cs, classAtom, FALSE );
    60     if(window == NULL) 
     60    if(window == NULL)
    6161    {
    62         dprintf(("Win32Window creation failed!!"));
    63         return 0;
     62        dprintf(("Win32Window creation failed!!"));
     63        return 0;
    6464    }
    6565    if(GetLastError() != 0)
    6666    {
    67         delete window;
    68         return 0;
     67        dprintf(("Win32Window error found!!"));
     68        delete window;
     69        return 0;
    6970    }
    7071    return window->getWindowHandle();
  • trunk/src/user32/new/windowclass.cpp

    r300 r304  
    1 /* $Id: windowclass.cpp,v 1.1 1999-07-14 08:35:37 sandervl Exp $ */
     1/* $Id: windowclass.cpp,v 1.2 1999-07-14 21:05:59 cbratschi Exp $ */
    22/*
    33 * Win32 Window Class Code for OS/2
     
    3737 Win32WndClass *wclass;
    3838
    39    memcpy(&wc, lpWndClass, sizeof(WNDCLASSA));
     39   //CB: size new in ex structure
     40   wc.cbSize = sizeof(wc);
     41   memcpy(&wc.style, lpWndClass, sizeof(WNDCLASSA));
    4042   wc.hIconSm = 0;
    41    
    42    wclass = new Win32WndClass(&wc);
     43
     44   wclass = new Win32WndClass(&wc,FALSE);
    4345   if(wclass == NULL) {
    44         dprintf(("RegisterClassA wclass == NULL!"));
    45         return(0);
     46        dprintf(("RegisterClassA wclass == NULL!"));
     47        return(0);
    4648   }
    4749   return(wclass->getAtom());
     
    5355 Win32WndClass *wclass;
    5456
    55    wclass = new Win32WndClass((WNDCLASSEXA *)lpWndClass);
     57   wclass = new Win32WndClass((WNDCLASSEXA *)lpWndClass,FALSE);
    5658   if(wclass == NULL) {
    57         dprintf(("RegisterClassExA wclass == NULL!"));
    58         return(0);
     59        dprintf(("RegisterClassExA wclass == NULL!"));
     60        return(0);
    5961   }
    6062   return(wclass->getAtom());
    6163}
    6264//******************************************************************************
     65//CB: update to unicode!
    6366//******************************************************************************
    6467WORD WIN32API RegisterClassW(CONST WNDCLASSW *lpwc)
     
    6871
    6972    dprintf(("RegisterClassW\n"));
    70     memcpy(&wclass, lpwc, sizeof(WNDCLASSA));
     73    //CB: size new in ex structure
     74    wclass.cbSize = sizeof(wclass);
     75    memcpy(&wclass.style, lpwc, sizeof(WNDCLASSA));
    7176    if(wclass.lpszMenuName && ((ULONG)wclass.lpszMenuName >> 16 != 0)) {
    72         wclass.lpszMenuName = UnicodeToAsciiString((LPWSTR)lpwc->lpszMenuName);
     77        wclass.lpszMenuName = UnicodeToAsciiString((LPWSTR)lpwc->lpszMenuName);
    7378    }
    7479    if(wclass.lpszClassName && ((ULONG)wclass.lpszClassName >> 16 != 0)) {
    75         wclass.lpszClassName = UnicodeToAsciiString((LPWSTR)lpwc->lpszClassName);
     80        wclass.lpszClassName = UnicodeToAsciiString((LPWSTR)lpwc->lpszClassName);
    7681    }
    7782    rc = RegisterClassA((CONST WNDCLASSA *)&wclass);
    7883
    7984    if(lpwc->lpszMenuName && ((ULONG)lpwc->lpszMenuName >> 16 != 0)) {
    80         FreeAsciiString((char *)wclass.lpszMenuName);
     85        FreeAsciiString((char *)wclass.lpszMenuName);
    8186    }
    8287    if(lpwc->lpszClassName && ((ULONG)lpwc->lpszClassName >> 16 != 0)) {
    83         FreeAsciiString((char *)wclass.lpszClassName);
     88        FreeAsciiString((char *)wclass.lpszClassName);
    8489    }
    8590    return(rc);
    8691}
    8792//******************************************************************************
     93//CB: update to unicode!
    8894//******************************************************************************
    8995ATOM WIN32API RegisterClassExW(CONST WNDCLASSEXW *lpwc)
     
    95101    memcpy(&wclass, lpwc, sizeof(WNDCLASSEXA));
    96102    if(wclass.lpszMenuName && ((ULONG)wclass.lpszMenuName >> 16 != 0)) {
    97         wclass.lpszMenuName = UnicodeToAsciiString((LPWSTR)lpwc->lpszMenuName);
     103        wclass.lpszMenuName = UnicodeToAsciiString((LPWSTR)lpwc->lpszMenuName);
    98104    }
    99105    if(wclass.lpszClassName && ((ULONG)wclass.lpszClassName >> 16 != 0)) {
    100         wclass.lpszClassName = UnicodeToAsciiString((LPWSTR)lpwc->lpszClassName);
     106        wclass.lpszClassName = UnicodeToAsciiString((LPWSTR)lpwc->lpszClassName);
    101107    }
    102108    rc = RegisterClassExA((CONST WNDCLASSEXA *)&wclass);
    103109
    104110    if(lpwc->lpszMenuName && ((ULONG)lpwc->lpszMenuName >> 16 != 0)) {
    105         FreeAsciiString((char *)wclass.lpszMenuName);
     111        FreeAsciiString((char *)wclass.lpszMenuName);
    106112    }
    107113    if(lpwc->lpszClassName && ((ULONG)lpwc->lpszClassName >> 16 != 0)) {
    108         FreeAsciiString((char *)wclass.lpszClassName);
     114        FreeAsciiString((char *)wclass.lpszClassName);
    109115    }
    110116    return(rc);
     
    121127}
    122128//******************************************************************************
     129//CB:update to unicode!
    123130//******************************************************************************
    124131BOOL WIN32API UnregisterClassW(LPCWSTR lpszClassName, HINSTANCE hinst)
     
    128135  dprintf(("USER32:  UnregisterClassW\n"));
    129136  if((ULONG)lpszClassName >> 16 != 0) {
    130         astring = UnicodeToAsciiString((LPWSTR)lpszClassName);
    131   }
    132   else  astring = (char *)lpszClassName;
     137        astring = UnicodeToAsciiString((LPWSTR)lpszClassName);
     138  }
     139  else  astring = (char *)lpszClassName;
    133140
    134141  Win32WndClass::UnregisterClassA(hinst, (LPSTR)astring);
    135   if((ULONG)astring >> 16 != 0) 
    136         FreeAsciiString((char *)astring);
     142  if((ULONG)astring >> 16 != 0)
     143        FreeAsciiString((char *)astring);
    137144  //Spintest returns FALSE in dll termination, so pretend it succeeded
    138145  return(TRUE);
     
    150157  wndclass = Win32WndClass::FindClass(hInstance, (LPSTR)lpszClass);
    151158  if(wndclass) {
    152         wndclass->getClassInfo(&wc);
    153         memcpy(lpwc, &wc, sizeof(WNDCLASSA));
    154         return(TRUE);
    155   }
    156   return(FALSE); 
    157 }
    158 //******************************************************************************
     159        wndclass->getClassInfo(&wc);
     160        memcpy(lpwc, &wc, sizeof(WNDCLASSA));
     161        return(TRUE);
     162  }
     163  return(FALSE);
     164}
     165//******************************************************************************
     166//CB: update to unicode!
    159167//******************************************************************************
    160168BOOL WIN32API GetClassInfoW(HINSTANCE  hinst, LPCWSTR lpszClass, WNDCLASSW *lpwc)
     
    168176
    169177  if((ULONG)lpszClass >> 16 != 0) {
    170         astring = UnicodeToAsciiString((LPWSTR)lpszClass);
     178        astring = UnicodeToAsciiString((LPWSTR)lpszClass);
    171179  }
    172180  else  astring = (char *)lpszClass;
    173181
    174182  wndclass = Win32WndClass::FindClass(hinst, astring);
    175   if((ULONG)astring >> 16 != 0) 
    176         FreeAsciiString((char *)astring);
     183  if((ULONG)astring >> 16 != 0)
     184        FreeAsciiString((char *)astring);
    177185  if(wndclass) {
    178         wndclass->getClassInfo(&wc);
    179         memcpy(lpwc, &wc, sizeof(WNDCLASSW));
    180         return(TRUE);
    181   }
    182   return(FALSE); 
     186        wndclass->getClassInfo(&wc);
     187        memcpy(lpwc, &wc, sizeof(WNDCLASSW));
     188        return(TRUE);
     189  }
     190  return(FALSE);
    183191}
    184192/****************************************************************************
     
    203211 BOOL           rc;
    204212 Win32WndClass *wndclass;
    205  
     213
    206214  dprintf(("USER32:GetClassInfoExA (%08xh,%x,%08x).\n",
    207215         hInstance,
    208216         lpszClass,
    209217         lpwcx));
    210  
     218
    211219  wndclass = Win32WndClass::FindClass(hInstance, (LPSTR)lpszClass);
    212220  if(wndclass) {
    213         wndclass->getClassInfo(lpwcx);
    214         return(TRUE);
    215   }
    216   return(FALSE); 
     221        wndclass->getClassInfo(lpwcx);
     222        return(TRUE);
     223  }
     224  return(FALSE);
    217225}
    218226/*****************************************************************************
     
    243251
    244252  if((ULONG)lpszClass >> 16 != 0) {
    245         astring = UnicodeToAsciiString((LPWSTR)lpszClass);
     253        astring = UnicodeToAsciiString((LPWSTR)lpszClass);
    246254  }
    247255  else  astring = (char *)lpszClass;
    248256
    249257  wndclass = Win32WndClass::FindClass(hInstance, astring);
    250   if((ULONG)astring >> 16 != 0) 
    251         FreeAsciiString((char *)astring);
     258  if((ULONG)astring >> 16 != 0)
     259        FreeAsciiString((char *)astring);
    252260  if(wndclass) {
    253         wndclass->getClassInfo(lpwcx);
    254         return(TRUE);
    255   }
    256   return(FALSE); 
     261        wndclass->getClassInfo(lpwcx);
     262        return(TRUE);
     263  }
     264  return(FALSE);
    257265}
    258266//******************************************************************************
     
    265273    wnd = WIN2OS2HWND(hwnd);
    266274    if(wnd == NULL) {
    267         dprintf(("GetClassNameA wnd == NULL"));
    268         return(0);
     275        dprintf(("GetClassNameA wnd == NULL"));
     276        return(0);
    269277    }
    270278    return (wnd->getClass())->getClassName(lpszClassName, cchClassName);
     
    279287    wnd = WIN2OS2HWND(hwnd);
    280288    if(wnd == NULL) {
    281         dprintf(("GetClassNameA wnd == NULL"));
    282         return(0);
     289        dprintf(("GetClassNameA wnd == NULL"));
     290        return(0);
    283291    }
    284292    return (wnd->getClass())->getClassName(lpszClassName, cchClassName);
     
    293301    wnd = WIN2OS2HWND(hwnd);
    294302    if(wnd == NULL) {
    295         dprintf(("SetClassLongA wnd == NULL"));
    296         return(0);
     303        dprintf(("SetClassLongA wnd == NULL"));
     304        return(0);
    297305    }
    298306    return (wnd->getClass())->setClassLongA(nIndex, lNewVal);
     
    307315    wnd = WIN2OS2HWND(hwnd);
    308316    if(wnd == NULL) {
    309         dprintf(("SetClassLongW wnd == NULL"));
    310         return(0);
     317        dprintf(("SetClassLongW wnd == NULL"));
     318        return(0);
    311319    }
    312320    return (wnd->getClass())->setClassLongW(nIndex, lNewVal);
     
    321329    wnd = WIN2OS2HWND(hwnd);
    322330    if(wnd == NULL) {
    323         dprintf(("SetClassWordA wnd == NULL"));
    324         return(0);
     331        dprintf(("SetClassWordA wnd == NULL"));
     332        return(0);
    325333    }
    326334    return (wnd->getClass())->setClassWord(nIndex, wNewVal);
     
    335343    wnd = WIN2OS2HWND(hwnd);
    336344    if(wnd == NULL) {
    337         dprintf(("GetClassWordA wnd == NULL"));
    338         return(0);
     345        dprintf(("GetClassWordA wnd == NULL"));
     346        return(0);
    339347    }
    340348    return (wnd->getClass())->getClassWord(nIndex);
     
    349357    wnd = WIN2OS2HWND(hwnd);
    350358    if(wnd == NULL) {
    351         dprintf(("GetClassLongA wnd == NULL"));
    352         return(0);
     359        dprintf(("GetClassLongA wnd == NULL"));
     360        return(0);
    353361    }
    354362    return (wnd->getClass())->getClassLongA(nIndex);
     
    363371    wnd = WIN2OS2HWND(hwnd);
    364372    if(wnd == NULL) {
    365         dprintf(("GetClassLongW wnd == NULL"));
    366         return(0);
     373        dprintf(("GetClassLongW wnd == NULL"));
     374        return(0);
    367375    }
    368376    return (wnd->getClass())->getClassLongW(nIndex);
  • trunk/src/user32/new/windowmsg.cpp

    r300 r304  
    1 /* $Id: windowmsg.cpp,v 1.1 1999-07-14 08:35:37 sandervl Exp $ */
     1/* $Id: windowmsg.cpp,v 1.2 1999-07-14 21:05:59 cbratschi Exp $ */
    22/*
    33 * Win32 window message APIs for OS/2
     
    3737    dprintf(("USER32:  PostQuitMessage\n"));
    3838
    39     O32_PostQuitMessage(arg1);
     39    O32_PostQuitMessage(nExitCode);
    4040}
    4141//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.