Ignore:
Timestamp:
Sep 4, 1999, 7:56:41 PM (26 years ago)
Author:
dengert
Message:

begin DAXifying windows

File:
1 edited

Legend:

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

    r780 r819  
    1 /* $Id: win32wbase.cpp,v 1.5 1999-09-01 19:12:22 phaller Exp $ */
     1/* $Id: win32wbase.cpp,v 1.6 1999-09-04 17:56:41 dengert Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    6262//******************************************************************************
    6363Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
    64                         : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
     64                        : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
    6565{
    6666  Init();
     
    7272void Win32BaseWindow::Init()
    7373{
    74   isUnicode        = FALSE;
    75   fCreated         = FALSE;
    76   fFirstShow       = TRUE;
    77 
    78   windowNameA      = NULL;
    79   windowNameW      = NULL;
     74  isUnicode        = FALSE;
     75  fCreated         = FALSE;
     76  fFirstShow       = TRUE;
     77
     78  windowNameA      = NULL;
     79  windowNameW      = NULL;
    8080  wndNameLength    = 0;
    8181
     
    8383  nrUserWindowLong = 0;
    8484
    85   magic            = WIN32PM_MAGIC;
    86   OS2Hwnd          = 0;
    87   OS2HwndFrame     = 0;
    88   OS2HwndMenu      = 0;
    89   Win32Hwnd        = 0;
     85  magic            = WIN32PM_MAGIC;
     86  OS2Hwnd          = 0;
     87  OS2HwndFrame     = 0;
     88  OS2HwndMenu      = 0;
     89  Win32Hwnd        = 0;
    9090
    9191  if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
    9292  {
    93         dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
    94         DebugInt3();
    95   }
    96 
    97   posx = posy      = 0;
     93        dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
     94        DebugInt3();
     95  }
     96
     97  posx = posy      = 0;
    9898  width = height   = 0;
    9999
    100   dwExStyle        = 0;
    101   dwStyle          = 0;
    102   win32wndproc     = 0;
    103   hInstance        = 0;
    104   windowId         = 0xFFFFFFFF;        //default = -1
    105   userData         = 0;
     100  dwExStyle        = 0;
     101  dwStyle          = 0;
     102  win32wndproc     = 0;
     103  hInstance        = 0;
     104  windowId         = 0xFFFFFFFF;        //default = -1
     105  userData         = 0;
    106106
    107107  hwndLinkAfter    = HWND_BOTTOM;
    108   flags            = 0;
    109   isIcon           = FALSE;
     108  flags            = 0;
     109  isIcon           = FALSE;
    110110  lastHitTestVal   = 0;
    111   owner            = NULL;
    112   windowClass      = 0;
     111  owner            = NULL;
     112  windowClass      = 0;
    113113
    114114  acceltableResource = NULL;
    115   menuResource       = NULL;
    116   iconResource       = NULL;
     115  menuResource       = NULL;
     116  iconResource       = NULL;
    117117}
    118118//******************************************************************************
     
    125125
    126126  if(Win32Hwnd)
    127         HwFreeWindowHandle(Win32Hwnd);
     127        HwFreeWindowHandle(Win32Hwnd);
    128128
    129129  if(userWindowLong)
    130         free(userWindowLong);
     130        free(userWindowLong);
    131131  if(windowNameA) {
    132         free(windowNameA);
    133         windowNameA = NULL;
     132        free(windowNameA);
     133        windowNameA = NULL;
    134134  }
    135135  if(windowNameW) {
    136         free(windowNameW);
    137         windowNameW = NULL;
     136        free(windowNameW);
     137        windowNameW = NULL;
    138138  }
    139139}
     
    157157    if (cs->hwndParent)
    158158    {
    159             Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
    160             if(!window) {
    161                     dprintf(("Bad parent %04x\n", cs->hwndParent ));
    162                     SetLastError(ERROR_INVALID_PARAMETER);
    163                     return FALSE;
    164             }
    165             /* Make sure parent is valid */
    166             if (!window->IsWindow() )
    167             {
    168                     dprintf(("Bad parent %04x\n", cs->hwndParent ));
    169                     SetLastError(ERROR_INVALID_PARAMETER);
    170                     return FALSE;
    171             }
     159            Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
     160            if(!window) {
     161                    dprintf(("Bad parent %04x\n", cs->hwndParent ));
     162                    SetLastError(ERROR_INVALID_PARAMETER);
     163                    return FALSE;
     164            }
     165            /* Make sure parent is valid */
     166            if (!window->IsWindow() )
     167            {
     168                    dprintf(("Bad parent %04x\n", cs->hwndParent ));
     169                    SetLastError(ERROR_INVALID_PARAMETER);
     170                    return FALSE;
     171            }
    172172    }
    173173    else
    174174    if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
    175             dprintf(("No parent for child window\n" ));
    176             SetLastError(ERROR_INVALID_PARAMETER);
    177             return FALSE;  /* WS_CHILD needs a parent, but WS_POPUP doesn't */
     175            dprintf(("No parent for child window\n" ));
     176            SetLastError(ERROR_INVALID_PARAMETER);
     177            return FALSE;  /* WS_CHILD needs a parent, but WS_POPUP doesn't */
    178178    }
    179179
     
    182182  if (!windowClass)
    183183  {
    184         GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
    185         dprintf(("Bad class '%s'\n", buffer ));
    186         return 0;
     184        GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
     185        dprintf(("Bad class '%s'\n", buffer ));
     186        return 0;
    187187  }
    188188
     
    192192   */
    193193  if (!HIWORD(cs->lpszClass) ) {
    194         if (isUnicode) {
    195                 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
    196         }
    197         else {
    198                 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
    199         }
    200         cs->lpszClass = buffer;
     194        if (isUnicode) {
     195                GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
     196        }
     197        else {
     198                GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
     199        }
     200        cs->lpszClass = buffer;
    201201  }
    202202
     
    204204  if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16)
    205205  {
    206 //        PDB *pdb = PROCESS_Current();
     206//        PDB *pdb = PROCESS_Current();
    207207
    208208       /* Never believe Microsoft's documentation... CreateWindowEx doc says
    209         * that if an overlapped window is created with WS_VISIBLE style bit
    210         * set and the x parameter is set to CW_USEDEFAULT, the system ignores
    211         * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
    212         * reveals that
    213         *
    214         * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
    215         * 2) it does not ignore the y parameter as the docs claim; instead, it
    216         *    uses it as second parameter to ShowWindow() unless y is either
    217         *    CW_USEDEFAULT or CW_USEDEFAULT16.
    218         *
    219         * The fact that we didn't do 2) caused bogus windows pop up when wine
    220         * was running apps that were using this obscure feature. Example -
    221         * calc.exe that comes with Win98 (only Win98, it's different from
    222         * the one that comes with Win95 and NT)
    223         */
    224         if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y;
    225 
    226         /* We have saved cs->y, now we can trash it */
     209        * that if an overlapped window is created with WS_VISIBLE style bit
     210        * set and the x parameter is set to CW_USEDEFAULT, the system ignores
     211        * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
     212        * reveals that
     213        *
     214        * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
     215        * 2) it does not ignore the y parameter as the docs claim; instead, it
     216        *    uses it as second parameter to ShowWindow() unless y is either
     217        *    CW_USEDEFAULT or CW_USEDEFAULT16.
     218        *
     219        * The fact that we didn't do 2) caused bogus windows pop up when wine
     220        * was running apps that were using this obscure feature. Example -
     221        * calc.exe that comes with Win98 (only Win98, it's different from
     222        * the one that comes with Win95 and NT)
     223        */
     224        if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y;
     225
     226        /* We have saved cs->y, now we can trash it */
    227227#if 0
    228         if (   !(cs->style & (WS_CHILD | WS_POPUP))
    229             &&  (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
    230         {
    231             cs->x = pdb->env_db->startup_info->dwX;
    232             cs->y = pdb->env_db->startup_info->dwY;
    233         }
     228        if (   !(cs->style & (WS_CHILD | WS_POPUP))
     229            &&  (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
     230        {
     231            cs->x = pdb->env_db->startup_info->dwX;
     232            cs->y = pdb->env_db->startup_info->dwY;
     233        }
    234234#endif
    235             cs->x = 0;
    236             cs->y = 0;
    237 //        }
     235            cs->x = 0;
     236            cs->y = 0;
     237//        }
    238238  }
    239239  if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16)
    240240  {
    241241#if 0
    242         PDB *pdb = PROCESS_Current();
    243         if (   !(cs->style & (WS_CHILD | WS_POPUP))
    244             &&  (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
    245         {
    246             cs->cx = pdb->env_db->startup_info->dwXSize;
    247             cs->cy = pdb->env_db->startup_info->dwYSize;
    248         }
    249         else
    250         {
     242        PDB *pdb = PROCESS_Current();
     243        if (   !(cs->style & (WS_CHILD | WS_POPUP))
     244            &&  (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
     245        {
     246            cs->cx = pdb->env_db->startup_info->dwXSize;
     247            cs->cy = pdb->env_db->startup_info->dwYSize;
     248        }
     249        else
     250        {
    251251#endif
    252             cs->cx = 600; /* FIXME */
    253             cs->cy = 400;
    254 //        }
     252            cs->cx = 600; /* FIXME */
     253            cs->cy = 400;
     254//        }
    255255  }
    256256
     
    261261  nrUserWindowLong = windowClass->getExtraWndWords();
    262262  if(nrUserWindowLong) {
    263         userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
    264         memset(userWindowLong, 0, nrUserWindowLong);
     263        userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
     264        memset(userWindowLong, 0, nrUserWindowLong);
    265265  }
    266266
    267267  if ((cs->style & WS_CHILD) && cs->hwndParent)
    268268  {
    269         SetParent(cs->hwndParent);
    270         owner = GetWindowFromHandle(cs->hwndParent);
    271         if(owner == NULL)
    272         {
    273             dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
    274             return FALSE;
    275         }
     269        SetParent(cs->hwndParent);
     270        owner = GetWindowFromHandle(cs->hwndParent);
     271        if(owner == NULL)
     272        {
     273            dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
     274            return FALSE;
     275        }
    276276  }
    277277  else
    278278  {
    279         if (!cs->hwndParent) {
    280             owner = NULL;
    281         }
    282         else
    283         {
    284             owner = GetWindowFromHandle(cs->hwndParent);
    285             if(owner == NULL)
    286             {
    287                 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
    288                 return FALSE;
    289             }
    290         }
     279        if (!cs->hwndParent) {
     280            owner = NULL;
     281        }
     282        else
     283        {
     284            owner = GetWindowFromHandle(cs->hwndParent);
     285            if(owner == NULL)
     286            {
     287                dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
     288                return FALSE;
     289            }
     290        }
    291291  }
    292292
     
    297297
    298298  hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
    299                   ? HWND_BOTTOM : HWND_TOP;
     299                  ? HWND_BOTTOM : HWND_TOP;
    300300
    301301#if 0
     
    306306    {
    307307    CBT_CREATEWNDA cbtc;
    308         LRESULT ret;
     308        LRESULT ret;
    309309
    310310    cbtc.lpcs = cs;
    311311    cbtc.hwndInsertAfter = hwndLinkAfter;
    312         ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc)
    313                       : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc);
    314         if (ret)
     312        ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc)
     313                      : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc);
     314        if (ret)
    315315    {
    316         TRACE_(win)("CBT-hook returned 0\n");
    317         wndPtr->pDriver->pFinalize(wndPtr);
    318             retvalue =  0;
    319             goto end;
     316        TRACE_(win)("CBT-hook returned 0\n");
     317        wndPtr->pDriver->pFinalize(wndPtr);
     318            retvalue =  0;
     319            goto end;
    320320    }
    321321    }
     
    328328  if (!(cs->style & WS_CHILD))
    329329  {
    330         dwStyle |= WS_CLIPSIBLINGS;
    331         if (!(cs->style & WS_POPUP))
    332         {
    333             dwStyle |= WS_CAPTION;
    334             flags |= WIN_NEED_SIZE;
    335         }
     330        dwStyle |= WS_CLIPSIBLINGS;
     331        if (!(cs->style & WS_POPUP))
     332        {
     333            dwStyle |= WS_CAPTION;
     334            flags |= WIN_NEED_SIZE;
     335        }
    336336  }
    337337  if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
     
    348348  if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
    349349  {
    350         GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
    351         if (maxSize.x < cs->cx) cs->cx = maxSize.x;
    352         if (maxSize.y < cs->cy) cs->cy = maxSize.y;
    353         if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
    354         if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
     350        GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
     351        if (maxSize.x < cs->cx) cs->cx = maxSize.x;
     352        if (maxSize.y < cs->cy) cs->cy = maxSize.y;
     353        if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
     354        if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
    355355  }
    356356
    357357  if(cs->style & WS_CHILD)
    358358  {
    359         if(cs->cx < 0) cs->cx = 0;
    360         if(cs->cy < 0) cs->cy = 0;
     359        if(cs->cx < 0) cs->cx = 0;
     360        if(cs->cy < 0) cs->cy = 0;
    361361  }
    362362  else
    363363  {
    364         if (cs->cx <= 0) cs->cx = 1;
    365         if (cs->cy <= 0) cs->cy = 1;
     364        if (cs->cx <= 0) cs->cx = 1;
     365        if (cs->cy <= 0) cs->cy = 1;
    366366  }
    367367
     
    370370  rectWindow.right  = cs->x + cs->cx;
    371371  rectWindow.bottom = cs->y + cs->cy;
    372   rectClient        = rectWindow;
     372  rectClient        = rectWindow;
    373373
    374374  DWORD dwOSWinStyle, dwOSFrameStyle;
     
    379379#if 1
    380380  if(cs->style & WS_CHILD) {
    381         dwOSFrameStyle = 0;
     381        dwOSFrameStyle = 0;
    382382  }
    383383#endif
    384384
    385385  if(cs->lpszName)
    386         SetWindowText((LPSTR)cs->lpszName);
     386        SetWindowText((LPSTR)cs->lpszName);
    387387
    388388  OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
    389                                 dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA,
    390                                 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
    391                                 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
    392                                 &OS2HwndFrame);
     389                                dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA,
     390                                (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
     391                                (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
     392                                &OS2HwndFrame);
    393393
    394394  if(OS2Hwnd == 0) {
    395         dprintf(("Window creation failed!!"));
    396         return FALSE;
     395        dprintf(("Window creation failed!!"));
     396        return FALSE;
    397397  }
    398398
    399399  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
    400         dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
    401         return FALSE;
     400        dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
     401        return FALSE;
    402402  }
    403403  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
    404         dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
    405         return FALSE;
     404        dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
     405        return FALSE;
    406406  }
    407407  //SvL: Need to store the shared memory base, or else other apps can map it into their memory space
    408408  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_SHAREDMEM, HeapGetSharedMemBase()) == FALSE) {
    409         dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
    410         return FALSE;
     409        dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
     410        return FALSE;
    411411  }
    412412#if 0
    413413  if(OS2Hwnd != OS2HwndFrame) {
    414414    if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
    415             dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame));
    416             return FALSE;
     415            dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame));
     416            return FALSE;
    417417    }
    418418    if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
    419             dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
    420             return FALSE;
     419            dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
     420            return FALSE;
    421421    }
    422422    //SvL: Need to store the shared memory base, or else other apps can map it into their memory space
    423423    if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_SHAREDMEM, HeapGetSharedMemBase()) == FALSE) {
    424             dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
    425             return FALSE;
     424            dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
     425            return FALSE;
    426426    }
    427427  }
    428428#endif
     429
     430  fakeWinBase.hwndThisObject = OS2Hwnd;
     431  fakeWinBase.pWindowClass = windowClass;
     432  *(PULONG)&fakeWinBase -= 0x90 - 8;
     433//  SetFakeOpen32();
    429434
    430435  /* Set the window menu */
    431436  if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
    432437  {
    433         if (cs->hMenu) SetMenu(cs->hMenu);
    434         else
    435         {
    436                 if (windowClass->getMenuNameA()) {
    437                         cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
    438                         if (cs->hMenu) SetMenu(cs->hMenu );
    439                 }
    440         }
    441   }
    442   else  windowId = (UINT)cs->hMenu;
     438        if (cs->hMenu) SetMenu(cs->hMenu);
     439        else
     440        {
     441                if (windowClass->getMenuNameA()) {
     442                        cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
     443                        if (cs->hMenu) SetMenu(cs->hMenu );
     444                }
     445        }
     446  }
     447  else  windowId = (UINT)cs->hMenu;
    443448
    444449  //Set icon from class
    445450  if(windowClass->getIcon())
    446         SetIcon(windowClass->getIcon());
     451        SetIcon(windowClass->getIcon());
    447452
    448453  if(getParent()) {
    449         SetWindowPos(getParent()->getWindowHandle(), rectClient.left, rectClient.top,
    450                      rectClient.right-rectClient.left,
    451                      rectClient.bottom-rectClient.top,
    452                      SWP_NOACTIVATE | SWP_NOZORDER);
     454        SetWindowPos(getParent()->getWindowHandle(), rectClient.left, rectClient.top,
     455                     rectClient.right-rectClient.left,
     456                     rectClient.bottom-rectClient.top,
     457                     SWP_NOACTIVATE | SWP_NOZORDER);
    453458  }
    454459  else {
    455         SetWindowPos(HWND_TOP, rectClient.left, rectClient.top,
    456                      rectClient.right-rectClient.left,
    457                      rectClient.bottom-rectClient.top,
    458                      SWP_NOACTIVATE);
     460        SetWindowPos(HWND_TOP, rectClient.left, rectClient.top,
     461                     rectClient.right-rectClient.left,
     462                     rectClient.bottom-rectClient.top,
     463                     SWP_NOACTIVATE);
    459464  }
    460465  //Get the client window rectangle
     
    470475  if(SendInternalMessage(WM_NCCREATE, 0, (LPARAM)cs) )
    471476  {
    472         //doesn't work right, messes up client rectangle
     477        //doesn't work right, messes up client rectangle
    473478#if 0
    474         SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
     479        SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
    475480#endif
    476         OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
    477         dprintf(("Sending WM_CREATE"));
    478         if( (SendInternalMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 )
    479         {
    480             if(!(flags & WIN_NEED_SIZE)) {
    481                 SendMessageA(WM_SIZE, SIZE_RESTORED,
    482                                 MAKELONG(rectClient.right-rectClient.left,
    483                                         rectClient.bottom-rectClient.top));
    484                 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
    485             }
    486             if (cs->style & WS_VISIBLE) ShowWindow( sw );
     481        OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
     482        dprintf(("Sending WM_CREATE"));
     483        if( (SendInternalMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 )
     484        {
     485            if(!(flags & WIN_NEED_SIZE)) {
     486                SendMessageA(WM_SIZE, SIZE_RESTORED,
     487                                MAKELONG(rectClient.right-rectClient.left,
     488                                        rectClient.bottom-rectClient.top));
     489                SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
     490            }
     491            if (cs->style & WS_VISIBLE) ShowWindow( sw );
    487492
    488493#if 0
    489             /* Call WH_SHELL hook */
    490 
    491             if (!(dwStyle & WS_CHILD) && !owner)
    492                 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
     494            /* Call WH_SHELL hook */
     495
     496            if (!(dwStyle & WS_CHILD) && !owner)
     497                HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
    493498#endif
    494             SetLastError(0);
    495             return TRUE;
    496         }
     499            SetLastError(0);
     500            return TRUE;
     501        }
    497502  }
    498503  fCreated = FALSE;
     
    504509#if 0
    505510/***********************************************************************
    506  *           WINPOS_MinMaximize
     511 *           WINPOS_MinMaximize
    507512 *
    508513 * Fill in lpRect and return additional flags to be used with SetWindowPos().
     
    523528    if( dwStyle & WS_MINIMIZE )
    524529    {
    525         if( !SendInternalMessageA(WM_QUERYOPEN, 0, 0L ) )
    526         return (SWP_NOSIZE | SWP_NOMOVE);
    527         swpFlags |= SWP_NOCOPYBITS;
     530        if( !SendInternalMessageA(WM_QUERYOPEN, 0, 0L ) )
     531        return (SWP_NOSIZE | SWP_NOMOVE);
     532        swpFlags |= SWP_NOCOPYBITS;
    528533    }
    529534    switch( cmd )
    530535    {
    531         case SW_MINIMIZE:
    532         if( dwStyle & WS_MAXIMIZE)
    533         {
    534              flags |= WIN_RESTORE_MAX;
    535              dwStyle &= ~WS_MAXIMIZE;
    536                 }
    537                 else
    538              flags &= ~WIN_RESTORE_MAX;
    539              dwStyle |= WS_MINIMIZE;
     536        case SW_MINIMIZE:
     537        if( dwStyle & WS_MAXIMIZE)
     538        {
     539             flags |= WIN_RESTORE_MAX;
     540             dwStyle &= ~WS_MAXIMIZE;
     541                }
     542                else
     543             flags &= ~WIN_RESTORE_MAX;
     544             dwStyle |= WS_MINIMIZE;
    540545
    541546#if 0
    542         if( flags & WIN_NATIVE )
    543              if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) )
    544              swpFlags |= MINMAX_NOSWP;
     547        if( flags & WIN_NATIVE )
     548             if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) )
     549             swpFlags |= MINMAX_NOSWP;
    545550#endif
    546551
    547         lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
    548 
    549         SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
    550              GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
    551         swpFlags |= SWP_NOCOPYBITS;
    552         break;
    553 
    554         case SW_MAXIMIZE:
    555                 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
    556 
    557         if( dwStyle & WS_MINIMIZE )
    558         {
    559              if( flags & WIN_NATIVE )
    560              if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
    561                 swpFlags |= MINMAX_NOSWP;
    562 
    563              WINPOS_ShowIconTitle( wndPtr, FALSE );
    564              dwStyle &= ~WS_MINIMIZE;
    565         }
    566                 dwStyle |= WS_MAXIMIZE;
    567 
    568         SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
    569                     size.x, size.y );
    570         break;
    571 
    572         case SW_RESTORE:
    573         if( dwStyle & WS_MINIMIZE )
    574         {
    575              if( flags & WIN_NATIVE )
    576              if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
    577                 swpFlags |= MINMAX_NOSWP;
    578 
    579              dwStyle &= ~WS_MINIMIZE;
    580              WINPOS_ShowIconTitle( wndPtr, FALSE );
    581 
    582              if( flags & WIN_RESTORE_MAX)
    583              {
    584              /* Restore to maximized position */
    585                         CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
    586                         WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
    587                         CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
    588              dwStyle |= WS_MAXIMIZE;
    589              SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
    590              break;
    591              }
    592         }
    593         else
    594              if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
    595              else dwStyle &= ~WS_MAXIMIZE;
    596 
    597         /* Restore to normal position */
    598 
    599         *lpRect = lpPos->rectNormal;
    600         lpRect->right -= lpRect->left;
    601         lpRect->bottom -= lpRect->top;
    602 
    603         break;
     552        lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
     553
     554        SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
     555             GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
     556        swpFlags |= SWP_NOCOPYBITS;
     557        break;
     558
     559        case SW_MAXIMIZE:
     560                WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
     561
     562        if( dwStyle & WS_MINIMIZE )
     563        {
     564             if( flags & WIN_NATIVE )
     565             if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
     566                swpFlags |= MINMAX_NOSWP;
     567
     568             WINPOS_ShowIconTitle( wndPtr, FALSE );
     569             dwStyle &= ~WS_MINIMIZE;
     570        }
     571                dwStyle |= WS_MAXIMIZE;
     572
     573        SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
     574                    size.x, size.y );
     575        break;
     576
     577        case SW_RESTORE:
     578        if( dwStyle & WS_MINIMIZE )
     579        {
     580             if( flags & WIN_NATIVE )
     581             if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
     582                swpFlags |= MINMAX_NOSWP;
     583
     584             dwStyle &= ~WS_MINIMIZE;
     585             WINPOS_ShowIconTitle( wndPtr, FALSE );
     586
     587             if( flags & WIN_RESTORE_MAX)
     588             {
     589             /* Restore to maximized position */
     590                        CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
     591                        WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
     592                        CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
     593             dwStyle |= WS_MAXIMIZE;
     594             SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
     595             break;
     596             }
     597        }
     598        else
     599             if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
     600             else dwStyle &= ~WS_MAXIMIZE;
     601
     602        /* Restore to normal position */
     603
     604        *lpRect = lpPos->rectNormal;
     605        lpRect->right -= lpRect->left;
     606        lpRect->bottom -= lpRect->top;
     607
     608        break;
    604609    }
    605610    } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
     
    608613#endif
    609614/*******************************************************************
    610  *           GetMinMaxInfo
     615 *           GetMinMaxInfo
    611616 *
    612617 * Get the minimized and maximized information for a window.
    613618 */
    614619void Win32BaseWindow::GetMinMaxInfo(POINT *maxSize, POINT *maxPos,
    615                                 POINT *minTrack, POINT *maxTrack )
     620                                POINT *minTrack, POINT *maxTrack )
    616621{
    617622    MINMAXINFO MinMax;
     
    630635    else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
    631636    {
    632         xinc = GetSystemMetrics(SM_CXDLGFRAME);
    633         yinc = GetSystemMetrics(SM_CYDLGFRAME);
     637        xinc = GetSystemMetrics(SM_CXDLGFRAME);
     638        yinc = GetSystemMetrics(SM_CYDLGFRAME);
    634639    }
    635640    else
    636641    {
    637         xinc = yinc = 0;
    638         if (HAS_THICKFRAME(dwStyle))
    639         {
    640             xinc += GetSystemMetrics(SM_CXFRAME);
    641             yinc += GetSystemMetrics(SM_CYFRAME);
    642         }
    643         if (dwStyle & WS_BORDER)
    644         {
    645             xinc += GetSystemMetrics(SM_CXBORDER);
    646             yinc += GetSystemMetrics(SM_CYBORDER);
    647         }
     642        xinc = yinc = 0;
     643        if (HAS_THICKFRAME(dwStyle))
     644        {
     645            xinc += GetSystemMetrics(SM_CXFRAME);
     646            yinc += GetSystemMetrics(SM_CYFRAME);
     647        }
     648        if (dwStyle & WS_BORDER)
     649        {
     650            xinc += GetSystemMetrics(SM_CXBORDER);
     651            yinc += GetSystemMetrics(SM_CYBORDER);
     652        }
    648653    }
    649654    MinMax.ptMaxSize.x += 2 * xinc;
     
    653658    lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos );
    654659    if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
    655         CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
     660        CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
    656661    else
    657662    {
    658663#endif
    659         MinMax.ptMaxPosition.x = -xinc;
    660         MinMax.ptMaxPosition.y = -yinc;
     664        MinMax.ptMaxPosition.x = -xinc;
     665        MinMax.ptMaxPosition.y = -yinc;
    661666//    }
    662667
     
    666671
    667672    dprintf(("GetMinMaxInfo: %ld %ld / %ld %ld / %ld %ld / %ld %ld\n",
    668                       MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
    669                       MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
    670                       MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
    671                       MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y));
     673                      MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
     674                      MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
     675                      MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
     676                      MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y));
    672677    MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
    673                                    MinMax.ptMinTrackSize.x );
     678                                   MinMax.ptMinTrackSize.x );
    674679    MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
    675                                    MinMax.ptMinTrackSize.y );
     680                                   MinMax.ptMinTrackSize.y );
    676681
    677682    if (maxSize)    *maxSize  = MinMax.ptMaxSize;
     
    681686}
    682687/***********************************************************************
    683  *           WINPOS_SendNCCalcSize
     688 *           WINPOS_SendNCCalcSize
    684689 *
    685690 * Send a WM_NCCALCSIZE message to a window.
     
    689694 */
    690695LONG Win32BaseWindow::SendNCCalcSize(BOOL calcValidRect, RECT *newWindowRect, RECT *oldWindowRect,
    691                                 RECT *oldClientRect, WINDOWPOS *winpos,
    692                                 RECT *newClientRect )
     696                                RECT *oldClientRect, WINDOWPOS *winpos,
     697                                RECT *newClientRect )
    693698{
    694699   NCCALCSIZE_PARAMS params;
     
    699704   if (calcValidRect)
    700705   {
    701         winposCopy = *winpos;
    702         params.rgrc[1] = *oldWindowRect;
    703         params.rgrc[2] = *oldClientRect;
    704         params.lppos = &winposCopy;
     706        winposCopy = *winpos;
     707        params.rgrc[1] = *oldWindowRect;
     708        params.rgrc[2] = *oldClientRect;
     709        params.lppos = &winposCopy;
    705710   }
    706711   result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect,
    707                                 (LPARAM)&params );
     712                                (LPARAM)&params );
    708713   *newClientRect = params.rgrc[0];
    709714   return result;
     
    727732{
    728733  if(SendInternalMessageA(WM_CLOSE, 0, 0) == 0) {
    729         return 0; //app handles this message
     734        return 0; //app handles this message
    730735  }
    731736  delete this;
     
    762767#if 1
    763768    if(fCreated == FALSE) {
    764         return 1;
     769        return 1;
    765770    }
    766771#endif
     
    774779#if 1
    775780    if(fCreated == FALSE) {
    776         return 1;
     781        return 1;
    777782    }
    778783#endif
     
    785790    dprintf(("MsgMove to (%d,%d)", x, y));
    786791    if(fCreated == FALSE) {
    787         return 1;
     792        return 1;
    788793    }
    789794
     
    796801  switch(cmd) {
    797802    case CMD_MENU:
    798         return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0);
     803        return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0);
    799804    case CMD_CONTROL:
    800         return 0; //todo
     805        return 0; //todo
    801806    case CMD_ACCELERATOR:
    802         dprintf(("accelerator command"));
    803         return 0; //todo
     807        dprintf(("accelerator command"));
     808        return 0; //todo
    804809  }
    805810  return 0;
     
    820825
    821826    if(fCreated == FALSE) {//Solitaire crashes if it receives a WM_SIZE during CreateWindowEx (normal or our fault?)
    822         return 1;
     827        return 1;
    823828    }
    824829
    825830    if(fMinimize) {
    826             fwSizeType = SIZE_MINIMIZED;
     831            fwSizeType = SIZE_MINIMIZED;
    827832    }
    828833    else
    829834    if(fMaximize) {
    830             fwSizeType = SIZE_MAXIMIZED;
     835            fwSizeType = SIZE_MAXIMIZED;
    831836    }
    832837    else    fwSizeType = SIZE_RESTORED;
     
    840845    if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE)
    841846    {
    842         if(!fActivate) {
    843             return 1;
    844         }
     847        if(!fActivate) {
     848            return 1;
     849        }
    845850    }
    846851    return SendInternalMessageA(WM_ACTIVATE, (fActivate) ? WA_ACTIVE : WA_INACTIVE, hwnd);
     
    862867    lParam |= (scancode << 16);
    863868    if(keyflags & KEY_ALTDOWN)
    864         lParam |= (1<<29);
     869        lParam |= (1<<29);
    865870    if(keyflags & KEY_PREVDOWN)
    866         lParam |= (1<<30);
     871        lParam |= (1<<30);
    867872    if(keyflags & KEY_UP)
    868         lParam |= (1<<31);
     873        lParam |= (1<<31);
    869874    if(keyflags & KEY_DEADKEY) {
    870         dprintf(("WM_DEADCHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
    871         return SendInternalMessageA(WM_DEADCHAR, cmd, lParam);
     875        dprintf(("WM_DEADCHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
     876        return SendInternalMessageA(WM_DEADCHAR, cmd, lParam);
    872877    }
    873878    else {
    874         dprintf(("WM_CHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
    875         return SendInternalMessageA(WM_CHAR, cmd, lParam);
     879        dprintf(("WM_CHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
     880        return SendInternalMessageA(WM_CHAR, cmd, lParam);
    876881    }
    877882}
     
    881886{
    882887    if(hwnd == 0) {
    883             //other app lost focus
    884             SendInternalMessageA(WM_ACTIVATEAPP, TRUE, 0); //TODO: Need thread id from hwnd app
     888            //other app lost focus
     889            SendInternalMessageA(WM_ACTIVATEAPP, TRUE, 0); //TODO: Need thread id from hwnd app
    885890    }
    886891    return  SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
     
    891896{
    892897    if(hwnd == 0) {
    893             //other app lost focus
    894             SendInternalMessageA(WM_ACTIVATEAPP, FALSE, 0); //TODO: Need thread id from hwnd app
     898            //other app lost focus
     899            SendInternalMessageA(WM_ACTIVATEAPP, FALSE, 0); //TODO: Need thread id from hwnd app
    895900    }
    896901    return  SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
     
    905910    dprintf(("MsgButton to (%d,%d)", ncx, ncy));
    906911    switch(msg) {
    907         case BUTTON_LEFTDOWN:
    908                 win32msg = WM_LBUTTONDOWN;
    909                 win32ncmsg = WM_NCLBUTTONDOWN;
    910                 break;
    911         case BUTTON_LEFTUP:
    912                 win32msg = WM_LBUTTONUP;
    913                 win32ncmsg = WM_NCLBUTTONUP;
    914                 break;
    915         case BUTTON_LEFTDBLCLICK:
    916                 win32msg = WM_LBUTTONDBLCLK;
    917                 win32ncmsg = WM_NCLBUTTONDBLCLK;
    918                 break;
    919         case BUTTON_RIGHTUP:
    920                 win32msg = WM_RBUTTONUP;
    921                 win32ncmsg = WM_NCRBUTTONUP;
    922                 break;
    923         case BUTTON_RIGHTDOWN:
    924                 win32msg = WM_RBUTTONDOWN;
    925                 win32ncmsg = WM_NCRBUTTONDOWN;
    926                 break;
    927         case BUTTON_RIGHTDBLCLICK:
    928                 win32msg = WM_RBUTTONDBLCLK;
    929                 win32ncmsg = WM_NCRBUTTONDBLCLK;
    930                 break;
    931         case BUTTON_MIDDLEUP:
    932                 win32msg = WM_MBUTTONUP;
    933                 win32ncmsg = WM_NCMBUTTONUP;
    934                 break;
    935         case BUTTON_MIDDLEDOWN:
    936                 win32msg = WM_MBUTTONDOWN;
    937                 win32ncmsg = WM_NCMBUTTONDOWN;
    938                 break;
    939         case BUTTON_MIDDLEDBLCLICK:
    940                 win32msg = WM_MBUTTONDBLCLK;
    941                 win32ncmsg = WM_NCMBUTTONDBLCLK;
    942                 break;
    943         default:
    944                 dprintf(("Win32BaseWindow::Button: invalid msg!!!!"));
    945                 return 1;
     912        case BUTTON_LEFTDOWN:
     913                win32msg = WM_LBUTTONDOWN;
     914                win32ncmsg = WM_NCLBUTTONDOWN;
     915                break;
     916        case BUTTON_LEFTUP:
     917                win32msg = WM_LBUTTONUP;
     918                win32ncmsg = WM_NCLBUTTONUP;
     919                break;
     920        case BUTTON_LEFTDBLCLICK:
     921                win32msg = WM_LBUTTONDBLCLK;
     922                win32ncmsg = WM_NCLBUTTONDBLCLK;
     923                break;
     924        case BUTTON_RIGHTUP:
     925                win32msg = WM_RBUTTONUP;
     926                win32ncmsg = WM_NCRBUTTONUP;
     927                break;
     928        case BUTTON_RIGHTDOWN:
     929                win32msg = WM_RBUTTONDOWN;
     930                win32ncmsg = WM_NCRBUTTONDOWN;
     931                break;
     932        case BUTTON_RIGHTDBLCLICK:
     933                win32msg = WM_RBUTTONDBLCLK;
     934                win32ncmsg = WM_NCRBUTTONDBLCLK;
     935                break;
     936        case BUTTON_MIDDLEUP:
     937                win32msg = WM_MBUTTONUP;
     938                win32ncmsg = WM_NCMBUTTONUP;
     939                break;
     940        case BUTTON_MIDDLEDOWN:
     941                win32msg = WM_MBUTTONDOWN;
     942                win32ncmsg = WM_NCMBUTTONDOWN;
     943                break;
     944        case BUTTON_MIDDLEDBLCLICK:
     945                win32msg = WM_MBUTTONDBLCLK;
     946                win32ncmsg = WM_NCMBUTTONDBLCLK;
     947                break;
     948        default:
     949                dprintf(("Win32BaseWindow::Button: invalid msg!!!!"));
     950                return 1;
    946951    }
    947952    if(win32msg == WM_MBUTTONDBLCLK || win32msg == WM_RBUTTONDBLCLK || win32msg == WM_LBUTTONDBLCLK) {
    948         if(!(windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)) {
    949             return 1;
    950         }
     953        if(!(windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)) {
     954            return 1;
     955        }
    951956    }
    952957    SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, win32ncmsg));
     
    954959    //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
    955960    if(lastHitTestVal != HTCLIENT) {
    956             SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(ncx, ncy)); //TODO:
     961            SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(ncx, ncy)); //TODO:
    957962    }
    958963    return  SendInternalMessageA(win32msg, 0, MAKELONG(clx, cly));
     
    966971
    967972    if(keystate & WMMOVE_LBUTTON)
    968         winstate |= MK_LBUTTON;
     973        winstate |= MK_LBUTTON;
    969974    if(keystate & WMMOVE_RBUTTON)
    970         winstate |= MK_RBUTTON;
     975        winstate |= MK_RBUTTON;
    971976    if(keystate & WMMOVE_MBUTTON)
    972         winstate |= MK_MBUTTON;
     977        winstate |= MK_MBUTTON;
    973978    if(keystate & WMMOVE_SHIFT)
    974         winstate |= MK_SHIFT;
     979        winstate |= MK_SHIFT;
    975980    if(keystate & WMMOVE_CTRL)
    976         winstate |= MK_CONTROL;
     981        winstate |= MK_CONTROL;
    977982
    978983    if(lastHitTestVal != HTCLIENT) {
    979         setcursormsg = WM_NCMOUSEMOVE;
     984        setcursormsg = WM_NCMOUSEMOVE;
    980985    }
    981986    //TODO: hiword should be 0 if window enters menu mode (SDK docs)
     
    984989    //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
    985990    if(lastHitTestVal != HTCLIENT) {
    986             SendInternalMessageA(WM_NCMOUSEMOVE, lastHitTestVal, MAKELONG(x, y));
     991            SendInternalMessageA(WM_NCMOUSEMOVE, lastHitTestVal, MAKELONG(x, y));
    987992    }
    988993    return  SendInternalMessageA(WM_MOUSEMOVE, keystate, MAKELONG(x, y));
     
    9961001//******************************************************************************
    9971002//TODO: Is the clipper region of the window DC equal to the invalidated rectangle?
    998 //      (or are we simply erasing too much here)
     1003//      (or are we simply erasing too much here)
    9991004//******************************************************************************
    10001005ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc)
     
    10041009
    10051010    if (hdcErase == 0)
    1006         hdcErase = O32_GetDC(OS2Hwnd);
     1011        hdcErase = O32_GetDC(OS2Hwnd);
    10071012
    10081013    if(isIcon)
    1009         rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0);
     1014        rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0);
    10101015    else
    1011         rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0);
     1016        rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0);
    10121017    if (hdc == 0)
    1013         O32_ReleaseDC(OS2Hwnd, hdcErase);
     1018        O32_ReleaseDC(OS2Hwnd, hdcErase);
    10141019    return (rc);
    10151020}
     
    10191024{
    10201025    if(isUnicode) {
    1021             return SendInternalMessageW(WM_SETTEXT, 0, (LPARAM)lpsz);
     1026            return SendInternalMessageW(WM_SETTEXT, 0, (LPARAM)lpsz);
    10221027    }
    10231028    else    return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
     
    10351040{
    10361041    if(isUnicode) {
    1037         SendInternalMessageW(WM_GETTEXT, wndNameLength, (LPARAM)windowNameW);
     1042        SendInternalMessageW(WM_GETTEXT, wndNameLength, (LPARAM)windowNameW);
    10381043    }
    10391044    else {
    1040         SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA);
     1045        SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA);
    10411046    }
    10421047    return windowNameA;
     
    10491054    {
    10501055    case WM_GETTEXTLENGTH:
    1051         return wndNameLength;
     1056        return wndNameLength;
    10521057
    10531058    case WM_GETTEXT:   //TODO: SS_ICON controls
    1054         strncpy((LPSTR)lParam, windowNameA, wParam);
    1055         return min(wndNameLength, wParam);
     1059        strncpy((LPSTR)lParam, windowNameA, wParam);
     1060        return min(wndNameLength, wParam);
    10561061
    10571062    case WM_SETTEXT:
    1058         return 0;
     1063        return 0;
    10591064
    10601065    case WM_SETREDRAW:
    1061         if(wParam)
    1062                 SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) | WS_VISIBLE);
    1063         else    SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE);
    1064 
    1065         return 0; //TODO
     1066        if(wParam)
     1067                SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) | WS_VISIBLE);
     1068        else    SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE);
     1069
     1070        return 0; //TODO
    10661071
    10671072    case WM_NCCREATE:
    1068         return(TRUE);
     1073        return(TRUE);
    10691074
    10701075    case WM_CTLCOLORMSGBOX:
     
    10751080    case WM_CTLCOLORSTATIC:
    10761081    case WM_CTLCOLORSCROLLBAR:
    1077         SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
    1078         SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
    1079         return GetSysColorBrush(COLOR_BTNFACE);
     1082        SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
     1083        SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
     1084        return GetSysColorBrush(COLOR_BTNFACE);
    10801085
    10811086    case WM_PARENTNOTIFY:
    1082         return 0;
     1087        return 0;
    10831088
    10841089    case WM_MOUSEACTIVATE:
    10851090    {
    1086         DWORD dwStyle = GetWindowLongA(GWL_STYLE);
    1087         DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
    1088         dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
    1089         if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
    1090         {
    1091             if(getParent()) {
    1092                 LRESULT rc = getParent()->SendMessageA(WM_MOUSEACTIVATE, wParam, lParam );
    1093                 if(rc)  return rc;
    1094             }
    1095         }
    1096         return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
     1091        DWORD dwStyle = GetWindowLongA(GWL_STYLE);
     1092        DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
     1093        dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
     1094        if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
     1095        {
     1096            if(getParent()) {
     1097                LRESULT rc = getParent()->SendMessageA(WM_MOUSEACTIVATE, wParam, lParam );
     1098                if(rc)  return rc;
     1099            }
     1100        }
     1101        return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
    10971102    }
    10981103    case WM_SETCURSOR:
    10991104    {
    1100         DWORD dwStyle = GetWindowLongA(GWL_STYLE);
    1101         DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
    1102         dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
    1103         if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
    1104         {
    1105             if(getParent()) {
    1106                 LRESULT rc = getParent()->SendMessageA(WM_SETCURSOR, wParam, lParam);
    1107                 if(rc)  return rc;
    1108             }
    1109         }
    1110         return 1;
     1105        DWORD dwStyle = GetWindowLongA(GWL_STYLE);
     1106        DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
     1107        dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
     1108        if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
     1109        {
     1110            if(getParent()) {
     1111                LRESULT rc = getParent()->SendMessageA(WM_SETCURSOR, wParam, lParam);
     1112                if(rc)  return rc;
     1113            }
     1114        }
     1115        return 1;
    11111116    }
    11121117    case WM_MOUSEMOVE:
    1113         return 0;
     1118        return 0;
    11141119
    11151120    case WM_WINDOWPOSCHANGED:
     
    11171122
    11181123/* undocumented SWP flags - from SDK 3.1 */
    1119 #define SWP_NOCLIENTSIZE        0x0800
    1120 #define SWP_NOCLIENTMOVE        0x1000
    1121 
    1122         PWINDOWPOS wpos = (PWINDOWPOS)lParam;
    1123         WPARAM     wp   = SIZE_RESTORED;
    1124 
    1125         if (!(wpos->flags & SWP_NOCLIENTMOVE))
    1126             SendMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
    1127 
    1128         if (!(wpos->flags & SWP_NOCLIENTSIZE))
    1129         {
    1130             if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
    1131             else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
    1132 
    1133            SendMessageA(WM_SIZE, wp, MAKELONG(rectClient.right  - rectClient.left,
    1134                                               rectClient.bottom - rectClient.top));
    1135         }
    1136         return 0;
     1124#define SWP_NOCLIENTSIZE        0x0800
     1125#define SWP_NOCLIENTMOVE        0x1000
     1126
     1127        PWINDOWPOS wpos = (PWINDOWPOS)lParam;
     1128        WPARAM     wp   = SIZE_RESTORED;
     1129
     1130        if (!(wpos->flags & SWP_NOCLIENTMOVE))
     1131            SendMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
     1132
     1133        if (!(wpos->flags & SWP_NOCLIENTSIZE))
     1134        {
     1135            if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
     1136            else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
     1137
     1138           SendMessageA(WM_SIZE, wp, MAKELONG(rectClient.right  - rectClient.left,
     1139                                              rectClient.bottom - rectClient.top));
     1140        }
     1141        return 0;
    11371142    }
    11381143    case WM_ERASEBKGND:
     
    11421147      int rc;
    11431148
    1144         if (!windowClass->getBackgroundBrush()) return 0;
    1145 
    1146         /*  Since WM_ERASEBKGND may receive either a window dc or a    */
    1147         /*  client dc, the area to be erased has to be retrieved from  */
    1148         /*  the device context.                                    */
    1149         rc = GetClipBox( (HDC)wParam, &rect );
    1150         if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
    1151             FillRect( (HDC)wParam, &rect, windowClass->getBackgroundBrush());
    1152 
    1153         return 1;
     1149        if (!windowClass->getBackgroundBrush()) return 0;
     1150
     1151        /*  Since WM_ERASEBKGND may receive either a window dc or a    */
     1152        /*  client dc, the area to be erased has to be retrieved from  */
     1153        /*  the device context.                                    */
     1154        rc = GetClipBox( (HDC)wParam, &rect );
     1155        if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
     1156            FillRect( (HDC)wParam, &rect, windowClass->getBackgroundBrush());
     1157
     1158        return 1;
    11541159    }
    11551160
     
    11631168    case WM_NCMBUTTONUP:
    11641169    case WM_NCMBUTTONDBLCLK:
    1165         return 0;           //TODO: Send WM_SYSCOMMAND if required
     1170        return 0;           //TODO: Send WM_SYSCOMMAND if required
    11661171
    11671172    case WM_NCHITTEST: //TODO: Calculate position of
    1168         return HTCLIENT;
     1173        return HTCLIENT;
    11691174
    11701175    default:
    1171         return 1;
     1176        return 1;
    11721177    }
    11731178}
     
    11791184    {
    11801185    case WM_GETTEXTLENGTH:
    1181         return wndNameLength;
     1186        return wndNameLength;
    11821187
    11831188    case WM_GETTEXT:   //TODO: SS_ICON controls
    1184         lstrcpynW((LPWSTR)lParam, windowNameW, wParam);
    1185         return min(wndNameLength, wParam);
     1189        lstrcpynW((LPWSTR)lParam, windowNameW, wParam);
     1190        return min(wndNameLength, wParam);
    11861191
    11871192    default:
    1188         return DefWindowProcA(Msg, wParam, lParam);
     1193        return DefWindowProcA(Msg, wParam, lParam);
    11891194    }
    11901195}
     
    11941199{
    11951200  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    1196         dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     1201        dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    11971202
    11981203  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1199         return(0);
     1204        return(0);
    12001205  }
    12011206  switch(Msg)
    12021207  {
    1203         case WM_CREATE:
    1204         {
    1205                 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    1206                         dprintf(("WM_NCCREATE returned FALSE\n"));
    1207                         return(-1); //don't create window
    1208                 }
    1209                 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
    1210                         dprintf(("WM_CREATE returned -1\n"));
    1211                         return(-1); //don't create window
    1212                 }
    1213                 NotifyParent(Msg, wParam, lParam);
    1214 
    1215                 return(0);
    1216         }
    1217         case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
    1218                 return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
    1219 
    1220         case WM_LBUTTONDOWN:
    1221         case WM_MBUTTONDOWN:
    1222         case WM_RBUTTONDOWN:
    1223                 NotifyParent(Msg, wParam, lParam);
    1224                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    1225 
    1226         case WM_DESTROY:
    1227                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1228                 NotifyParent(Msg, wParam, lParam);
    1229                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1230         default:
    1231                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1208        case WM_CREATE:
     1209        {
     1210                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
     1211                        dprintf(("WM_NCCREATE returned FALSE\n"));
     1212                        return(-1); //don't create window
     1213                }
     1214                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
     1215                        dprintf(("WM_CREATE returned -1\n"));
     1216                        return(-1); //don't create window
     1217                }
     1218                NotifyParent(Msg, wParam, lParam);
     1219
     1220                return(0);
     1221        }
     1222        case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
     1223                return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
     1224
     1225        case WM_LBUTTONDOWN:
     1226        case WM_MBUTTONDOWN:
     1227        case WM_RBUTTONDOWN:
     1228                NotifyParent(Msg, wParam, lParam);
     1229                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1230
     1231        case WM_DESTROY:
     1232                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     1233                NotifyParent(Msg, wParam, lParam);
     1234                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     1235        default:
     1236                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    12321237  }
    12331238}
     
    12371242{
    12381243  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    1239         dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     1244        dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    12401245
    12411246  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1242         return(0);
     1247        return(0);
    12431248  }
    12441249  switch(Msg)
    12451250  {
    1246         case WM_CREATE:
    1247         {
    1248                 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    1249                         dprintf(("WM_NCCREATE returned FALSE\n"));
    1250                         return(0); //don't create window
    1251                 }
    1252                 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
    1253                         dprintf(("WM_CREATE returned FALSE\n"));
    1254                         return(0); //don't create window
    1255                 }
    1256                 NotifyParent(Msg, wParam, lParam);
    1257 
    1258                 return(1);
    1259         }
    1260         case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
    1261                 return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
    1262 
    1263         case WM_LBUTTONDOWN:
    1264         case WM_MBUTTONDOWN:
    1265         case WM_RBUTTONDOWN:
    1266                 NotifyParent(Msg, wParam, lParam);
    1267                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    1268 
    1269         case WM_DESTROY:
    1270                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1271                 NotifyParent(Msg, wParam, lParam);
    1272                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1273 
    1274         default:
    1275                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1251        case WM_CREATE:
     1252        {
     1253                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
     1254                        dprintf(("WM_NCCREATE returned FALSE\n"));
     1255                        return(0); //don't create window
     1256                }
     1257                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
     1258                        dprintf(("WM_CREATE returned FALSE\n"));
     1259                        return(0); //don't create window
     1260                }
     1261                NotifyParent(Msg, wParam, lParam);
     1262
     1263                return(1);
     1264        }
     1265        case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
     1266                return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
     1267
     1268        case WM_LBUTTONDOWN:
     1269        case WM_MBUTTONDOWN:
     1270        case WM_RBUTTONDOWN:
     1271                NotifyParent(Msg, wParam, lParam);
     1272                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1273
     1274        case WM_DESTROY:
     1275                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     1276                NotifyParent(Msg, wParam, lParam);
     1277                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     1278
     1279        default:
     1280                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    12761281  }
    12771282}
     
    12821287{
    12831288  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    1284         dprintf(("SendInternalMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     1289        dprintf(("SendInternalMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    12851290
    12861291  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1287         return(0);
     1292        return(0);
    12881293  }
    12891294  switch(Msg)
    12901295  {
    1291         case WM_CREATE:
    1292         {
    1293                 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    1294                         dprintf(("WM_NCCREATE returned FALSE\n"));
    1295                         return(0); //don't create window
    1296                 }
    1297                 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
    1298                         dprintf(("WM_CREATE returned FALSE\n"));
    1299                         return(0); //don't create window
    1300                 }
    1301                 NotifyParent(Msg, wParam, lParam);
    1302 
    1303                 return(1);
    1304         }
    1305         case WM_LBUTTONDOWN:
    1306         case WM_MBUTTONDOWN:
    1307         case WM_RBUTTONDOWN:
    1308                 NotifyParent(Msg, wParam, lParam);
    1309                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    1310 
    1311         case WM_DESTROY:
    1312                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1313                 NotifyParent(Msg, wParam, lParam);
    1314                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1315         default:
    1316                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1296        case WM_CREATE:
     1297        {
     1298                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
     1299                        dprintf(("WM_NCCREATE returned FALSE\n"));
     1300                        return(0); //don't create window
     1301                }
     1302                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
     1303                        dprintf(("WM_CREATE returned FALSE\n"));
     1304                        return(0); //don't create window
     1305                }
     1306                NotifyParent(Msg, wParam, lParam);
     1307
     1308                return(1);
     1309        }
     1310        case WM_LBUTTONDOWN:
     1311        case WM_MBUTTONDOWN:
     1312        case WM_RBUTTONDOWN:
     1313                NotifyParent(Msg, wParam, lParam);
     1314                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1315
     1316        case WM_DESTROY:
     1317                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     1318                NotifyParent(Msg, wParam, lParam);
     1319                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     1320        default:
     1321                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    13171322  }
    13181323}
     
    13241329{
    13251330  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    1326         dprintf(("SendInternalMessageW %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     1331        dprintf(("SendInternalMessageW %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    13271332
    13281333  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1329         return(0);
     1334        return(0);
    13301335  }
    13311336  switch(Msg)
    13321337  {
    1333         case WM_CREATE:
    1334         {
    1335                 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    1336                         dprintf(("WM_NCCREATE returned FALSE\n"));
    1337                         return(0); //don't create window
    1338                 }
    1339                 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
    1340                         dprintf(("WM_CREATE returned FALSE\n"));
    1341                         return(0); //don't create window
    1342                 }
    1343                 NotifyParent(Msg, wParam, lParam);
    1344 
    1345                 return(1);
    1346         }
    1347         case WM_LBUTTONDOWN:
    1348         case WM_MBUTTONDOWN:
    1349         case WM_RBUTTONDOWN:
    1350                 NotifyParent(Msg, wParam, lParam);
    1351                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    1352 
    1353         case WM_DESTROY:
    1354                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1355                 NotifyParent(Msg, wParam, lParam);
    1356                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1357         default:
    1358                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1338        case WM_CREATE:
     1339        {
     1340                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
     1341                        dprintf(("WM_NCCREATE returned FALSE\n"));
     1342                        return(0); //don't create window
     1343                }
     1344                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
     1345                        dprintf(("WM_CREATE returned FALSE\n"));
     1346                        return(0); //don't create window
     1347                }
     1348                NotifyParent(Msg, wParam, lParam);
     1349
     1350                return(1);
     1351        }
     1352        case WM_LBUTTONDOWN:
     1353        case WM_MBUTTONDOWN:
     1354        case WM_RBUTTONDOWN:
     1355                NotifyParent(Msg, wParam, lParam);
     1356                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1357
     1358        case WM_DESTROY:
     1359                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     1360                NotifyParent(Msg, wParam, lParam);
     1361                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     1362        default:
     1363                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    13591364  }
    13601365}
     
    13811386   while(window)
    13821387   {
    1383         if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
    1384         {
    1385                 /* Notify the parent window only */
    1386                 parentwindow = window->getParent();
    1387                 if(parentwindow) {
    1388                         if(Msg == WM_CREATE || Msg == WM_DESTROY) {
    1389                                 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
    1390                         }
    1391                         else    parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
    1392                 }
    1393         }
    1394         else    break;
    1395 
    1396         window = parentwindow;
     1388        if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
     1389        {
     1390                /* Notify the parent window only */
     1391                parentwindow = window->getParent();
     1392                if(parentwindow) {
     1393                        if(Msg == WM_CREATE || Msg == WM_DESTROY) {
     1394                                parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
     1395                        }
     1396                        else    parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
     1397                }
     1398        }
     1399        else    break;
     1400
     1401        window = parentwindow;
    13971402   }
    13981403}
     
    14011406BOOL Win32BaseWindow::SetMenu(HMENU hMenu)
    14021407{
    1403  PVOID          menutemplate;
     1408 PVOID          menutemplate;
    14041409 Win32Resource *winres = (Win32Resource *)hMenu;
    14051410
    14061411    dprintf(("SetMenu %x", hMenu));
    14071412    if(HIWORD(winres) == 0) {
    1408         dprintf(("Win32BaseWindow:: Win32Resource *winres == 0"));
    1409         SetLastError(ERROR_INVALID_PARAMETER);
    1410         return FALSE;
     1413        dprintf(("Win32BaseWindow:: Win32Resource *winres == 0"));
     1414        SetLastError(ERROR_INVALID_PARAMETER);
     1415        return FALSE;
    14111416    }
    14121417    menutemplate = winres->lockOS2Resource();
    14131418    if(menutemplate == NULL)
    14141419    {
    1415         dprintf(("Win32BaseWindow::SetMenu menutemplate == 0"));
    1416         return FALSE;
     1420        dprintf(("Win32BaseWindow::SetMenu menutemplate == 0"));
     1421        return FALSE;
    14171422    }
    14181423    OS2HwndMenu = OSLibWinCreateMenu(OS2HwndFrame, menutemplate);
    14191424    if(OS2HwndMenu == 0) {
    1420         dprintf(("Win32BaseWindow::SetMenu OS2HwndMenu == 0"));
    1421         return FALSE;
     1425        dprintf(("Win32BaseWindow::SetMenu OS2HwndMenu == 0"));
     1426        return FALSE;
    14221427    }
    14231428    winres->setOS2Handle(OS2HwndMenu);
     
    14301435{
    14311436 Win32Resource *winres = (Win32Resource *)hAccel;
    1432  HANDLE         accelhandle;
     1437 HANDLE         accelhandle;
    14331438
    14341439    if(HIWORD(hAccel) == 0) {
    1435         dprintf(("SetAccelTable: hAccel %x invalid", hAccel));
    1436         SetLastError(ERROR_INVALID_PARAMETER);
    1437         return FALSE;
     1440        dprintf(("SetAccelTable: hAccel %x invalid", hAccel));
     1441        SetLastError(ERROR_INVALID_PARAMETER);
     1442        return FALSE;
    14381443    }
    14391444    acceltableResource = winres;
     
    14571462    dprintf(("ShowWindow %x", nCmdShow));
    14581463    if(fFirstShow) {
    1459         if(isFrameWindow() && IS_OVERLAPPED(getStyle())) {
    1460                 SendMessageA(WM_SIZE, SIZE_RESTORED,
    1461                                 MAKELONG(rectClient.right-rectClient.left,
    1462                                         rectClient.bottom-rectClient.top));
    1463                 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
    1464 
    1465         }
    1466         fFirstShow = FALSE;
     1464        if(isFrameWindow() && IS_OVERLAPPED(getStyle())) {
     1465                SendMessageA(WM_SIZE, SIZE_RESTORED,
     1466                                MAKELONG(rectClient.right-rectClient.left,
     1467                                        rectClient.bottom-rectClient.top));
     1468                SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
     1469
     1470        }
     1471        fFirstShow = FALSE;
    14671472    }
    14681473    switch(nCmdShow)
     
    14701475    case SW_SHOW:
    14711476    case SW_SHOWDEFAULT: //todo
    1472         showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
    1473         break;
     1477        showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
     1478        break;
    14741479    case SW_HIDE:
    1475         showstate = SWPOS_HIDE;
    1476         break;
     1480        showstate = SWPOS_HIDE;
     1481        break;
    14771482    case SW_RESTORE:
    1478         showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
    1479         break;
     1483        showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
     1484        break;
    14801485    case SW_MINIMIZE:
    1481         showstate = SWPOS_MINIMIZE;
    1482         break;
     1486        showstate = SWPOS_MINIMIZE;
     1487        break;
    14831488    case SW_SHOWMAXIMIZED:
    1484         showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
    1485         break;
     1489        showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
     1490        break;
    14861491    case SW_SHOWMINIMIZED:
    1487         showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
    1488         break;
     1492        showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
     1493        break;
    14891494    case SW_SHOWMINNOACTIVE:
    1490         showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
    1491         break;
     1495        showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
     1496        break;
    14921497    case SW_SHOWNA:
    1493         showstate = SWPOS_SHOW;
    1494         break;
     1498        showstate = SWPOS_SHOW;
     1499        break;
    14951500    case SW_SHOWNOACTIVATE:
    1496         showstate = SWPOS_SHOW;
    1497         break;
     1501        showstate = SWPOS_SHOW;
     1502        break;
    14981503    case SW_SHOWNORMAL:
    1499         showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
    1500         break;
     1504        showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
     1505        break;
    15011506    }
    15021507    return OSLibWinShowWindow(OS2HwndFrame, showstate);
     
    15121517   dprintf (("SetWindowPos %x %x (%d,%d)(%d,%d) %x", Win32Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
    15131518
    1514    /* Validate the flags passed in ...                  */
     1519   /* Validate the flags passed in ...                  */
    15151520   if ( fuFlags &
    1516         ~(SWP_NOSIZE     | SWP_NOMOVE     | SWP_NOZORDER     |
    1517           SWP_NOREDRAW  | SWP_NOACTIVATE | SWP_FRAMECHANGED |
    1518           SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS   |
    1519           SWP_NOOWNERZORDER) )
     1521        ~(SWP_NOSIZE     | SWP_NOMOVE     | SWP_NOZORDER     |
     1522          SWP_NOREDRAW  | SWP_NOACTIVATE | SWP_FRAMECHANGED |
     1523          SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS   |
     1524          SWP_NOOWNERZORDER) )
    15201525   {
    15211526      return FALSE;
     
    15281533   // Set up with Windows values.
    15291534   //****************************
    1530    wpos.flags            = fuFlags;
    1531    wpos.cy              = cy;
    1532    wpos.cx              = cx;
    1533    wpos.x                = x;
    1534    wpos.y                = y;
     1535   wpos.flags            = fuFlags;
     1536   wpos.cy              = cy;
     1537   wpos.cx              = cx;
     1538   wpos.x                = x;
     1539   wpos.y                = y;
    15351540   wpos.hwndInsertAfter  = hwndInsertAfter;
    1536    wpos.hwnd            = getWindowHandle();
     1541   wpos.hwnd            = getWindowHandle();
    15371542
    15381543   //**********************************************
     
    15421547       if (isChild())
    15431548       {
    1544            hParent = getParent()->getOS2WindowHandle();
    1545            OSLibWinQueryWindowPos(OS2Hwnd, &swpOld);
     1549           hParent = getParent()->getOS2WindowHandle();
     1550           OSLibWinQueryWindowPos(OS2Hwnd, &swpOld);
    15461551       } else
    1547            OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
     1552           OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
    15481553   }
    15491554   OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame);
     
    15901595   if (rc == FALSE)
    15911596   {
    1592 //      SET_ERROR_LAST();
     1597//      SET_ERROR_LAST();
    15931598   }
    15941599   else
     
    16021607      ** a WM_UPDATEFRAME, which will provide the behavior of WM_NCCALCSIZE.
    16031608      */
    1604 //      if (fuFlags & SWP_FRAMECHANGED_W)
    1605 //         WinSendMsg(hWindow, WM_UPDATEFRAME, (MPARAM)-1, 0);
     1609//      if (fuFlags & SWP_FRAMECHANGED_W)
     1610//         WinSendMsg(hWindow, WM_UPDATEFRAME, (MPARAM)-1, 0);
    16061611   }
    16071612
     
    16221627    return getParent()->getWindowHandle();
    16231628  }
    1624   else  return 0;
     1629  else  return 0;
    16251630}
    16261631//******************************************************************************
     
    16321637
    16331638   if(getParent()) {
    1634         oldhwnd = getParent()->getWindowHandle();
     1639        oldhwnd = getParent()->getWindowHandle();
    16351640   }
    16361641   else oldhwnd = 0;
     
    16381643   if(hwndNewParent == 0) {//desktop window = parent
    16391644    setParent(NULL);
    1640         OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
    1641         return oldhwnd;
     1645        OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
     1646        return oldhwnd;
    16421647   }
    16431648   newparent = GetWindowFromHandle(hwndNewParent);
    16441649   if(newparent)
    16451650   {
    1646         setParent(newparent);
    1647         OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
    1648         return oldhwnd;
     1651        setParent(newparent);
     1652        OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
     1653        return oldhwnd;
    16491654   }
    16501655   SetLastError(ERROR_INVALID_PARAMETER);
     
    16581663    return getParent()->getWindowHandle() == hwndParent;
    16591664  }
    1660   else  return 0;
     1665  else  return 0;
    16611666}
    16621667//******************************************************************************
     
    16771682    if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
    16781683    {//update region not empty
    1679         HDC hdc;
    1680 
    1681         hdc = O32_GetDC(OS2Hwnd);
    1682         if (isIcon)
    1683         {
    1684             SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
    1685             SendInternalMessageA(WM_PAINTICON, 0, 0);
    1686         } else
    1687         {
    1688             SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
    1689             SendInternalMessageA(WM_PAINT, 0, 0);
    1690         }
    1691         O32_ReleaseDC(OS2Hwnd, hdc);
     1684        HDC hdc;
     1685
     1686        hdc = O32_GetDC(OS2Hwnd);
     1687        if (isIcon)
     1688        {
     1689            SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
     1690            SendInternalMessageA(WM_PAINTICON, 0, 0);
     1691        } else
     1692        {
     1693            SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
     1694            SendInternalMessageA(WM_PAINT, 0, 0);
     1695        }
     1696        O32_ReleaseDC(OS2Hwnd, hdc);
    16921697    }
    16931698    return TRUE;
     
    17051710//******************************************************************************
    17061711HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
    1707                                BOOL fUnicode)
     1712                               BOOL fUnicode)
    17081713{
    17091714 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
     
    17141719       (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
    17151720    {
    1716         dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
    1717         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    1718         return 0;
     1721        dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
     1722        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     1723        return 0;
    17191724    }
    17201725    if(hwndParent != OSLIB_HWND_DESKTOP)
    17211726    {//if the current process owns the window, just do a quick search
    1722         child = (Win32BaseWindow *)parent->getFirstChild();
    1723         if(hwndChildAfter != 0)
    1724         {
    1725             while(child)
    1726             {
    1727                 if(child->getWindowHandle() == hwndChildAfter)
    1728                 {
    1729                     child = (Win32BaseWindow *)child->getNextChild();
    1730                     break;
    1731                 }
    1732                 child = (Win32BaseWindow *)child->getNextChild();
    1733             }
    1734         }
    1735         while(child)
    1736         {
    1737             if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
    1738                (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
    1739             {
    1740                 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
    1741                 return child->getWindowHandle();
    1742             }
    1743             child = (Win32BaseWindow *)child->getNextChild();
    1744         }
     1727        child = (Win32BaseWindow *)parent->getFirstChild();
     1728        if(hwndChildAfter != 0)
     1729        {
     1730            while(child)
     1731            {
     1732                if(child->getWindowHandle() == hwndChildAfter)
     1733                {
     1734                    child = (Win32BaseWindow *)child->getNextChild();
     1735                    break;
     1736                }
     1737                child = (Win32BaseWindow *)child->getNextChild();
     1738            }
     1739        }
     1740        while(child)
     1741        {
     1742            if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
     1743               (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
     1744            {
     1745                dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
     1746                return child->getWindowHandle();
     1747            }
     1748            child = (Win32BaseWindow *)child->getNextChild();
     1749        }
    17451750    }
    17461751    else {
    1747         Win32BaseWindow *wnd;
    1748         HWND henum, hwnd;
    1749 
    1750         henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
    1751         hwnd = OSLibWinGetNextWindow(henum);
    1752 
    1753         while(hwnd)
    1754         {
    1755             wnd = GetWindowFromOS2Handle(hwnd);
    1756             if(wnd == NULL) {
    1757                 hwnd = OSLibWinQueryClientWindow(hwnd);
    1758                 if(hwnd)  wnd = GetWindowFromOS2Handle(hwnd);
    1759             }
    1760 
    1761             if(wnd) {
    1762                 LPVOID sharedmembase = (LPVOID)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_SHAREDMEM);
    1763 
    1764                 if(OSLibDosGetSharedMem(sharedmembase, MAX_HEAPSIZE, OSLIB_PAG_READ) != 0) {
    1765                     dprintf(("OSLibDosGetSharedMem returned error for %x", wnd));
    1766                     break;
    1767                 }
    1768                 if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
    1769                    (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
    1770                 {
    1771                     OSLibWinEndEnumWindows(henum);
    1772                     dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
    1773                     return wnd->getWindowHandle();
    1774                 }
    1775             }
    1776             hwnd = OSLibWinGetNextWindow(henum);
    1777         }
    1778         OSLibWinEndEnumWindows(henum);
     1752        Win32BaseWindow *wnd;
     1753        HWND henum, hwnd;
     1754
     1755        henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
     1756        hwnd = OSLibWinGetNextWindow(henum);
     1757
     1758        while(hwnd)
     1759        {
     1760            wnd = GetWindowFromOS2Handle(hwnd);
     1761            if(wnd == NULL) {
     1762                hwnd = OSLibWinQueryClientWindow(hwnd);
     1763                if(hwnd)  wnd = GetWindowFromOS2Handle(hwnd);
     1764            }
     1765
     1766            if(wnd) {
     1767                LPVOID sharedmembase = (LPVOID)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_SHAREDMEM);
     1768
     1769                if(OSLibDosGetSharedMem(sharedmembase, MAX_HEAPSIZE, OSLIB_PAG_READ) != 0) {
     1770                    dprintf(("OSLibDosGetSharedMem returned error for %x", wnd));
     1771                    break;
     1772                }
     1773                if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
     1774                   (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
     1775                {
     1776                    OSLibWinEndEnumWindows(henum);
     1777                    dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
     1778                    return wnd->getWindowHandle();
     1779                }
     1780            }
     1781            hwnd = OSLibWinGetNextWindow(henum);
     1782        }
     1783        OSLibWinEndEnumWindows(henum);
    17791784    }
    17801785    SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
     
    17871792{
    17881793 Win32BaseWindow  *win32wnd;
    1789  ULONG         magic;
    1790  ULONG         getcmd = 0;
    1791  HWND          hwndRelated;
     1794 ULONG         magic;
     1795 ULONG         getcmd = 0;
     1796 HWND          hwndRelated;
    17921797
    17931798    dprintf(("GetWindow %x %d NOT COMPLETE", getWindowHandle(), uCmd));
    17941799    switch(uCmd)
    17951800    {
    1796         case GW_CHILD:
    1797             getcmd = QWOS_TOP;
    1798             break;
    1799         case GW_HWNDFIRST:
    1800             if(getParent()) {
    1801                     getcmd = QWOS_TOP; //top of child windows
    1802             }
    1803             else    getcmd = QWOS_TOP; //TODO
    1804             break;
    1805         case GW_HWNDLAST:
    1806             if(getParent()) {
    1807                     getcmd = QWOS_BOTTOM; //bottom of child windows
    1808             }
    1809             else    getcmd = QWOS_BOTTOM; //TODO
    1810             break;
    1811         case GW_HWNDNEXT:
    1812             getcmd = QWOS_NEXT;
    1813             break;
    1814         case GW_HWNDPREV:
    1815             getcmd = QWOS_PREV;
    1816             break;
    1817         case GW_OWNER:
    1818             if(owner) {
    1819                     return owner->getWindowHandle();
    1820             }
    1821             else    return 0;
     1801        case GW_CHILD:
     1802            getcmd = QWOS_TOP;
     1803            break;
     1804        case GW_HWNDFIRST:
     1805            if(getParent()) {
     1806                    getcmd = QWOS_TOP; //top of child windows
     1807            }
     1808            else    getcmd = QWOS_TOP; //TODO
     1809            break;
     1810        case GW_HWNDLAST:
     1811            if(getParent()) {
     1812                    getcmd = QWOS_BOTTOM; //bottom of child windows
     1813            }
     1814            else    getcmd = QWOS_BOTTOM; //TODO
     1815            break;
     1816        case GW_HWNDNEXT:
     1817            getcmd = QWOS_NEXT;
     1818            break;
     1819        case GW_HWNDPREV:
     1820            getcmd = QWOS_PREV;
     1821            break;
     1822        case GW_OWNER:
     1823            if(owner) {
     1824                    return owner->getWindowHandle();
     1825            }
     1826            else    return 0;
    18221827    }
    18231828    hwndRelated = OSLibWinQueryWindow(OS2Hwnd, getcmd);
    18241829    if(hwndRelated)
    18251830    {
    1826         win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR);
    1827         magic    = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC);
    1828         if(CheckMagicDword(magic) && win32wnd)
    1829         {
    1830             return win32wnd->getWindowHandle();
    1831         }
     1831        win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR);
     1832        magic    = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC);
     1833        if(CheckMagicDword(magic) && win32wnd)
     1834        {
     1835            return win32wnd->getWindowHandle();
     1836        }
    18321837    }
    18331838    return 0;
     
    18561861HWND Win32BaseWindow::GetActiveWindow()
    18571862{
    1858  HWND          hwndActive;
     1863 HWND          hwndActive;
    18591864 Win32BaseWindow  *win32wnd;
    1860  ULONG         magic;
     1865 ULONG         magic;
    18611866
    18621867  hwndActive = OSLibWinQueryActiveWindow();
     
    18661871  if(CheckMagicDword(magic) && win32wnd)
    18671872  {
    1868         return win32wnd->getWindowHandle();
     1873        return win32wnd->getWindowHandle();
    18691874  }
    18701875  return hwndActive;
     
    18991904{
    19001905    if(fUnicode) {
    1901             return (lstrcmpW(windowNameW, (LPWSTR)wndname) == 0);
     1906            return (lstrcmpW(windowNameW, (LPWSTR)wndname) == 0);
    19021907    }
    19031908    else    return (strcmp(windowNameA, wndname) == 0);
     
    19201925{
    19211926    if(lpsz == NULL)
    1922         return FALSE;
     1927        return FALSE;
    19231928
    19241929    if(isUnicode == FALSE) {
    1925         windowNameA = (LPSTR)_smalloc(strlen(lpsz)+1);
    1926         strcpy(windowNameA, lpsz);
    1927         windowNameW = (LPWSTR)_smalloc((strlen(lpsz)+1)*sizeof(WCHAR));
    1928         lstrcpyAtoW(windowNameW, windowNameA);
     1930        windowNameA = (LPSTR)_smalloc(strlen(lpsz)+1);
     1931        strcpy(windowNameA, lpsz);
     1932        windowNameW = (LPWSTR)_smalloc((strlen(lpsz)+1)*sizeof(WCHAR));
     1933        lstrcpyAtoW(windowNameW, windowNameA);
    19291934    }
    19301935    else {
    1931         windowNameW = (LPWSTR)_smalloc((lstrlenW((LPWSTR)lpsz)+1)*sizeof(WCHAR));
    1932         lstrcpyW(windowNameW, (LPWSTR)lpsz);
    1933         windowNameA = (LPSTR)_smalloc(lstrlenW((LPWSTR)lpsz)+1);
    1934         lstrcpyWtoA(windowNameA, windowNameW);
     1936        windowNameW = (LPWSTR)_smalloc((lstrlenW((LPWSTR)lpsz)+1)*sizeof(WCHAR));
     1937        lstrcpyW(windowNameW, (LPWSTR)lpsz);
     1938        windowNameA = (LPSTR)_smalloc(lstrlenW((LPWSTR)lpsz)+1);
     1939        lstrcpyWtoA(windowNameA, windowNameW);
    19351940    }
    19361941    wndNameLength = strlen(windowNameA)+1; //including 0 terminator
    19371942
    19381943    if(OS2Hwnd)
    1939         return OSLibWinSetWindowText(OS2Hwnd, (LPSTR)windowNameA);
     1944        return OSLibWinSetWindowText(OS2Hwnd, (LPSTR)windowNameA);
    19401945
    19411946    return TRUE;
     
    19481953
    19491954   switch(index) {
    1950         case GWL_EXSTYLE:
    1951                 oldval = dwExStyle;
    1952                 setExStyle(value);
    1953                 return oldval;
    1954         case GWL_STYLE:
    1955                 oldval = dwStyle;
    1956                 setStyle(value);
    1957                 return oldval;
    1958         case GWL_WNDPROC:
    1959                 oldval = (LONG)getWindowProc();
    1960                 setWindowProc((WNDPROC)value);
    1961                 return oldval;
    1962         case GWL_HINSTANCE:
    1963                 oldval = hInstance;
    1964                 hInstance = value;
    1965                 return oldval;
    1966         case GWL_HWNDPARENT:
    1967                 return SetParent((HWND)value);
    1968 
    1969         case GWL_ID:
    1970                 oldval = getWindowId();
    1971                 setWindowId(value);
    1972                 return oldval;
    1973         case GWL_USERDATA:
    1974                 oldval = userData;
    1975                 userData = value;
    1976                 return oldval;
    1977         default:
    1978                 if(index >= 0 && index/4 < nrUserWindowLong)
    1979                 {
    1980                         oldval = userWindowLong[index/4];
    1981                         userWindowLong[index/4] = value;
    1982                         return oldval;
    1983                 }
    1984                 SetLastError(ERROR_INVALID_PARAMETER);
    1985                 return 0;
     1955        case GWL_EXSTYLE:
     1956                oldval = dwExStyle;
     1957                setExStyle(value);
     1958                return oldval;
     1959        case GWL_STYLE:
     1960                oldval = dwStyle;
     1961                setStyle(value);
     1962                return oldval;
     1963        case GWL_WNDPROC:
     1964                oldval = (LONG)getWindowProc();
     1965                setWindowProc((WNDPROC)value);
     1966                return oldval;
     1967        case GWL_HINSTANCE:
     1968                oldval = hInstance;
     1969                hInstance = value;
     1970                return oldval;
     1971        case GWL_HWNDPARENT:
     1972                return SetParent((HWND)value);
     1973
     1974        case GWL_ID:
     1975                oldval = getWindowId();
     1976                setWindowId(value);
     1977                return oldval;
     1978        case GWL_USERDATA:
     1979                oldval = userData;
     1980                userData = value;
     1981                return oldval;
     1982        default:
     1983                if(index >= 0 && index/4 < nrUserWindowLong)
     1984                {
     1985                        oldval = userWindowLong[index/4];
     1986                        userWindowLong[index/4] = value;
     1987                        return oldval;
     1988                }
     1989                SetLastError(ERROR_INVALID_PARAMETER);
     1990                return 0;
    19861991   }
    19871992}
     
    19911996{
    19921997   switch(index) {
    1993         case GWL_EXSTYLE:
    1994                 return dwExStyle;
    1995         case GWL_STYLE:
    1996                 return dwStyle;
    1997         case GWL_WNDPROC:
    1998                 return (ULONG)getWindowProc();
    1999         case GWL_HINSTANCE:
    2000                 return hInstance;
    2001         case GWL_HWNDPARENT:
    2002                 if(getParent()) {
    2003                         return getParent()->getWindowHandle();
    2004                 }
    2005                 else    return 0;
    2006         case GWL_ID:
    2007                 return getWindowId();
    2008         case GWL_USERDATA:
    2009                 return userData;
    2010         default:
    2011                 if(index >= 0 && index/4 < nrUserWindowLong)
    2012                 {
    2013                         return userWindowLong[index/4];
    2014                 }
    2015                 SetLastError(ERROR_INVALID_PARAMETER);
    2016                 return 0;
     1998        case GWL_EXSTYLE:
     1999                return dwExStyle;
     2000        case GWL_STYLE:
     2001                return dwStyle;
     2002        case GWL_WNDPROC:
     2003                return (ULONG)getWindowProc();
     2004        case GWL_HINSTANCE:
     2005                return hInstance;
     2006        case GWL_HWNDPARENT:
     2007                if(getParent()) {
     2008                        return getParent()->getWindowHandle();
     2009                }
     2010                else    return 0;
     2011        case GWL_ID:
     2012                return getWindowId();
     2013        case GWL_USERDATA:
     2014                return userData;
     2015        default:
     2016                if(index >= 0 && index/4 < nrUserWindowLong)
     2017                {
     2018                        return userWindowLong[index/4];
     2019                }
     2020                SetLastError(ERROR_INVALID_PARAMETER);
     2021                return 0;
    20172022   }
    20182023}
     
    20252030   if(index >= 0 && index/4 < nrUserWindowLong)
    20262031   {
    2027         oldval = ((WORD *)userWindowLong)[index/2];
    2028         ((WORD *)userWindowLong)[index/2] = value;
    2029         return oldval;
     2032        oldval = ((WORD *)userWindowLong)[index/2];
     2033        ((WORD *)userWindowLong)[index/2] = value;
     2034        return oldval;
    20302035   }
    20312036   SetLastError(ERROR_INVALID_PARAMETER);
     
    20382043   if(index >= 0 && index/4 < nrUserWindowLong)
    20392044   {
    2040         return ((WORD *)userWindowLong)[index/2];
     2045        return ((WORD *)userWindowLong)[index/2];
    20412046   }
    20422047   SetLastError(ERROR_INVALID_PARAMETER);
     
    20502055
    20512056   if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
    2052         return window;
     2057        return window;
    20532058   }
    20542059   else return NULL;
     
    20592064{
    20602065 Win32BaseWindow *win32wnd;
    2061  DWORD        magic;
     2066 DWORD        magic;
    20622067
    20632068  win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
     
    20652070
    20662071  if(win32wnd && CheckMagicDword(magic)) {
    2067         return win32wnd;
     2072        return win32wnd;
    20682073  }
    20692074  return 0;
Note: See TracChangeset for help on using the changeset viewer.