Ignore:
Timestamp:
Aug 30, 1999, 6:38:59 PM (26 years ago)
Author:
dengert
Message:

optimized background erasing

File:
1 edited

Legend:

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

    r741 r745  
    1 /* $Id: win32wbase.cpp,v 1.1 1999-08-30 12:00:12 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.2 1999-08-30 16:38:59 dengert Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    6060//******************************************************************************
    6161Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
    62                         : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
     62                        : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
    6363{
    6464  Init();
     
    7070void Win32BaseWindow::Init()
    7171{
    72   isUnicode        = FALSE;
    73   fCreated         = FALSE;
    74   fFirstShow       = TRUE;
    75 
    76   windowNameA      = NULL;
    77   windowNameW      = NULL;
     72  isUnicode        = FALSE;
     73  fCreated         = FALSE;
     74  fFirstShow       = TRUE;
     75
     76  windowNameA      = NULL;
     77  windowNameW      = NULL;
    7878  wndNameLength    = 0;
    7979
     
    8181  nrUserWindowLong = 0;
    8282
    83   magic            = WIN32PM_MAGIC;
    84   OS2Hwnd          = 0;
    85   OS2HwndFrame     = 0;
    86   OS2HwndMenu      = 0;
    87   Win32Hwnd        = 0;
     83  magic            = WIN32PM_MAGIC;
     84  OS2Hwnd          = 0;
     85  OS2HwndFrame     = 0;
     86  OS2HwndMenu      = 0;
     87  Win32Hwnd        = 0;
    8888
    8989  if(HwAllocateWindowHandle(&Win32Hwnd, (ULONG)this) == FALSE)
    9090  {
    91         dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
    92         DebugInt3();
    93   }
    94 
    95   posx = posy      = 0;
     91        dprintf(("Win32BaseWindow::Init HwAllocateWindowHandle failed!!"));
     92        DebugInt3();
     93  }
     94
     95  posx = posy      = 0;
    9696  width = height   = 0;
    9797
    98   dwExStyle        = 0;
    99   dwStyle          = 0;
    100   win32wndproc     = 0;
    101   hInstance        = 0;
    102   windowId         = 0xFFFFFFFF;        //default = -1
    103   userData         = 0;
     98  dwExStyle        = 0;
     99  dwStyle          = 0;
     100  win32wndproc     = 0;
     101  hInstance        = 0;
     102  windowId         = 0xFFFFFFFF;        //default = -1
     103  userData         = 0;
    104104
    105105  hwndLinkAfter    = HWND_BOTTOM;
    106   flags            = 0;
    107   isIcon           = FALSE;
     106  flags            = 0;
     107  isIcon           = FALSE;
    108108  lastHitTestVal   = 0;
    109   owner            = NULL;
    110   windowClass      = 0;
     109  owner            = NULL;
     110  windowClass      = 0;
    111111
    112112  acceltableResource = NULL;
    113   menuResource       = NULL;
    114   iconResource       = NULL;
     113  menuResource       = NULL;
     114  iconResource       = NULL;
    115115}
    116116//******************************************************************************
     
    123123
    124124  if(Win32Hwnd)
    125         HwFreeWindowHandle(Win32Hwnd);
     125        HwFreeWindowHandle(Win32Hwnd);
    126126
    127127  if(userWindowLong)
    128         free(userWindowLong);
     128        free(userWindowLong);
    129129  if(windowNameA) {
    130         free(windowNameA);
    131         windowNameA = NULL;
     130        free(windowNameA);
     131        windowNameA = NULL;
    132132  }
    133133  if(windowNameW) {
    134         free(windowNameW);
    135         windowNameW = NULL;
     134        free(windowNameW);
     135        windowNameW = NULL;
    136136  }
    137137}
     
    155155    if (cs->hwndParent)
    156156    {
    157             Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
    158             if(!window) {
    159                     dprintf(("Bad parent %04x\n", cs->hwndParent ));
    160                     SetLastError(ERROR_INVALID_PARAMETER);
    161                     return FALSE;
    162             }
    163             /* Make sure parent is valid */
    164             if (!window->IsWindow() )
    165             {
    166                     dprintf(("Bad parent %04x\n", cs->hwndParent ));
    167                     SetLastError(ERROR_INVALID_PARAMETER);
    168                     return FALSE;
    169             }
     157            Win32BaseWindow *window = GetWindowFromHandle(cs->hwndParent);
     158            if(!window) {
     159                    dprintf(("Bad parent %04x\n", cs->hwndParent ));
     160                    SetLastError(ERROR_INVALID_PARAMETER);
     161                    return FALSE;
     162            }
     163            /* Make sure parent is valid */
     164            if (!window->IsWindow() )
     165            {
     166                    dprintf(("Bad parent %04x\n", cs->hwndParent ));
     167                    SetLastError(ERROR_INVALID_PARAMETER);
     168                    return FALSE;
     169            }
    170170    }
    171171    else
    172172    if ((cs->style & WS_CHILD) && !(cs->style & WS_POPUP)) {
    173             dprintf(("No parent for child window\n" ));
    174             SetLastError(ERROR_INVALID_PARAMETER);
    175             return FALSE;  /* WS_CHILD needs a parent, but WS_POPUP doesn't */
     173            dprintf(("No parent for child window\n" ));
     174            SetLastError(ERROR_INVALID_PARAMETER);
     175            return FALSE;  /* WS_CHILD needs a parent, but WS_POPUP doesn't */
    176176    }
    177177
     
    180180  if (!windowClass)
    181181  {
    182         GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
    183         dprintf(("Bad class '%s'\n", buffer ));
    184         return 0;
     182        GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
     183        dprintf(("Bad class '%s'\n", buffer ));
     184        return 0;
    185185  }
    186186
     
    190190   */
    191191  if (!HIWORD(cs->lpszClass) ) {
    192         if (isUnicode) {
    193                 GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
    194         }
    195         else {
    196                 GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
    197         }
    198         cs->lpszClass = buffer;
     192        if (isUnicode) {
     193                GlobalGetAtomNameW( classAtom, (LPWSTR)buffer, sizeof(buffer) );
     194        }
     195        else {
     196                GlobalGetAtomNameA( classAtom, buffer, sizeof(buffer) );
     197        }
     198        cs->lpszClass = buffer;
    199199  }
    200200
     
    202202  if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16)
    203203  {
    204 //        PDB *pdb = PROCESS_Current();
     204//        PDB *pdb = PROCESS_Current();
    205205
    206206       /* Never believe Microsoft's documentation... CreateWindowEx doc says
    207         * that if an overlapped window is created with WS_VISIBLE style bit
    208         * set and the x parameter is set to CW_USEDEFAULT, the system ignores
    209         * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
    210         * reveals that
    211         *
    212         * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
    213         * 2) it does not ignore the y parameter as the docs claim; instead, it
    214         *    uses it as second parameter to ShowWindow() unless y is either
    215         *    CW_USEDEFAULT or CW_USEDEFAULT16.
    216         *
    217         * The fact that we didn't do 2) caused bogus windows pop up when wine
    218         * was running apps that were using this obscure feature. Example -
    219         * calc.exe that comes with Win98 (only Win98, it's different from
    220         * the one that comes with Win95 and NT)
    221         */
    222         if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y;
    223 
    224         /* We have saved cs->y, now we can trash it */
     207        * that if an overlapped window is created with WS_VISIBLE style bit
     208        * set and the x parameter is set to CW_USEDEFAULT, the system ignores
     209        * the y parameter. However, disassembling NT implementation (WIN32K.SYS)
     210        * reveals that
     211        *
     212        * 1) not only if checks for CW_USEDEFAULT but also for CW_USEDEFAULT16
     213        * 2) it does not ignore the y parameter as the docs claim; instead, it
     214        *    uses it as second parameter to ShowWindow() unless y is either
     215        *    CW_USEDEFAULT or CW_USEDEFAULT16.
     216        *
     217        * The fact that we didn't do 2) caused bogus windows pop up when wine
     218        * was running apps that were using this obscure feature. Example -
     219        * calc.exe that comes with Win98 (only Win98, it's different from
     220        * the one that comes with Win95 and NT)
     221        */
     222        if (cs->y != CW_USEDEFAULT && cs->y != CW_USEDEFAULT16) sw = cs->y;
     223
     224        /* We have saved cs->y, now we can trash it */
    225225#if 0
    226         if (   !(cs->style & (WS_CHILD | WS_POPUP))
    227             &&  (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
    228         {
    229             cs->x = pdb->env_db->startup_info->dwX;
    230             cs->y = pdb->env_db->startup_info->dwY;
    231         }
     226        if (   !(cs->style & (WS_CHILD | WS_POPUP))
     227            &&  (pdb->env_db->startup_info->dwFlags & STARTF_USEPOSITION) )
     228        {
     229            cs->x = pdb->env_db->startup_info->dwX;
     230            cs->y = pdb->env_db->startup_info->dwY;
     231        }
    232232#endif
    233             cs->x = 0;
    234             cs->y = 0;
    235 //        }
     233            cs->x = 0;
     234            cs->y = 0;
     235//        }
    236236  }
    237237  if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16)
    238238  {
    239239#if 0
    240         PDB *pdb = PROCESS_Current();
    241         if (   !(cs->style & (WS_CHILD | WS_POPUP))
    242             &&  (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
    243         {
    244             cs->cx = pdb->env_db->startup_info->dwXSize;
    245             cs->cy = pdb->env_db->startup_info->dwYSize;
    246         }
    247         else
    248         {
     240        PDB *pdb = PROCESS_Current();
     241        if (   !(cs->style & (WS_CHILD | WS_POPUP))
     242            &&  (pdb->env_db->startup_info->dwFlags & STARTF_USESIZE) )
     243        {
     244            cs->cx = pdb->env_db->startup_info->dwXSize;
     245            cs->cy = pdb->env_db->startup_info->dwYSize;
     246        }
     247        else
     248        {
    249249#endif
    250             cs->cx = 600; /* FIXME */
    251             cs->cy = 400;
    252 //        }
     250            cs->cx = 600; /* FIXME */
     251            cs->cy = 400;
     252//        }
    253253  }
    254254
     
    259259  nrUserWindowLong = windowClass->getExtraWndWords();
    260260  if(nrUserWindowLong) {
    261         userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
    262         memset(userWindowLong, 0, nrUserWindowLong);
     261        userWindowLong = (ULONG *)_smalloc(nrUserWindowLong);
     262        memset(userWindowLong, 0, nrUserWindowLong);
    263263  }
    264264
    265265  if ((cs->style & WS_CHILD) && cs->hwndParent)
    266266  {
    267         SetParent(cs->hwndParent);
    268         owner = GetWindowFromHandle(cs->hwndParent);
    269         if(owner == NULL)
    270         {
    271             dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
    272             return FALSE;
    273         }
     267        SetParent(cs->hwndParent);
     268        owner = GetWindowFromHandle(cs->hwndParent);
     269        if(owner == NULL)
     270        {
     271            dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
     272            return FALSE;
     273        }
    274274  }
    275275  else
    276276  {
    277         if (!cs->hwndParent) {
    278             owner = NULL;
    279         }
    280         else
    281         {
    282             owner = GetWindowFromHandle(cs->hwndParent);
    283             if(owner == NULL)
    284             {
    285                 dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
    286                 return FALSE;
    287             }
    288         }
     277        if (!cs->hwndParent) {
     278            owner = NULL;
     279        }
     280        else
     281        {
     282            owner = GetWindowFromHandle(cs->hwndParent);
     283            if(owner == NULL)
     284            {
     285                dprintf(("HwGetWindowHandleData couldn't find owner window %x!!!", cs->hwndParent));
     286                return FALSE;
     287            }
     288        }
    289289  }
    290290
     
    295295
    296296  hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
    297                   ? HWND_BOTTOM : HWND_TOP;
     297                  ? HWND_BOTTOM : HWND_TOP;
    298298
    299299#if 0
     
    304304    {
    305305    CBT_CREATEWNDA cbtc;
    306         LRESULT ret;
     306        LRESULT ret;
    307307
    308308    cbtc.lpcs = cs;
    309309    cbtc.hwndInsertAfter = hwndLinkAfter;
    310         ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc)
    311                       : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc);
    312         if (ret)
     310        ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc)
     311                      : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc);
     312        if (ret)
    313313    {
    314         TRACE_(win)("CBT-hook returned 0\n");
    315         wndPtr->pDriver->pFinalize(wndPtr);
    316             retvalue =  0;
    317             goto end;
     314        TRACE_(win)("CBT-hook returned 0\n");
     315        wndPtr->pDriver->pFinalize(wndPtr);
     316            retvalue =  0;
     317            goto end;
    318318    }
    319319    }
     
    326326  if (!(cs->style & WS_CHILD))
    327327  {
    328         dwStyle |= WS_CLIPSIBLINGS;
    329         if (!(cs->style & WS_POPUP))
    330         {
    331             dwStyle |= WS_CAPTION;
    332             flags |= WIN_NEED_SIZE;
    333         }
     328        dwStyle |= WS_CLIPSIBLINGS;
     329        if (!(cs->style & WS_POPUP))
     330        {
     331            dwStyle |= WS_CAPTION;
     332            flags |= WIN_NEED_SIZE;
     333        }
    334334  }
    335335  if (cs->dwExStyle & WS_EX_DLGMODALFRAME) dwStyle &= ~WS_THICKFRAME;
     
    346346  if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
    347347  {
    348         GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
    349         if (maxSize.x < cs->cx) cs->cx = maxSize.x;
    350         if (maxSize.y < cs->cy) cs->cy = maxSize.y;
    351         if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
    352         if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
     348        GetMinMaxInfo(&maxSize, &maxPos, &minTrack, &maxTrack);
     349        if (maxSize.x < cs->cx) cs->cx = maxSize.x;
     350        if (maxSize.y < cs->cy) cs->cy = maxSize.y;
     351        if (cs->cx < minTrack.x ) cs->cx = minTrack.x;
     352        if (cs->cy < minTrack.y ) cs->cy = minTrack.y;
    353353  }
    354354
    355355  if(cs->style & WS_CHILD)
    356356  {
    357         if(cs->cx < 0) cs->cx = 0;
    358         if(cs->cy < 0) cs->cy = 0;
     357        if(cs->cx < 0) cs->cx = 0;
     358        if(cs->cy < 0) cs->cy = 0;
    359359  }
    360360  else
    361361  {
    362         if (cs->cx <= 0) cs->cx = 1;
    363         if (cs->cy <= 0) cs->cy = 1;
     362        if (cs->cx <= 0) cs->cx = 1;
     363        if (cs->cy <= 0) cs->cy = 1;
    364364  }
    365365
     
    368368  rectWindow.right  = cs->x + cs->cx;
    369369  rectWindow.bottom = cs->y + cs->cy;
    370   rectClient        = rectWindow;
     370  rectClient        = rectWindow;
    371371
    372372  DWORD dwOSWinStyle, dwOSFrameStyle;
     
    377377#if 1
    378378  if(cs->style & WS_CHILD) {
    379         dwOSFrameStyle = 0;
     379        dwOSFrameStyle = 0;
    380380  }
    381381#endif
    382382
    383383  if(cs->lpszName)
    384         SetWindowText((LPSTR)cs->lpszName);
     384        SetWindowText((LPSTR)cs->lpszName);
    385385
    386386  OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
    387                                 dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA,
    388                                 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
    389                                 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
    390                                 &OS2HwndFrame);
     387                                dwOSWinStyle, dwOSFrameStyle, (char *)windowNameA,
     388                                (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
     389                                (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
     390                                &OS2HwndFrame);
    391391
    392392  if(OS2Hwnd == 0) {
    393         dprintf(("Window creation failed!!"));
    394         return FALSE;
     393        dprintf(("Window creation failed!!"));
     394        return FALSE;
    395395  }
    396396
    397397  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
    398         dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
    399         return FALSE;
     398        dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
     399        return FALSE;
    400400  }
    401401  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
    402         dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
    403         return FALSE;
     402        dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
     403        return FALSE;
    404404  }
    405405  //SvL: Need to store the shared memory base, or else other apps can map it into their memory space
    406406  if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_SHAREDMEM, HeapGetSharedMemBase()) == FALSE) {
    407         dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
    408         return FALSE;
     407        dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2Hwnd));
     408        return FALSE;
    409409  }
    410410#if 0
    411411  if(OS2Hwnd != OS2HwndFrame) {
    412412    if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
    413             dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame));
    414             return FALSE;
     413            dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame));
     414            return FALSE;
    415415    }
    416416    if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) {
    417             dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
    418             return FALSE;
     417            dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
     418            return FALSE;
    419419    }
    420420    //SvL: Need to store the shared memory base, or else other apps can map it into their memory space
    421421    if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_SHAREDMEM, HeapGetSharedMemBase()) == FALSE) {
    422             dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
    423             return FALSE;
     422            dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame));
     423            return FALSE;
    424424    }
    425425  }
     
    429429  if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION )
    430430  {
    431         if (cs->hMenu) SetMenu(cs->hMenu);
    432         else
    433         {
    434                 if (windowClass->getMenuNameA()) {
    435                         cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
    436                         if (cs->hMenu) SetMenu(cs->hMenu );
    437                 }
    438         }
    439   }
    440   else  windowId = (UINT)cs->hMenu;
     431        if (cs->hMenu) SetMenu(cs->hMenu);
     432        else
     433        {
     434                if (windowClass->getMenuNameA()) {
     435                        cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA());
     436                        if (cs->hMenu) SetMenu(cs->hMenu );
     437                }
     438        }
     439  }
     440  else  windowId = (UINT)cs->hMenu;
    441441
    442442  //Set icon from class
    443443  if(windowClass->getIcon())
    444         SetIcon(windowClass->getIcon());
     444        SetIcon(windowClass->getIcon());
    445445
    446446  if(getParent()) {
    447         SetWindowPos(getParent()->getWindowHandle(), rectClient.left, rectClient.top,
    448                      rectClient.right-rectClient.left,
    449                      rectClient.bottom-rectClient.top,
    450                      SWP_NOACTIVATE | SWP_NOZORDER);
     447        SetWindowPos(getParent()->getWindowHandle(), rectClient.left, rectClient.top,
     448                     rectClient.right-rectClient.left,
     449                     rectClient.bottom-rectClient.top,
     450                     SWP_NOACTIVATE | SWP_NOZORDER);
    451451  }
    452452  else {
    453         SetWindowPos(HWND_TOP, rectClient.left, rectClient.top,
    454                      rectClient.right-rectClient.left,
    455                      rectClient.bottom-rectClient.top,
    456                      SWP_NOACTIVATE);
     453        SetWindowPos(HWND_TOP, rectClient.left, rectClient.top,
     454                     rectClient.right-rectClient.left,
     455                     rectClient.bottom-rectClient.top,
     456                     SWP_NOACTIVATE);
    457457  }
    458458  //Get the client window rectangle
     
    468468  if(SendInternalMessage(WM_NCCREATE, 0, (LPARAM)cs) )
    469469  {
    470         //doesn't work right, messes up client rectangle
     470        //doesn't work right, messes up client rectangle
    471471#if 0
    472         SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
     472        SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient );
    473473#endif
    474         OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
    475         dprintf(("Sending WM_CREATE"));
    476         if( (SendInternalMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 )
    477         {
    478             if(!(flags & WIN_NEED_SIZE)) {
    479                 SendMessageA(WM_SIZE, SIZE_RESTORED,
    480                                 MAKELONG(rectClient.right-rectClient.left,
    481                                         rectClient.bottom-rectClient.top));
    482                 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
    483             }
    484             if (cs->style & WS_VISIBLE) ShowWindow( sw );
     474        OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
     475        dprintf(("Sending WM_CREATE"));
     476        if( (SendInternalMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 )
     477        {
     478            if(!(flags & WIN_NEED_SIZE)) {
     479                SendMessageA(WM_SIZE, SIZE_RESTORED,
     480                                MAKELONG(rectClient.right-rectClient.left,
     481                                        rectClient.bottom-rectClient.top));
     482                SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
     483            }
     484            if (cs->style & WS_VISIBLE) ShowWindow( sw );
    485485
    486486#if 0
    487             /* Call WH_SHELL hook */
    488 
    489             if (!(dwStyle & WS_CHILD) && !owner)
    490                 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
     487            /* Call WH_SHELL hook */
     488
     489            if (!(dwStyle & WS_CHILD) && !owner)
     490                HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 );
    491491#endif
    492             SetLastError(0);
    493             return TRUE;
    494         }
     492            SetLastError(0);
     493            return TRUE;
     494        }
    495495  }
    496496  fCreated = FALSE;
     
    502502#if 0
    503503/***********************************************************************
    504  *           WINPOS_MinMaximize
     504 *           WINPOS_MinMaximize
    505505 *
    506506 * Fill in lpRect and return additional flags to be used with SetWindowPos().
     
    521521    if( dwStyle & WS_MINIMIZE )
    522522    {
    523         if( !SendInternalMessageA(WM_QUERYOPEN, 0, 0L ) )
    524         return (SWP_NOSIZE | SWP_NOMOVE);
    525         swpFlags |= SWP_NOCOPYBITS;
     523        if( !SendInternalMessageA(WM_QUERYOPEN, 0, 0L ) )
     524        return (SWP_NOSIZE | SWP_NOMOVE);
     525        swpFlags |= SWP_NOCOPYBITS;
    526526    }
    527527    switch( cmd )
    528528    {
    529         case SW_MINIMIZE:
    530         if( dwStyle & WS_MAXIMIZE)
    531         {
    532              flags |= WIN_RESTORE_MAX;
    533              dwStyle &= ~WS_MAXIMIZE;
    534                 }
    535                 else
    536              flags &= ~WIN_RESTORE_MAX;
    537              dwStyle |= WS_MINIMIZE;
     529        case SW_MINIMIZE:
     530        if( dwStyle & WS_MAXIMIZE)
     531        {
     532             flags |= WIN_RESTORE_MAX;
     533             dwStyle &= ~WS_MAXIMIZE;
     534                }
     535                else
     536             flags &= ~WIN_RESTORE_MAX;
     537             dwStyle |= WS_MINIMIZE;
    538538
    539539#if 0
    540         if( flags & WIN_NATIVE )
    541              if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) )
    542              swpFlags |= MINMAX_NOSWP;
     540        if( flags & WIN_NATIVE )
     541             if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) )
     542             swpFlags |= MINMAX_NOSWP;
    543543#endif
    544544
    545         lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
    546 
    547         SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
    548              GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
    549         swpFlags |= SWP_NOCOPYBITS;
    550         break;
    551 
    552         case SW_MAXIMIZE:
    553                 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
    554 
    555         if( dwStyle & WS_MINIMIZE )
    556         {
    557              if( flags & WIN_NATIVE )
    558              if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
    559                 swpFlags |= MINMAX_NOSWP;
    560 
    561              WINPOS_ShowIconTitle( wndPtr, FALSE );
    562              dwStyle &= ~WS_MINIMIZE;
    563         }
    564                 dwStyle |= WS_MAXIMIZE;
    565 
    566         SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
    567                     size.x, size.y );
    568         break;
    569 
    570         case SW_RESTORE:
    571         if( dwStyle & WS_MINIMIZE )
    572         {
    573              if( flags & WIN_NATIVE )
    574              if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
    575                 swpFlags |= MINMAX_NOSWP;
    576 
    577              dwStyle &= ~WS_MINIMIZE;
    578              WINPOS_ShowIconTitle( wndPtr, FALSE );
    579 
    580              if( flags & WIN_RESTORE_MAX)
    581              {
    582              /* Restore to maximized position */
    583                         CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
    584                         WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
    585                         CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
    586              dwStyle |= WS_MAXIMIZE;
    587              SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
    588              break;
    589              }
    590         }
    591         else
    592              if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
    593              else dwStyle &= ~WS_MAXIMIZE;
    594 
    595         /* Restore to normal position */
    596 
    597         *lpRect = lpPos->rectNormal;
    598         lpRect->right -= lpRect->left;
    599         lpRect->bottom -= lpRect->top;
    600 
    601         break;
     545        lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos );
     546
     547        SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y,
     548             GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
     549        swpFlags |= SWP_NOCOPYBITS;
     550        break;
     551
     552        case SW_MAXIMIZE:
     553                WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL );
     554
     555        if( dwStyle & WS_MINIMIZE )
     556        {
     557             if( flags & WIN_NATIVE )
     558             if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
     559                swpFlags |= MINMAX_NOSWP;
     560
     561             WINPOS_ShowIconTitle( wndPtr, FALSE );
     562             dwStyle &= ~WS_MINIMIZE;
     563        }
     564                dwStyle |= WS_MAXIMIZE;
     565
     566        SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y,
     567                    size.x, size.y );
     568        break;
     569
     570        case SW_RESTORE:
     571        if( dwStyle & WS_MINIMIZE )
     572        {
     573             if( flags & WIN_NATIVE )
     574             if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) )
     575                swpFlags |= MINMAX_NOSWP;
     576
     577             dwStyle &= ~WS_MINIMIZE;
     578             WINPOS_ShowIconTitle( wndPtr, FALSE );
     579
     580             if( flags & WIN_RESTORE_MAX)
     581             {
     582             /* Restore to maximized position */
     583                        CONV_POINT16TO32( &lpPos->ptMaxPos, &pt );
     584                        WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL);
     585                        CONV_POINT32TO16( &pt, &lpPos->ptMaxPos );
     586             dwStyle |= WS_MAXIMIZE;
     587             SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y );
     588             break;
     589             }
     590        }
     591        else
     592             if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1);
     593             else dwStyle &= ~WS_MAXIMIZE;
     594
     595        /* Restore to normal position */
     596
     597        *lpRect = lpPos->rectNormal;
     598        lpRect->right -= lpRect->left;
     599        lpRect->bottom -= lpRect->top;
     600
     601        break;
    602602    }
    603603    } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
     
    606606#endif
    607607/*******************************************************************
    608  *           GetMinMaxInfo
     608 *           GetMinMaxInfo
    609609 *
    610610 * Get the minimized and maximized information for a window.
    611611 */
    612612void Win32BaseWindow::GetMinMaxInfo(POINT *maxSize, POINT *maxPos,
    613                                 POINT *minTrack, POINT *maxTrack )
     613                                POINT *minTrack, POINT *maxTrack )
    614614{
    615615    MINMAXINFO MinMax;
     
    628628    else if (HAS_DLGFRAME( dwStyle, dwExStyle ))
    629629    {
    630         xinc = GetSystemMetrics(SM_CXDLGFRAME);
    631         yinc = GetSystemMetrics(SM_CYDLGFRAME);
     630        xinc = GetSystemMetrics(SM_CXDLGFRAME);
     631        yinc = GetSystemMetrics(SM_CYDLGFRAME);
    632632    }
    633633    else
    634634    {
    635         xinc = yinc = 0;
    636         if (HAS_THICKFRAME(dwStyle))
    637         {
    638             xinc += GetSystemMetrics(SM_CXFRAME);
    639             yinc += GetSystemMetrics(SM_CYFRAME);
    640         }
    641         if (dwStyle & WS_BORDER)
    642         {
    643             xinc += GetSystemMetrics(SM_CXBORDER);
    644             yinc += GetSystemMetrics(SM_CYBORDER);
    645         }
     635        xinc = yinc = 0;
     636        if (HAS_THICKFRAME(dwStyle))
     637        {
     638            xinc += GetSystemMetrics(SM_CXFRAME);
     639            yinc += GetSystemMetrics(SM_CYFRAME);
     640        }
     641        if (dwStyle & WS_BORDER)
     642        {
     643            xinc += GetSystemMetrics(SM_CXBORDER);
     644            yinc += GetSystemMetrics(SM_CYBORDER);
     645        }
    646646    }
    647647    MinMax.ptMaxSize.x += 2 * xinc;
     
    651651    lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos );
    652652    if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) )
    653         CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
     653        CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition );
    654654    else
    655655    {
    656656#endif
    657         MinMax.ptMaxPosition.x = -xinc;
    658         MinMax.ptMaxPosition.y = -yinc;
     657        MinMax.ptMaxPosition.x = -xinc;
     658        MinMax.ptMaxPosition.y = -yinc;
    659659//    }
    660660
     
    664664
    665665    dprintf(("GetMinMaxInfo: %ld %ld / %ld %ld / %ld %ld / %ld %ld\n",
    666                       MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
    667                       MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
    668                       MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
    669                       MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y));
     666                      MinMax.ptMaxSize.x, MinMax.ptMaxSize.y,
     667                      MinMax.ptMaxPosition.x, MinMax.ptMaxPosition.y,
     668                      MinMax.ptMaxTrackSize.x, MinMax.ptMaxTrackSize.y,
     669                      MinMax.ptMinTrackSize.x, MinMax.ptMinTrackSize.y));
    670670    MinMax.ptMaxTrackSize.x = MAX( MinMax.ptMaxTrackSize.x,
    671                                    MinMax.ptMinTrackSize.x );
     671                                   MinMax.ptMinTrackSize.x );
    672672    MinMax.ptMaxTrackSize.y = MAX( MinMax.ptMaxTrackSize.y,
    673                                    MinMax.ptMinTrackSize.y );
     673                                   MinMax.ptMinTrackSize.y );
    674674
    675675    if (maxSize)    *maxSize  = MinMax.ptMaxSize;
     
    679679}
    680680/***********************************************************************
    681  *           WINPOS_SendNCCalcSize
     681 *           WINPOS_SendNCCalcSize
    682682 *
    683683 * Send a WM_NCCALCSIZE message to a window.
     
    687687 */
    688688LONG Win32BaseWindow::SendNCCalcSize(BOOL calcValidRect, RECT *newWindowRect, RECT *oldWindowRect,
    689                                 RECT *oldClientRect, WINDOWPOS *winpos,
    690                                 RECT *newClientRect )
     689                                RECT *oldClientRect, WINDOWPOS *winpos,
     690                                RECT *newClientRect )
    691691{
    692692   NCCALCSIZE_PARAMS params;
     
    697697   if (calcValidRect)
    698698   {
    699         winposCopy = *winpos;
    700         params.rgrc[1] = *oldWindowRect;
    701         params.rgrc[2] = *oldClientRect;
    702         params.lppos = &winposCopy;
     699        winposCopy = *winpos;
     700        params.rgrc[1] = *oldWindowRect;
     701        params.rgrc[2] = *oldClientRect;
     702        params.lppos = &winposCopy;
    703703   }
    704704   result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect,
    705                                 (LPARAM)&params );
     705                                (LPARAM)&params );
    706706   *newClientRect = params.rgrc[0];
    707707   return result;
     
    725725{
    726726  if(SendInternalMessageA(WM_CLOSE, 0, 0) == 0) {
    727         return 0; //app handles this message
     727        return 0; //app handles this message
    728728  }
    729729  delete this;
     
    760760#if 1
    761761    if(fCreated == FALSE) {
    762         return 1;
     762        return 1;
    763763    }
    764764#endif
     
    772772#if 1
    773773    if(fCreated == FALSE) {
    774         return 1;
     774        return 1;
    775775    }
    776776#endif
     
    783783    dprintf(("MsgMove to (%d,%d)", x, y));
    784784    if(fCreated == FALSE) {
    785         return 1;
     785        return 1;
    786786    }
    787787
     
    794794  switch(cmd) {
    795795    case CMD_MENU:
    796         return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0);
     796        return SendInternalMessageA(WM_COMMAND, MAKELONG(Id, 0), 0);
    797797    case CMD_CONTROL:
    798         return 0; //todo
     798        return 0; //todo
    799799    case CMD_ACCELERATOR:
    800         dprintf(("accelerator command"));
    801         return 0; //todo
     800        dprintf(("accelerator command"));
     801        return 0; //todo
    802802  }
    803803  return 0;
     
    818818
    819819    if(fCreated == FALSE) {//Solitaire crashes if it receives a WM_SIZE during CreateWindowEx (normal or our fault?)
    820         return 1;
     820        return 1;
    821821    }
    822822
    823823    if(fMinimize) {
    824             fwSizeType = SIZE_MINIMIZED;
     824            fwSizeType = SIZE_MINIMIZED;
    825825    }
    826826    else
    827827    if(fMaximize) {
    828             fwSizeType = SIZE_MAXIMIZED;
     828            fwSizeType = SIZE_MAXIMIZED;
    829829    }
    830830    else    fwSizeType = SIZE_RESTORED;
     
    838838    if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE)
    839839    {
    840         if(!fActivate) {
    841             return 1;
    842         }
     840        if(!fActivate) {
     841            return 1;
     842        }
    843843    }
    844844    return SendInternalMessageA(WM_ACTIVATE, (fActivate) ? WA_ACTIVE : WA_INACTIVE, hwnd);
     
    860860    lParam |= (scancode << 16);
    861861    if(keyflags & KEY_ALTDOWN)
    862         lParam |= (1<<29);
     862        lParam |= (1<<29);
    863863    if(keyflags & KEY_PREVDOWN)
    864         lParam |= (1<<30);
     864        lParam |= (1<<30);
    865865    if(keyflags & KEY_UP)
    866         lParam |= (1<<31);
     866        lParam |= (1<<31);
    867867    if(keyflags & KEY_DEADKEY) {
    868         dprintf(("WM_DEADCHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
    869         return SendInternalMessageA(WM_DEADCHAR, cmd, lParam);
     868        dprintf(("WM_DEADCHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
     869        return SendInternalMessageA(WM_DEADCHAR, cmd, lParam);
    870870    }
    871871    else {
    872         dprintf(("WM_CHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
    873         return SendInternalMessageA(WM_CHAR, cmd, lParam);
     872        dprintf(("WM_CHAR: %x %x %08x", OS2Hwnd, cmd, lParam));
     873        return SendInternalMessageA(WM_CHAR, cmd, lParam);
    874874    }
    875875}
     
    879879{
    880880    if(hwnd == 0) {
    881             //other app lost focus
    882             SendInternalMessageA(WM_ACTIVATEAPP, TRUE, 0); //TODO: Need thread id from hwnd app
     881            //other app lost focus
     882            SendInternalMessageA(WM_ACTIVATEAPP, TRUE, 0); //TODO: Need thread id from hwnd app
    883883    }
    884884    return  SendInternalMessageA(WM_SETFOCUS, hwnd, 0);
     
    889889{
    890890    if(hwnd == 0) {
    891             //other app lost focus
    892             SendInternalMessageA(WM_ACTIVATEAPP, FALSE, 0); //TODO: Need thread id from hwnd app
     891            //other app lost focus
     892            SendInternalMessageA(WM_ACTIVATEAPP, FALSE, 0); //TODO: Need thread id from hwnd app
    893893    }
    894894    return  SendInternalMessageA(WM_KILLFOCUS, hwnd, 0);
     
    903903    dprintf(("MsgButton to (%d,%d)", ncx, ncy));
    904904    switch(msg) {
    905         case BUTTON_LEFTDOWN:
    906                 win32msg = WM_LBUTTONDOWN;
    907                 win32ncmsg = WM_NCLBUTTONDOWN;
    908                 break;
    909         case BUTTON_LEFTUP:
    910                 win32msg = WM_LBUTTONUP;
    911                 win32ncmsg = WM_NCLBUTTONUP;
    912                 break;
    913         case BUTTON_LEFTDBLCLICK:
    914                 win32msg = WM_LBUTTONDBLCLK;
    915                 win32ncmsg = WM_NCLBUTTONDBLCLK;
    916                 break;
    917         case BUTTON_RIGHTUP:
    918                 win32msg = WM_RBUTTONUP;
    919                 win32ncmsg = WM_NCRBUTTONUP;
    920                 break;
    921         case BUTTON_RIGHTDOWN:
    922                 win32msg = WM_RBUTTONDOWN;
    923                 win32ncmsg = WM_NCRBUTTONDOWN;
    924                 break;
    925         case BUTTON_RIGHTDBLCLICK:
    926                 win32msg = WM_RBUTTONDBLCLK;
    927                 win32ncmsg = WM_NCRBUTTONDBLCLK;
    928                 break;
    929         case BUTTON_MIDDLEUP:
    930                 win32msg = WM_MBUTTONUP;
    931                 win32ncmsg = WM_NCMBUTTONUP;
    932                 break;
    933         case BUTTON_MIDDLEDOWN:
    934                 win32msg = WM_MBUTTONDOWN;
    935                 win32ncmsg = WM_NCMBUTTONDOWN;
    936                 break;
    937         case BUTTON_MIDDLEDBLCLICK:
    938                 win32msg = WM_MBUTTONDBLCLK;
    939                 win32ncmsg = WM_NCMBUTTONDBLCLK;
    940                 break;
    941         default:
    942                 dprintf(("Win32BaseWindow::Button: invalid msg!!!!"));
    943                 return 1;
     905        case BUTTON_LEFTDOWN:
     906                win32msg = WM_LBUTTONDOWN;
     907                win32ncmsg = WM_NCLBUTTONDOWN;
     908                break;
     909        case BUTTON_LEFTUP:
     910                win32msg = WM_LBUTTONUP;
     911                win32ncmsg = WM_NCLBUTTONUP;
     912                break;
     913        case BUTTON_LEFTDBLCLICK:
     914                win32msg = WM_LBUTTONDBLCLK;
     915                win32ncmsg = WM_NCLBUTTONDBLCLK;
     916                break;
     917        case BUTTON_RIGHTUP:
     918                win32msg = WM_RBUTTONUP;
     919                win32ncmsg = WM_NCRBUTTONUP;
     920                break;
     921        case BUTTON_RIGHTDOWN:
     922                win32msg = WM_RBUTTONDOWN;
     923                win32ncmsg = WM_NCRBUTTONDOWN;
     924                break;
     925        case BUTTON_RIGHTDBLCLICK:
     926                win32msg = WM_RBUTTONDBLCLK;
     927                win32ncmsg = WM_NCRBUTTONDBLCLK;
     928                break;
     929        case BUTTON_MIDDLEUP:
     930                win32msg = WM_MBUTTONUP;
     931                win32ncmsg = WM_NCMBUTTONUP;
     932                break;
     933        case BUTTON_MIDDLEDOWN:
     934                win32msg = WM_MBUTTONDOWN;
     935                win32ncmsg = WM_NCMBUTTONDOWN;
     936                break;
     937        case BUTTON_MIDDLEDBLCLICK:
     938                win32msg = WM_MBUTTONDBLCLK;
     939                win32ncmsg = WM_NCMBUTTONDBLCLK;
     940                break;
     941        default:
     942                dprintf(("Win32BaseWindow::Button: invalid msg!!!!"));
     943                return 1;
    944944    }
    945945    if(win32msg == WM_MBUTTONDBLCLK || win32msg == WM_RBUTTONDBLCLK || win32msg == WM_LBUTTONDBLCLK) {
    946         if(!(windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)) {
    947             return 1;
    948         }
     946        if(!(windowClass->getClassLongA(GCL_STYLE) & CS_DBLCLKS)) {
     947            return 1;
     948        }
    949949    }
    950950    SendInternalMessageA(WM_SETCURSOR, Win32Hwnd, MAKELONG(lastHitTestVal, win32ncmsg));
     
    952952    //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
    953953    if(lastHitTestVal != HTCLIENT) {
    954             SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(ncx, ncy)); //TODO:
     954            SendInternalMessageA(win32ncmsg, lastHitTestVal, MAKELONG(ncx, ncy)); //TODO:
    955955    }
    956956    return  SendInternalMessageA(win32msg, 0, MAKELONG(clx, cly));
     
    964964
    965965    if(keystate & WMMOVE_LBUTTON)
    966         winstate |= MK_LBUTTON;
     966        winstate |= MK_LBUTTON;
    967967    if(keystate & WMMOVE_RBUTTON)
    968         winstate |= MK_RBUTTON;
     968        winstate |= MK_RBUTTON;
    969969    if(keystate & WMMOVE_MBUTTON)
    970         winstate |= MK_MBUTTON;
     970        winstate |= MK_MBUTTON;
    971971    if(keystate & WMMOVE_SHIFT)
    972         winstate |= MK_SHIFT;
     972        winstate |= MK_SHIFT;
    973973    if(keystate & WMMOVE_CTRL)
    974         winstate |= MK_CONTROL;
     974        winstate |= MK_CONTROL;
    975975
    976976    if(lastHitTestVal != HTCLIENT) {
    977         setcursormsg = WM_NCMOUSEMOVE;
     977        setcursormsg = WM_NCMOUSEMOVE;
    978978    }
    979979    //TODO: hiword should be 0 if window enters menu mode (SDK docs)
     
    982982    //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
    983983    if(lastHitTestVal != HTCLIENT) {
    984             SendInternalMessageA(WM_NCMOUSEMOVE, lastHitTestVal, MAKELONG(x, y));
     984            SendInternalMessageA(WM_NCMOUSEMOVE, lastHitTestVal, MAKELONG(x, y));
    985985    }
    986986    return  SendInternalMessageA(WM_MOUSEMOVE, keystate, MAKELONG(x, y));
     
    994994//******************************************************************************
    995995//TODO: Is the clipper region of the window DC equal to the invalidated rectangle?
    996 //      (or are we simply erasing too much here)
     996//      (or are we simply erasing too much here)
    997997//******************************************************************************
    998998ULONG Win32BaseWindow::MsgEraseBackGround(HDC hdc)
     
    10021002
    10031003    if (hdcErase == 0)
    1004         hdcErase = O32_GetDC(OS2Hwnd);
     1004        hdcErase = O32_GetDC(OS2Hwnd);
    10051005
    10061006    if(isIcon)
    1007         rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0);
     1007        rc = SendInternalMessageA(WM_ICONERASEBKGND, hdcErase, 0);
    10081008    else
    1009         rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0);
     1009        rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0);
    10101010    if (hdc == 0)
    1011         O32_ReleaseDC(OS2Hwnd, hdcErase);
     1011        O32_ReleaseDC(OS2Hwnd, hdcErase);
    10121012    return (rc);
    10131013}
     
    10171017{
    10181018    if(isUnicode) {
    1019             return SendInternalMessageW(WM_SETTEXT, 0, (LPARAM)lpsz);
     1019            return SendInternalMessageW(WM_SETTEXT, 0, (LPARAM)lpsz);
    10201020    }
    10211021    else    return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz);
     
    10331033{
    10341034    if(isUnicode) {
    1035         SendInternalMessageW(WM_GETTEXT, wndNameLength, (LPARAM)windowNameW);
     1035        SendInternalMessageW(WM_GETTEXT, wndNameLength, (LPARAM)windowNameW);
    10361036    }
    10371037    else {
    1038         SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA);
     1038        SendInternalMessageA(WM_GETTEXT, wndNameLength, (LPARAM)windowNameA);
    10391039    }
    10401040    return windowNameA;
     
    10471047    {
    10481048    case WM_GETTEXTLENGTH:
    1049         return wndNameLength;
     1049        return wndNameLength;
    10501050
    10511051    case WM_GETTEXT:   //TODO: SS_ICON controls
    1052         strncpy((LPSTR)lParam, windowNameA, wParam);
    1053         return min(wndNameLength, wParam);
     1052        strncpy((LPSTR)lParam, windowNameA, wParam);
     1053        return min(wndNameLength, wParam);
    10541054
    10551055    case WM_SETTEXT:
    1056         return 0;
     1056        return 0;
    10571057
    10581058    case WM_SETREDRAW:
    1059         if(wParam)
    1060                 SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) | WS_VISIBLE);
    1061         else    SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE);
    1062 
    1063         return 0; //TODO
     1059        if(wParam)
     1060                SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) | WS_VISIBLE);
     1061        else    SetWindowLongA (GWL_STYLE, GetWindowLongA (GWL_STYLE) & ~WS_VISIBLE);
     1062
     1063        return 0; //TODO
    10641064
    10651065    case WM_NCCREATE:
    1066         return(TRUE);
     1066        return(TRUE);
    10671067
    10681068    case WM_CTLCOLORMSGBOX:
     
    10731073    case WM_CTLCOLORSTATIC:
    10741074    case WM_CTLCOLORSCROLLBAR:
    1075         SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
    1076         SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
    1077         return GetSysColorBrush(COLOR_BTNFACE);
     1075        SetBkColor((HDC)wParam, GetSysColor(COLOR_WINDOW));
     1076        SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT));
     1077        return GetSysColorBrush(COLOR_BTNFACE);
    10781078
    10791079    case WM_PARENTNOTIFY:
    1080         return 0;
     1080        return 0;
    10811081
    10821082    case WM_MOUSEACTIVATE:
    10831083    {
    1084         DWORD dwStyle = GetWindowLongA(GWL_STYLE);
    1085         DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
    1086         dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
    1087         if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
    1088         {
    1089             if(getParent()) {
    1090                 LRESULT rc = getParent()->SendMessageA(WM_MOUSEACTIVATE, wParam, lParam );
    1091                 if(rc)  return rc;
    1092             }
    1093         }
    1094         return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
     1084        DWORD dwStyle = GetWindowLongA(GWL_STYLE);
     1085        DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
     1086        dprintf(("DefWndProc: WM_MOUSEACTIVATE for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
     1087        if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
     1088        {
     1089            if(getParent()) {
     1090                LRESULT rc = getParent()->SendMessageA(WM_MOUSEACTIVATE, wParam, lParam );
     1091                if(rc)  return rc;
     1092            }
     1093        }
     1094        return (LOWORD(lParam) == HTCAPTION) ? MA_NOACTIVATE : MA_ACTIVATE;
    10951095    }
    10961096    case WM_SETCURSOR:
    10971097    {
    1098         DWORD dwStyle = GetWindowLongA(GWL_STYLE);
    1099         DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
    1100         dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
    1101         if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
    1102         {
    1103             if(getParent()) {
    1104                 LRESULT rc = getParent()->SendMessageA(WM_SETCURSOR, wParam, lParam);
    1105                 if(rc)  return rc;
    1106             }
    1107         }
    1108         return 1;
     1098        DWORD dwStyle = GetWindowLongA(GWL_STYLE);
     1099        DWORD dwExStyle = GetWindowLongA(GWL_EXSTYLE);
     1100        dprintf(("DefWndProc: WM_SETCURSOR for %x Msg %s", Win32Hwnd, GetMsgText(HIWORD(lParam))));
     1101        if(dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) )
     1102        {
     1103            if(getParent()) {
     1104                LRESULT rc = getParent()->SendMessageA(WM_SETCURSOR, wParam, lParam);
     1105                if(rc)  return rc;
     1106            }
     1107        }
     1108        return 1;
    11091109    }
    11101110    case WM_MOUSEMOVE:
    1111         return 0;
     1111        return 0;
    11121112
    11131113    case WM_WINDOWPOSCHANGED:
     
    11151115
    11161116/* undocumented SWP flags - from SDK 3.1 */
    1117 #define SWP_NOCLIENTSIZE        0x0800
    1118 #define SWP_NOCLIENTMOVE        0x1000
    1119 
    1120         PWINDOWPOS wpos = (PWINDOWPOS)lParam;
    1121         WPARAM     wp   = SIZE_RESTORED;
    1122 
    1123         if (!(wpos->flags & SWP_NOCLIENTMOVE))
    1124             SendMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
    1125 
    1126         if (!(wpos->flags & SWP_NOCLIENTSIZE))
    1127         {
    1128             if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
    1129             else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
    1130 
    1131            SendMessageA(WM_SIZE, wp, MAKELONG(rectClient.right  - rectClient.left,
    1132                                               rectClient.bottom - rectClient.top));
    1133         }
    1134         return 0;
     1117#define SWP_NOCLIENTSIZE        0x0800
     1118#define SWP_NOCLIENTMOVE        0x1000
     1119
     1120        PWINDOWPOS wpos = (PWINDOWPOS)lParam;
     1121        WPARAM     wp   = SIZE_RESTORED;
     1122
     1123        if (!(wpos->flags & SWP_NOCLIENTMOVE))
     1124            SendMessageA(WM_MOVE, 0, MAKELONG(rectClient.left, rectClient.top));
     1125
     1126        if (!(wpos->flags & SWP_NOCLIENTSIZE))
     1127        {
     1128            if (dwStyle & WS_MAXIMIZE) wp = SIZE_MAXIMIZED;
     1129            else if (dwStyle & WS_MINIMIZE) wp = SIZE_MINIMIZED;
     1130
     1131           SendMessageA(WM_SIZE, wp, MAKELONG(rectClient.right  - rectClient.left,
     1132                                              rectClient.bottom - rectClient.top));
     1133        }
     1134        return 0;
    11351135    }
    11361136    case WM_ERASEBKGND:
     
    11381138    {
    11391139      RECT rect;
    1140 
    1141         if (!windowClass->getBackgroundBrush()) return 0;
    1142 
    1143         /*  Since WM_ERASEBKGND may receive either a window dc or a    */
    1144         /*  client dc, the area to be erased has to be retrieved from  */
    1145         /*  the device context.                                    */
    1146         GetClipBox( (HDC)wParam, &rect );
    1147 
    1148         FillRect( (HDC)wParam, &rect, windowClass->getBackgroundBrush());
    1149 
    1150         return 1;
     1140      int rc;
     1141
     1142        if (!windowClass->getBackgroundBrush()) return 0;
     1143
     1144        /*  Since WM_ERASEBKGND may receive either a window dc or a    */
     1145        /*  client dc, the area to be erased has to be retrieved from  */
     1146        /*  the device context.                                    */
     1147        rc = GetClipBox( (HDC)wParam, &rect );
     1148        if ((rc == SIMPLEREGION) || (rc == COMPLEXREGION))
     1149            FillRect( (HDC)wParam, &rect, windowClass->getBackgroundBrush());
     1150
     1151        return 1;
    11511152    }
    11521153
     
    11601161    case WM_NCMBUTTONUP:
    11611162    case WM_NCMBUTTONDBLCLK:
    1162         return 0;           //TODO: Send WM_SYSCOMMAND if required
     1163        return 0;           //TODO: Send WM_SYSCOMMAND if required
    11631164
    11641165    case WM_NCHITTEST: //TODO: Calculate position of
    1165         return HTCLIENT;
     1166        return HTCLIENT;
    11661167
    11671168    default:
    1168         return 1;
     1169        return 1;
    11691170    }
    11701171}
     
    11761177    {
    11771178    case WM_GETTEXTLENGTH:
    1178         return wndNameLength;
     1179        return wndNameLength;
    11791180
    11801181    case WM_GETTEXT:   //TODO: SS_ICON controls
    1181         lstrcpynW((LPWSTR)lParam, windowNameW, wParam);
    1182         return min(wndNameLength, wParam);
     1182        lstrcpynW((LPWSTR)lParam, windowNameW, wParam);
     1183        return min(wndNameLength, wParam);
    11831184
    11841185    default:
    1185         return DefWindowProcA(Msg, wParam, lParam);
     1186        return DefWindowProcA(Msg, wParam, lParam);
    11861187    }
    11871188}
     
    11911192{
    11921193  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    1193         dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     1194        dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    11941195
    11951196  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1196         return(0);
     1197        return(0);
    11971198  }
    11981199  switch(Msg)
    11991200  {
    1200         case WM_CREATE:
    1201         {
    1202                 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    1203                         dprintf(("WM_NCCREATE returned FALSE\n"));
    1204                         return(-1); //don't create window
    1205                 }
    1206                 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
    1207                         dprintf(("WM_CREATE returned -1\n"));
    1208                         return(-1); //don't create window
    1209                 }
    1210                 NotifyParent(Msg, wParam, lParam);
    1211 
    1212                 return(0);
    1213         }
    1214         case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
    1215                 return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
    1216 
    1217         case WM_LBUTTONDOWN:
    1218         case WM_MBUTTONDOWN:
    1219         case WM_RBUTTONDOWN:
    1220                 NotifyParent(Msg, wParam, lParam);
    1221                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    1222 
    1223         case WM_DESTROY:
    1224                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1225                 NotifyParent(Msg, wParam, lParam);
    1226                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1227         default:
    1228                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1201        case WM_CREATE:
     1202        {
     1203                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
     1204                        dprintf(("WM_NCCREATE returned FALSE\n"));
     1205                        return(-1); //don't create window
     1206                }
     1207                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == -1) {
     1208                        dprintf(("WM_CREATE returned -1\n"));
     1209                        return(-1); //don't create window
     1210                }
     1211                NotifyParent(Msg, wParam, lParam);
     1212
     1213                return(0);
     1214        }
     1215        case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
     1216                return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
     1217
     1218        case WM_LBUTTONDOWN:
     1219        case WM_MBUTTONDOWN:
     1220        case WM_RBUTTONDOWN:
     1221                NotifyParent(Msg, wParam, lParam);
     1222                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1223
     1224        case WM_DESTROY:
     1225                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     1226                NotifyParent(Msg, wParam, lParam);
     1227                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     1228        default:
     1229                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    12291230  }
    12301231}
     
    12341235{
    12351236  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    1236         dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     1237        dprintf(("SendMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    12371238
    12381239  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1239         return(0);
     1240        return(0);
    12401241  }
    12411242  switch(Msg)
    12421243  {
    1243         case WM_CREATE:
    1244         {
    1245                 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    1246                         dprintf(("WM_NCCREATE returned FALSE\n"));
    1247                         return(0); //don't create window
    1248                 }
    1249                 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
    1250                         dprintf(("WM_CREATE returned FALSE\n"));
    1251                         return(0); //don't create window
    1252                 }
    1253                 NotifyParent(Msg, wParam, lParam);
    1254 
    1255                 return(1);
    1256         }
    1257         case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
    1258                 return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
    1259 
    1260         case WM_LBUTTONDOWN:
    1261         case WM_MBUTTONDOWN:
    1262         case WM_RBUTTONDOWN:
    1263                 NotifyParent(Msg, wParam, lParam);
    1264                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    1265 
    1266         case WM_DESTROY:
    1267                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1268                 NotifyParent(Msg, wParam, lParam);
    1269                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1270 
    1271         default:
    1272                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1244        case WM_CREATE:
     1245        {
     1246                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
     1247                        dprintf(("WM_NCCREATE returned FALSE\n"));
     1248                        return(0); //don't create window
     1249                }
     1250                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
     1251                        dprintf(("WM_CREATE returned FALSE\n"));
     1252                        return(0); //don't create window
     1253                }
     1254                NotifyParent(Msg, wParam, lParam);
     1255
     1256                return(1);
     1257        }
     1258        case WM_SETTEXT: //TODO: Nothing happens if passed to DefWindowProc
     1259                return win32wndproc(getWindowHandle(), WM_SETTEXT, wParam, lParam);
     1260
     1261        case WM_LBUTTONDOWN:
     1262        case WM_MBUTTONDOWN:
     1263        case WM_RBUTTONDOWN:
     1264                NotifyParent(Msg, wParam, lParam);
     1265                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1266
     1267        case WM_DESTROY:
     1268                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     1269                NotifyParent(Msg, wParam, lParam);
     1270                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     1271
     1272        default:
     1273                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    12731274  }
    12741275}
     
    12791280{
    12801281  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    1281         dprintf(("SendInternalMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     1282        dprintf(("SendInternalMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    12821283
    12831284  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1284         return(0);
     1285        return(0);
    12851286  }
    12861287  switch(Msg)
    12871288  {
    1288         case WM_CREATE:
    1289         {
    1290                 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    1291                         dprintf(("WM_NCCREATE returned FALSE\n"));
    1292                         return(0); //don't create window
    1293                 }
    1294                 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
    1295                         dprintf(("WM_CREATE returned FALSE\n"));
    1296                         return(0); //don't create window
    1297                 }
    1298                 NotifyParent(Msg, wParam, lParam);
    1299 
    1300                 return(1);
    1301         }
    1302         case WM_LBUTTONDOWN:
    1303         case WM_MBUTTONDOWN:
    1304         case WM_RBUTTONDOWN:
    1305                 NotifyParent(Msg, wParam, lParam);
    1306                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    1307 
    1308         case WM_DESTROY:
    1309                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1310                 NotifyParent(Msg, wParam, lParam);
    1311                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1312         default:
    1313                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1289        case WM_CREATE:
     1290        {
     1291                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
     1292                        dprintf(("WM_NCCREATE returned FALSE\n"));
     1293                        return(0); //don't create window
     1294                }
     1295                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
     1296                        dprintf(("WM_CREATE returned FALSE\n"));
     1297                        return(0); //don't create window
     1298                }
     1299                NotifyParent(Msg, wParam, lParam);
     1300
     1301                return(1);
     1302        }
     1303        case WM_LBUTTONDOWN:
     1304        case WM_MBUTTONDOWN:
     1305        case WM_RBUTTONDOWN:
     1306                NotifyParent(Msg, wParam, lParam);
     1307                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1308
     1309        case WM_DESTROY:
     1310                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     1311                NotifyParent(Msg, wParam, lParam);
     1312                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     1313        default:
     1314                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    13141315  }
    13151316}
     
    13211322{
    13221323  if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE)
    1323         dprintf(("SendInternalMessageW %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
     1324        dprintf(("SendInternalMessageW %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam));
    13241325
    13251326  if(HkCBT::OS2HkCBTProc(getWindowHandle(), Msg, wParam, lParam) == TRUE) {//hook swallowed msg
    1326         return(0);
     1327        return(0);
    13271328  }
    13281329  switch(Msg)
    13291330  {
    1330         case WM_CREATE:
    1331         {
    1332                 if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
    1333                         dprintf(("WM_NCCREATE returned FALSE\n"));
    1334                         return(0); //don't create window
    1335                 }
    1336                 if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
    1337                         dprintf(("WM_CREATE returned FALSE\n"));
    1338                         return(0); //don't create window
    1339                 }
    1340                 NotifyParent(Msg, wParam, lParam);
    1341 
    1342                 return(1);
    1343         }
    1344         case WM_LBUTTONDOWN:
    1345         case WM_MBUTTONDOWN:
    1346         case WM_RBUTTONDOWN:
    1347                 NotifyParent(Msg, wParam, lParam);
    1348                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    1349 
    1350         case WM_DESTROY:
    1351                 win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
    1352                 NotifyParent(Msg, wParam, lParam);
    1353                 return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
    1354         default:
    1355                 return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1331        case WM_CREATE:
     1332        {
     1333                if(win32wndproc(getWindowHandle(), WM_NCCREATE, 0, lParam) == 0) {
     1334                        dprintf(("WM_NCCREATE returned FALSE\n"));
     1335                        return(0); //don't create window
     1336                }
     1337                if(win32wndproc(getWindowHandle(), WM_CREATE, 0, lParam) == 0) {
     1338                        dprintf(("WM_CREATE returned FALSE\n"));
     1339                        return(0); //don't create window
     1340                }
     1341                NotifyParent(Msg, wParam, lParam);
     1342
     1343                return(1);
     1344        }
     1345        case WM_LBUTTONDOWN:
     1346        case WM_MBUTTONDOWN:
     1347        case WM_RBUTTONDOWN:
     1348                NotifyParent(Msg, wParam, lParam);
     1349                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     1350
     1351        case WM_DESTROY:
     1352                win32wndproc(getWindowHandle(), WM_NCDESTROY, 0, 0);
     1353                NotifyParent(Msg, wParam, lParam);
     1354                return win32wndproc(getWindowHandle(), WM_DESTROY, 0, 0);
     1355        default:
     1356                return win32wndproc(getWindowHandle(), Msg, wParam, lParam);
    13561357  }
    13571358}
     
    13781379   while(window)
    13791380   {
    1380         if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
    1381         {
    1382                 /* Notify the parent window only */
    1383                 parentwindow = window->getParent();
    1384                 if(parentwindow) {
    1385                         if(Msg == WM_CREATE || Msg == WM_DESTROY) {
    1386                                 parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
    1387                         }
    1388                         else    parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
    1389                 }
    1390         }
    1391         else    break;
    1392 
    1393         window = parentwindow;
     1381        if(window->getStyle() & WS_CHILD && !(window->getExStyle() & WS_EX_NOPARENTNOTIFY) )
     1382        {
     1383                /* Notify the parent window only */
     1384                parentwindow = window->getParent();
     1385                if(parentwindow) {
     1386                        if(Msg == WM_CREATE || Msg == WM_DESTROY) {
     1387                                parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), (LPARAM)window->getWindowHandle());
     1388                        }
     1389                        else    parentwindow->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(Msg, window->getWindowId()), lParam );
     1390                }
     1391        }
     1392        else    break;
     1393
     1394        window = parentwindow;
    13941395   }
    13951396}
     
    13981399BOOL Win32BaseWindow::SetMenu(HMENU hMenu)
    13991400{
    1400  PVOID          menutemplate;
     1401 PVOID          menutemplate;
    14011402 Win32Resource *winres = (Win32Resource *)hMenu;
    14021403
    14031404    dprintf(("SetMenu %x", hMenu));
    14041405    if(HIWORD(winres) == 0) {
    1405         dprintf(("Win32BaseWindow:: Win32Resource *winres == 0"));
    1406         SetLastError(ERROR_INVALID_PARAMETER);
    1407         return FALSE;
     1406        dprintf(("Win32BaseWindow:: Win32Resource *winres == 0"));
     1407        SetLastError(ERROR_INVALID_PARAMETER);
     1408        return FALSE;
    14081409    }
    14091410    menutemplate = winres->lockOS2Resource();
    14101411    if(menutemplate == NULL)
    14111412    {
    1412         dprintf(("Win32BaseWindow::SetMenu menutemplate == 0"));
    1413         return FALSE;
     1413        dprintf(("Win32BaseWindow::SetMenu menutemplate == 0"));
     1414        return FALSE;
    14141415    }
    14151416    OS2HwndMenu = OSLibWinCreateMenu(OS2HwndFrame, menutemplate);
    14161417    if(OS2HwndMenu == 0) {
    1417         dprintf(("Win32BaseWindow::SetMenu OS2HwndMenu == 0"));
    1418         return FALSE;
     1418        dprintf(("Win32BaseWindow::SetMenu OS2HwndMenu == 0"));
     1419        return FALSE;
    14191420    }
    14201421    menuResource = winres;
     
    14261427{
    14271428 Win32Resource *winres = (Win32Resource *)hAccel;
    1428  HANDLE         accelhandle;
     1429 HANDLE         accelhandle;
    14291430
    14301431    if(HIWORD(hAccel) == 0) {
    1431         dprintf(("SetAccelTable: hAccel %x invalid", hAccel));
    1432         SetLastError(ERROR_INVALID_PARAMETER);
    1433         return FALSE;
     1432        dprintf(("SetAccelTable: hAccel %x invalid", hAccel));
     1433        SetLastError(ERROR_INVALID_PARAMETER);
     1434        return FALSE;
    14341435    }
    14351436    acceltableResource = winres;
     
    14531454    dprintf(("ShowWindow %x", nCmdShow));
    14541455    if(fFirstShow) {
    1455         if(isFrameWindow() && IS_OVERLAPPED(getStyle())) {
    1456                 SendMessageA(WM_SIZE, SIZE_RESTORED,
    1457                                 MAKELONG(rectClient.right-rectClient.left,
    1458                                         rectClient.bottom-rectClient.top));
    1459                 SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
    1460 
    1461         }
    1462         fFirstShow = FALSE;
     1456        if(isFrameWindow() && IS_OVERLAPPED(getStyle())) {
     1457                SendMessageA(WM_SIZE, SIZE_RESTORED,
     1458                                MAKELONG(rectClient.right-rectClient.left,
     1459                                        rectClient.bottom-rectClient.top));
     1460                SendMessageA(WM_MOVE, 0, MAKELONG( rectClient.left, rectClient.top ) );
     1461
     1462        }
     1463        fFirstShow = FALSE;
    14631464    }
    14641465    switch(nCmdShow)
     
    14661467    case SW_SHOW:
    14671468    case SW_SHOWDEFAULT: //todo
    1468         showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
    1469         break;
     1469        showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
     1470        break;
    14701471    case SW_HIDE:
    1471         showstate = SWPOS_HIDE;
    1472         break;
     1472        showstate = SWPOS_HIDE;
     1473        break;
    14731474    case SW_RESTORE:
    1474         showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
    1475         break;
     1475        showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
     1476        break;
    14761477    case SW_MINIMIZE:
    1477         showstate = SWPOS_MINIMIZE;
    1478         break;
     1478        showstate = SWPOS_MINIMIZE;
     1479        break;
    14791480    case SW_SHOWMAXIMIZED:
    1480         showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
    1481         break;
     1481        showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
     1482        break;
    14821483    case SW_SHOWMINIMIZED:
    1483         showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
    1484         break;
     1484        showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
     1485        break;
    14851486    case SW_SHOWMINNOACTIVE:
    1486         showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
    1487         break;
     1487        showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
     1488        break;
    14881489    case SW_SHOWNA:
    1489         showstate = SWPOS_SHOW;
    1490         break;
     1490        showstate = SWPOS_SHOW;
     1491        break;
    14911492    case SW_SHOWNOACTIVATE:
    1492         showstate = SWPOS_SHOW;
    1493         break;
     1493        showstate = SWPOS_SHOW;
     1494        break;
    14941495    case SW_SHOWNORMAL:
    1495         showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
    1496         break;
     1496        showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
     1497        break;
    14971498    }
    14981499    return OSLibWinShowWindow(OS2HwndFrame, showstate);
     
    15081509   dprintf (("SetWindowPos %x %x (%d,%d)(%d,%d) %x", Win32Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
    15091510
    1510    /* Validate the flags passed in ...                  */
     1511   /* Validate the flags passed in ...                  */
    15111512   if ( fuFlags &
    1512         ~(SWP_NOSIZE     | SWP_NOMOVE     | SWP_NOZORDER     |
    1513           SWP_NOREDRAW  | SWP_NOACTIVATE | SWP_FRAMECHANGED |
    1514           SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS   |
    1515           SWP_NOOWNERZORDER) )
     1513        ~(SWP_NOSIZE     | SWP_NOMOVE     | SWP_NOZORDER     |
     1514          SWP_NOREDRAW  | SWP_NOACTIVATE | SWP_FRAMECHANGED |
     1515          SWP_SHOWWINDOW | SWP_HIDEWINDOW | SWP_NOCOPYBITS   |
     1516          SWP_NOOWNERZORDER) )
    15161517   {
    15171518      return FALSE;
     
    15241525   // Set up with Windows values.
    15251526   //****************************
    1526    wpos.flags            = fuFlags;
    1527    wpos.cy              = cy;
    1528    wpos.cx              = cx;
    1529    wpos.x                = x;
    1530    wpos.y                = y;
     1527   wpos.flags            = fuFlags;
     1528   wpos.cy              = cy;
     1529   wpos.cx              = cx;
     1530   wpos.x                = x;
     1531   wpos.y                = y;
    15311532   wpos.hwndInsertAfter  = hwndInsertAfter;
    1532    wpos.hwnd            = getWindowHandle();
     1533   wpos.hwnd            = getWindowHandle();
    15331534
    15341535   //**********************************************
     
    15381539       if (isChild())
    15391540       {
    1540            hParent = getParent()->getOS2WindowHandle();
    1541            OSLibWinQueryWindowPos(OS2Hwnd, &swpOld);
     1541           hParent = getParent()->getOS2WindowHandle();
     1542           OSLibWinQueryWindowPos(OS2Hwnd, &swpOld);
    15421543       } else
    1543            OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
     1544           OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
    15441545   }
    15451546   OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame);
     
    15861587   if (rc == FALSE)
    15871588   {
    1588 //      SET_ERROR_LAST();
     1589//      SET_ERROR_LAST();
    15891590   }
    15901591   else
     
    15981599      ** a WM_UPDATEFRAME, which will provide the behavior of WM_NCCALCSIZE.
    15991600      */
    1600 //      if (fuFlags & SWP_FRAMECHANGED_W)
    1601 //         WinSendMsg(hWindow, WM_UPDATEFRAME, (MPARAM)-1, 0);
     1601//      if (fuFlags & SWP_FRAMECHANGED_W)
     1602//         WinSendMsg(hWindow, WM_UPDATEFRAME, (MPARAM)-1, 0);
    16021603   }
    16031604
     
    16181619    return getParent()->getWindowHandle();
    16191620  }
    1620   else  return 0;
     1621  else  return 0;
    16211622}
    16221623//******************************************************************************
     
    16281629
    16291630   if(getParent()) {
    1630         oldhwnd = getParent()->getWindowHandle();
     1631        oldhwnd = getParent()->getWindowHandle();
    16311632   }
    16321633   else oldhwnd = 0;
     
    16341635   if(hwndNewParent == 0) {//desktop window = parent
    16351636    setParent(NULL);
    1636         OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
    1637         return oldhwnd;
     1637        OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
     1638        return oldhwnd;
    16381639   }
    16391640   newparent = GetWindowFromHandle(hwndNewParent);
    16401641   if(newparent)
    16411642   {
    1642         setParent(newparent);
    1643         OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
    1644         return oldhwnd;
     1643        setParent(newparent);
     1644        OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
     1645        return oldhwnd;
    16451646   }
    16461647   SetLastError(ERROR_INVALID_PARAMETER);
     
    16541655    return getParent()->getWindowHandle() == hwndParent;
    16551656  }
    1656   else  return 0;
     1657  else  return 0;
    16571658}
    16581659//******************************************************************************
     
    16731674    if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect))
    16741675    {//update region not empty
    1675         HDC hdc;
    1676 
    1677         hdc = O32_GetDC(OS2Hwnd);
    1678         if (isIcon)
    1679         {
    1680             SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
    1681             SendInternalMessageA(WM_PAINTICON, 0, 0);
    1682         } else
    1683         {
    1684             SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
    1685             SendInternalMessageA(WM_PAINT, 0, 0);
    1686         }
    1687         O32_ReleaseDC(OS2Hwnd, hdc);
     1676        HDC hdc;
     1677
     1678        hdc = O32_GetDC(OS2Hwnd);
     1679        if (isIcon)
     1680        {
     1681            SendInternalMessageA(WM_ICONERASEBKGND, (WPARAM)hdc, 0);
     1682            SendInternalMessageA(WM_PAINTICON, 0, 0);
     1683        } else
     1684        {
     1685            SendInternalMessageA(WM_ERASEBKGND, (WPARAM)hdc, 0);
     1686            SendInternalMessageA(WM_PAINT, 0, 0);
     1687        }
     1688        O32_ReleaseDC(OS2Hwnd, hdc);
    16881689    }
    16891690    return TRUE;
     
    17011702//******************************************************************************
    17021703HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, LPSTR lpszClass, LPSTR lpszWindow,
    1703                                BOOL fUnicode)
     1704                               BOOL fUnicode)
    17041705{
    17051706 Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
     
    17101711       (hwndParent == OSLIB_HWND_DESKTOP && hwndChildAfter != 0))
    17111712    {
    1712         dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
    1713         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    1714         return 0;
     1713        dprintf(("Win32BaseWindow::FindWindowEx: parent or child not found %x %x", hwndParent, hwndChildAfter));
     1714        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     1715        return 0;
    17151716    }
    17161717    if(hwndParent != OSLIB_HWND_DESKTOP)
    17171718    {//if the current process owns the window, just do a quick search
    1718         child = (Win32BaseWindow *)parent->GetFirstChild();
    1719         if(hwndChildAfter != 0)
    1720         {
    1721             while(child)
    1722             {
    1723                 if(child->getWindowHandle() == hwndChildAfter)
    1724                 {
    1725                     child = (Win32BaseWindow *)child->GetNextChild();
    1726                     break;
    1727                 }
    1728                 child = (Win32BaseWindow *)child->GetNextChild();
    1729             }
    1730         }
    1731         while(child)
    1732         {
    1733             if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
    1734                (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
    1735             {
    1736                 dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
    1737                 return child->getWindowHandle();
    1738             }
    1739             child = (Win32BaseWindow *)child->GetNextChild();
    1740         }
     1719        child = (Win32BaseWindow *)parent->GetFirstChild();
     1720        if(hwndChildAfter != 0)
     1721        {
     1722            while(child)
     1723            {
     1724                if(child->getWindowHandle() == hwndChildAfter)
     1725                {
     1726                    child = (Win32BaseWindow *)child->GetNextChild();
     1727                    break;
     1728                }
     1729                child = (Win32BaseWindow *)child->GetNextChild();
     1730            }
     1731        }
     1732        while(child)
     1733        {
     1734            if(child->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
     1735               (!lpszWindow || child->hasWindowName(lpszWindow, fUnicode)))
     1736            {
     1737                dprintf(("FindWindowEx: Found window %x", child->getWindowHandle()));
     1738                return child->getWindowHandle();
     1739            }
     1740            child = (Win32BaseWindow *)child->GetNextChild();
     1741        }
    17411742    }
    17421743    else {
    1743         Win32BaseWindow *wnd;
    1744         HWND henum, hwnd;
    1745 
    1746         henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
    1747         hwnd = OSLibWinGetNextWindow(henum);
    1748 
    1749         while(hwnd)
    1750         {
    1751             wnd = GetWindowFromOS2Handle(hwnd);
    1752             if(wnd == NULL) {
    1753                 hwnd = OSLibWinQueryClientWindow(hwnd);
    1754                 if(hwnd)  wnd = GetWindowFromOS2Handle(hwnd);
    1755             }
    1756 
    1757             if(wnd) {
    1758                 LPVOID sharedmembase = (LPVOID)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_SHAREDMEM);
    1759 
    1760                 if(OSLibDosGetSharedMem(sharedmembase, MAX_HEAPSIZE, OSLIB_PAG_READ) != 0) {
    1761                     dprintf(("OSLibDosGetSharedMem returned error for %x", wnd));
    1762                     break;
    1763                 }
    1764                 if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
    1765                    (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
    1766                 {
    1767                     OSLibWinEndEnumWindows(henum);
    1768                     dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
    1769                     return wnd->getWindowHandle();
    1770                 }
    1771             }
    1772             hwnd = OSLibWinGetNextWindow(henum);
    1773         }
    1774         OSLibWinEndEnumWindows(henum);
     1744        Win32BaseWindow *wnd;
     1745        HWND henum, hwnd;
     1746
     1747        henum = OSLibWinBeginEnumWindows(OSLIB_HWND_DESKTOP);
     1748        hwnd = OSLibWinGetNextWindow(henum);
     1749
     1750        while(hwnd)
     1751        {
     1752            wnd = GetWindowFromOS2Handle(hwnd);
     1753            if(wnd == NULL) {
     1754                hwnd = OSLibWinQueryClientWindow(hwnd);
     1755                if(hwnd)  wnd = GetWindowFromOS2Handle(hwnd);
     1756            }
     1757
     1758            if(wnd) {
     1759                LPVOID sharedmembase = (LPVOID)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_SHAREDMEM);
     1760
     1761                if(OSLibDosGetSharedMem(sharedmembase, MAX_HEAPSIZE, OSLIB_PAG_READ) != 0) {
     1762                    dprintf(("OSLibDosGetSharedMem returned error for %x", wnd));
     1763                    break;
     1764                }
     1765                if(wnd->getWindowClass()->hasClassName(lpszClass, fUnicode) &&
     1766                   (!lpszWindow || wnd->hasWindowName(lpszWindow, fUnicode)))
     1767                {
     1768                    OSLibWinEndEnumWindows(henum);
     1769                    dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
     1770                    return wnd->getWindowHandle();
     1771                }
     1772            }
     1773            hwnd = OSLibWinGetNextWindow(henum);
     1774        }
     1775        OSLibWinEndEnumWindows(henum);
    17751776    }
    17761777    SetLastError(ERROR_CANNOT_FIND_WND_CLASS); //TODO: not always correct
     
    17831784{
    17841785 Win32BaseWindow  *win32wnd;
    1785  ULONG         magic;
    1786  ULONG         getcmd = 0;
    1787  HWND          hwndRelated;
     1786 ULONG         magic;
     1787 ULONG         getcmd = 0;
     1788 HWND          hwndRelated;
    17881789
    17891790    dprintf(("GetWindow %x %d NOT COMPLETE", getWindowHandle(), uCmd));
    17901791    switch(uCmd)
    17911792    {
    1792         case GW_CHILD:
    1793             getcmd = QWOS_TOP;
    1794             break;
    1795         case GW_HWNDFIRST:
    1796             if(getParent()) {
    1797                     getcmd = QWOS_TOP; //top of child windows
    1798             }
    1799             else    getcmd = QWOS_TOP; //TODO
    1800             break;
    1801         case GW_HWNDLAST:
    1802             if(getParent()) {
    1803                     getcmd = QWOS_BOTTOM; //bottom of child windows
    1804             }
    1805             else    getcmd = QWOS_BOTTOM; //TODO
    1806             break;
    1807         case GW_HWNDNEXT:
    1808             getcmd = QWOS_NEXT;
    1809             break;
    1810         case GW_HWNDPREV:
    1811             getcmd = QWOS_PREV;
    1812             break;
    1813         case GW_OWNER:
    1814             if(owner) {
    1815                     return owner->getWindowHandle();
    1816             }
    1817             else    return 0;
     1793        case GW_CHILD:
     1794            getcmd = QWOS_TOP;
     1795            break;
     1796        case GW_HWNDFIRST:
     1797            if(getParent()) {
     1798                    getcmd = QWOS_TOP; //top of child windows
     1799            }
     1800            else    getcmd = QWOS_TOP; //TODO
     1801            break;
     1802        case GW_HWNDLAST:
     1803            if(getParent()) {
     1804                    getcmd = QWOS_BOTTOM; //bottom of child windows
     1805            }
     1806            else    getcmd = QWOS_BOTTOM; //TODO
     1807            break;
     1808        case GW_HWNDNEXT:
     1809            getcmd = QWOS_NEXT;
     1810            break;
     1811        case GW_HWNDPREV:
     1812            getcmd = QWOS_PREV;
     1813            break;
     1814        case GW_OWNER:
     1815            if(owner) {
     1816                    return owner->getWindowHandle();
     1817            }
     1818            else    return 0;
    18181819    }
    18191820    hwndRelated = OSLibWinQueryWindow(OS2Hwnd, getcmd);
    18201821    if(hwndRelated)
    18211822    {
    1822         win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR);
    1823         magic    = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC);
    1824         if(CheckMagicDword(magic) && win32wnd)
    1825         {
    1826             return win32wnd->getWindowHandle();
    1827         }
     1823        win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR);
     1824        magic    = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC);
     1825        if(CheckMagicDword(magic) && win32wnd)
     1826        {
     1827            return win32wnd->getWindowHandle();
     1828        }
    18281829    }
    18291830    return 0;
     
    18521853HWND Win32BaseWindow::GetActiveWindow()
    18531854{
    1854  HWND          hwndActive;
     1855 HWND          hwndActive;
    18551856 Win32BaseWindow  *win32wnd;
    1856  ULONG         magic;
     1857 ULONG         magic;
    18571858
    18581859  hwndActive = OSLibWinQueryActiveWindow();
     
    18621863  if(CheckMagicDword(magic) && win32wnd)
    18631864  {
    1864         return win32wnd->getWindowHandle();
     1865        return win32wnd->getWindowHandle();
    18651866  }
    18661867  return hwndActive;
     
    18951896{
    18961897    if(fUnicode) {
    1897             return (lstrcmpW(windowNameW, (LPWSTR)wndname) == 0);
     1898            return (lstrcmpW(windowNameW, (LPWSTR)wndname) == 0);
    18981899    }
    18991900    else    return (strcmp(windowNameA, wndname) == 0);
     
    19161917{
    19171918    if(lpsz == NULL)
    1918         return FALSE;
     1919        return FALSE;
    19191920
    19201921    if(isUnicode == FALSE) {
    1921         windowNameA = (LPSTR)_smalloc(strlen(lpsz)+1);
    1922         strcpy(windowNameA, lpsz);
    1923         windowNameW = (LPWSTR)_smalloc((strlen(lpsz)+1)*sizeof(WCHAR));
    1924         lstrcpyAtoW(windowNameW, windowNameA);
     1922        windowNameA = (LPSTR)_smalloc(strlen(lpsz)+1);
     1923        strcpy(windowNameA, lpsz);
     1924        windowNameW = (LPWSTR)_smalloc((strlen(lpsz)+1)*sizeof(WCHAR));
     1925        lstrcpyAtoW(windowNameW, windowNameA);
    19251926    }
    19261927    else {
    1927         windowNameW = (LPWSTR)_smalloc((lstrlenW((LPWSTR)lpsz)+1)*sizeof(WCHAR));
    1928         lstrcpyW(windowNameW, (LPWSTR)lpsz);
    1929         windowNameA = (LPSTR)_smalloc(lstrlenW((LPWSTR)lpsz)+1);
    1930         lstrcpyWtoA(windowNameA, windowNameW);
     1928        windowNameW = (LPWSTR)_smalloc((lstrlenW((LPWSTR)lpsz)+1)*sizeof(WCHAR));
     1929        lstrcpyW(windowNameW, (LPWSTR)lpsz);
     1930        windowNameA = (LPSTR)_smalloc(lstrlenW((LPWSTR)lpsz)+1);
     1931        lstrcpyWtoA(windowNameA, windowNameW);
    19311932    }
    19321933    wndNameLength = strlen(windowNameA)+1; //including 0 terminator
    19331934
    19341935    if(OS2Hwnd)
    1935         return OSLibWinSetWindowText(OS2Hwnd, (LPSTR)windowNameA);
     1936        return OSLibWinSetWindowText(OS2Hwnd, (LPSTR)windowNameA);
    19361937
    19371938    return TRUE;
     
    19441945
    19451946   switch(index) {
    1946         case GWL_EXSTYLE:
    1947                 oldval = dwExStyle;
    1948                 dwExStyle = value;
    1949                 return oldval;
    1950         case GWL_STYLE:
    1951                 oldval = dwStyle;
    1952                 dwStyle = value;
    1953                 return oldval;
    1954         case GWL_WNDPROC:
    1955                 oldval = (LONG)getWindowProc();
    1956                 setWindowProc((WNDPROC)value);
    1957                 return oldval;
    1958         case GWL_HINSTANCE:
    1959                 oldval = hInstance;
    1960                 hInstance = value;
    1961                 return oldval;
    1962         case GWL_HWNDPARENT:
    1963                 return SetParent((HWND)value);
    1964 
    1965         case GWL_ID:
    1966                 oldval = getWindowId();
    1967                 setWindowId(value);
    1968                 return oldval;
    1969         case GWL_USERDATA:
    1970                 oldval = userData;
    1971                 userData = value;
    1972                 return oldval;
    1973         default:
    1974                 if(index >= 0 && index/4 < nrUserWindowLong)
    1975                 {
    1976                         oldval = userWindowLong[index/4];
    1977                         userWindowLong[index/4] = value;
    1978                         return oldval;
    1979                 }
    1980                 SetLastError(ERROR_INVALID_PARAMETER);
    1981                 return 0;
     1947        case GWL_EXSTYLE:
     1948                oldval = dwExStyle;
     1949                dwExStyle = value;
     1950                return oldval;
     1951        case GWL_STYLE:
     1952                oldval = dwStyle;
     1953                dwStyle = value;
     1954                return oldval;
     1955        case GWL_WNDPROC:
     1956                oldval = (LONG)getWindowProc();
     1957                setWindowProc((WNDPROC)value);
     1958                return oldval;
     1959        case GWL_HINSTANCE:
     1960                oldval = hInstance;
     1961                hInstance = value;
     1962                return oldval;
     1963        case GWL_HWNDPARENT:
     1964                return SetParent((HWND)value);
     1965
     1966        case GWL_ID:
     1967                oldval = getWindowId();
     1968                setWindowId(value);
     1969                return oldval;
     1970        case GWL_USERDATA:
     1971                oldval = userData;
     1972                userData = value;
     1973                return oldval;
     1974        default:
     1975                if(index >= 0 && index/4 < nrUserWindowLong)
     1976                {
     1977                        oldval = userWindowLong[index/4];
     1978                        userWindowLong[index/4] = value;
     1979                        return oldval;
     1980                }
     1981                SetLastError(ERROR_INVALID_PARAMETER);
     1982                return 0;
    19821983   }
    19831984}
     
    19871988{
    19881989   switch(index) {
    1989         case GWL_EXSTYLE:
    1990                 return dwExStyle;
    1991         case GWL_STYLE:
    1992                 return dwStyle;
    1993         case GWL_WNDPROC:
    1994                 return (ULONG)getWindowProc();
    1995         case GWL_HINSTANCE:
    1996                 return hInstance;
    1997         case GWL_HWNDPARENT:
    1998                 if(getParent()) {
    1999                         return getParent()->getWindowHandle();
    2000                 }
    2001                 else    return 0;
    2002         case GWL_ID:
    2003                 return getWindowId();
    2004         case GWL_USERDATA:
    2005                 return userData;
    2006         default:
    2007                 if(index >= 0 && index/4 < nrUserWindowLong)
    2008                 {
    2009                         return userWindowLong[index/4];
    2010                 }
    2011                 SetLastError(ERROR_INVALID_PARAMETER);
    2012                 return 0;
     1990        case GWL_EXSTYLE:
     1991                return dwExStyle;
     1992        case GWL_STYLE:
     1993                return dwStyle;
     1994        case GWL_WNDPROC:
     1995                return (ULONG)getWindowProc();
     1996        case GWL_HINSTANCE:
     1997                return hInstance;
     1998        case GWL_HWNDPARENT:
     1999                if(getParent()) {
     2000                        return getParent()->getWindowHandle();
     2001                }
     2002                else    return 0;
     2003        case GWL_ID:
     2004                return getWindowId();
     2005        case GWL_USERDATA:
     2006                return userData;
     2007        default:
     2008                if(index >= 0 && index/4 < nrUserWindowLong)
     2009                {
     2010                        return userWindowLong[index/4];
     2011                }
     2012                SetLastError(ERROR_INVALID_PARAMETER);
     2013                return 0;
    20132014   }
    20142015}
     
    20212022   if(index >= 0 && index/4 < nrUserWindowLong)
    20222023   {
    2023         oldval = ((WORD *)userWindowLong)[index/2];
    2024         ((WORD *)userWindowLong)[index/2] = value;
    2025         return oldval;
     2024        oldval = ((WORD *)userWindowLong)[index/2];
     2025        ((WORD *)userWindowLong)[index/2] = value;
     2026        return oldval;
    20262027   }
    20272028   SetLastError(ERROR_INVALID_PARAMETER);
     
    20342035   if(index >= 0 && index/4 < nrUserWindowLong)
    20352036   {
    2036         return ((WORD *)userWindowLong)[index/2];
     2037        return ((WORD *)userWindowLong)[index/2];
    20372038   }
    20382039   SetLastError(ERROR_INVALID_PARAMETER);
     
    20462047
    20472048   if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
    2048         return window;
     2049        return window;
    20492050   }
    20502051   else return NULL;
     
    20552056{
    20562057 Win32BaseWindow *win32wnd;
    2057  DWORD        magic;
     2058 DWORD        magic;
    20582059
    20592060  win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
     
    20612062
    20622063  if(win32wnd && CheckMagicDword(magic)) {
    2063         return win32wnd;
     2064        return win32wnd;
    20642065  }
    20652066  return 0;
Note: See TracChangeset for help on using the changeset viewer.