Changeset 5685 for trunk/src


Ignore:
Timestamp:
May 11, 2001, 10:39:46 AM (24 years ago)
Author:
sandervl
Message:

client/frame rewrite

Location:
trunk/src/user32
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/Makefile

    r5496 r5685  
    1 # $Id: Makefile,v 1.82 2001-04-12 14:04:32 sandervl Exp $
     1# $Id: Makefile,v 1.83 2001-05-11 08:39:41 sandervl Exp $
    22
    33#
     
    1818#
    1919!ifndef WAT
    20 CDEFINES = $(CDEFINES) -DINVERT -DODIN_HITTEST
     20CDEFINES = $(CDEFINES) -DINVERT -DCLIENTFRAME
    2121!else
    22 CDEFINES += -DINVERT -DODIN_HITTEST
     22CDEFINES += -DINVERT -DCLIENTFRAME
    2323!endif
    2424
  • trunk/src/user32/caret.cpp

    r4976 r5685  
    1 /* $Id: caret.cpp,v 1.16 2001-01-19 23:03:45 sandervl Exp $ */
     1/* $Id: caret.cpp,v 1.17 2001-05-11 08:39:41 sandervl Exp $ */
    22
    33/*
     
    157157        else
    158158        {
    159            long height = wnd->getWindowHeight();
    160            caretPos.y = height - (caretPos.y + wnd->getClientRectPtr()->top) - 1;
    161            xNew = caretPos.x + wnd->getClientRectPtr()->left;
     159           long height = wnd->getClientHeight();
     160           caretPos.y = height - caretPos.y;
     161           xNew = caretPos.x;
    162162           yNew = caretPos.y - cursorInfo.cy;
    163163        }
     
    208208         }
    209209         else {
    210             long height   = wnd->getWindowHeight();
     210            long height   = wnd->getClientHeight();
    211211            caretPos.y   += cursorInfo.cy;
    212             cursorInfo.y  = height - caretPos.y - wnd->getClientRectPtr()->top - 1;
    213             cursorInfo.x -= wnd->getClientRectPtr()->left;
     212            cursorInfo.y  = height - caretPos.y;
    214213         }
    215214      }
  • trunk/src/user32/dc.cpp

    r5655 r5685  
    1 /* $Id: dc.cpp,v 1.98 2001-05-04 17:02:50 sandervl Exp $ */
     1/* $Id: dc.cpp,v 1.99 2001-05-11 08:39:41 sandervl Exp $ */
    22
    33/*
     
    387387VOID removeClientArea(Win32BaseWindow *window, pDCData pHps)
    388388{
    389  POINTL point;
    390 
    391    // This function checks to see if a client area is currently selected, if
    392    // it is the origin plus the visible region of the frame are restored.
    393 
    394389   pHps->isClient = FALSE;
    395 
    396 ////   dprintfOrigin(pHps->hps);
    397 
    398    if(pHps->isClientArea)
    399    {
    400         dprintf2(("removeClientArea %x: (%d,%d) -> (%d,%d)", window->getWindowHandle(), point.x, point.y, pHps->ptlOrigin.x, pHps->ptlOrigin.y));
    401         pHps->isClientArea = FALSE;
    402         GreSetupDC(pHps->hps,
    403                    pHps->hrgnVis,
    404                    pHps->ptlOrigin.x,
    405                    pHps->ptlOrigin.y,
    406                    0,
    407                    SETUPDC_ORIGIN | SETUPDC_VISRGN | SETUPDC_RECALCCLIP);
    408    }
    409 ////   else dprintf2(("removeClientArea: %x (%d,%d) (%d,%d)", window->getWindowHandle(), point.x, point.y, pHps->ptlOrigin.x, pHps->ptlOrigin.y));
    410 
     390   pHps->isClientArea = FALSE;
    411391}
    412392//******************************************************************************
     
    414394void selectClientArea(Win32BaseWindow *window, pDCData pHps)
    415395{
    416    // This function checks to see if the DC needs to be adjusted to a client
    417    // area and makes the adjustment.
    418    RECTL rcl, rcltemp;
    419    HRGN  hrgnRect, hrgnClip, hrgnOldClip = 0;
    420    HWND  hwnd;
    421    LONG  rc;
    422    PRECT pClient = window->getClientRectPtr();
    423    PRECT pWindow = window->getWindowRect();
    424    RECT  rectWindow;
    425    RECTL rectWindowOS2;
    426 
    427    if(!window->isOwnDCDirty() && (pClient->left == 0 && pClient->top == 0 &&
    428       window->getClientHeight() == window->getWindowHeight() &&
    429       window->getClientWidth()  == window->getWindowWidth()))
    430    {
    431         //client rectangle = frame rectangle -> no change necessary
    432         return;
    433    }
    434396   pHps->isClient = TRUE;
    435 
    436    hwnd = window->getOS2WindowHandle();
    437 
    438    mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&rcl);
    439 
    440    GetWindowRect(window->getWindowHandle(), &rectWindow);
    441    mapWin32ToOS2Rect(GetScreenHeight(), &rectWindow, (PRECTLOS2)&rectWindowOS2);
    442    dprintf2(("frame (%d,%d)(%d,%d) hps height %d", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop, pHps->height));
    443 
    444    //convert to screen coordinates
    445    GreGetDCOrigin(pHps->hps, (PPOINTL)&rcltemp);
    446 
    447    if(pHps->isClientArea)
    448    {
    449         //TODO: counter
    450         dprintf2(("WARNING: selectClientArea %x; already selected! origin (%d,%d) original origin (%d,%d)", window->getWindowHandle(), rcltemp.xLeft, rcltemp.yBottom, pHps->ptlOrigin.x, pHps->ptlOrigin.y));
    451         GetWindowRect(window->getWindowHandle(), &rectWindow);
    452         mapWin32ToOS2Rect(GetScreenHeight(), &rectWindow, (PRECTLOS2)&rectWindowOS2);
    453         if(rectWindowOS2.xLeft + rcl.xLeft != rcltemp.xLeft ||
    454            rectWindowOS2.yBottom + rcl.yBottom != rcltemp.yBottom)
    455         {
    456                 dprintf2(("WARNING: origin changed (%d,%d) instead of (%d,%d)!", rcltemp.xLeft, rcltemp.yBottom, rectWindowOS2.xLeft + rcl.xLeft, rectWindowOS2.yBottom + rcl.yBottom));
    457                 rcl.xLeft   += rectWindowOS2.xLeft;
    458                 rcl.xRight  += rectWindowOS2.xLeft;
    459                 rcl.yTop    += rectWindowOS2.yBottom;
    460                 rcl.yBottom += rectWindowOS2.yBottom;
    461         }
    462         else    return;
    463    }
    464    else {
    465         rcl.xLeft   += rcltemp.xLeft;
    466         rcl.xRight  += rcltemp.xLeft;
    467         rcl.yTop    += rcltemp.yBottom;
    468         rcl.yBottom += rcltemp.yBottom;
    469 
    470         pHps->ptlOrigin.x = rcltemp.xLeft;
    471         pHps->ptlOrigin.y = rcltemp.yBottom;
    472    }
    473    dprintf2(("selectClientArea %x: (%d,%d) -> (%d,%d)", window->getWindowHandle(), rcltemp.xLeft, rcltemp.yBottom, rcl.xLeft, rcl.yBottom));
    474 
    475    if(pHps->hrgnVis == 0)
    476         pHps->hrgnVis = GreCreateRectRegion(pHps->hps, &rcl, 1);
    477 
    478    hrgnRect = GreCreateRectRegion(pHps->hps, &rcl, 1);
    479 #if 0
    480    if(window->getParent())
    481    {
    482      HRGN hrgnParentClip;
    483 
    484         pClient = window->getParent()->getClientRectPtr();
    485         GetWindowRect(window->getParent()->getWindowHandle(), &rectWindow);
    486         rectWindow.right   = rectWindow.left + pClient->right;
    487         rectWindow.left   += pClient->left;
    488         rectWindow.bottom  = rectWindow.top + pClient->bottom;
    489         rectWindow.top    += pClient->top;
    490         mapWin32ToOS2Rect(GetScreenHeight(), &rectWindow, (PRECTLOS2)&rectWindowOS2);
    491 
    492         hrgnParentClip = GreCreateRectRegion(pHps->hps, &rectWindowOS2, 1);
    493 #ifdef DEBUG
    494         dprintf(("Combining client & parent client regions"));
    495         dprintfRegion1(pHps->hps, window->getWindowHandle(), hrgnParentClip);
    496         dprintfRegion1(pHps->hps, window->getWindowHandle(), hrgnRect);
    497 #endif
    498 
    499         GreCombineRegion(pHps->hps, hrgnRect, hrgnParentClip, hrgnRect, CRGN_AND);
    500         GreDestroyRegion(pHps->hps, hrgnParentClip);
    501    }
    502 #endif
    503 
    504    // Query the visible region
    505    GreCopyClipRegion(pHps->hps, pHps->hrgnVis, 0, COPYCRGN_VISRGN);
    506    GpiQueryRegionBox(pHps->hps, pHps->hrgnVis, &rcltemp);
    507    // And the visible region of the frame with the client rectangle
    508    // to get the new visible region
    509    GreCombineRegion(pHps->hps, hrgnRect, pHps->hrgnVis, hrgnRect, CRGN_AND);
    510 #ifdef DEBUG
    511    dprintfRegion1(pHps->hps, window->getWindowHandle(), hrgnRect);
    512 #endif
    513 
    514    // Set the new origin plus visible region in the DC
    515    GreSetupDC(pHps->hps,
    516               hrgnRect,
    517               rcl.xLeft,
    518               rcl.yBottom,
    519               NULL,
    520               SETUPDC_ORIGIN | SETUPDC_VISRGN | SETUPDC_RECALCCLIP);
    521 
    522    // Destroy the region now we have finished with it.
    523    GreDestroyRegion(pHps->hps, hrgnRect);
    524 
    525397   pHps->isClientArea = TRUE;
    526 
    527    if(pClient->left == 0 && pClient->top == 0 &&
    528       window->getClientHeight() == window->getWindowHeight() &&
    529       window->getClientWidth()  == window->getWindowWidth())
    530    {
    531        //client = frame, so no changes are necessary when switching between the two
    532        pHps->isClient = FALSE;
    533        pHps->isClientArea = FALSE;
    534    }
    535    if(window->isOwnDCDirty()) {
    536        window->validateOwnDC();
    537        setPageXForm(window, pHps);
    538    }
    539 
    540 //testestest
    541 #if 0
    542    GpiQueryViewingLimits(pHps->hps, &rectWindowOS2);
    543    dprintf2(("view limits (%d,%d)(%d,%d)", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop));
    544    GpiQueryDefViewingLimits(pHps->hps, &rectWindowOS2);
    545    dprintf2(("def view limits (%d,%d)(%d,%d)", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop));
    546    GpiQueryPageViewport(pHps->hps, &rectWindowOS2);
    547    dprintf2(("page viewport (%d,%d)(%d,%d)", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop));
    548 
    549    GpiQueryBoundaryData(pHps->hps, &rectWindowOS2);
    550    dprintf2(("boundary data (%d,%d)(%d,%d)", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop));
    551 
    552    GpiQueryGraphicsField(pHps->hps, &rectWindowOS2);
    553    dprintf2(("graphics field (%d,%d)(%d,%d)", rectWindowOS2.xLeft, rectWindowOS2.yBottom, rectWindowOS2.xRight, rectWindowOS2.yTop));
    554 
    555    SIZEL size;
    556    GpiQueryPickApertureSize(pHps->hps, &size);
    557    dprintf2(("page viewport (%d,%d)", size.cx, size.cy));
    558 
    559    GpiQueryPS(pHps->hps, &size);
    560    dprintf2(("page space (%d,%d)", size.cx, size.cy));
    561 #endif
    562 //testestest
    563 
    564398}
    565399//******************************************************************************
     
    576410LONG clientHeight(Win32BaseWindow *wnd, HWND hwnd, pDCData pHps)
    577411{
    578    if ((hwnd == 0) && (pHps != 0))
    579       hwnd = pHps->hwnd;
    580 
    581    if ((hwnd != 0) || (pHps == 0))
    582    {
     412    if ((hwnd == 0) && (pHps != 0))
     413        hwnd = pHps->hwnd;
     414
     415    if ((hwnd != 0) || (pHps == 0))
     416    {
    583417        if(wnd) {
    584                 if(pHps && !pHps->isClientArea) {
    585                         return (wnd->getWindowHeight());
    586                 }
    587                 else    return (wnd->getClientHeight());
    588         }
    589         else    return OSLibQueryScreenHeight();
    590    }
    591    else if (pHps->bitmapHandle)
    592    {
    593       return pHps->bitmapHeight;
    594    }
    595    else if (pHps->isMetaPS)
    596    {
    597       return 0;
    598    }
    599    else if (pHps->isPrinter)
    600    {
    601       return pHps->printPageHeight;
    602    }
    603    else
    604    {
    605       return MEM_HPS_MAX;
    606    }
    607 }
    608 //******************************************************************************
    609 //******************************************************************************
    610 BOOL   WIN32API changePageXForm(pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev)
     418            if(pHps && !pHps->isClientArea) {
     419                return (wnd->getWindowHeight());
     420            }
     421            else return (wnd->getClientHeight());
     422        }
     423        else return OSLibQueryScreenHeight();
     424    }
     425    else if (pHps->bitmapHandle)
     426    {
     427        return pHps->bitmapHeight;
     428    }
     429    else if (pHps->isMetaPS)
     430    {
     431        return 0;
     432    }
     433    else if (pHps->isPrinter)
     434    {
     435        return pHps->printPageHeight;
     436    }
     437    else
     438    {
     439        return MEM_HPS_MAX;
     440    }
     441}
     442//******************************************************************************
     443//******************************************************************************
     444BOOL WIN32API changePageXForm(pDCData pHps, PPOINTL pValue, int x, int y, PPOINTL pPrev)
    611445{
    612446 Win32BaseWindow *wnd;
    613447
    614    wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     448   if(pHps->isClient) {
     449        wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     450   }
     451   else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
    615452   return changePageXForm(wnd, pHps, pValue, x, y, pPrev);
    616453}
    617454//******************************************************************************
    618455//******************************************************************************
    619 BOOL   WIN32API setPageXForm(pDCData pHps)
     456BOOL WIN32API setPageXForm(pDCData pHps)
    620457{
    621458 Win32BaseWindow *wnd;
    622459
    623    wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     460   if(pHps->isClient) {
     461        wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     462   }
     463   else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
    624464   return setPageXForm(wnd, pHps);
    625465}
    626466//******************************************************************************
    627467//******************************************************************************
    628 VOID   WIN32API removeClientArea(pDCData pHps)
     468VOID WIN32API removeClientArea(pDCData pHps)
    629469{
    630470 Win32BaseWindow *wnd;
    631471
    632    wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     472   if(pHps->isClient) {
     473        wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     474   }
     475   else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
    633476   if(wnd) {
    634477      removeClientArea(wnd, pHps);
     
    641484 Win32BaseWindow *wnd;
    642485
    643    wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     486   if(pHps->isClient) {
     487        wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     488   }
     489   else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
    644490   if(wnd) {
    645491      selectClientArea(wnd, pHps);
     
    652498 Win32BaseWindow *wnd;
    653499
    654    wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     500   if(pHps->isClient) {
     501        wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     502   }
     503   else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
    655504   if(wnd) {
    656       dprintfOrigin(pHps->hps);
    657505      if(pHps->isClient)
    658506          selectClientArea(wnd, pHps);
     
    661509//******************************************************************************
    662510//******************************************************************************
    663 LONG   WIN32API clientHeight(HWND hwnd, pDCData pHps)
     511LONG WIN32API clientHeight(HWND hwnd, pDCData pHps)
    664512{
    665513 Win32BaseWindow *wnd;
    666514
    667    wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     515   if(pHps->isClient) {
     516        wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     517   }
     518   else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
    668519   return clientHeight(wnd, hwnd, pHps);
    669520}
    670521//******************************************************************************
    671522//******************************************************************************
    672 int  WIN32API setMapMode(pDCData pHps, int mode)
     523int WIN32API setMapMode(pDCData pHps, int mode)
    673524{
    674525 Win32BaseWindow *wnd;
    675526
    676    wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     527   if(pHps->isClient) {
     528        wnd = Win32BaseWindow::GetWindowFromOS2Handle(pHps->hwnd);
     529   }
     530   else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
    677531   return setMapMode(wnd, pHps, mode);
    678532}
     
    790644 RECTL    rectlClip;
    791645
    792    if(lpps == NULL) {
     646    if(lpps == NULL) {
    793647        //BeginPaint does NOT change last error in this case
    794648        //(verified in NT4, SP6)
    795649        dprintf (("USER32: BeginPaint %x NULL PAINTSTRUCT pointer", hWnd));
    796650        return 0;
    797    }
    798    memset(lpps, 0, sizeof(*lpps));
    799 
    800    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    801    if(!wnd) {
     651    }
     652    memset(lpps, 0, sizeof(*lpps));
     653
     654    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     655    if(!wnd) {
    802656        dprintf (("USER32: BeginPaint %x %x: invalid window handle!!", hWnd, lpps));
    803657        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W); //(verified in NT4, SP6)
    804658        return (HDC)0;
    805    }
    806    HWND hwndClient = wnd->getOS2WindowHandle();
    807 
    808    if(hwnd != HWND_DESKTOP && wnd->isOwnDC())
    809    {
     659    }
     660    HWND hwndClient = wnd->getOS2WindowHandle();
     661
     662    if(hwnd != HWND_DESKTOP && wnd->isOwnDC())
     663    {
    810664        hPS_ownDC = wnd->getOwnDC();
    811665        //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
    812666        if(hPS_ownDC) {
    813                 pHps = (pDCData)GpiQueryDCData(hPS_ownDC);
    814                 if (!pHps)
    815                 {
    816                         dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
    817                         SetLastError(ERROR_INVALID_PARAMETER_W);
    818                         return (HDC)NULLHANDLE;
    819                 }
    820                 hpsPaint = hPS_ownDC;
    821         }
    822    }
    823    if(!hpsPaint) {
    824         hpsPaint = GetDCEx(hwnd, 0, (DCX_CACHE_W|DCX_WINDOW_W|DCX_USESTYLE_W));
     667            pHps = (pDCData)GpiQueryDCData(hPS_ownDC);
     668            if (!pHps)
     669            {
     670                dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
     671                SetLastError(ERROR_INVALID_PARAMETER_W);
     672                return (HDC)NULLHANDLE;
     673            }
     674            hpsPaint = hPS_ownDC;
     675        }
     676    }
     677    if(!hpsPaint) {
     678        hpsPaint = GetDCEx(hwnd, 0, (DCX_CACHE_W|DCX_USESTYLE_W));
    825679        pHps = (pDCData)GpiQueryDCData(hpsPaint);
    826680        if (!pHps)
    827681        {
    828                 dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
    829                 SetLastError(ERROR_INVALID_PARAMETER_W);
    830                 return (HDC)NULLHANDLE;
    831         }
    832    }
    833 
    834    if(WinQueryUpdateRect(hwndClient, &rectl) == FALSE) {
     682            dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
     683            SetLastError(ERROR_INVALID_PARAMETER_W);
     684            return (HDC)NULLHANDLE;
     685        }
     686    }
     687
     688    if(WinQueryUpdateRect(hwndClient, &rectl) == FALSE)
     689    {
    835690        memset(&rectl, 0, sizeof(rectl));
    836691        dprintf (("USER32: WARNING: WinQueryUpdateRect failed (error or no update rectangle)!!"));
     
    844699        wnd->SetClipRegion(hrgnOldClip);
    845700        lComplexity = RGN_NULL;
    846    }
    847    else {
     701    }
     702    else {
    848703        rectlClip.yBottom = rectlClip.xLeft = 0;
    849704        rectlClip.yTop = rectlClip.xRight = 1;
     
    854709        WinValidateRegion(hwndClient, hrgnClip, FALSE);
    855710
    856         mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient);
    857         WinIntersectRect(NULL, &rectlClip, &rectl, &rectlClient);
    858         WinOffsetRect(NULL, &rectlClip, -rectlClient.xLeft, -rectlClient.yBottom);
    859 
    860         //clip update region with client window rectangle
    861         HRGN hrgnClient = GpiCreateRegion(pHps->hps, 1, &rectlClient);
    862         GpiCombineRegion(pHps->hps, hrgnClip, hrgnClip, hrgnClient, CRGN_AND);
    863         GpiDestroyRegion(pHps->hps, hrgnClient);
    864 
    865         //change origin of clip region (window -> client)
    866         POINTL point = {-rectlClient.xLeft, -rectlClient.yBottom};
    867         GpiOffsetRegion(pHps->hps, hrgnClip, &point);
     711        dprintfRegion(pHps->hps, wnd->getWindowHandle(), hrgnClip);
     712
    868713#ifdef DEBUG
    869         dprintfRegion1(pHps->hps, hWnd, hrgnClip);
     714        lComplexity = GpiQueryClipBox(pHps->hps, &rectlClip);
     715        dprintf(("ClipBox (%d): (%d,%d)(%d,%d)", lComplexity, rectlClip.xLeft, rectlClip.yBottom, rectlClip.xRight, rectlClip.yTop));
    870716#endif
     717
    871718        //set clip region
    872719        lComplexity = GpiSetClipRegion(pHps->hps, hrgnClip, &hrgnOldClip);
    873720
    874         //change presentation space for client window
    875         //NOTE: MUST do this after GpiSetClipRegion call!
    876         //      When a window with CS_OWNDC looses focus, for some reason
    877         //      GpiSetClipRegion resets the window dc origin back to (0,0)
     721        if(lComplexity == RGN_NULL) {
     722            dprintf (("BeginPaint %x: EMPTY update rectangle (show=%d/%d vis=%d/%d", hWnd,  WinIsWindowVisible(wnd->getOS2FrameWindowHandle()), WinIsWindowVisible(wnd->getOS2WindowHandle()),  WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle())));
     723        }
    878724        selectClientArea(wnd, pHps);
    879725
    880         GpiQueryClipBox(pHps->hps, &rectl);
    881         dprintf(("ClipBox (%d): (%d,%d)(%d,%d)", lComplexity, rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
    882 
     726#ifdef DEBUG
     727        GpiQueryClipBox(pHps->hps, &rectlClip);
     728        dprintf(("ClipBox (%d): (%d,%d)(%d,%d)", lComplexity, rectlClip.xLeft, rectlClip.yBottom, rectlClip.xRight, rectlClip.yTop));
     729#endif
    883730        //save old clip region (restored for CS_OWNDC windows in EndPaint)
    884731        wnd->SetClipRegion(hrgnOldClip);
    885         memcpy(&rectl, &rectlClip, sizeof(RECTL));
    886         lComplexity = RGN_RECT;
    887    }
    888 
    889    if(hPS_ownDC == 0)
    890       setMapMode (wnd, pHps, MM_TEXT_W);
    891    else
    892       setPageXForm(wnd, pHps);
    893 
    894    pHps->hdcType = TYPE_3;
    895 
    896    HideCaret(hwnd);
    897    WinShowTrackRect(wnd->getOS2WindowHandle(), FALSE);
    898 
    899    if(wnd->needsEraseBkgnd() && lComplexity != RGN_NULL) {
     732    }
     733
     734    if(hPS_ownDC == 0)
     735        setMapMode (wnd, pHps, MM_TEXT_W);
     736    else
     737        setPageXForm(wnd, pHps);
     738
     739    pHps->hdcType = TYPE_3;
     740
     741    HideCaret(hwnd);
     742    WinShowTrackRect(wnd->getOS2WindowHandle(), FALSE);
     743
     744    if((wnd->needsEraseBkgnd() || wnd->IsVisibleRegionChanged()) && lComplexity != RGN_NULL) {
    900745        wnd->setEraseBkgnd(FALSE);
     746        wnd->SetVisibleRegionChanged(FALSE);
    901747        lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) == 0);
    902    }
    903    else lpps->fErase = TRUE;
    904 
    905    dprintfOrigin(pHps->hps);
    906 
    907    lpps->hdc    = (HDC)pHps->hps;
    908 
    909    if(lComplexity != RGN_NULL) {
     748    }
     749    else lpps->fErase = TRUE;
     750
     751    lpps->hdc    = (HDC)pHps->hps;
     752
     753    if(lComplexity != RGN_NULL) {
    910754        long height  = wnd->getClientHeight();
    911755        lpps->rcPaint.top    = height - rectl.yTop;
     
    913757        lpps->rcPaint.bottom = height - rectl.yBottom;
    914758        lpps->rcPaint.right  = rectl.xRight;
    915    }
    916    else {
     759    }
     760    else {
    917761        lpps->rcPaint.bottom = lpps->rcPaint.top = 0;
    918762        lpps->rcPaint.right = lpps->rcPaint.left = 0;
    919    }
    920 
    921    SetLastError(0);
    922    dprintf(("USER32: BeginPaint %x -> hdc %x (%d,%d)(%d,%d)", hWnd, pHps->hps, lpps->rcPaint.left, lpps->rcPaint.top, lpps->rcPaint.right, lpps->rcPaint.bottom));
    923    return (HDC)pHps->hps;
     763    }
     764
     765    SetLastError(0);
     766    dprintf(("USER32: BeginPaint %x -> hdc %x (%d,%d)(%d,%d)", hWnd, pHps->hps, lpps->rcPaint.left, lpps->rcPaint.top, lpps->rcPaint.right, lpps->rcPaint.bottom));
     767    return (HDC)pHps->hps;
    924768}
    925769//******************************************************************************
     
    931775  pDCData pHps;
    932776
    933    dprintf (("USER32: EndPaint(%x)", hwnd));
    934 
    935    if (!pPaint || !pPaint->hdc )
    936       return TRUE;
    937 
    938    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    939 
    940    if (!wnd) goto exit;
    941 
    942    pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc);
    943    if (pHps && (pHps->hdcType == TYPE_3))
    944    {
    945         dprintfOrigin(pHps->hps);
    946 
     777    dprintf (("USER32: EndPaint(%x)", hwnd));
     778
     779    if (!pPaint || !pPaint->hdc )
     780        return TRUE;
     781
     782    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     783
     784    if (!wnd) goto exit;
     785
     786    pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc);
     787    if (pHps && (pHps->hdcType == TYPE_3))
     788    {
    947789        GpiSetClipRegion(pHps->hps, wnd->GetClipRegion(), &hrgnOld);
    948790        wnd->SetClipRegion(0);
    949791        if(hrgnOld) {
    950                 GpiDestroyRegion(pHps->hps, hrgnOld);
     792            GpiDestroyRegion(pHps->hps, hrgnOld);
    951793        }
    952794        pHps->hdcType = TYPE_1; //otherwise Open32's ReleaseDC fails
    953795        ReleaseDC(hwnd, pPaint->hdc);
    954    }
    955    else {
     796    }
     797    else {
    956798        dprintf(("EndPaint: wrong hdc %x!!", pPaint->hdc));
    957    }
    958    wnd->setEraseBkgnd(TRUE);
    959    ShowCaret(hwnd);
    960    WinShowTrackRect(wnd->getOS2WindowHandle(), TRUE);
     799    }
     800    wnd->setEraseBkgnd(TRUE);
     801    ShowCaret(hwnd);
     802    WinShowTrackRect(wnd->getOS2WindowHandle(), TRUE);
    961803
    962804exit:
    963    SetLastError(0);
    964    return TRUE;
     805    SetLastError(0);
     806    return TRUE;
    965807}
    966808//******************************************************************************
     
    971813   int rc;
    972814
    973    if (hwnd)
    974    {
     815    if (hwnd)
     816    {
    975817        Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
    976818        if(wnd == NULL) {
    977                 dprintf(("ERROR: ReleaseDC %x %x failed", hwnd, hdc));
    978                 return 0;
     819            dprintf(("ERROR: ReleaseDC %x %x failed", hwnd, hdc));
     820            return 0;
    979821        }
    980822        isOwnDC = wnd->isOwnDC() && (wnd->getOwnDC() == hdc);
    981823        if(!isOwnDC)
    982824        {
    983                 pDCData  pHps = (pDCData)GpiQueryDCData((HPS)hdc);
    984                 if(pHps && pHps->psType == MICRO_CACHED) {
    985                         removeClientArea(wnd, pHps);
    986                         if(pHps->hrgnVis) {
    987                                 GreDestroyRegion(pHps->hps, pHps->hrgnVis);
    988                                 pHps->hrgnVis = 0;
    989                         }
     825            pDCData  pHps = (pDCData)GpiQueryDCData((HPS)hdc);
     826            if(pHps && pHps->psType == MICRO_CACHED) {
     827                removeClientArea(wnd, pHps);
     828                if(pHps->hrgnVis) {
     829                    GreDestroyRegion(pHps->hps, pHps->hrgnVis);
     830                    pHps->hrgnVis = 0;
    990831                }
    991                 else {
    992                         dprintf(("ERROR: ReleaseDC: pHps == NULL!!"));
    993                         DebugInt3();
    994                 }
     832            }
     833            else {
     834                dprintf(("ERROR: ReleaseDC: pHps == NULL!!"));
     835                DebugInt3();
     836            }
    995837        }
    996838        else {
    997                 dprintf2(("ReleaseDC: CS_OWNDC, not released"));
    998         }
    999    }
    1000 
    1001    if(isOwnDC) {
     839            dprintf2(("ReleaseDC: CS_OWNDC, not released"));
     840        }
     841    }
     842
     843    if(isOwnDC) {
    1002844        rc = TRUE;
    1003    }
    1004    else {
     845    }
     846    else {
    1005847        UnselectGDIObjects(hdc);
    1006848        rc = O32_ReleaseDC (0, hdc);
    1007    }
    1008 
    1009    dprintf(("ReleaseDC %x %x", hwnd, hdc));
    1010    return (rc);
     849    }
     850
     851    dprintf(("ReleaseDC %x %x", hwnd, hdc));
     852    return (rc);
    1011853}
    1012854//******************************************************************************
     
    1035877   PS_Type  psType;
    1036878
    1037    if(hwnd == 0) {
     879    if(hwnd == 0) {
    1038880        dprintf(("error: GetDCEx window %x not found", hwnd));
    1039881        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    1040882        return 0;
    1041    }
    1042 
    1043    if (hwnd)
    1044    {
     883    }
     884
     885    if(hwnd)
     886    {
    1045887        wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1046888        if(wnd == NULL) {
     
    1049891                return 0;
    1050892        }
    1051         hWindow = wnd->getOS2WindowHandle();
    1052    }
    1053 
    1054    isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC()))
    1055                  && !(flags & (DCX_CACHE_W|DCX_WINDOW_W)));
    1056 
    1057    if(isWindowOwnDC) //own dc always for client area
    1058    {
    1059       hps = wnd->getOwnDC();
    1060       if (hps)
    1061       {
    1062         pDCData pHps = (pDCData)GpiQueryDCData (hps);
    1063         if (!pHps)
    1064             goto error;
    1065 
    1066         selectClientArea(wnd, pHps);
    1067 
    1068         //TODO: Is this always necessary??
    1069         setPageXForm (wnd, pHps);
    1070         pHps->hdcType = TYPE_1;
    1071 
    1072         //TODO: intersect/exclude clip region?
    1073         dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps));
    1074         return (HDC)hps;
    1075       }
    1076       else
    1077         creatingOwnDC = TRUE;
    1078    }
    1079 
    1080    if(isWindowOwnDC)
    1081    {
    1082       SIZEL sizel = {0,0};
    1083       hps = GpiCreatePS (WinQueryAnchorBlock (hWindow),
    1084                          WinOpenWindowDC (hWindow),
    1085                          &sizel, PU_PELS | GPIT_MICRO | GPIA_ASSOC );
    1086       psType = MICRO;
    1087       // default cp is OS/2 one: set to windows default (ODIN.INI)
    1088       GpiSetCp(hps, GetDisplayCodepage());
    1089    }
    1090    else
    1091    {
    1092       if (hWindow == HWND_DESKTOP) {
    1093          hps = WinGetScreenPS (hWindow);
    1094       }
    1095       else {
    1096         int clipstyle = 0;
    1097         int clipwnd   = HWND_TOP;
    1098         if(flags & (DCX_USESTYLE_W)) {
     893        if(flags & DCX_WINDOW_W) {
     894             hWindow = wnd->getOS2FrameWindowHandle();
     895        }
     896        else hWindow = wnd->getOS2WindowHandle();
     897    }
     898
     899    isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC()))
     900                    && !(flags & (DCX_CACHE_W|DCX_WINDOW_W)));
     901
     902    if(isWindowOwnDC) //own dc always for client area
     903    {
     904        hps = wnd->getOwnDC();
     905        if (hps)
     906        {
     907            pDCData pHps = (pDCData)GpiQueryDCData (hps);
     908            if (!pHps)
     909                goto error;
     910
     911            selectClientArea(wnd, pHps);
     912
     913            //TODO: Is this always necessary??
     914            setPageXForm (wnd, pHps);
     915            pHps->hdcType = TYPE_1;
     916
     917            //TODO: intersect/exclude clip region?
     918            dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps));
     919            return (HDC)hps;
     920        }
     921        else creatingOwnDC = TRUE;
     922    }
     923
     924    if(isWindowOwnDC)
     925    {
     926        SIZEL sizel = {0,0};
     927        hps = GpiCreatePS (WinQueryAnchorBlock (hWindow),
     928                           WinOpenWindowDC (hWindow),
     929                           &sizel, PU_PELS | GPIT_MICRO | GPIA_ASSOC );
     930        psType = MICRO;
     931        // default cp is OS/2 one: set to windows default (ODIN.INI)
     932        GpiSetCp(hps, GetDisplayCodepage());
     933    }
     934    else
     935    {
     936        if (hWindow == HWND_DESKTOP) {
     937            hps = WinGetScreenPS (hWindow);
     938        }
     939        else {
     940            int clipstyle = 0;
     941            int clipwnd   = HWND_TOP;
     942            if(flags & (DCX_USESTYLE_W)) {
    1099943                int style = wnd->getStyle();
    1100944                if(style & WS_CLIPCHILDREN_W) {
    1101                         clipstyle |= PSF_CLIPCHILDREN;
     945                    clipstyle |= PSF_CLIPCHILDREN;
    1102946                }
    1103947                if(style & WS_CLIPSIBLINGS_W) {
    1104                         clipstyle |= PSF_CLIPSIBLINGS;
     948                    clipstyle |= PSF_CLIPSIBLINGS;
    1105949                }
    1106950                if(wnd->fHasParentDC()) {
    1107                         clipstyle |= PSF_PARENTCLIP;
     951                    clipstyle |= PSF_PARENTCLIP;
    1108952                }
    1109         }
    1110         if(flags & DCX_CLIPSIBLINGS_W) {
     953            }
     954            if(flags & DCX_CLIPSIBLINGS_W) {
    1111955                clipstyle |= PSF_CLIPSIBLINGS;
    1112         }
    1113         if(flags & DCX_CLIPCHILDREN_W) {
     956            }
     957            if(flags & DCX_CLIPCHILDREN_W) {
    1114958                clipstyle |= PSF_CLIPCHILDREN;
    1115         }
    1116         if(flags & DCX_PARENTCLIP_W) {
     959            }
     960            if(flags & DCX_PARENTCLIP_W) {
    1117961                clipstyle |= PSF_PARENTCLIP;
    1118         }
    1119         if(clipstyle) {
    1120                 dprintf2(("WinGetClipPS style %x", clipstyle));
    1121                 hps = WinGetClipPS(hWindow, clipwnd, clipstyle);
    1122         }
    1123         else    hps = WinGetPS (hWindow);
    1124 
    1125         // default cp is OS/2 one: set to windows default (ODIN.INI)
    1126         GpiSetCp(hps, GetDisplayCodepage());
    1127       }
    1128       psType = MICRO_CACHED;
    1129    }
    1130 
    1131    if (!hps)
    1132       goto error;
    1133 
    1134    HPSToHDC (hWindow, hps, NULL, NULL);
    1135    pHps = (pDCData)GpiQueryDCData (hps);
    1136 
    1137    if(!(flags & DCX_WINDOW_W))
    1138    {
    1139         selectClientArea(wnd, pHps);
    1140    }
    1141    else removeClientArea(wnd, pHps);
    1142 
    1143    setMapMode(wnd, pHps, MM_TEXT_W);
    1144 
    1145    if ((flags & DCX_EXCLUDERGN_W) || (flags & DCX_INTERSECTRGN_W))
    1146    {
    1147       ULONG BytesNeeded;
    1148       PRGNDATA RgnData;
    1149       PRECT pr;
    1150       int i;
    1151       RECTL rectl;
    1152 
    1153       if (!hrgn)
    1154          goto error;
    1155 
    1156       success = TRUE;
    1157       if (flags & DCX_EXCLUDERGN_W)
    1158       {
     962            }
     963            if(clipstyle) {
     964                 dprintf2(("WinGetClipPS style %x", clipstyle));
     965                 hps = WinGetClipPS(hWindow, clipwnd, clipstyle);
     966            }
     967            else hps = WinGetPS (hWindow);
     968
     969            // default cp is OS/2 one: set to windows default (ODIN.INI)
     970            GpiSetCp(hps, GetDisplayCodepage());
     971        }
     972        psType = MICRO_CACHED;
     973    }
     974
     975    if (!hps)
     976        goto error;
     977
     978    HPSToHDC (hWindow, hps, NULL, NULL);
     979    pHps = (pDCData)GpiQueryDCData (hps);
     980
     981    if(flags & DCX_WINDOW_W) {
     982         removeClientArea(wnd, pHps);
     983    }
     984    else selectClientArea(wnd, pHps);
     985
     986    setMapMode(wnd, pHps, MM_TEXT_W);
     987
     988    if ((flags & DCX_EXCLUDERGN_W) || (flags & DCX_INTERSECTRGN_W))
     989    {
     990        ULONG BytesNeeded;
     991        PRGNDATA RgnData;
     992        PRECT pr;
     993        int i;
     994        RECTL rectl;
     995
     996        if (!hrgn)
     997            goto error;
     998
     999        success = TRUE;
     1000        if (flags & DCX_EXCLUDERGN_W)
     1001        {
    11591002#if 0 //CB: todo
    11601003         long height;
     
    11811024         }
    11821025#endif
    1183       }
    1184       else //DCX_INTERSECTRGN_W
    1185       {
    1186          //SvL: I'm getting paint problems when clipping a dc created in GetDCEx
    1187          //     with a region that covers the entire window (RealPlayer 7 Update 1)
    1188          //     Using SelectClipRgn here doesn't make any difference.
    1189          if(ExtSelectClipRgn(pHps->hps, hrgn, RGN_AND_W) == ERROR_W) {
     1026        }
     1027        else //DCX_INTERSECTRGN_W
     1028        {
     1029            //SvL: I'm getting paint problems when clipping a dc created in GetDCEx
     1030            //     with a region that covers the entire window (RealPlayer 7 Update 1)
     1031            //     Using SelectClipRgn here doesn't make any difference.
     1032            if(ExtSelectClipRgn(pHps->hps, hrgn, RGN_AND_W) == ERROR_W) {
    11901033                dprintf(("ExtSelectClipRgn failed!!"));
    1191          }
    1192       }
    1193       if (!success)
    1194          goto error;
    1195    }
    1196 
    1197    if (creatingOwnDC)
    1198       wnd->setOwnDC ((HDC)hps);
    1199 
    1200    pHps->psType  = psType;
    1201    pHps->hdcType = TYPE_1;
    1202    //TODO: WM_SETREDRAW affects drawingAllowed flag!!
    1203    GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF);
    1204 
    1205    dprintf (("User32: GetDCEx hwnd %x (%x %x) -> hdc %x", hwnd, hrgn, flags, pHps->hps));
    1206    return (HDC)pHps->hps;
     1034            }
     1035        }
     1036        if (!success)
     1037            goto error;
     1038    }
     1039
     1040    if (creatingOwnDC)
     1041        wnd->setOwnDC ((HDC)hps);
     1042
     1043    pHps->psType  = psType;
     1044    pHps->hdcType = TYPE_1;
     1045    //TODO: WM_SETREDRAW affects drawingAllowed flag!!
     1046    GpiSetDrawControl (hps, DCTL_DISPLAY, drawingAllowed ? DCTL_ON : DCTL_OFF);
     1047
     1048    dprintf (("User32: GetDCEx hwnd %x (%x %x) -> hdc %x", hwnd, hrgn, flags, pHps->hps));
     1049    return (HDC)pHps->hps;
    12071050
    12081051error:
    1209    /* Something went wrong; clean up
    1210     */
    1211    dprintf(("ERROR: GetDCEx hwnd %x (%x %x) FAILED!", hwnd, hrgn, flags));
    1212    DebugInt3();
    1213    if (pHps)
    1214    {
    1215       if (pHps->hps)
    1216       {
    1217          if(pHps->psType == MICRO_CACHED)
    1218             WinReleasePS(pHps->hps);
    1219          else
    1220             GpiDestroyPS(pHps->hps);
    1221       }
    1222 
    1223       if (pHps->hdc)     DevCloseDC(pHps->hdc);
    1224       if (pHps->hrgnHDC) GpiDestroyRegion(pHps->hps, pHps->hrgnHDC);
    1225 
    1226       O32_DeleteObject (pHps->nullBitmapHandle);
    1227    }
    1228    SetLastError(ERROR_INVALID_PARAMETER_W);
    1229    return NULL;
     1052    /* Something went wrong; clean up
     1053     */
     1054    dprintf(("ERROR: GetDCEx hwnd %x (%x %x) FAILED!", hwnd, hrgn, flags));
     1055    DebugInt3();
     1056    if (pHps)
     1057    {
     1058        if (pHps->hps)
     1059        {
     1060            if(pHps->psType == MICRO_CACHED)
     1061                WinReleasePS(pHps->hps);
     1062            else
     1063                GpiDestroyPS(pHps->hps);
     1064        }
     1065
     1066        if (pHps->hdc)     DevCloseDC(pHps->hdc);
     1067        if (pHps->hrgnHDC) GpiDestroyRegion(pHps->hps, pHps->hrgnHDC);
     1068
     1069        O32_DeleteObject (pHps->nullBitmapHandle);
     1070    }
     1071    SetLastError(ERROR_INVALID_PARAMETER_W);
     1072    return NULL;
    12301073}
    12311074//******************************************************************************
     
    12331076HDC WIN32API GetDC (HWND hwnd)
    12341077{
    1235   if(!hwnd)
    1236        return GetDCEx( GetDesktopWindow(), 0, DCX_CACHE_W | DCX_WINDOW_W );
    1237   return GetDCEx (hwnd, NULL, 0);
     1078    if(!hwnd)
     1079        return GetDCEx( GetDesktopWindow(), 0, DCX_CACHE_W | DCX_WINDOW_W );
     1080
     1081    return GetDCEx (hwnd, NULL, 0);
    12381082}
    12391083//******************************************************************************
     
    12411085HDC WIN32API GetWindowDC (HWND hwnd)
    12421086{
    1243   if (!hwnd) hwnd = GetDesktopWindow();
    1244   return GetDCEx (hwnd, NULL, DCX_WINDOW_W);
     1087    if (!hwnd) hwnd = GetDesktopWindow();
     1088    return GetDCEx (hwnd, NULL, DCX_WINDOW_W);
    12451089}
    12461090//******************************************************************************
     
    12491093LRESULT WIN32API RedrawChildEnumProc(HWND hwnd, LPARAM lParam)
    12501094{
    1251   RedrawWindow(hwnd, NULL, 0, lParam);
    1252   return TRUE;
     1095    RedrawWindow(hwnd, NULL, 0, lParam);
     1096    return TRUE;
    12531097}
    12541098//******************************************************************************
     
    12651109//
    12661110//TODO: Works ok for RDW_FRAME??
     1111//      SDK docs say RDW_FRAME is only valid for RDW_INVALIDATE...
    12671112//******************************************************************************
    12681113BOOL WIN32API RedrawWindow(HWND hwnd, const RECT* pRect, HRGN hrgn, DWORD redraw)
    12691114{
    1270    Win32BaseWindow *wnd;
    1271 
    1272    if(pRect) {
    1273           dprintf(("RedrawWindow %x (%d,%d)(%d,%d) %x %x", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, hrgn, redraw));
    1274    }
    1275    else  dprintf(("RedrawWindow %x %x %x %x", hwnd, pRect, hrgn, redraw));
    1276 
    1277    if (hwnd == NULLHANDLE)
    1278    {
     1115    Win32BaseWindow *wnd;
     1116
     1117    if(pRect) {
     1118         dprintf(("RedrawWindow %x (%d,%d)(%d,%d) %x %x", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, hrgn, redraw));
     1119    }
     1120    else dprintf(("RedrawWindow %x %x %x %x", hwnd, pRect, hrgn, redraw));
     1121
     1122    if (hwnd == NULLHANDLE)
     1123    {
    12791124#if 1
    12801125        // Don't do this for now (causes lots of desktop repaints in WordPad)
    1281          SetLastError(ERROR_INVALID_PARAMETER_W);
    1282          return FALSE;
     1126        SetLastError(ERROR_INVALID_PARAMETER_W);
     1127        return FALSE;
    12831128#else
    12841129        hwnd = HWND_DESKTOP;
     
    12931138        }
    12941139#endif
    1295    }
    1296    else
    1297    {
     1140    }
     1141    else
     1142    {
    12981143        wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
    12991144
     
    13051150            return FALSE;
    13061151        }
    1307         hwnd = wnd->getOS2WindowHandle();
    1308    }
    1309 
    1310    BOOL  IncludeChildren = (redraw & RDW_ALLCHILDREN_W) ? TRUE : FALSE;
    1311    BOOL  success = TRUE;
    1312    HPS   hpsTemp = NULLHANDLE;
    1313    HRGN  hrgnTemp = NULLHANDLE;
    1314    RECTL rectl;
    1315 
    1316    if (hrgn)
    1317    {
    1318       ULONG BytesNeeded;
    1319       PRGNDATA RgnData;
    1320       PRECTL pr;
    1321       int i;
    1322       LONG height;
    1323 
    1324       if(wnd) {
    1325                 height = (redraw & RDW_FRAME_W) ? wnd->getWindowHeight() : wnd->getClientHeight();
    1326       }
    1327       else      height = OSLibQueryScreenHeight();
    1328 
    1329       if (!hrgn)
    1330          goto error;
    1331 
    1332       BytesNeeded = GetRegionData (hrgn, 0, NULL);
    1333       RgnData = (PRGNDATA)_alloca (BytesNeeded);
    1334       if (RgnData == NULL)
     1152        if(redraw & RDW_FRAME_W) {
     1153             hwnd = wnd->getOS2FrameWindowHandle();
     1154        }
     1155        else hwnd = wnd->getOS2WindowHandle();
     1156    }
     1157
     1158    BOOL  IncludeChildren = (redraw & RDW_ALLCHILDREN_W) ? TRUE : FALSE;
     1159    BOOL  success = TRUE;
     1160    HPS   hpsTemp = NULLHANDLE;
     1161    HRGN  hrgnTemp = NULLHANDLE;
     1162    RECTL rectl;
     1163
     1164    if (hrgn)
     1165    {
     1166        ULONG BytesNeeded;
     1167        PRGNDATA RgnData;
     1168        PRECTL pr;
     1169        int i;
     1170        LONG height;
     1171
     1172        if(wnd) {
     1173             height = (redraw & RDW_FRAME_W) ? wnd->getWindowHeight() : wnd->getClientHeight();
     1174        }
     1175        else height = OSLibQueryScreenHeight();
     1176
     1177        if (!hrgn)
     1178            goto error;
     1179
     1180        BytesNeeded = GetRegionData (hrgn, 0, NULL);
     1181        RgnData = (PRGNDATA)_alloca (BytesNeeded);
     1182        if (RgnData == NULL)
    13351183          goto error;
    1336       GetRegionData (hrgn, BytesNeeded, RgnData);
    1337 
    1338       pr = (PRECTL)(RgnData->Buffer);
    1339       for (i = RgnData->rdh.nCount; i > 0; i--, pr++) {
    1340          LONG temp = pr->yTop;
    1341          pr->yTop = height - pr->yBottom;
    1342          pr->yBottom = height - temp;
    1343          dprintf2(("RedrawWindow: region (%d,%d) (%d,%d)", pr->xLeft, pr->yBottom, pr->xRight, pr->yTop));
    1344       }
    1345 
    1346       hpsTemp = WinGetScreenPS (HWND_DESKTOP);
    1347       hrgnTemp = GpiCreateRegion (hpsTemp, RgnData->rdh.nCount, (PRECTL)(RgnData->Buffer));
    1348       if (!hrgnTemp) goto error;
    1349    }
    1350    else if (pRect)
    1351    {
    1352       if(wnd) {
    1353                 if(redraw & RDW_FRAME_W) {
    1354                         mapWin32ToOS2Rect(wnd->getWindowHeight(), (PRECT)pRect, (PRECTLOS2)&rectl);
    1355                 }
    1356                 else    mapWin32ToOS2RectClientToFrame(wnd, (PRECT)pRect, (PRECTLOS2)&rectl);
    1357       }
    1358       else      mapWin32ToOS2Rect(OSLibQueryScreenHeight(), (PRECT)pRect, (PRECTLOS2)&rectl);
    1359    }
    1360 
    1361    if (redraw & RDW_INVALIDATE_W)
    1362    {
     1184        GetRegionData (hrgn, BytesNeeded, RgnData);
     1185
     1186        pr = (PRECTL)(RgnData->Buffer);
     1187        for (i = RgnData->rdh.nCount; i > 0; i--, pr++) {
     1188            LONG temp = pr->yTop;
     1189            pr->yTop = height - pr->yBottom;
     1190            pr->yBottom = height - temp;
     1191            dprintf2(("RedrawWindow: region (%d,%d) (%d,%d)", pr->xLeft, pr->yBottom, pr->xRight, pr->yTop));
     1192        }
     1193
     1194        hpsTemp = WinGetScreenPS (HWND_DESKTOP);
     1195        hrgnTemp = GpiCreateRegion (hpsTemp, RgnData->rdh.nCount, (PRECTL)(RgnData->Buffer));
     1196        if (!hrgnTemp) goto error;
     1197    }
     1198    else if (pRect)
     1199    {
     1200        if(wnd) {
     1201            if(redraw & RDW_FRAME_W) {
     1202                 mapWin32ToOS2Rect(wnd->getWindowHeight(), (PRECT)pRect, (PRECTLOS2)&rectl);
     1203            }
     1204            else mapWin32ToOS2Rect(wnd->getClientHeight(), (PRECT)pRect, (PRECTLOS2)&rectl);
     1205        }
     1206        else mapWin32ToOS2Rect(OSLibQueryScreenHeight(), (PRECT)pRect, (PRECTLOS2)&rectl);
     1207    }
     1208
     1209    if (redraw & RDW_INVALIDATE_W)
     1210    {
    13631211        //TODO: SvL: pingpong.exe doesn't have RDW_NOERASE, but doesn't want WM_ERASEBKGND msgs
    13641212        if (redraw & RDW_ERASE_W) {
    13651213             wnd->setEraseBkgnd(TRUE);
    13661214        }
    1367         else
    1368         if (redraw & RDW_NOERASE_W)
    1369             wnd->setEraseBkgnd(FALSE);
     1215        else wnd->setEraseBkgnd(FALSE);
    13701216
    13711217        if (!pRect && !hrgn)
     
    14031249
    14041250        if (!success) goto error;
    1405    }
    1406    else if (redraw & RDW_VALIDATE_W)
    1407    {
     1251    }
     1252    else if (redraw & RDW_VALIDATE_W)
     1253    {
    14081254        if (redraw & RDW_NOERASE_W)
    14091255            wnd->setEraseBkgnd(FALSE);
     
    14231269            if(!success) goto error;
    14241270        }
    1425    }
    1426 
    1427    if(WinQueryUpdateRect(hwnd, NULL))
    1428    {
     1271    }
     1272
     1273    if(WinQueryUpdateRect(hwnd, &rectl))
     1274    {
    14291275        //TODO: Does this work if RDW_ALLCHILDREN is set??
    14301276        if(redraw & RDW_UPDATENOW_W) {
    1431                 wnd->MsgNCPaint();
    1432                 wnd->MsgPaint(0, FALSE);
     1277            RECT rectUpdate;
     1278
     1279            if(redraw & RDW_FRAME_W) {
     1280                mapOS2ToWin32Rect(wnd->getWindowHeight(), (PRECTLOS2)&rectl, &rectUpdate);
     1281                wnd->MsgNCPaint(&rectUpdate);
     1282            }
     1283
     1284            wnd->MsgPaint(0, FALSE);
    14331285        }
    14341286        else
    14351287//        if((redraw & RDW_ERASE_W) && (redraw & RDW_ERASENOW_W))
    14361288        if(redraw & RDW_ERASENOW_W && wnd->needsEraseBkgnd())
    1437                 wnd->setEraseBkgnd(sendEraseBkgnd(wnd) == 0);
     1289            wnd->setEraseBkgnd(sendEraseBkgnd(wnd) == 0);
    14381290//      if(redraw & RDW_ALLCHILDREN_W) {
    14391291//              EnumChildWindows(wnd->getWindowHandle(), RedrawChildEnumProc, redraw);
    14401292//      }
    1441    }
    1442    else if((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W))
    1443    {
     1293    }
     1294    else if((redraw & RDW_INTERNALPAINT_W) && !(redraw & RDW_INVALIDATE_W))
     1295    {
    14441296        if(redraw & RDW_UPDATENOW_W) {
    1445                 wnd->MsgNCPaint();
    1446                 wnd->MsgPaint (0, FALSE);
    1447         }
    1448         else    PostMessageA(hwnd, WINWM_PAINT, 0, 0);
    1449    }
     1297            wnd->MsgPaint(0, FALSE);
     1298        }
     1299        else PostMessageA(hwnd, WINWM_PAINT, 0, 0);
     1300    }
    14501301
    14511302error:
    1452    /* clean up */
    1453    if (hrgnTemp)
    1454       GpiDestroyRegion (hpsTemp, hrgnTemp);
    1455 
    1456    if (hpsTemp)
    1457       WinReleasePS (hpsTemp);
    1458 
    1459    if (!success) {
     1303    /* clean up */
     1304    if (hrgnTemp)
     1305        GpiDestroyRegion (hpsTemp, hrgnTemp);
     1306
     1307    if (hpsTemp)
     1308        WinReleasePS (hpsTemp);
     1309
     1310    if (!success) {
    14601311        dprintf(("RedrawWindow failure!"));
    14611312        SetLastError(ERROR_INVALID_PARAMETER_W);
    1462    }
    1463    return (success);
     1313    }
     1314    return (success);
    14641315}
    14651316//******************************************************************************
     
    14681319{
    14691320  Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
    1470 
    1471    if(!wnd) {
     1321  RECTL rectl;
     1322  BOOL  rc;
     1323
     1324    if(!wnd) {
     1325        dprintf (("ERROR: User32: UpdateWindow INVALID hwnd %x", hwnd));
    14721326        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    14731327        return FALSE;
    1474    }
    1475 
    1476    dprintf (("User32: UpdateWindow hwnd %x", hwnd));
    1477 //SvL: This doesn't work right (Wine uses RDW_NOCHILDREN_W -> doesn't work here)
    1478 //     Breaks vpbuddy
    1479 //   return RedrawWindow(hwnd, NULL, 0, RDW_UPDATENOW_W | RDW_ALLCHILDREN_W);
    1480 //   -> RDW_UPDATENOW causes WM_PAINT messages to be directy posted to window
    1481 //   handler; possibly bypassing queued WM_PAINT messages for parent window(s)
    1482 //   -> out of sync painting (i.e. parent paints over child)
    1483    WinUpdateWindow(wnd->getOS2WindowHandle());
    1484    return TRUE;
     1328    }
     1329
     1330#ifdef DEBUG
     1331    if(WinQueryUpdateRect(wnd->getOS2WindowHandle(), &rectl))
     1332    {
     1333         RECT rectUpdate;
     1334         mapOS2ToWin32Rect(wnd->getClientHeight(), (PRECTLOS2)&rectl, &rectUpdate);
     1335
     1336         dprintf (("User32: UpdateWindow hwnd %x: update rectangle (%d,%d)(%d,%d)", hwnd, rectUpdate.left, rectUpdate.top, rectUpdate.right, rectUpdate.bottom));
     1337    }
     1338    else dprintf (("User32: UpdateWindow hwnd %x; EMPTY update rectangle (vis=%d/%d)", hwnd, WinIsWindowVisible(wnd->getOS2FrameWindowHandle()), WinIsWindowVisible(wnd->getOS2WindowHandle())));
     1339#endif
     1340    //SvL: This doesn't work right (Wine uses RDW_NOCHILDREN_W -> doesn't work here)
     1341    //     Breaks vpbuddy
     1342    //rc = RedrawWindow(hwnd, NULL, 0, RDW_UPDATENOW_W | RDW_ALLCHILDREN_W);
     1343    //   -> RDW_UPDATENOW causes WM_PAINT messages to be directy posted to window
     1344    //   handler; possibly bypassing queued WM_PAINT messages for parent window(s)
     1345    //   -> out of sync painting (i.e. parent paints over child)
     1346
     1347//    if(!WinIsWindowShowing(wnd->getOS2FrameWindowHandle()) || !WinIsWindowShowing(wnd->getOS2WindowHandle())) {
     1348//        dprintf(("UpdateWindow: window not showing %d/%d", WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle()) ));
     1349//        return FALSE;
     1350//    }
     1351    //Must use frame window here. If the frame window has a valid update region and we call
     1352    //WinUpdateWindow for the client window, then no WM_PAINT messages will be sent.
     1353    rc = WinUpdateWindow(wnd->getOS2FrameWindowHandle());
     1354#ifdef DEBUG
     1355    if(WinQueryUpdateRect(wnd->getOS2WindowHandle(), NULL))
     1356    {
     1357        //if parent has valid update region then WinUpdateWindow will still fail..
     1358        //might be harmless and happen even in windows
     1359        dprintf (("ERROR: User32: UpdateWindow didn't send WM_PAINT messages!!"));
     1360    }
     1361#endif
     1362    return rc;
    14851363}
    14861364//******************************************************************************
     
    15081386   BOOL result;
    15091387
    1510    if(pRect) {
     1388    if(pRect) {
    15111389        dprintf(("InvalidateRect %x (%d,%d)(%d,%d) erase=%d", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom, erase));
    1512    }
    1513    else dprintf(("InvalidateRect %x NULL erase=%d", hwnd, erase));
     1390    }
     1391    else dprintf(("InvalidateRect %x NULL erase=%d", hwnd, erase));
    15141392#if 1
    1515    result = RedrawWindow (hwnd, pRect, NULLHANDLE,
    1516                           RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
     1393    result = RedrawWindow (hwnd, pRect, NULLHANDLE,
     1394                           RDW_INVALIDATE_W |
     1395                           (erase ? RDW_ERASE_W : 0) |
     1396                           (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
     1397#else
     1398    result = RedrawWindow (hwnd, pRect, NULLHANDLE,
     1399                           RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
     1400                           (erase ? RDW_ERASE_W : RDW_NOERASE_W) |
     1401                           (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
     1402#endif
     1403    return (result);
     1404}
     1405//******************************************************************************
     1406//******************************************************************************
     1407BOOL WIN32API InvalidateRgn (HWND hwnd, HRGN hrgn, BOOL erase)
     1408{
     1409    BOOL result;
     1410
     1411    dprintf(("InvalidateRgn %x %x erase=%d", hwnd, hrgn, erase));
     1412#if 1
     1413    result = RedrawWindow (hwnd, NULL, hrgn,
     1414                          RDW_INVALIDATE_W |
    15171415                          (erase ? RDW_ERASE_W : 0) |
    15181416                          (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
    15191417#else
    1520    result = RedrawWindow (hwnd, pRect, NULLHANDLE,
     1418    result = RedrawWindow (hwnd, NULL, hrgn,
    15211419                          RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
    15221420                          (erase ? RDW_ERASE_W : RDW_NOERASE_W) |
    15231421                          (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
    15241422#endif
    1525    return (result);
    1526 }
    1527 //******************************************************************************
    1528 //******************************************************************************
    1529 BOOL WIN32API InvalidateRgn (HWND hwnd, HRGN hrgn, BOOL erase)
    1530 {
    1531    BOOL result;
    1532 
    1533    dprintf(("InvalidateRgn %x %x erase=%d", hwnd, hrgn, erase));
    1534 #if 1
    1535    result = RedrawWindow (hwnd, NULL, hrgn,
    1536                           RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
    1537                           (erase ? RDW_ERASE_W : 0) |
    1538                           (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
    1539 #else
    1540    result = RedrawWindow (hwnd, NULL, hrgn,
    1541                           RDW_ALLCHILDREN_W | RDW_INVALIDATE_W |
    1542                           (erase ? RDW_ERASE_W : RDW_NOERASE_W) |
    1543                           (hwnd == NULLHANDLE ? RDW_UPDATENOW_W : 0));
    1544 #endif
    1545    return (result);
     1423    return (result);
    15461424}
    15471425//******************************************************************************
     
    16251503   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
    16261504
    1627    if ((hwnd == NULLHANDLE) || !wnd)
     1505   if((hwnd == NULLHANDLE) || !wnd)
    16281506   {
    16291507      return (FALSE);
     
    17021580   RECTL  rectlUpdate;
    17031581   HRGN   hrgn;
    1704    RECTL  clientRect;
    17051582   RECTL  clipOS2;
    17061583   RECTL  scrollOS2;
     
    17081585   PRECTL pClipOS2   = NULL;
    17091586
    1710    mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&clientRect);
    1711 
    17121587   if(pScroll) {
    1713         mapWin32ToOS2RectClientToFrame(wnd, &scrollRect, (PRECTLOS2)&scrollOS2);
     1588        mapWin32ToOS2Rect(wnd->getClientHeight(), &scrollRect, (PRECTLOS2)&scrollOS2);
    17141589        pScrollOS2 = &scrollOS2;
    1715 
    1716         //Scroll rectangle relative to client area
    1717         WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect);
    1718    }
    1719    else {
    1720         pScrollOS2 = &clientRect;
    17211590   }
    17221591
    17231592   if(pClip) {
    1724          mapWin32ToOS2RectClientToFrame(wnd, &clipRect, (PRECTLOS2)&clipOS2);
    1725          pClipOS2 = &clipOS2;
    1726 
    1727          //Clip rectangle relative to client area
    1728          WinIntersectRect((HAB) 0, pClipOS2, pClipOS2, &clientRect);
    1729    }
    1730    else {
    1731          pClipOS2 = &clientRect;
     1593        mapWin32ToOS2Rect(wnd->getClientHeight(), &clipRect, (PRECTLOS2)&clipOS2);
     1594        pClipOS2 = &clipOS2;
    17321595   }
    17331596
     
    17411604   RECT winRectUpdate;
    17421605
    1743    mapOS2ToWin32Rect(wnd->getWindowHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate);
     1606   mapOS2ToWin32Rect(wnd->getClientHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate);
    17441607
    17451608   if (pRectUpdate)
     
    17471610
    17481611   if (hrgnUpdate)
    1749       rc = setPMRgnIntoWinRgn(hrgn, hrgnUpdate, wnd->getWindowHeight());
     1612      rc = setPMRgnIntoWinRgn(hrgn, hrgnUpdate, wnd->getClientHeight());
    17501613
    17511614   return (rc);
    17521615}
    17531616//******************************************************************************
    1754 //SvL: Using WinScrollWindow to scroll child windows is better (smoother).
     1617//Using WinScrollWindow to scroll child windows is better (smoother).
    17551618//******************************************************************************
    17561619INT WIN32API ScrollWindowEx(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip,
     
    17591622 Win32BaseWindow *window;
    17601623 APIRET  rc;
    1761  RECTL   clientRect;
    17621624 RECTL   scrollRect;
    17631625 RECTL   clipRect;
     
    17811643    if (scrollFlag & SW_SCROLLCHILDREN_W)  scrollFlagsOS2 |= SW_SCROLLCHILDREN;
    17821644
    1783     mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&clientRect);
    1784 
    17851645    if(pScroll) {
    1786         mapWin32ToOS2RectClientToFrame(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
     1646        mapWin32ToOS2Rect(window->getClientHeight(), (RECT *)pScroll, (PRECTLOS2)&scrollRect);
    17871647        pScrollOS2 = &scrollRect;
    1788 
    1789         //Scroll rectangle relative to client area
    1790         WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect);
    1791     }
    1792     else {
    1793         pScrollOS2 = &clientRect;
    17941648    }
    17951649
    17961650    if(pClip) {
    1797          mapWin32ToOS2RectClientToFrame(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
    1798          pClipOS2 = &clipRect;
    1799 
    1800          //Clip rectangle relative to client area
    1801          WinIntersectRect ((HAB) 0, pClipOS2, pClipOS2, &clientRect);
    1802     }
    1803     else {
    1804          pClipOS2 = &clientRect;
     1651        mapWin32ToOS2Rect(window->getClientHeight(), (RECT *)pClip, (PRECTLOS2)&clipRect);
     1652        pClipOS2 = &clipRect;
    18051653    }
    18061654
     
    18161664    }
    18171665
    1818     LONG lComplexity = WinScrollWindow (window->getOS2WindowHandle(), dx, dy,
    1819                                         pScrollOS2,
    1820                                         pClipOS2,
    1821                                         hrgn, &rectlUpdate, scrollFlagsOS2);
     1666    LONG lComplexity = WinScrollWindow(window->getOS2WindowHandle(), dx, dy,
     1667                                       pScrollOS2, pClipOS2,
     1668                                       hrgn, &rectlUpdate, scrollFlagsOS2);
    18221669    if (lComplexity == RGN_ERROR)
    18231670    {
     
    18501697                }
    18511698                rectChild = *child->getWindowRect();
    1852                 if(!pRectUpdate || IntersectRect(&rectChild, &rectChild, &rc))
     1699                if(!pScroll || IntersectRect(&rectChild, &rectChild, &rc))
    18531700                {
    18541701                     dprintf(("ScrollWindowEx: Scroll child window %x", hwndChild));
     
    18621709    RECT winRectUpdate;
    18631710
    1864     mapOS2ToWin32Rect(window->getWindowHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate);
     1711    mapOS2ToWin32Rect(window->getClientHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate);
    18651712
    18661713    if (pRectUpdate)
     
    18681715
    18691716    if (hrgnUpdate)
    1870        rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, window->getWindowHeight());
     1717       rc = setPMRgnIntoWinRgn(hrgn, hrgnUpdate, window->getClientHeight());
    18711718
    18721719#if 0
     
    18911738    switch (lComplexity)
    18921739    {
    1893        case RGN_NULL:
    1894          regionType = NULLREGION_W;
    1895          break;
    1896        case RGN_RECT:
    1897          regionType = SIMPLEREGION_W;
    1898          break;
    1899        case RGN_COMPLEX:
    1900          regionType = COMPLEXREGION_W;
    1901          break;
    1902        default:
    1903          regionType = ERROR_W;
    1904          break;
     1740    case RGN_NULL:
     1741        regionType = NULLREGION_W;
     1742        break;
     1743    case RGN_RECT:
     1744        regionType = SIMPLEREGION_W;
     1745        break;
     1746    case RGN_COMPLEX:
     1747        regionType = COMPLEXREGION_W;
     1748        break;
     1749    default:
     1750        regionType = ERROR_W;
     1751        break;
    19051752    }
    19061753
     
    19371784//******************************************************************************
    19381785//******************************************************************************
    1939 #ifdef DEBUG
    1940 void dprintfOrigin(HDC hdc)
    1941 {
    1942    POINTL point;
    1943 
    1944     pDCData  pHps = (pDCData)GpiQueryDCData((HPS)hdc);
    1945     if(!pHps)
    1946     {
    1947         return;
    1948     }
    1949 
    1950     GreGetDCOrigin(pHps->hps, &point);
    1951     dprintf(("HDC %x origin (%d,%d) org (%d,%d)", hdc, point.x, point.y, pHps->ptlOrigin.x, pHps->ptlOrigin.y));
    1952 }
    1953 #endif
    1954 //******************************************************************************
    1955 //******************************************************************************
     1786
  • trunk/src/user32/dc.h

    r5164 r5685  
    1 /* $Id: dc.h,v 1.16 2001-02-18 14:18:38 sandervl Exp $ */
     1/* $Id: dc.h,v 1.17 2001-05-11 08:39:42 sandervl Exp $ */
    22/*
    33 * public dc functions
     
    1616extern HDC sendEraseBkgnd (Win32BaseWindow *wnd);
    1717extern void releaseOwnDC (HDC hps);
     18BOOL setPageXForm(Win32BaseWindow *wnd, struct _DCData * pHps);
    1819
    1920void selectClientArea(Win32BaseWindow *wnd, HDC hdc);
  • trunk/src/user32/dcrgn.cpp

    r3725 r5685  
    1 /* $Id: dcrgn.cpp,v 1.3 2000-06-17 11:56:14 sandervl Exp $ */
     1/* $Id: dcrgn.cpp,v 1.4 2001-05-11 08:39:42 sandervl Exp $ */
    22
    33/*
     
    4646BOOL WIN32API GetUpdateRect(HWND hwnd, LPRECT pRect, BOOL erase)
    4747{
    48    if (!hwnd)
    49    {
    50         dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));
    51         SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    52         return FALSE;
    53    }
    54 
    55    RECTL rectl, rectlClient;
    56    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    57 
    58    if (!wnd)
    59    {
    60         SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    61         dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));
    62         return FALSE;
    63    }
    64 
    65    dprintf(("GetUpdateRect %x %x %d", hwnd, pRect, erase));
    66 
    67    BOOL updateRegionExists = WinQueryUpdateRect (wnd->getOS2WindowHandle(), pRect ? &rectl : NULL);
    68    if (!pRect) {
    69       return (updateRegionExists);
    70    }
    71 
    72    if(updateRegionExists)
    73    {
     48    if (!hwnd)
     49    {
     50        dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));
     51        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     52        return FALSE;
     53    }
     54
     55    RECTL rectl, rectlClient;
     56    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     57
     58    if (!wnd)
     59    {
     60        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     61        dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));
     62        return FALSE;
     63    }
     64
     65    dprintf(("GetUpdateRect %x %x %d", hwnd, pRect, erase));
     66
     67    BOOL updateRegionExists = WinQueryUpdateRect(wnd->getOS2WindowHandle(), pRect ? &rectl : NULL);
     68    if (!pRect) {
     69        return (updateRegionExists);
     70    }
     71
     72    if(updateRegionExists)
     73    {
    7474        //CB: for PM empty rect is valid
    7575        if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) {
    76                 if(pRect) {
    77                         pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
    78                 }
    79                 return FALSE;
    80         }
    81         mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient);
    82         WinIntersectRect(NULL, &rectl, &rectl, &rectlClient);
    83         mapOS2ToWin32RectFrameToClient(wnd, (PRECTLOS2)&rectl, pRect);
     76            if(pRect) {
     77                pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
     78            }
     79            return FALSE;
     80        }
     81        mapOS2ToWin32Rect(wnd->getClientHeight(), (PRECTLOS2)&rectl, pRect);
    8482
    8583        if(wnd->isOwnDC() && GetMapMode(wnd->getOwnDC()) != MM_TEXT_W)
    8684        {
    87                 DPtoLP(wnd->getOwnDC(), (LPPOINT)pRect, 2);
     85            DPtoLP(wnd->getOwnDC(), (LPPOINT)pRect, 2);
    8886        }
    8987        if (erase)
    90                 sendEraseBkgnd (wnd);
     88            sendEraseBkgnd (wnd);
    9189   }
    9290   else
    9391   {
    9492        if(pRect) {
    95                 pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
     93            pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
    9694        }
    9795   }
     
    10098}
    10199//******************************************************************************
    102 //******************************************************************************
    103 BOOL GetOS2UpdateRect(Win32BaseWindow *window, LPRECT pRect)
    104 {
    105    RECTL rectl;
    106    BOOL updateRegionExists = WinQueryUpdateRect(window->getOS2WindowHandle(),pRect ? &rectl:NULL);
    107 
    108    if (!pRect)
    109      return (updateRegionExists);
    110 
    111    if (updateRegionExists)
    112    {
    113      //CB: for PM empty rect is valid
    114      if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) return FALSE;
    115      mapOS2ToWin32Rect(window->getWindowHeight(), (PRECTLOS2)&rectl,pRect);
    116    }
    117    else
    118        pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
    119 
    120    return updateRegionExists;
    121 }
    122 //******************************************************************************
    123100//TODO: Seems to return region in window coordinates instead of client coordinates
    124101//******************************************************************************
    125102int WIN32API GetUpdateRgn(HWND hwnd, HRGN hrgn, BOOL erase)
    126103{
    127    LONG lComplexity;
    128    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    129 
    130    hrgn = ObjWinToOS2Region(hrgn);
    131    if(!wnd || !hrgn)
    132    {
    133         dprintf(("WARNING: GetUpdateRgn %x %x %d; invalid handle", hwnd, hrgn, erase));
    134         SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    135         return ERROR_W;
    136    }
    137    lComplexity = WinQueryUpdateRegion(wnd->getOS2WindowHandle(), hrgn);
    138    if(lComplexity == RGN_ERROR) {
    139         dprintf(("WARNING: GetUpdateRgn %x %x %d; RGN_ERROR", hwnd, hrgn, erase));
    140         SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    141         return ERROR_W;
    142    }
    143 
    144    if(lComplexity != RGN_NULL)
    145    {
    146         if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, hrgn, NULL, wnd->getOS2WindowHandle()))
    147         {
    148                 dprintf(("WARNING: GetUpdateRgn %x %x %d; setWinDeviceRegionFromPMDeviceRegion failed!", hwnd, hrgn, erase));
    149                 SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    150                 return ERROR_W;
    151         }
    152 
     104    LONG lComplexity;
     105    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     106
     107    hrgn = ObjWinToOS2Region(hrgn);
     108    if(!wnd || !hrgn)
     109    {
     110        dprintf(("WARNING: GetUpdateRgn %x %x %d; invalid handle", hwnd, hrgn, erase));
     111        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     112        return ERROR_W;
     113    }
     114    lComplexity = WinQueryUpdateRegion(wnd->getOS2WindowHandle(), hrgn);
     115    if(lComplexity == RGN_ERROR) {
     116        dprintf(("WARNING: GetUpdateRgn %x %x %d; RGN_ERROR", hwnd, hrgn, erase));
     117        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     118        return ERROR_W;
     119    }
     120
     121    if(lComplexity != RGN_NULL)
     122    {
     123        if(!setWinDeviceRegionFromPMDeviceRegion(hrgn, hrgn, NULL, wnd->getOS2WindowHandle()))
     124        {
     125            dprintf(("WARNING: GetUpdateRgn %x %x %d; setWinDeviceRegionFromPMDeviceRegion failed!", hwnd, hrgn, erase));
     126            SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     127            return ERROR_W;
     128        }
    153129        if(erase) sendEraseBkgnd(wnd);
    154    }
    155 
    156    return lComplexity;
     130    }
     131    return lComplexity;
    157132}
    158133//******************************************************************************
     
    161136INT WIN32API ExcludeUpdateRgn(HDC hdc, HWND hwnd)
    162137{
    163    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    164    pDCData          pHps = (pDCData)GpiQueryDCData((HPS)hdc);
    165    LONG             lComplexity;
    166 
    167    if(!wnd || !pHps)
    168    {
    169         dprintf(("WARNING: ExcludeUpdateRgn %x %x; invalid handle", hdc, hwnd));
    170         SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    171         return ERROR_W;
    172    }
    173    dprintf(("USER32: ExcludeUpdateRgn %x %x", hdc, hwnd));
    174 
    175    lComplexity = WinExcludeUpdateRegion(pHps->hps, wnd->getOS2WindowHandle());
    176    if(lComplexity == RGN_ERROR) {
    177         SetLastError(ERROR_INVALID_HANDLE_W); //todo: correct error
    178    }
    179    else SetLastError(ERROR_SUCCESS_W);
    180    return lComplexity;      // windows and PM values are identical
     138    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     139    pDCData          pHps = (pDCData)GpiQueryDCData((HPS)hdc);
     140    LONG             lComplexity;
     141
     142    if(!wnd || !pHps)
     143    {
     144        dprintf(("WARNING: ExcludeUpdateRgn %x %x; invalid handle", hdc, hwnd));
     145        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     146        return ERROR_W;
     147    }
     148    dprintf(("USER32: ExcludeUpdateRgn %x %x", hdc, hwnd));
     149
     150    lComplexity = WinExcludeUpdateRegion(pHps->hps, wnd->getOS2WindowHandle());
     151    if(lComplexity == RGN_ERROR) {
     152         SetLastError(ERROR_INVALID_HANDLE_W); //todo: correct error
     153    }
     154    else SetLastError(ERROR_SUCCESS_W);
     155    return lComplexity;      // windows and PM values are identical
    181156}
    182157/*****************************************************************************
     
    195170int WIN32API GetWindowRgn(HWND hwnd, HRGN hRgn)
    196171{
    197   Win32BaseWindow *window;
    198   HRGN hWindowRegion;
     172    Win32BaseWindow *window;
     173    HRGN hWindowRegion;
    199174
    200175    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    234209                          BOOL bRedraw)
    235210{
    236   Win32BaseWindow *window;
    237   HRGN hWindowRegion;
     211    Win32BaseWindow *window;
     212    HRGN hWindowRegion;
    238213
    239214    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
  • trunk/src/user32/oslibgdi.cpp

    r3679 r5685  
    1 /* $Id: oslibgdi.cpp,v 1.13 2000-06-08 18:10:10 sandervl Exp $ */
     1/* $Id: oslibgdi.cpp,v 1.14 2001-05-11 08:39:42 sandervl Exp $ */
    22/*
    33 * Window GDI wrapper functions for OS/2
     
    120120  return TRUE;
    121121}
     122#ifndef CLIENTFRAME
    122123//******************************************************************************
    123124//Win32 rectangle in client coordinates (relative to upper left corner of client window)
     
    172173  return TRUE;
    173174}
     175#endif //CLIENTFRAME
    174176//******************************************************************************
    175177//******************************************************************************
  • trunk/src/user32/oslibgdi.h

    r4628 r5685  
    1 /* $Id: oslibgdi.h,v 1.8 2000-11-19 11:52:39 sandervl Exp $ */
     1/* $Id: oslibgdi.h,v 1.9 2001-05-11 08:39:43 sandervl Exp $ */
    22/*
    33 * Window GDI wrapper functions for OS/2
     
    8080BOOL mapWin32ToOS2Rect(int height, PRECT rectWin32,PRECTLOS2 rectOS2);
    8181
     82#ifndef CLIENTFRAME
    8283BOOL mapWin32ToOS2RectClientToFrame(Win32BaseWindow *window, PRECT rectWin32,PRECTLOS2 rectOS2);
    8384BOOL mapOS2ToWin32RectFrameToClient(Win32BaseWindow *window, PRECTLOS2 rectOS2, PRECT rectWin32);
     85#endif
    8486
    8587#define mapWin32ToOS2RectFrame(window, rectWin32, rectOS2) \
  • trunk/src/user32/oslibmsgtranslate.cpp

    r5620 r5685  
    1 /* $Id: oslibmsgtranslate.cpp,v 1.49 2001-04-28 13:35:52 sandervl Exp $ */
     1/* $Id: oslibmsgtranslate.cpp,v 1.50 2001-05-11 08:39:43 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    194194  int i;
    195195
    196   memset(winMsg, 0, sizeof(MSG));
    197   win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(os2Msg->hwnd);
    198 
    199   //PostThreadMessage posts WIN32APP_POSTMSG msg without window handle
    200   //Realplayer starts a timer with hwnd 0 & proc 0; check this here
    201   if(win32wnd == 0 && (os2Msg->msg != WM_CREATE && os2Msg->msg != WM_QUIT && os2Msg->msg != WM_TIMER && os2Msg->msg != WIN32APP_POSTMSG))
    202   {
     196    memset(winMsg, 0, sizeof(MSG));
     197    win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(os2Msg->hwnd);
     198    if(!win32wnd) {
     199        win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(os2Msg->hwnd);
     200    }
     201
     202    //PostThreadMessage posts WIN32APP_POSTMSG msg without window handle
     203    //Realplayer starts a timer with hwnd 0 & proc 0; check this here
     204    if(win32wnd == 0 && (os2Msg->msg != WM_CREATE && os2Msg->msg != WM_QUIT && os2Msg->msg != WM_TIMER && os2Msg->msg != WIN32APP_POSTMSG))
     205    {
    203206        goto dummymessage; //not a win32 client window
    204   }
    205   winMsg->time = os2Msg->time;
    206   //CB: PM bug or undocumented feature? ptl.x highword is set!
    207   winMsg->pt.x = os2Msg->ptl.x & 0xFFFF;
    208   winMsg->pt.y = mapScreenY(os2Msg->ptl.y);
    209 
    210   if(win32wnd) //==0 for WM_CREATE/WM_QUIT
    211     winMsg->hwnd = win32wnd->getWindowHandle();
    212 
    213   switch(os2Msg->msg)
    214   {
     207    }
     208    winMsg->time = os2Msg->time;
     209    //CB: PM bug or undocumented feature? ptl.x highword is set!
     210    winMsg->pt.x = os2Msg->ptl.x & 0xFFFF;
     211    winMsg->pt.y = mapScreenY(os2Msg->ptl.y);
     212
     213    if(win32wnd) //==0 for WM_CREATE/WM_QUIT
     214        winMsg->hwnd = win32wnd->getWindowHandle();
     215
     216    switch(os2Msg->msg)
     217    {
    215218    case WIN32APP_POSTMSG:
    216219    {
     
    273276      LONG      xDelta = pswp->cx - swpOld.cx;
    274277
    275         dprintf(("OS2: WM_WINDOWPOSCHANGED %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    276 
    277278        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0) goto dummymessage;
    278279
     
    286287        }
    287288        if(win32wnd->getParent()) {
    288               OSLibMapSWPtoWINDOWPOS(pswp, &teb->o.odin.wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    289                                      win32wnd->getParent()->getClientRectPtr()->left,
    290                                      win32wnd->getParent()->getClientRectPtr()->top,
     289              OSLibMapSWPtoWINDOWPOS(pswp, &teb->o.odin.wp, &swpOld, win32wnd->getParent()->getClientHeight(),
    291290                                     win32wnd->getOS2WindowHandle());
    292291        }
    293         else  OSLibMapSWPtoWINDOWPOS(pswp, &teb->o.odin.wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, win32wnd->getOS2WindowHandle());
     292        else  OSLibMapSWPtoWINDOWPOS(pswp, &teb->o.odin.wp, &swpOld, OSLibQueryScreenHeight(), win32wnd->getOS2WindowHandle());
    294293
    295294        if (!win32wnd->CanReceiveSizeMsgs())    goto dummymessage;
     
    320319        hwndActivate = OS2ToWin32Handle(hwndActivate);
    321320        if(hwndActivate == 0) {
    322                 //another (non-win32) application's window
    323                 //set to desktop window handle
    324                 hwndActivate = windowDesktop->getWindowHandle();
     321            //another (non-win32) application's window
     322            //set to desktop window handle
     323            hwndActivate = windowDesktop->getWindowHandle();
    325324        }
    326325
     
    361360    //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
    362361    //**************************************************************************
    363 #ifndef ODIN_HITTEST
    364     case WM_HITTEST:
    365       winMsg->message = WINWM_NCHITTEST;
    366       winMsg->wParam  = 0;
    367       winMsg->lParam  = MAKELONG(winMsg->pt.x,winMsg->pt.y);
    368       if(!IsWindowEnabled(win32wnd->getWindowHandle())) {
    369                 if(win32wnd->getParent()) {
    370                         winMsg->hwnd = win32wnd->getParent()->getWindowHandle();
    371                 }
    372                 else    goto dummymessage; //don't send mouse messages to disabled windows
    373       }
    374       break;
    375 #endif
    376 
    377362    case WM_BUTTON1DOWN:
    378363    case WM_BUTTON1UP:
     
    387372        //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
    388373
    389 #ifdef ODIN_HITTEST
    390374        HWND hwnd;
    391375
    392376        DisableLogging();
    393         if(GetCapture() != winMsg->hwnd) 
     377        if(GetCapture() != winMsg->hwnd)
    394378        {
    395379            hwnd = WindowFromPoint(winMsg->pt);
     
    404388            }
    405389        }
    406 #endif
    407390
    408391        //if a window is disabled, it's parent receives the mouse messages
     
    420403        }
    421404        else {
    422 #ifdef ODIN_HITTEST
    423405            ClientPoint.x = winMsg->pt.x;
    424406            ClientPoint.y = winMsg->pt.y;
    425407            MapWindowPoints(0, win32wnd->getWindowHandle(), (LPPOINT)&ClientPoint, 1);
    426 #else
    427             point.x         = (*(POINTS *)&os2Msg->mp1).x;
    428             point.y         = (*(POINTS *)&os2Msg->mp1).y;
    429             ClientPoint.x   = mapOS2ToWin32X(win32wnd, point.x);
    430             ClientPoint.y   = mapOS2ToWin32Y(win32wnd, point.y);
    431 #endif
    432408            winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
    433409            winMsg->wParam  = GetMouseKeyState();
    434410            winMsg->lParam  = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
    435411        }
    436 #ifdef ODIN_HITTEST
    437412        EnableLogging();
    438 #endif
    439413        if((fMsgRemoved == MSG_REMOVE) && ISMOUSE_CAPTURED())
    440414        {
     
    472446        //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
    473447
    474 #ifdef ODIN_HITTEST
    475448        HWND hwnd;
    476449
    477450        dprintf2(("WM_NCMOUSEMOVE (%d,%d)", winMsg->pt.x, winMsg->pt.y));
    478451        DisableLogging();
    479         if(GetCapture() != winMsg->hwnd) 
     452        if(GetCapture() != winMsg->hwnd)
    480453        {
    481454            hwnd = WindowFromPoint(winMsg->pt);
     
    490463            }
    491464        }
    492 #endif
    493465
    494466        //if a window is disabled, it's parent receives the mouse messages
     
    507479        else
    508480        {
    509 #ifdef ODIN_HITTEST
    510481            ClientPoint.x = winMsg->pt.x;
    511482            ClientPoint.y = winMsg->pt.y;
    512483            MapWindowPoints(0, win32wnd->getWindowHandle(), (LPPOINT)&ClientPoint, 1);
    513 #else
    514             point.x         = (*(POINTS *)&os2Msg->mp1).x;
    515             point.y         = (*(POINTS *)&os2Msg->mp1).y;
    516             ClientPoint.x   = mapOS2ToWin32X(win32wnd, point.x);
    517             ClientPoint.y   = mapOS2ToWin32Y(win32wnd, point.y);
    518 #endif
    519484
    520485            winMsg->message = WINWM_MOUSEMOVE;
     
    522487            winMsg->lParam  = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
    523488        }
    524 #ifdef ODIN_HITTEST
    525489        EnableLogging();
    526 #endif
    527490        if((fMsgRemoved == MSG_REMOVE) && ISMOUSE_CAPTURED())
    528491        {
     
    822785        winMsg->lParam  = 0;
    823786        return FALSE;
    824   }
    825   return TRUE;
     787    }
     788    return TRUE;
    826789}
    827790//******************************************************************************
  • trunk/src/user32/oslibwin.cpp

    r5512 r5685  
    1 /* $Id: oslibwin.cpp,v 1.91 2001-04-15 17:05:29 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.92 2001-05-11 08:39:43 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    5353//******************************************************************************
    5454HWND OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle,
    55                           char *pszName, HWND Owner, ULONG fHWND_BOTTOM, 
     55                          char *pszName, HWND Owner, ULONG fHWND_BOTTOM,
    5656                          ULONG id, BOOL fTaskList,BOOL fShellPosition,
    57                           int classStyle)
     57                          int classStyle, HWND *hwndFrame)
    5858{
    5959 HWND  hwndClient;
    6060 ULONG dwFrameStyle = 0;
    6161
    62   if(pszName && *pszName == 0) {
     62    if(pszName && *pszName == 0) {
    6363        pszName = NULL;
    64   }
    65   if(hwndParent == OSLIB_HWND_DESKTOP) {
     64    }
     65    if(hwndParent == OSLIB_HWND_DESKTOP) {
    6666        hwndParent = HWND_DESKTOP;
    67   }
    68   if(Owner == OSLIB_HWND_DESKTOP) {
     67    }
     68    if(Owner == OSLIB_HWND_DESKTOP) {
    6969        Owner = HWND_DESKTOP;
    70   }
    71 
    72   if(classStyle & CS_SAVEBITS_W) dwWinStyle |= WS_SAVEBITS;
    73   if(classStyle & CS_PARENTDC_W) dwWinStyle |= WS_PARENTCLIP;
    74 
    75   dwWinStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
    76 
    77   if(fTaskList)
    78   {
    79         dwFrameStyle |= FCF_NOMOVEWITHOWNER;
    80   }
    81   if (fShellPosition) dwFrameStyle |= FCF_SHELLPOSITION;
    82 
    83   FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
    84   FCData.flCreateFlags = dwFrameStyle;
    85 
    86   dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x winstyle %x bottom %d", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle, dwWinStyle, fHWND_BOTTOM));
    87 
    88   return WinCreateWindow (hwndParent,
    89                           (hwndParent == HWND_DESKTOP) ? WIN32_STDFRAMECLASS : WIN32_STDCLASS,
    90                           pszName, dwWinStyle, 0, 0, 0, 0,
    91                           Owner, (fHWND_BOTTOM) ? HWND_BOTTOM : HWND_TOP,
    92                           id, NULL, NULL);
     70    }
     71
     72    if(classStyle & CS_SAVEBITS_W) dwWinStyle |= WS_SAVEBITS;
     73    if(classStyle & CS_PARENTDC_W) dwWinStyle |= WS_PARENTCLIP;
     74
     75    dwWinStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
     76
     77    if(fTaskList)
     78    {
     79        dwFrameStyle |= FCF_NOMOVEWITHOWNER;
     80    }
     81    if (fShellPosition) dwFrameStyle |= FCF_SHELLPOSITION;
     82
     83    FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
     84    FCData.flCreateFlags = dwFrameStyle;
     85
     86    dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x winstyle %x bottom %d", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle, dwWinStyle, fHWND_BOTTOM));
     87
     88    //Must not use WS_CLIPCHILDREN style with frame window. Transparency won't work otherwise.
     89    //Eg: dialog parent, groupbox; invalidate part of groupbox -> painting algorithm stops when it finds
     90    //    a window with WS_CLIPCHILDREN -> result: dialog window won't update groupbox background as groupbox only draws the border
     91    *hwndFrame = WinCreateWindow(hwndParent,
     92                           WIN32_STDFRAMECLASS,
     93                           pszName, (dwWinStyle & ~WS_CLIPCHILDREN), 0, 0, 0, 0,
     94                           Owner, (fHWND_BOTTOM) ? HWND_BOTTOM : HWND_TOP,
     95                           id, NULL, NULL);
     96    hwndClient = WinCreateWindow (*hwndFrame, WIN32_STDCLASS,
     97                              NULL, dwWinStyle | WS_VISIBLE, 0, 0, 0, 0,
     98                              *hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL);
     99    return hwndClient;
    93100}
    94101//******************************************************************************
     
    294301  rc = WinSetActiveWindow(HWND_DESKTOP, hwnd);
    295302  if(rc == FALSE) {
    296         dprintf(("WinSetActiveWindow %x failure: %x", hwnd, OSLibWinGetLastError()));
     303    dprintf(("WinSetActiveWindow %x failure: %x", hwnd, OSLibWinGetLastError()));
    297304  }
    298305  return rc;
     
    394401//******************************************************************************
    395402//******************************************************************************
    396 void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld,
    397                             int parentHeight, int clientOrgX, int clientOrgY,
    398                             HWND hwnd)
     403void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld,
     404                            int parentHeight, HWND hwnd)
    399405{
    400406   HWND hWindow            = pswp->hwnd;
    401407   HWND hWndInsertAfter    = pswp->hwndInsertBehind;
    402    long x                  = pswp->x - clientOrgX;
    403    long y                  = pswp->y + clientOrgY;
     408   long x                  = pswp->x;
     409   long y                  = pswp->y;
    404410   long cx                 = pswp->cx;
    405411   long cy                 = pswp->cy;
     
    467473//******************************************************************************
    468474//******************************************************************************
    469 void OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld, 
    470                             int parentHeight, int clientOrgX, int clientOrgY, HWND hFrame)
     475void OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld,
     476                            int parentHeight, HWND hFrame)
    471477{
    472478 BOOL fCvt = FALSE;
     
    474480   HWND hWnd            = pwpos->hwnd;
    475481   HWND hWndInsertAfter = pwpos->hwndInsertAfter;
    476    long x               = pwpos->x + clientOrgX;
    477    long y               = pwpos->y + clientOrgY;
     482   long x               = pwpos->x;
     483   long y               = pwpos->y;
    478484   long cx              = pwpos->cx;
    479485   long cy              = pwpos->cy;
     
    546552}
    547553//******************************************************************************
    548 //Position in screen coordinates
     554//******************************************************************************
     555void OSLibWinSetClientPos(HWND hwnd, int x, int y, int cx, int cy, int parentHeight)
     556{
     557 SWP swp;
     558 BOOL rc;
     559
     560   swp.hwnd = hwnd;
     561   swp.hwndInsertBehind = 0;
     562   swp.x  = x;
     563   swp.y  = parentHeight - y - cy;
     564   swp.cx = cx;
     565   swp.cy = cy;
     566   swp.fl = SWP_MOVE | SWP_SIZE;
     567
     568   dprintf(("OSLibWinSetClientPos (%d,%d) (%d,%d) -> (%d,%d) (%d,%d)", x, y, x+cx, y+cy, swp.x, swp.y, swp.x+swp.cx, swp.y+swp.cy));
     569
     570   rc = WinSetMultWindowPos(GetThreadHAB(), &swp, 1);
     571   if(rc == FALSE) {
     572        dprintf(("OSLibWinSetClientPos: WinSetMultWindowPos %x failed %x", hwnd, WinGetLastError(GetThreadHAB())));
     573   }
     574}
     575//******************************************************************************
    549576//******************************************************************************
    550577BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
     
    716743//******************************************************************************
    717744//******************************************************************************
    718 void OSLibSetWindowStyle(HWND hwnd, ULONG dwStyle, ULONG dwExStyle)
    719 {
    720   ULONG dwWinStyle = WinQueryWindowULong(hwnd, QWL_STYLE);
    721   ULONG dwOldWinStyle = dwWinStyle;
    722 
    723   if(dwStyle & WS_DISABLED_W) {
    724         dwWinStyle |= WS_DISABLED;
    725   }
    726   else  dwWinStyle &= ~WS_DISABLED;
    727 
    728   if(dwStyle & WS_CLIPSIBLINGS_W) {
    729         dwWinStyle |= WS_CLIPSIBLINGS;
    730   }
    731   else  dwWinStyle &= ~WS_CLIPSIBLINGS;
    732 
    733   if(dwStyle & WS_CLIPCHILDREN_W) {
    734         dwWinStyle |= WS_CLIPCHILDREN;
    735   }
    736   else  dwWinStyle &= ~WS_CLIPCHILDREN;
    737 
    738   if(dwWinStyle != dwOldWinStyle) {
    739       WinSetWindowULong(hwnd, QWL_STYLE, dwWinStyle);
    740   }
     745void OSLibSetWindowStyle(HWND hwndFrame, HWND hwndClient, ULONG dwStyle, ULONG dwExStyle)
     746{
     747    ULONG dwWinStyle;
     748    ULONG dwOldWinStyle;
     749
     750    //client window:
     751    dwWinStyle    = WinQueryWindowULong(hwndClient, QWL_STYLE);
     752    dwOldWinStyle = dwWinStyle;
     753
     754    if(dwStyle & WS_CLIPCHILDREN_W) {
     755         dwWinStyle |= WS_CLIPCHILDREN;
     756    }
     757    else dwWinStyle &= ~WS_CLIPCHILDREN;
     758
     759    if(dwWinStyle != dwOldWinStyle) {
     760        WinSetWindowULong(hwndClient, QWL_STYLE, dwWinStyle);
     761    }
     762
     763    //Frame window
     764    dwWinStyle    = WinQueryWindowULong(hwndFrame, QWL_STYLE);
     765    dwOldWinStyle = dwWinStyle;
     766    if(dwStyle & WS_DISABLED_W) {
     767         dwWinStyle |= WS_DISABLED;
     768    }
     769    else dwWinStyle &= ~WS_DISABLED;
     770
     771    if(dwStyle & WS_CLIPSIBLINGS_W) {
     772         dwWinStyle |= WS_CLIPSIBLINGS;
     773    }
     774    else dwWinStyle &= ~WS_CLIPSIBLINGS;
     775
     776    if(dwWinStyle != dwOldWinStyle) {
     777      WinSetWindowULong(hwndFrame, QWL_STYLE, dwWinStyle);
     778    }
    741779}
    742780//******************************************************************************
     
    744782DWORD OSLibQueryWindowStyle(HWND hwnd)
    745783{
    746   return WinQueryWindowULong(hwnd, QWL_STYLE);
     784    return WinQueryWindowULong(hwnd, QWL_STYLE);
    747785}
    748786//******************************************************************************
     
    750788void OSLibWinSetVisibleRegionNotify(HWND hwnd, BOOL fNotify)
    751789{
    752   WinSetVisibleRegionNotify(hwnd, fNotify);
     790    WinSetVisibleRegionNotify(hwnd, fNotify);
    753791}
    754792//******************************************************************************
     
    756794HWND OSLibWinQueryCapture()
    757795{
    758   return WinQueryCapture(HWND_DESKTOP);
     796    return WinQueryCapture(HWND_DESKTOP);
    759797}
    760798//******************************************************************************
     
    762800BOOL OSLibWinSetCapture(HWND hwnd)
    763801{
    764   return WinSetCapture(HWND_DESKTOP, hwnd);
     802    return WinSetCapture(HWND_DESKTOP, hwnd);
    765803}
    766804//******************************************************************************
     
    768806BOOL OSLibWinRemoveFromTasklist(HANDLE hTaskList)
    769807{
    770   return (WinRemoveSwitchEntry(hTaskList)) ? FALSE : TRUE;
     808    return (WinRemoveSwitchEntry(hTaskList)) ? FALSE : TRUE;
    771809}
    772810//******************************************************************************
     
    774812HANDLE OSLibWinAddToTaskList(HWND hwndFrame, char *title, BOOL fVisible)
    775813{
    776  SWCNTRL swctrl;
    777  ULONG   tid;
    778 
    779   swctrl.hwnd          = hwndFrame;
    780   swctrl.hwndIcon      = 0;
    781   swctrl.hprog         = 0;
    782   WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
    783   swctrl.idSession     = 0;
    784   swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
    785   swctrl.fbJump        = SWL_JUMPABLE;
    786   swctrl.bProgType     = PROG_PM;
    787   if(title) {
    788         strncpy(swctrl.szSwtitle, title, MAXNAMEL+4);
    789         swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
    790   }
    791   else {
    792         swctrl.szSwtitle[0] = 0;
    793         swctrl.uchVisibility    = SWL_INVISIBLE;
    794   }
    795   return WinAddSwitchEntry(&swctrl);
     814    SWCNTRL swctrl;
     815    ULONG   tid;
     816
     817    swctrl.hwnd          = hwndFrame;
     818    swctrl.hwndIcon      = 0;
     819    swctrl.hprog         = 0;
     820    WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
     821    swctrl.idSession     = 0;
     822    swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
     823    swctrl.fbJump        = SWL_JUMPABLE;
     824    swctrl.bProgType     = PROG_PM;
     825    if(title) {
     826        strncpy(swctrl.szSwtitle, title, MAXNAMEL+4);
     827        swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
     828    }
     829    else {
     830        swctrl.szSwtitle[0] = 0;
     831        swctrl.uchVisibility    = SWL_INVISIBLE;
     832    }
     833    return WinAddSwitchEntry(&swctrl);
    796834}
    797835//******************************************************************************
     
    799837BOOL OSLibWinChangeTaskList(HANDLE hTaskList, HWND hwndFrame, char *title, BOOL fVisible)
    800838{
    801  SWCNTRL swctrl;
    802  ULONG   tid;
    803  
    804   swctrl.hwnd          = hwndFrame;
    805   swctrl.hwndIcon      = 0;
    806   swctrl.hprog         = 0;
    807   WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
    808   swctrl.idSession     = 0;
    809   swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
    810   swctrl.fbJump        = SWL_JUMPABLE;
    811   swctrl.bProgType     = PROG_PM;
    812   if(title) {
    813         strncpy(swctrl.szSwtitle, title, MAXNAMEL+4);
    814         swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
    815   }
    816   else {
    817         swctrl.szSwtitle[0] = 0;
    818         swctrl.uchVisibility    = SWL_INVISIBLE;
    819   }
    820   return (WinChangeSwitchEntry(hTaskList, &swctrl)) ? FALSE : TRUE;
     839    SWCNTRL swctrl;
     840    ULONG   tid;
     841
     842    swctrl.hwnd          = hwndFrame;
     843    swctrl.hwndIcon      = 0;
     844    swctrl.hprog         = 0;
     845    WinQueryWindowProcess(hwndFrame, (PPID)&swctrl.idProcess, (PTID)&tid);
     846    swctrl.idSession     = 0;
     847    swctrl.uchVisibility = (fVisible) ? SWL_VISIBLE : SWL_INVISIBLE;
     848    swctrl.fbJump        = SWL_JUMPABLE;
     849    swctrl.bProgType     = PROG_PM;
     850    if(title) {
     851        strncpy(swctrl.szSwtitle, title, MAXNAMEL+4);
     852        swctrl.szSwtitle[MAXNAMEL+4-1] = 0;
     853    }
     854    else {
     855        swctrl.szSwtitle[0] = 0;
     856        swctrl.uchVisibility    = SWL_INVISIBLE;
     857    }
     858    return (WinChangeSwitchEntry(hTaskList, &swctrl)) ? FALSE : TRUE;
    821859}
    822860//******************************************************************************
     
    824862BOOL OSLibWinLockWindowUpdate(HWND hwnd)
    825863{
    826   return WinLockWindowUpdate(HWND_DESKTOP, (HWND)hwnd);
     864    return WinLockWindowUpdate(HWND_DESKTOP, (HWND)hwnd);
    827865}
    828866//******************************************************************************
     
    830868ULONG OSLibGetScreenHeight()
    831869{
    832   return ScreenHeight;
     870    return ScreenHeight;
    833871}
    834872//******************************************************************************
     
    836874ULONG OSLibGetScreenWidth()
    837875{
    838   return ScreenWidth;
     876    return ScreenWidth;
    839877}
    840878//******************************************************************************
     
    845883{
    846884 SWP  swp;
    847  
    848   if(!WinGetMaxPosition(hwndOS2, &swp)) {
    849         dprintf(("WARNING: WinGetMaxPosition %x returned FALSE", hwndOS2));
    850         return FALSE;
    851   }
    852   rect->left   = swp.x;
    853   rect->right  = swp.x + swp.cx;
    854   rect->top    = ScreenHeight - (swp.y + swp.cy);
    855   rect->bottom = ScreenHeight - swp.y;
    856   return TRUE;
     885
     886    if(!WinGetMaxPosition(hwndOS2, &swp)) {
     887        dprintf(("WARNING: WinGetMaxPosition %x returned FALSE", hwndOS2));
     888        return FALSE;
     889    }
     890    rect->left   = swp.x;
     891    rect->right  = swp.x + swp.cx;
     892    rect->top    = ScreenHeight - (swp.y + swp.cy);
     893    rect->bottom = ScreenHeight - swp.y;
     894    return TRUE;
    857895}
    858896//******************************************************************************
     
    860898BOOL OSLibWinShowPointer(BOOL fShow)
    861899{
    862   return WinShowPointer(HWND_DESKTOP, fShow);
    863 }
    864 //******************************************************************************
    865 //******************************************************************************
     900    return WinShowPointer(HWND_DESKTOP, fShow);
     901}
     902//******************************************************************************
     903//******************************************************************************
  • trunk/src/user32/oslibwin.h

    r5512 r5685  
    1 /* $Id: oslibwin.h,v 1.53 2001-04-15 17:05:29 sandervl Exp $ */
     1/* $Id: oslibwin.h,v 1.54 2001-05-11 08:39:43 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    4040HWND  OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle,
    4141                           char *pszName, HWND Owner, ULONG fBottom,
    42                            ULONG id, BOOL fTaskList,BOOL fShellPosition, int classStyle);
     42                           ULONG id, BOOL fTaskList,BOOL fShellPosition,
     43                           int classStyle, HWND *hwndFrame);
    4344
    4445BOOL  OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle);
    45 void  OSLibSetWindowStyle(HWND hwnd, ULONG dwStyle, ULONG dwExStyle);
     46void  OSLibSetWindowStyle(HWND hwndFrame, HWND hwndClient, ULONG dwStyle, ULONG dwExStyle);
    4647DWORD OSLibQueryWindowStyle(HWND hwnd);
    4748
     
    250251BOOL  OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp);
    251252void  OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld,
    252                             int parentHeight, int clientOrgX, int clientOrgY,
    253                             HWND hwnd);
     253                            int parentHeight, HWND hwnd);
    254254void  OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld,
    255                              int parentHeight, int clientOrgX, int clientOrgY, HWND hFrame);
     255                             int parentHeight, HWND hFrame);
     256
     257void  OSLibWinSetClientPos(HWND hwnd, int x, int y, int cx, int cy, int parentHeight);
    256258
    257259HWND  OSLibWinBeginEnumWindows(HWND hwnd);
  • trunk/src/user32/pmwindow.cpp

    r5655 r5685  
    1 /* $Id: pmwindow.cpp,v 1.124 2001-05-04 17:02:51 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.125 2001-05-11 08:39:44 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    3434#include "oslibgdi.h"
    3535#include "oslibmsg.h"
     36#define INCLUDED_BY_DC
    3637#include "dc.h"
    3738#include <thread.h>
     
    5960MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
    6061MRESULT EXPENTRY Win32FrameWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
    61 MRESULT ProcessPMMessage(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, Win32BaseWindow *win32wnd,
    62                          MSG *pWinMsg, TEB *teb, BOOL isFrame);
    6362
    6463//******************************************************************************
     
    105104        (PSZ)WIN32_STDCLASS,               /* Window class name            */
    106105        (PFNWP)Win32WindowProc,            /* Address of window procedure  */
    107 #ifdef ODIN_HITTEST
    108106        0,
    109 #else
    110         CS_HITTEST,
    111 #endif
    112107        NROF_WIN32WNDBYTES))
    113108    {
     
    129124        (PSZ)WIN32_STDFRAMECLASS,          /* Window class name            */
    130125        (PFNWP)Win32FrameWindowProc,       /* Address of window procedure  */
    131 #ifdef ODIN_HITTEST
    132126        CS_FRAME,
    133 #else
    134         CS_HITTEST | CS_FRAME,
    135 #endif
    136127        FrameClassInfo.cbWindowData+NROF_WIN32WNDBYTES))
    137128    {
     
    166157 MSG              winMsg, *pWinMsg;
    167158 MRESULT          rc = 0;
     159 POSTMSG_PACKET  *postmsg;
     160 OSLIBPOINT       point, ClientPoint;
    168161
    169162    //Restore our FS selector
     
    175168
    176169    if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
    177         dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
     170        dprintf(("OS2: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
    178171        goto RunDefWndProc;
    179172    }
     
    205198    }
    206199    //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- END
    207     rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, FALSE);
    208     RestoreOS2TIB();
    209     return rc;
    210 
    211 RunDefWndProc:
    212     RestoreOS2TIB();
    213     return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    214 }
    215 //******************************************************************************
    216 //******************************************************************************
    217 MRESULT ProcessPMMessage(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2, Win32BaseWindow *win32wnd, MSG *pWinMsg, TEB *teb, BOOL isFrame)
    218 {
    219  POSTMSG_PACKET  *postmsg;
    220  OSLIBPOINT       point, ClientPoint;
    221  MRESULT          rc = 0;
    222 
    223   if(msg == WIN32APP_POSTMSG) {
     200
     201    if(msg == WIN32APP_POSTMSG) {
    224202        //probably win32 app user message
    225203        if((ULONG)mp1 == WIN32MSG_MAGICA) {
     
    230208            return (MRESULT)win32wnd->DispatchMsgW(pWinMsg);
    231209        }
    232   }
    233   else
    234   if(msg == WIN32APP_SETFOCUSMSG) {
     210    }
     211    else
     212    if(msg == WIN32APP_SETFOCUSMSG) {
    235213      //PM doesn't allow SetFocus calls during WM_SETFOCUS message processing;
    236214      //must delay this function call
     
    240218      teb->o.odin.hwndFocus = 0;
    241219      WinFocusChange(HWND_DESKTOP, hwnd, mp2 ? FC_NOLOSEACTIVE : 0);
    242   }
    243 
    244   switch( msg )
    245   {
     220    }
     221
     222    switch( msg )
     223    {
    246224    //OS/2 msgs
    247225    case WM_CREATE:
     
    280258    case WM_ENABLE:
    281259        dprintf(("OS2: WM_ENABLE %x", hwnd));
    282         win32wnd->MsgEnable(SHORT1FROMMP(mp1));
    283260        break;
    284261
    285262    case WM_SHOW:
    286263        dprintf(("OS2: WM_SHOW %x %d", hwnd, mp1));
    287         win32wnd->MsgShow((ULONG)mp1);
    288         break;
    289 
    290     case WM_ADJUSTWINDOWPOS:
    291     {
    292       PSWP     pswp = (PSWP)mp1;
    293       SWP      swpOld;
    294       WINDOWPOS wp,wpOld;
    295       HWND      hParent = NULLHANDLE, hwndAfter;
    296 
    297         dprintf(("OS2: WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    298 
    299         if(pswp->fl & SWP_NOADJUST) {
    300             //ignore weird messages (TODO: why are they sent?)
    301             break;
    302         }
    303         //CB: show dialog in front of owner
    304         if (win32wnd->IsModalDialogOwner())
    305         {
    306             dprintf(("win32wnd->IsModalDialogOwner %x", win32wnd->getWindowHandle()));
    307             pswp->fl |= SWP_ZORDER;
    308             pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
    309             if (pswp->fl & SWP_ACTIVATE)
    310             {
    311                 pswp->fl &= ~SWP_ACTIVATE;
    312                 WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
    313             }
    314         }
    315 
    316         if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
    317             goto RunDefWndProc;
    318 
    319         if(!win32wnd->CanReceiveSizeMsgs())
    320             break;
    321 
    322         WinQueryWindowPos(hwnd, &swpOld);
    323         if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
    324             if (win32wnd->isChild()) {
    325                 if(win32wnd->getParent()) {
    326                         hParent = win32wnd->getParent()->getOS2WindowHandle();
    327                 }
    328                 else    goto RunDefWndProc;
    329             }
    330         }
    331         hwndAfter = pswp->hwndInsertBehind;
    332         if(win32wnd->getParent()) {
    333             OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    334                                    win32wnd->getParent()->getClientRectPtr()->left,
    335                                    win32wnd->getParent()->getClientRectPtr()->top,
    336                                    hwnd);
    337         }
    338         else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
    339 
    340         wp.hwnd = win32wnd->getWindowHandle();
    341         if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
    342         {
    343            Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
    344            if(wndAfter) {
    345                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
    346            }
    347            else wp.hwndInsertAfter = HWND_TOP_W;
    348         }
    349 
    350         wpOld = wp;
    351         win32wnd->MsgPosChanging((LPARAM)&wp);
    352 
    353         if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
    354             (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
    355         {
    356             ULONG flags = pswp->fl;      //make a backup copy; OSLibMapWINDOWPOStoSWP will modify it
    357 
    358             dprintf(("OS2: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
    359             dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    360 
    361             if(win32wnd->getParent()) {
    362                   OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    363                                          win32wnd->getParent()->getClientRectPtr()->left,
    364                                          win32wnd->getParent()->getClientRectPtr()->top,
    365                                          hwnd);
    366             }
    367             else  OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
    368 
    369             dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    370 
    371             //OSLibMapWINDOWPOStoSWP can add flags, but we must not let it remove flags!
    372             if(pswp->fl & SWP_SIZE)
    373                 flags |= SWP_SIZE;
    374 
    375             if(pswp->fl & SWP_MOVE)
    376                 flags |= SWP_MOVE;
    377 
    378             pswp->fl = flags;   //restore flags
    379 
    380             pswp->fl |= SWP_NOADJUST;
    381             pswp->hwndInsertBehind = hwndAfter;
    382             pswp->hwnd = hwnd;
    383 
    384             return (MRESULT)0xf;
    385         }
    386         return (MRESULT)0;
    387     }
    388 
    389     case WM_WINDOWPOSCHANGED:
    390     {
    391       PSWP      pswp   = (PSWP)mp1,pswpOld = pswp+1;
    392       SWP       swpOld = *(pswp + 1);
    393       WINDOWPOS wp;
    394       HWND      hParent = NULLHANDLE;
    395       RECTL     rect;
    396 
    397         dprintf(("OS2: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    398 
    399         if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
    400         {
    401             if(pswp->fl & SWP_ACTIVATE)
    402             {
    403                 //Only send PM WM_ACTIVATE to top-level windows (frame windows)
    404                 if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE))
    405                 {
    406                         WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
    407                 }
    408             }
    409             else
    410             if(pswp->fl & SWP_DEACTIVATE)
    411             {
    412                 //Only send PM WM_ACTIVATE to top-level windows (frame windows)
    413                 if(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE)
    414                 {
    415                         WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)hwnd);
    416                 }
    417             }
    418             goto RunDefWndProc;
    419         }
    420 
    421         if(pswp->fl & (SWP_MOVE | SWP_SIZE))
    422         {
    423             if(win32wnd->isChild())
    424             {
    425                 if(win32wnd->getParent()) {
    426                         hParent = win32wnd->getParent()->getOS2WindowHandle();
    427                 }
    428                 else    goto PosChangedEnd; //parent has just been destroyed
    429             }
    430         }
    431 
    432 
    433         if(win32wnd->getParent()) {
    434              OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    435                                     win32wnd->getParent()->getClientRectPtr()->left,
    436                                     win32wnd->getParent()->getClientRectPtr()->top,
    437                                     hwnd);
    438         }
    439         else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
    440 
    441         wp.hwnd = win32wnd->getWindowHandle();
    442         if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
    443         {
    444             Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
    445             if(wndAfter) {
    446                  wp.hwndInsertAfter = wndAfter->getWindowHandle();
    447             }
    448             else wp.hwndInsertAfter = HWND_TOP_W;
    449         }
    450 
    451 #ifndef USE_CALCVALIDRECT
    452         if((pswp->fl & (SWP_MOVE | SWP_SIZE)))
    453         {
    454             //CB: todo: use result for WM_CALCVALIDRECTS
    455             //Get old client rectangle (for invalidation of frame window parts later on)
    456             //Use new window height to calculate the client area
    457             mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
    458 
    459             //Note: Also updates the new window rectangle
    460             win32wnd->MsgFormatFrame(&wp);
    461 
    462             if(win32wnd->isOwnDC()) {
    463                 dprintf(("Mark owndc of %x as dirty", win32wnd->getWindowHandle()));
    464                 win32wnd->invalidateOwnDC(); //mark DC as dirty. origin & visible region must be reinitialized
    465             }
    466             if(win32wnd->CanReceiveSizeMsgs())
    467                 win32wnd->MsgPosChanged((LPARAM)&wp);
    468 
    469             if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
    470             {
    471                 //redraw the frame (to prevent unnecessary client updates)
    472                 BOOL redrawAll = FALSE;
    473 
    474                 if (win32wnd->getWindowClass())
    475                 {
    476                     DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
    477 
    478                     if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
    479                         redrawAll = TRUE;
    480                     else
    481                     if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
    482                         redrawAll = TRUE;
    483                 }
    484                 else redrawAll = TRUE;
    485 
    486                 if(win32wnd->IsMixMaxStateChanging()) {
    487                     dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
    488                     redrawAll = TRUE;
    489                 }
    490 
    491                 if (redrawAll)
    492                 {
    493                     //CB: redraw all children for now
    494                     //    -> problems with update region if we don't do it
    495                     //       todo: rewrite whole handling
    496                     WinInvalidateRect(hwnd,NULL,TRUE);
    497                 }
    498                 else
    499                 {
    500                     HPS hps = WinGetPS(hwnd);
    501                     RECTL frame,client,arcl[4];
    502 
    503                     WinQueryWindowRect(hwnd,&frame);
    504 
    505                     //top
    506                     arcl[0].xLeft = 0;
    507                     arcl[0].xRight = frame.xRight;
    508                     arcl[0].yBottom = rect.yTop;
    509                     arcl[0].yTop = frame.yTop;
    510                     //right
    511                     arcl[1].xLeft = rect.xRight;
    512                     arcl[1].xRight = frame.xRight;
    513                     arcl[1].yBottom = 0;
    514                     arcl[1].yTop = frame.yTop;
    515                     //left
    516                     arcl[2].xLeft = 0;
    517                     arcl[2].xRight = rect.xLeft;
    518                     arcl[2].yBottom = 0;
    519                     arcl[2].yTop = frame.yTop;
    520                     //bottom
    521                     arcl[3].xLeft = 0;
    522                     arcl[3].xRight = frame.xRight;
    523                     arcl[3].yBottom = 0;
    524                     arcl[3].yTop = rect.yBottom;
    525 
    526                     HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
    527 
    528                     WinInvalidateRegion(hwnd,hrgn,FALSE);
    529                     GpiDestroyRegion(hps,hrgn);
    530                     WinReleasePS(hps);
    531                 }
    532             }
    533         }
    534         else
    535         {
    536 #endif //USE_CALCVALIDRECT
    537             if(win32wnd->CanReceiveSizeMsgs())
    538                 win32wnd->MsgPosChanged((LPARAM)&wp);
    539 #ifndef USE_CALCVALIDRECT
    540         }
    541 #endif
    542 
    543         if(pswp->fl & SWP_ACTIVATE)
    544         {
    545              //Only send PM WM_ACTIVATE to top-level windows (frame windows)
    546              if(!(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE))
    547              {
    548                 WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
    549              }
    550         }
    551         else
    552         if(pswp->fl & SWP_DEACTIVATE)
    553         {
    554             //Only send PM WM_ACTIVATE to top-level windows (frame windows)
    555             if(WinQueryWindowULong(hwnd, OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE)
    556             {
    557                     WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)hwnd);
    558             }
    559         }
    560 
    561 PosChangedEnd:
    562         return (MRESULT)FALSE;
    563     }
     264        break;
    564265
    565266    case WM_ACTIVATE:
     
    568269
    569270        dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
    570 
    571271        WinSetWindowULong(hwnd, OFFSET_WIN32FLAGS, SHORT1FROMMP(mp1) ? (flags | WINDOWFLAG_ACTIVE):(flags & ~WINDOWFLAG_ACTIVE));
    572272        if(win32wnd->IsWindowCreated())
    573273        {
    574274            win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
    575 
    576             //CB: show owner behind the dialog
    577             if(win32wnd->IsModalDialog())
    578             {
    579                 Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
    580 
    581                 if(topOwner) WinSetWindowPos(topOwner->getOS2WindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
    582             }
    583         }
    584         return 0;
     275        }
     276        break;
    585277    }
    586278
    587279    case WM_SIZE:
    588280    {
    589         dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp2)));
     281        dprintf(("OS2: WM_SIZE (%d,%d) (%d,%d)", SHORT1FROMMP(mp2), SHORT2FROMMP(mp2), SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)));
     282        win32wnd->SetVisibleRegionChanged(TRUE);
    590283        goto RunDefWndProc;
    591284    }
    592285
    593     case WM_CALCVALIDRECTS:
    594 #ifdef USE_CALCVALIDRECT
    595     {
    596         PRECTL    oldRect = (PRECTL)mp1, newRect = oldRect+1;
    597         PSWP      pswp = (PSWP)mp2;
    598         SWP       swpOld;
    599         WINDOWPOS wp;
    600         RECTL     newClientRect, oldClientRect;
    601         ULONG     nccalcret;
    602 //        UINT      res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
    603         UINT      res = 0;
    604 
    605         dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
    606 
    607         //Get old position info
    608         WinQueryWindowPos(hwnd, &swpOld);
    609 
    610         if(win32wnd->getParent()) {
    611              OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
    612                                     win32wnd->getParent()->getClientRectPtr()->left,
    613                                     win32wnd->getParent()->getClientRectPtr()->top,
    614                                     hwnd);
    615         }
    616         else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
    617 
    618         wp.hwnd = win32wnd->getWindowHandle();
    619         if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
    620         {
    621             Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
    622             if(wndAfter) {
    623                  wp.hwndInsertAfter = wndAfter->getWindowHandle();
    624             }
    625             else wp.hwndInsertAfter = HWND_TOP_W;
    626         }
    627 
    628         //Get old client rectangle
    629         mapWin32ToOS2Rect(oldRect->yTop - oldRect->yBottom, win32wnd->getClientRectPtr(), (PRECTLOS2)&oldClientRect);
    630 
    631         //Note: Also updates the new window rectangle
    632         nccalcret = win32wnd->MsgFormatFrame(&wp);
    633 
    634         //Get new client rectangle
    635         mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&newClientRect);
    636 
    637         if(nccalcret == 0) {
    638             res = CVR_ALIGNTOP | CVR_ALIGNLEFT;
    639         }
    640         else {
    641             if(nccalcret & WVR_ALIGNTOP_W) {
    642                 res |= CVR_ALIGNTOP;
    643             }
    644             else
    645             if(nccalcret & WVR_ALIGNBOTTOM_W) {
    646                 res |= CVR_ALIGNBOTTOM;
    647             }
    648 
    649             if(nccalcret & WVR_ALIGNLEFT_W) {
    650                 res |= CVR_ALIGNLEFT;
    651             }
    652             else
    653             if(nccalcret & WVR_ALIGNRIGHT_W) {
    654                 res |= CVR_ALIGNRIGHT;
    655             }
    656 
    657             if(nccalcret & WVR_REDRAW_W) {//WVR_REDRAW_W = (WVR_HREDRAW | WVR_VREDRAW)
    658                 res |= CVR_REDRAW;
    659             }
    660             else
    661             if(nccalcret & WVR_VALIDRECTS_W) {
    662                 //TODO:
    663                 //res = 0;
    664             }
    665         }
    666         if(win32wnd->IsMixMaxStateChanging()) {
    667             dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
    668             res |= CVR_REDRAW;
    669         }
    670         if(res == (CVR_ALIGNTOP|CVR_ALIGNLEFT)) {
    671             oldRect->xRight  -= oldClientRect.xLeft;
    672             oldRect->yBottom += oldClientRect.yBottom;
    673             newRect->xRight  -= newClientRect.xLeft;
    674             newRect->yBottom += newClientRect.yBottom;
    675         }
    676 
    677 #if 0
    678             if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
    679             {
    680                 //redraw the frame (to prevent unnecessary client updates)
    681                 BOOL redrawAll = FALSE;
    682 
    683                 if (win32wnd->getWindowClass())
    684                 {
    685                     DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
    686 
    687                     if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
    688                         redrawAll = TRUE;
    689                     else
    690                     if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
    691                         redrawAll = TRUE;
    692                 }
    693                 else redrawAll = TRUE;
    694 
    695                 if (redrawAll)
    696                 {
    697                     //CB: redraw all children for now
    698                     //    -> problems with update region if we don't do it
    699                     //       todo: rewrite whole handling
    700                     WinInvalidateRect(hwnd,NULL,TRUE);
    701                 }
    702                 else
    703                 {
    704                     HPS hps = WinGetPS(hwnd);
    705                     RECTL frame,client,arcl[4];
    706 
    707                     WinQueryWindowRect(hwnd,&frame);
    708 
    709                     //top
    710                     arcl[0].xLeft = 0;
    711                     arcl[0].xRight = frame.xRight;
    712                     arcl[0].yBottom = rect.yTop;
    713                     arcl[0].yTop = frame.yTop;
    714                     //right
    715                     arcl[1].xLeft = rect.xRight;
    716                     arcl[1].xRight = frame.xRight;
    717                     arcl[1].yBottom = 0;
    718                     arcl[1].yTop = frame.yTop;
    719                     //left
    720                     arcl[2].xLeft = 0;
    721                     arcl[2].xRight = rect.xLeft;
    722                     arcl[2].yBottom = 0;
    723                     arcl[2].yTop = frame.yTop;
    724                     //bottom
    725                     arcl[3].xLeft = 0;
    726                     arcl[3].xRight = frame.xRight;
    727                     arcl[3].yBottom = 0;
    728                     arcl[3].yTop = rect.yBottom;
    729 
    730                     HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
    731 
    732                     WinInvalidateRegion(hwnd,hrgn,FALSE);
    733                     GpiDestroyRegion(hps,hrgn);
    734                     WinReleasePS(hps);
    735                 }
    736             }
    737 
    738         }
    739 #endif
    740 
    741         return (MRESULT)res;
    742     }
    743 #else
    744       dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
    745       return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
    746 #endif
    747286
    748287    case WM_VRNENABLED:
     
    750289        if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
    751290        {
    752                 HWND hwndrelated;
    753                 Win32BaseWindow *topwindow;
    754 
    755                 win32wnd->setComingToTop(TRUE);
    756 
    757                 hwndrelated = WinQueryWindow(hwnd, QW_PREV);
    758                 dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
    759                 topwindow = Win32BaseWindow::GetWindowFromOS2Handle(hwndrelated);
    760                 if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
    761                         //put window at the top of z order
    762                         WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
    763                 }
    764 
    765                 win32wnd->setComingToTop(FALSE);
    766                 break;
    767         }
    768         //Restore window origin of window with CS_OWNDC style
    769         //(fixes paint offset problems in Opera windows)
    770         if(win32wnd->isOwnDC()) {
    771                 dprintfOrigin(win32wnd->getOwnDC());
    772                 selectClientArea(win32wnd, win32wnd->getOwnDC());
     291            HWND hwndrelated;
     292            Win32BaseWindow *topwindow;
     293
     294            win32wnd->setComingToTop(TRUE);
     295
     296            hwndrelated = WinQueryWindow(hwnd, QW_PREV);
     297            dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
     298            topwindow = Win32BaseWindow::GetWindowFromOS2Handle(hwndrelated);
     299            if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
     300                //put window at the top of z order
     301                WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
     302            }
     303
     304            win32wnd->setComingToTop(FALSE);
     305            break;
    773306        }
    774307        goto RunDefWndProc;
     
    776309    case WM_VRNDISABLED:
    777310        dprintf(("OS2: WM_VRNDISABLED %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
    778         if(win32wnd->isOwnDC()) {
    779                 dprintfOrigin(win32wnd->getOwnDC());
    780         }
    781311        goto RunDefWndProc;
    782312
     
    808338    }
    809339
    810 #if 0
    811     //is sent to both windows gaining and loosing the focus
    812     case WM_FOCUSCHANGE:
    813     {
    814      HWND   hwndFocus = (HWND)mp1;
    815      HWND   hwndLoseFocus, hwndGainFocus;
    816      USHORT usSetFocus = SHORT1FROMMP(mp2);
    817      USHORT fsFocusChange = SHORT2FROMMP(mp2);
    818 
    819         rc = 0;
    820         dprintf(("OS2: WM_FOCUSCHANGE (start) %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
    821         if(usSetFocus) {
    822             hwndGainFocus = hwnd;
    823             hwndLoseFocus = hwndFocus;
    824         }
    825         else {
    826             hwndGainFocus = hwndFocus;
    827             hwndLoseFocus = hwnd;
    828         }
    829 
    830         if(usSetFocus)
    831         {
    832           Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndLoseFocus);
    833           if(!(fsFocusChange & FC_NOSETACTIVE))
    834           {
    835             if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
    836             {
    837               if(winfocus)
    838                 WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    839               else
    840                 WinSendMsg(hwndLoseFocus, WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    841             }
    842           }
    843           //SvL: Check if window is still valid
    844           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    845           if(win32wnd == NULL)
    846             return (MRESULT)rc;
    847 
    848           if(!(fsFocusChange & FC_NOSETACTIVE))
    849           {
    850             Win32BaseWindow *topparent = win32wnd->GetTopParent();
    851             if(!winfocus || (winfocus->GetTopParent() != topparent))
    852             {
    853               if(!(fsFocusChange & FC_NOBRINGTOTOP))
    854               {
    855                 if(topparent) {
    856                   //put window at the top of z order
    857                   WinSetWindowPos(topparent->getOS2WindowHandle(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
    858                 }
    859               }
    860 
    861               // PH 2000/09/01 Netscape 4.7
    862               // check if topparent is valid
    863               if (topparent)
    864                 WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    865             }
    866           }
    867           //SvL: Check if window is still valid
    868           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    869           if(win32wnd == NULL)
    870             return (MRESULT)rc;
    871 
    872       //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
    873       if(!(fsFocusChange & FC_NOSETSELECTION)) {
    874             WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
    875       }
    876 
    877       if(!(fsFocusChange & FC_NOSETFOCUS)) {
    878             WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
    879       }
    880         }
    881         else /* no usSetFocus */
    882         {
    883       if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
    884             WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
    885       }
    886       //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
    887       if(!(fsFocusChange & FC_NOLOSESELECTION)) {
    888             WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
    889       }
    890           //SvL: Check if window is still valid
    891           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    892           if(win32wnd == NULL) {
    893                 return (MRESULT)rc;
    894           }
    895 
    896           Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndGainFocus);
    897           if(!(fsFocusChange & FC_NOLOSEACTIVE))
    898           {
    899             Win32BaseWindow *topparent = win32wnd->GetTopParent();
    900 
    901             if(!winfocus || (winfocus->GetTopParent() != topparent))
    902             {
    903               // PH 2000/09/01 Netscape 4.7
    904               // check if topparent is valid
    905               if (topparent)
    906                 WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    907             }
    908           }
    909           //SvL: Check if window is still valid
    910           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    911           if(win32wnd == NULL)
    912             return (MRESULT)rc;
    913 
    914           if(!(fsFocusChange & FC_NOSETACTIVE))
    915           {
    916             if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
    917             {
    918               if(winfocus)
    919               {
    920                 // PH 2000/09/01 Netscape 4.7
    921                 // check if topparent is valid
    922                 Win32BaseWindow *topparent = winfocus->GetTopParent();
    923                 if (topparent)
    924                   WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    925               }
    926               else
    927                 WinSendMsg(hwndGainFocus, WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    928             }
    929           }
    930         }
    931 
    932 
    933 #ifdef DEBUG
    934         SetWin32TIB();
    935         dprintf(("OS2: WM_FOCUSCHANGE (end) %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
    936 #endif
    937         return (MRESULT)rc;
    938     }
    939 #endif
    940 
    941340    //**************************************************************************
    942341    //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
    943342    //**************************************************************************
    944 #ifndef ODIN_HITTEST
    945     case WM_HITTEST:
    946     {
    947         if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
    948             win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    949         }
    950         if(win32wnd && win32wnd->IsWindowCreated())
    951         {
    952             MRESULT rc;
    953 
    954             rc = (MRESULT)win32wnd->MsgHitTest(pWinMsg);
    955             return rc;
    956         }
    957         return (MRESULT)HT_NORMAL;
    958     }
    959 #endif
    960343
    961344    case WM_BUTTON1DOWN:
     
    991374    case WM_MOUSEMOVE:
    992375    {
    993     if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
    994         win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    995     }
     376        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     377            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     378        }
    996379        if(win32wnd)
    997380            win32wnd->MsgMouseMove(pWinMsg);
     
    1068451           rectl.yBottom != rectl.yTop))
    1069452        {
    1070             PRECT pClient = win32wnd->getClientRectPtr();
    1071             PRECT pWindow = win32wnd->getWindowRect();
    1072 
    1073             if(!(pClient->left == 0 && pClient->top == 0 &&
    1074                win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
    1075                win32wnd->getClientWidth()  == win32wnd->getWindowWidth()))
    1076             {
    1077                 win32wnd->MsgNCPaint();
    1078             }
    1079             win32wnd->DispatchMsgA(pWinMsg);
     453                win32wnd->DispatchMsgA(pWinMsg);
    1080454        }
    1081455        else    goto RunDefWndProc;
    1082 
    1083         //SvL: Not calling the default window procedure causes all sorts of
    1084         //     strange problems (redraw & hanging app)
    1085         //     -> check what WinBeginPaint does what we're forgetting in BeginPaint
    1086 //      WinQueryUpdateRect(hwnd, &rectl);
    1087 //        if(rectl.xLeft == 0 && rectl.yTop == 0 && rectl.xRight == 0 && rectl.yBottom == 0) {
    1088 //          RestoreOS2TIB();
    1089 //          return (MRESULT)FALSE;
    1090 //  }
    1091 //  dprintf(("Update rectangle (%d,%d)(%d,%d) not empty, msg %x", rectl.xLeft, rectl.yTop, rectl.xRight, rectl.yBottom, pWinMsg->message));
    1092 //  goto RunDefWndProc;
    1093456        break;
    1094457    }
     
    1100463    }
    1101464
    1102 #if 0
    1103     case WM_CONTEXTMENU:
    1104     {
    1105         win32wnd->DispatchMsgA(pWinMsg);
    1106 
    1107         return (MRESULT)TRUE;
    1108     }
    1109 #endif
    1110 
    1111     case WM_QUERYTRACKINFO:
    1112     {
    1113       PTRACKINFO trackInfo = (PTRACKINFO)mp2;
    1114 
    1115         dprintf(("OS2: WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
    1116         trackInfo->cxBorder = 4;
    1117         trackInfo->cyBorder = 4;
    1118         win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
    1119         return (MRESULT)TRUE;
    1120     }
    1121 
    1122     case WM_QUERYBORDERSIZE:
    1123     {
    1124       PWPOINT size = (PWPOINT)mp1;
    1125 
    1126       dprintf(("OS2: WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
    1127 
    1128       size->x = 0;
    1129       size->y = 0;
    1130       return (MRESULT)TRUE;
    1131     }
     465    case WM_CALCVALIDRECTS:
     466      dprintf(("OS2: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
     467      return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
    1132468
    1133469    case WM_REALIZEPALETTE:
     
    1163499    default:
    1164500        dprintf2(("OS2: RunDefWndProc hwnd %x msg %x mp1 %x mp2 %x", hwnd, msg, mp1, mp2));
    1165         RestoreOS2TIB();
    1166         if(isFrame) {
    1167              return pfnFrameWndProc(hwnd, msg, mp1, mp2);
    1168         }
    1169         else return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    1170   }
    1171   return (MRESULT)rc;
     501        goto RunDefWndProc;
     502    }
     503    return (MRESULT)rc;
    1172504
    1173505RunDefWndProc:
    1174506//  dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
    1175   RestoreOS2TIB();
    1176   if(isFrame) {
    1177        return pfnFrameWndProc(hwnd, msg, mp1, mp2);
    1178   }
    1179   else return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     507    RestoreOS2TIB();
     508    return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    1180509} /* End of Win32WindowProc */
    1181510//******************************************************************************
     
    1195524    //NOTE-------------->>>>>> If this is changed, also change Win32WindowProc!! <<<<<<<<<<<-------------------- BEGIN
    1196525    teb = GetThreadTEB();
    1197     win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     526    win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
    1198527
    1199528    if(!teb || (msg != WM_CREATE && win32wnd == NULL)) {
    1200         dprintf(("Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
     529        dprintf(("PMFRAME: Invalid win32wnd pointer for window %x msg %x", hwnd, msg));
    1201530        goto RunDefFrameWndProc;
    1202531    }
     
    1233562    case WM_CREATE:
    1234563    {
    1235         RestoreOS2TIB();
    1236         pfnFrameWndProc(hwnd, msg, mp1, mp2);
    1237         SetWin32TIB();
    1238         rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
    1239         break;
    1240     }
     564        //WM_CREATE handled during client window creation
     565        goto RunDefFrameWndProc;
     566    }
     567
     568    case WM_PAINT:
     569    {
     570      RECTL rectl;
     571
     572
     573        HPS hps = WinBeginPaint(hwnd, NULL, &rectl);
     574        dprintf(("PMFRAME: WM_PAINT %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
     575
     576        if(win32wnd->IsWindowCreated() && (rectl.xLeft != rectl.xRight &&
     577           rectl.yBottom != rectl.yTop))
     578        {
     579            PRECT pClient = win32wnd->getClientRectPtr();
     580            PRECT pWindow = win32wnd->getWindowRect();
     581
     582            if(!(pClient->left == 0 && pClient->top == 0 &&
     583               win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
     584               win32wnd->getClientWidth()  == win32wnd->getWindowWidth()))
     585            {
     586                RECT rectUpdate;
     587
     588                mapOS2ToWin32Rect(win32wnd->getWindowHeight(), (PRECTLOS2)&rectl, &rectUpdate);
     589                win32wnd->MsgNCPaint(&rectUpdate);
     590            }
     591        }
     592        WinEndPaint(hps);
     593        break;
     594    }
     595
     596    case WM_ERASEBACKGROUND:
     597    {
     598        dprintf(("PMFRAME:WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
     599        return (MRESULT)FALSE;
     600    }
     601
     602    //**************************************************************************
     603    //Mouse messages (OS/2 Window coordinates -> Win32 coordinates relative to screen
     604    //**************************************************************************
     605
     606    case WM_BUTTON1DOWN:
     607    case WM_BUTTON1UP:
     608    case WM_BUTTON1DBLCLK:
     609    case WM_BUTTON2DOWN:
     610    case WM_BUTTON2UP:
     611    case WM_BUTTON2DBLCLK:
     612    case WM_BUTTON3DOWN:
     613    case WM_BUTTON3UP:
     614    case WM_BUTTON3DBLCLK:
     615        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     616            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     617        }
     618        if(win32wnd)
     619            win32wnd->MsgButton(pWinMsg);
     620
     621        rc = (MRESULT)TRUE;
     622        break;
     623
     624    case WM_BUTTON2MOTIONSTART:
     625    case WM_BUTTON2MOTIONEND:
     626    case WM_BUTTON2CLICK:
     627    case WM_BUTTON1MOTIONSTART:
     628    case WM_BUTTON1MOTIONEND:
     629    case WM_BUTTON1CLICK:
     630    case WM_BUTTON3MOTIONSTART:
     631    case WM_BUTTON3MOTIONEND:
     632    case WM_BUTTON3CLICK:
     633        rc = (MRESULT)TRUE;
     634        break;
     635
     636    case WM_MOUSEMOVE:
     637    {
     638        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     639            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     640        }
     641        if(win32wnd)
     642            win32wnd->MsgMouseMove(pWinMsg);
     643        break;
     644    }
     645
     646    case WM_ADJUSTWINDOWPOS:
     647    {
     648      PSWP     pswp = (PSWP)mp1;
     649      SWP      swpOld;
     650      WINDOWPOS wp,wpOld;
     651      HWND      hParent = NULLHANDLE, hwndAfter;
     652
     653        dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     654
     655        if(pswp->fl & SWP_NOADJUST) {
     656            //ignore weird messages (TODO: why are they sent?)
     657            break;
     658        }
     659        //CB: show dialog in front of owner
     660        if (win32wnd->IsModalDialogOwner())
     661        {
     662            dprintf(("win32wnd->IsModalDialogOwner %x", win32wnd->getWindowHandle()));
     663            pswp->fl |= SWP_ZORDER;
     664            pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
     665            if (pswp->fl & SWP_ACTIVATE)
     666            {
     667                pswp->fl &= ~SWP_ACTIVATE;
     668                WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
     669            }
     670        }
     671
     672        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
     673            goto RunDefWndProc;
     674
     675        if(!win32wnd->CanReceiveSizeMsgs())
     676            break;
     677
     678        WinQueryWindowPos(hwnd, &swpOld);
     679        if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
     680            if (win32wnd->isChild()) {
     681                if(win32wnd->getParent()) {
     682                        hParent = win32wnd->getParent()->getOS2WindowHandle();
     683                }
     684                else    goto RunDefWndProc;
     685            }
     686        }
     687        hwndAfter = pswp->hwndInsertBehind;
     688        if(win32wnd->getParent()) {
     689             OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(), hwnd);
     690        }
     691        else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
     692
     693        wp.hwnd = win32wnd->getWindowHandle();
     694        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     695        {
     696           Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     697           if(wndAfter) {
     698                wp.hwndInsertAfter = wndAfter->getWindowHandle();
     699           }
     700           else wp.hwndInsertAfter = HWND_TOP_W;
     701        }
     702
     703        wpOld = wp;
     704        win32wnd->MsgPosChanging((LPARAM)&wp);
     705
     706        if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
     707            (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
     708        {
     709            ULONG flags = pswp->fl;      //make a backup copy; OSLibMapWINDOWPOStoSWP will modify it
     710
     711            dprintf(("PMFRAME:WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
     712            dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     713
     714            if(win32wnd->getParent()) {
     715                  OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getClientHeight(),
     716                                         hwnd);
     717            }
     718            else  OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), hwnd);
     719
     720            dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     721
     722            //OSLibMapWINDOWPOStoSWP can add flags, but we must not let it remove flags!
     723            if(pswp->fl & SWP_SIZE)
     724                flags |= SWP_SIZE;
     725
     726            if(pswp->fl & SWP_MOVE)
     727                flags |= SWP_MOVE;
     728
     729            pswp->fl = flags;   //restore flags
     730
     731            pswp->fl |= SWP_NOADJUST;
     732            pswp->hwndInsertBehind = hwndAfter;
     733            pswp->hwnd = hwnd;
     734
     735            return (MRESULT)0xf;
     736        }
     737        return (MRESULT)0;
     738    }
     739
     740    case WM_WINDOWPOSCHANGED:
     741    {
     742      PSWP      pswp   = (PSWP)mp1,pswpOld = pswp+1;
     743      SWP       swpOld = *(pswp + 1);
     744      WINDOWPOS wp;
     745      HWND      hParent = NULLHANDLE;
     746      RECTL     rect;
     747
     748        dprintf(("PMFRAME:WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     749
     750        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
     751        {
     752            if(pswp->fl & SWP_ACTIVATE)
     753            {
     754                //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     755                if(!(WinQueryWindowULong(WinWindowFromID(hwnd,FID_CLIENT), OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE))
     756                {
     757                    WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
     758                }
     759            }
     760            else
     761            if(pswp->fl & SWP_DEACTIVATE)
     762            {
     763                //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     764                if(WinQueryWindowULong(WinWindowFromID(hwnd,FID_CLIENT), OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE)
     765                {
     766                    WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)hwnd);
     767                }
     768            }
     769            goto RunDefWndProc;
     770        }
     771
     772        if(pswp->fl & (SWP_MOVE | SWP_SIZE))
     773        {
     774            if(win32wnd->isChild())
     775            {
     776                if(win32wnd->getParent()) {
     777                        hParent = win32wnd->getParent()->getOS2WindowHandle();
     778                }
     779                else    goto PosChangedEnd; //parent has just been destroyed
     780            }
     781        }
     782
     783
     784        if(win32wnd->getParent()) {
     785             OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
     786                                    hwnd);
     787        }
     788        else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), hwnd);
     789
     790        wp.hwnd = win32wnd->getWindowHandle();
     791        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     792        {
     793            Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     794            if(wndAfter) {
     795                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
     796            }
     797            else wp.hwndInsertAfter = HWND_TOP_W;
     798        }
     799
     800        if(pswp->fl & SWP_SHOW) {
     801            WinShowWindow(win32wnd->getOS2WindowHandle(), 1);
     802        }
     803#ifndef USE_CALCVALIDRECT
     804        if((pswp->fl & (SWP_MOVE | SWP_SIZE)))
     805        {
     806            //CB: todo: use result for WM_CALCVALIDRECTS
     807            //Get old client rectangle (for invalidation of frame window parts later on)
     808            //Use new window height to calculate the client area
     809            mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
     810
     811            //Note: Also updates the new window rectangle
     812            win32wnd->MsgFormatFrame(&wp);
     813
     814            if(win32wnd->isOwnDC()) {
     815                setPageXForm(win32wnd, (pDCData)GpiQueryDCData(win32wnd->getOwnDC()));
     816            }
     817
     818            if(win32wnd->CanReceiveSizeMsgs())
     819                win32wnd->MsgPosChanged((LPARAM)&wp);
     820
     821            if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
     822            {
     823                //redraw the frame (to prevent unnecessary client updates)
     824                BOOL redrawAll = FALSE;
     825
     826                dprintf2(("WM_WINDOWPOSCHANGED: redraw frame"));
     827                if (win32wnd->getWindowClass())
     828                {
     829                    DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
     830
     831                    if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
     832                        redrawAll = TRUE;
     833                    else
     834                    if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
     835                        redrawAll = TRUE;
     836                }
     837                else redrawAll = TRUE;
     838
     839                if(win32wnd->IsMixMaxStateChanging()) {
     840                    dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
     841                    redrawAll = TRUE;
     842                }
     843
     844                if (redrawAll)
     845                {
     846                    //CB: redraw all children for now
     847                    //    -> problems with update region if we don't do it
     848                    //       todo: rewrite whole handling
     849                    WinInvalidateRect(hwnd,NULL,TRUE);
     850                }
     851                else
     852                {
     853                    HPS hps = WinGetPS(hwnd);
     854                    RECTL frame,client,arcl[4];
     855
     856                    WinQueryWindowRect(hwnd,&frame);
     857
     858                    //top
     859                    arcl[0].xLeft = 0;
     860                    arcl[0].xRight = frame.xRight;
     861                    arcl[0].yBottom = rect.yTop;
     862                    arcl[0].yTop = frame.yTop;
     863                    //right
     864                    arcl[1].xLeft = rect.xRight;
     865                    arcl[1].xRight = frame.xRight;
     866                    arcl[1].yBottom = 0;
     867                    arcl[1].yTop = frame.yTop;
     868                    //left
     869                    arcl[2].xLeft = 0;
     870                    arcl[2].xRight = rect.xLeft;
     871                    arcl[2].yBottom = 0;
     872                    arcl[2].yTop = frame.yTop;
     873                    //bottom
     874                    arcl[3].xLeft = 0;
     875                    arcl[3].xRight = frame.xRight;
     876                    arcl[3].yBottom = 0;
     877                    arcl[3].yTop = rect.yBottom;
     878
     879                    HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
     880
     881                    WinInvalidateRegion(hwnd,hrgn,FALSE);
     882                    GpiDestroyRegion(hps,hrgn);
     883                    WinReleasePS(hps);
     884                }
     885            }
     886        }
     887        else
     888        {
     889#endif //USE_CALCVALIDRECT
     890            if(win32wnd->CanReceiveSizeMsgs())
     891                win32wnd->MsgPosChanged((LPARAM)&wp);
     892#ifndef USE_CALCVALIDRECT
     893        }
     894#endif
     895
     896        if(pswp->fl & SWP_ACTIVATE)
     897        {
     898             //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     899             if(!(WinQueryWindowULong(WinWindowFromID(hwnd,FID_CLIENT), OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE))
     900             {
     901                WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)TRUE, (MPARAM)hwnd);
     902             }
     903        }
     904        else
     905        if(pswp->fl & SWP_DEACTIVATE)
     906        {
     907            //Only send PM WM_ACTIVATE to top-level windows (frame windows)
     908            if(WinQueryWindowULong(WinWindowFromID(hwnd,FID_CLIENT), OFFSET_WIN32FLAGS) & WINDOWFLAG_ACTIVE)
     909            {
     910                    WinSendMsg(hwnd, WM_ACTIVATE, (MPARAM)FALSE, (MPARAM)hwnd);
     911            }
     912        }
     913
     914PosChangedEnd:
     915        return (MRESULT)FALSE;
     916    }
     917
     918    case WM_CALCVALIDRECTS:
     919#ifdef USE_CALCVALIDRECT
     920    {
     921        PRECTL    oldRect = (PRECTL)mp1, newRect = oldRect+1;
     922        PSWP      pswp = (PSWP)mp2;
     923        SWP       swpOld;
     924        WINDOWPOS wp;
     925        RECTL     newClientRect, oldClientRect;
     926        ULONG     nccalcret;
     927//        UINT      res = CVR_ALIGNLEFT | CVR_ALIGNTOP;
     928        UINT      res = 0;
     929
     930        dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
     931
     932        //Get old position info
     933        WinQueryWindowPos(hwnd, &swpOld);
     934
     935        if(win32wnd->getParent()) {
     936             OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getClientHeight(),
     937                                    win32wnd->getParent()->getClientRectPtr()->left,
     938                                    win32wnd->getParent()->getClientRectPtr()->top,
     939                                    hwnd);
     940        }
     941        else OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
     942
     943        wp.hwnd = win32wnd->getWindowHandle();
     944        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     945        {
     946            Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     947            if(wndAfter) {
     948                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
     949            }
     950            else wp.hwndInsertAfter = HWND_TOP_W;
     951        }
     952
     953        //Get old client rectangle
     954        mapWin32ToOS2Rect(oldRect->yTop - oldRect->yBottom, win32wnd->getClientRectPtr(), (PRECTLOS2)&oldClientRect);
     955
     956        //Note: Also updates the new window rectangle
     957        nccalcret = win32wnd->MsgFormatFrame(&wp);
     958
     959        //Get new client rectangle
     960        mapWin32ToOS2Rect(pswp->cy, win32wnd->getClientRectPtr(), (PRECTLOS2)&newClientRect);
     961
     962        if(nccalcret == 0) {
     963            res = CVR_ALIGNTOP | CVR_ALIGNLEFT;
     964        }
     965        else {
     966            if(nccalcret & WVR_ALIGNTOP_W) {
     967                res |= CVR_ALIGNTOP;
     968            }
     969            else
     970            if(nccalcret & WVR_ALIGNBOTTOM_W) {
     971                res |= CVR_ALIGNBOTTOM;
     972            }
     973
     974            if(nccalcret & WVR_ALIGNLEFT_W) {
     975                res |= CVR_ALIGNLEFT;
     976            }
     977            else
     978            if(nccalcret & WVR_ALIGNRIGHT_W) {
     979                res |= CVR_ALIGNRIGHT;
     980            }
     981
     982            if(nccalcret & WVR_REDRAW_W) {//WVR_REDRAW_W = (WVR_HREDRAW | WVR_VREDRAW)
     983                res |= CVR_REDRAW;
     984            }
     985            else
     986            if(nccalcret & WVR_VALIDRECTS_W) {
     987                //TODO:
     988                //res = 0;
     989            }
     990        }
     991        if(win32wnd->IsMixMaxStateChanging()) {
     992            dprintf(("WM_CALCVALIDRECT: window changed min/max/restore state, invalidate entire window"));
     993            res |= CVR_REDRAW;
     994        }
     995        if(res == (CVR_ALIGNTOP|CVR_ALIGNLEFT)) {
     996            oldRect->xRight  -= oldClientRect.xLeft;
     997            oldRect->yBottom += oldClientRect.yBottom;
     998            newRect->xRight  -= newClientRect.xLeft;
     999            newRect->yBottom += newClientRect.yBottom;
     1000        }
     1001        return (MRESULT)res;
     1002    }
     1003#else
     1004        dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
     1005        return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
     1006#endif
    12411007
    12421008    case WM_CALCFRAMERECT:
    1243         dprintf(("OS2: WM_CALCFRAMERECT %x", win32wnd->getWindowHandle()));
     1009        dprintf(("PMFRAME:WM_CALCFRAMERECT %x", win32wnd->getWindowHandle()));
    12441010        rc = (MRESULT)TRUE;
    12451011        break;
     
    12471013    case WM_QUERYCTLTYPE:
    12481014        // This is a frame window
    1249         dprintf(("OS2: WM_QUERYCTLTYPE %x", win32wnd->getWindowHandle()));
     1015        dprintf(("PMFRAME:WM_QUERYCTLTYPE %x", win32wnd->getWindowHandle()));
    12501016        rc = (MRESULT)CCT_FRAME;
    12511017        break;
    12521018
     1019#ifdef DEBUG
    12531020    case WM_QUERYFOCUSCHAIN:
    1254         dprintf(("OS2: WM_QUERYFOCUSCHAIN %x fsCmd %x parent %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), mp2));
    1255        
    1256         RestoreOS2TIB();
    1257         rc = pfnFrameWndProc(hwnd, msg, mp1, mp2);
    1258         SetWin32TIB();
    1259         dprintf(("OS2: WM_QUERYFOCUSCHAIN %x fsCmd %x parent %x returned %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), mp2, rc));
    1260         break;
    1261 
     1021        dprintf(("PMFRAME:WM_QUERYFOCUSCHAIN %x fsCmd %x parent %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), mp2));
     1022
     1023//        RestoreOS2TIB();
     1024//        rc = pfnFrameWndProc(hwnd, msg, mp1, mp2);
     1025//        SetWin32TIB();
     1026//        dprintf(("PMFRAME:WM_QUERYFOCUSCHAIN %x fsCmd %x parent %x returned %x", win32wnd->getWindowHandle(), SHORT1FROMMP(mp1), mp2, rc));
     1027//        break;
     1028        goto RunDefFrameWndProc;
     1029#endif
     1030
     1031#if 0
     1032    //is sent to both windows gaining and loosing the focus
     1033    case WM_FOCUSCHANGE:
     1034    {
     1035     HWND   hwndFocus = (HWND)mp1;
     1036     HWND   hwndLoseFocus, hwndGainFocus;
     1037     USHORT usSetFocus = SHORT1FROMMP(mp2);
     1038     USHORT fsFocusChange = SHORT2FROMMP(mp2);
     1039
     1040        rc = 0;
     1041        dprintf(("PMFRAME:WM_FOCUSCHANGE (start) %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
     1042        if(usSetFocus) {
     1043            hwndGainFocus = hwnd;
     1044            hwndLoseFocus = hwndFocus;
     1045        }
     1046        else {
     1047            hwndGainFocus = hwndFocus;
     1048            hwndLoseFocus = hwnd;
     1049        }
     1050
     1051        if(usSetFocus)
     1052        {
     1053          Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndLoseFocus);
     1054          if(!(fsFocusChange & FC_NOSETACTIVE))
     1055          {
     1056            if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
     1057            {
     1058              if(winfocus)
     1059                WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
     1060              else
     1061                WinSendMsg(hwndLoseFocus, WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
     1062            }
     1063          }
     1064          //SvL: Check if window is still valid
     1065          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     1066          if(win32wnd == NULL)
     1067            return (MRESULT)rc;
     1068
     1069          if(!(fsFocusChange & FC_NOSETACTIVE))
     1070          {
     1071            Win32BaseWindow *topparent = win32wnd->GetTopParent();
     1072            if(!winfocus || (winfocus->GetTopParent() != topparent))
     1073            {
     1074              if(!(fsFocusChange & FC_NOBRINGTOTOP))
     1075              {
     1076                if(topparent) {
     1077                  //put window at the top of z order
     1078                  WinSetWindowPos(topparent->getOS2WindowHandle(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
     1079                }
     1080              }
     1081
     1082              // PH 2000/09/01 Netscape 4.7
     1083              // check if topparent is valid
     1084              if (topparent)
     1085                WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
     1086            }
     1087          }
     1088          //SvL: Check if window is still valid
     1089          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     1090          if(win32wnd == NULL)
     1091            return (MRESULT)rc;
     1092
     1093      //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
     1094      if(!(fsFocusChange & FC_NOSETSELECTION)) {
     1095            WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
     1096      }
     1097
     1098      if(!(fsFocusChange & FC_NOSETFOCUS)) {
     1099            WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
     1100      }
     1101        }
     1102        else /* no usSetFocus */
     1103        {
     1104      if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
     1105            WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
     1106      }
     1107      //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
     1108      if(!(fsFocusChange & FC_NOLOSESELECTION)) {
     1109            WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
     1110      }
     1111          //SvL: Check if window is still valid
     1112          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     1113          if(win32wnd == NULL) {
     1114                return (MRESULT)rc;
     1115          }
     1116
     1117          Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndGainFocus);
     1118          if(!(fsFocusChange & FC_NOLOSEACTIVE))
     1119          {
     1120            Win32BaseWindow *topparent = win32wnd->GetTopParent();
     1121
     1122            if(!winfocus || (winfocus->GetTopParent() != topparent))
     1123            {
     1124              // PH 2000/09/01 Netscape 4.7
     1125              // check if topparent is valid
     1126              if (topparent)
     1127                WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
     1128            }
     1129          }
     1130          //SvL: Check if window is still valid
     1131          win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     1132          if(win32wnd == NULL)
     1133            return (MRESULT)rc;
     1134
     1135          if(!(fsFocusChange & FC_NOSETACTIVE))
     1136          {
     1137            if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
     1138            {
     1139              if(winfocus)
     1140              {
     1141                // PH 2000/09/01 Netscape 4.7
     1142                // check if topparent is valid
     1143                Win32BaseWindow *topparent = winfocus->GetTopParent();
     1144                if (topparent)
     1145                  WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
     1146              }
     1147              else
     1148                WinSendMsg(hwndGainFocus, WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
     1149            }
     1150          }
     1151        }
     1152
     1153
     1154#ifdef DEBUG
     1155        dprintf(("PMFRAME:WM_FOCUSCHANGE (end) %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
     1156#endif
     1157        return (MRESULT)rc;
     1158    }
     1159#endif
     1160
     1161#ifdef DEBUG
    12621162    case WM_FOCUSCHANGE:
    12631163    {
     
    12671167        USHORT fsFocusChange = SHORT2FROMMP(mp2);
    12681168
    1269         dprintf(("OS2: WM_FOCUSCHANGE %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
     1169        dprintf(("PMFRAME:WM_FOCUSCHANGE %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
    12701170        goto RunDefFrameWndProc;
    12711171    }
     1172#endif
    12721173
    12731174    case WM_ACTIVATE:
     1175    {
     1176        HWND hwndTitle;
     1177        USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
     1178
     1179        dprintf(("PMFRAME: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
     1180        if (win32wnd->IsWindowCreated())
     1181        {
     1182            WinSendMsg(WinWindowFromID(hwnd,FID_CLIENT),WM_ACTIVATE,mp1,mp2);
     1183            WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
     1184
     1185            //CB: show owner behind the dialog
     1186            if (win32wnd->IsModalDialog())
     1187            {
     1188                Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
     1189
     1190                if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
     1191            }
     1192        }
     1193        else
     1194        {
     1195            WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
     1196        }
     1197        RestoreOS2TIB();
     1198        return 0;
     1199    }
     1200
     1201    case WM_ENABLE:
     1202        dprintf(("OS2: WM_ENABLE %x", hwnd));
     1203        win32wnd->MsgEnable(SHORT1FROMMP(mp1));
     1204        break;
     1205
     1206    case WM_SHOW:
     1207        dprintf(("OS2: WM_SHOW %x %d", hwnd, mp1));
     1208        //show client window
     1209        WinShowWindow(win32wnd->getOS2WindowHandle(), (BOOL)mp1);
     1210        win32wnd->MsgShow((ULONG)mp1);
     1211        break;
     1212
    12741213    case WM_SETFOCUS:
    12751214    {
    1276         rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
    12771215        goto RunDefFrameWndProc;
    12781216    }
    12791217
    1280 #if 0
    1281 //just a test
    1282     case WM_ADJUSTWINDOWPOS:
    1283     case WM_WINDOWPOSCHANGED:
    1284     {
    1285         rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
     1218    case WM_QUERYTRACKINFO:
     1219    {
     1220        PTRACKINFO trackInfo = (PTRACKINFO)mp2;
     1221
     1222        dprintf(("PMFRAME:WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
     1223        trackInfo->cxBorder = 4;
     1224        trackInfo->cyBorder = 4;
     1225        win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
     1226        return (MRESULT)TRUE;
     1227    }
     1228
     1229    case WM_QUERYBORDERSIZE:
     1230    {
     1231        PWPOINT size = (PWPOINT)mp1;
     1232
     1233        dprintf(("PMFRAME:WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
     1234
     1235        size->x = 0;
     1236        size->y = 0;
     1237        return (MRESULT)TRUE;
     1238    }
     1239
     1240    case WM_QUERYFRAMEINFO:
     1241        dprintf(("PMFRAME:WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
    12861242        goto RunDefFrameWndProc;
    1287     }
    1288 #endif
    1289 
    1290     case WM_QUERYFRAMEINFO:
    1291         dprintf(("OS2: WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
     1243
     1244    case WM_FORMATFRAME:
     1245        dprintf(("PMFRAME:WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
     1246        break;
     1247
     1248    case WM_ADJUSTFRAMEPOS:
     1249    {
     1250        PSWP pswp   = (PSWP)mp1;
     1251
     1252        dprintf(("PMFRAME:WM_ADJUSTFRAMEPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    12921253        goto RunDefFrameWndProc;
    1293 
    1294     case WM_FORMATFRAME:
    1295         dprintf(("OS2: WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
     1254    }
     1255
     1256    case WM_OWNERPOSCHANGE:
     1257    {
     1258        PSWP pswp   = (PSWP)mp1;
     1259
     1260        dprintf(("PMFRAME:WM_OWNERPOSCHANGE %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    12961261        goto RunDefFrameWndProc;
    1297 
    1298     case WM_ADJUSTFRAMEPOS:
    1299     {
    1300         PSWP pswp   = (PSWP)mp1;
    1301 
    1302         dprintf(("OS2: WM_ADJUSTFRAMEPOS %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    1303         goto RunDefFrameWndProc;
    1304     }
    1305 
    1306     case WM_OWNERPOSCHANGE:
    1307     {
    1308         PSWP pswp   = (PSWP)mp1;
    1309 
    1310         dprintf(("OS2: WM_OWNERPOSCHANGE %x %x %x (%d,%d) (%d,%d)", win32wnd->getWindowHandle(), pswp->hwnd, pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    1311         goto RunDefFrameWndProc;
    13121262    }
    13131263
     
    13181268        if (!win32wnd->IsWindowCreated()) goto RunDefWndProc;
    13191269
    1320         dprintf(("OS2: WM_MINMAXFRAME %x",hwnd));
     1270        dprintf(("PMFRAME:WM_MINMAXFRAME %x",hwnd));
    13211271        if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
    13221272        {
     
    13461296
    13471297    case WM_UPDATEFRAME:
    1348         dprintf(("OS2: WM_UPDATEFRAME %x", win32wnd->getWindowHandle()));
     1298        dprintf(("PMFRAME:WM_UPDATEFRAME %x", win32wnd->getWindowHandle()));
    13491299        goto RunDefFrameWndProc;
    13501300
    13511301    default:
    1352         rc = ProcessPMMessage(hwnd, msg, mp1, mp2, win32wnd, pWinMsg, teb, TRUE);
    1353         break;
     1302        goto RunDefFrameWndProc;
    13541303    }
    13551304    RestoreOS2TIB();
     
    13621311RunDefWndProc:
    13631312    RestoreOS2TIB();
    1364     return Win32WindowProc(hwnd, msg, mp1, mp2);
     1313    return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    13651314}
    13661315//******************************************************************************
     
    13731322  PRECT     pWindowRect, pClientRect;
    13741323  HWND      hwndTracking;
    1375   HPS       hpsTrack;
    13761324  LONG      parentHeight, parentWidth;
    1377   LONG      clientOrgX, clientOrgY;
    13781325
    13791326    dprintf(("FrameTrackFrame: %x %x", win32wnd->getWindowHandle(), flags));
     
    13871334    pWindowRect = win32wnd->getWindowRect();
    13881335    if(win32wnd->getParent()) {
    1389         parentHeight = win32wnd->getParent()->getWindowHeight();
    1390         parentWidth  = win32wnd->getParent()->getWindowWidth();
     1336        parentHeight = win32wnd->getParent()->getClientHeight();
     1337        parentWidth  = win32wnd->getParent()->getClientWidth();
    13911338        hwndTracking = win32wnd->getParent()->getOS2WindowHandle();
    1392         hpsTrack     = WinGetPS(hwndTracking);
    1393         clientOrgX   = win32wnd->getParent()->getClientRectPtr()->left;
    1394         clientOrgY   = win32wnd->getParent()->getClientRectPtr()->top;
    13951339    }
    13961340    else {
     
    13981342        parentWidth  = OSLibQueryScreenWidth();
    13991343        hwndTracking = HWND_DESKTOP;
    1400         hpsTrack     = NULL;
    1401         clientOrgX   = 0;
    1402         clientOrgY   = 0;
    14031344    }
    14041345
    14051346    mapWin32ToOS2Rect(parentHeight, pWindowRect, (PRECTLOS2)&track.rclTrack);
    1406     track.rclTrack.xLeft += clientOrgX;
    1407     track.rclTrack.yTop  -= clientOrgY;
    14081347    rcl = track.rclTrack;
    14091348    WinQueryWindowRect(hwndTracking, &track.rclBoundary);
     
    14201359    if(WinTrackRect(hwndTracking, NULL, &track) )
    14211360    {
    1422         if(hpsTrack)    WinReleasePS(hpsTrack);
    1423 
    14241361        /* if successful copy final position back */
    14251362        if(!WinEqualRect(0, &rcl, &track.rclTrack)) {
    14261363            dprintf(("FrameTrackFrame: new (os/2) window rect: (%d,%d)(%d,%d)", track.rclTrack.xLeft, track.rclTrack.yBottom, track.rclTrack.xRight - track.rclTrack.xLeft, track.rclTrack.yTop - track.rclTrack.yBottom));
    14271364            if(flags == TF_MOVE) {
    1428                 WinSetWindowPos(win32wnd->getOS2WindowHandle(),
     1365                WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),
    14291366                                0, track.rclTrack.xLeft, track.rclTrack.yBottom,
    14301367                                0, 0, SWP_MOVE);
    14311368            }
    14321369            else {
    1433 ////              SetWindowPos(win32wnd->getWindowHandle(), 0, track.rclTrack.xLeft,
    1434 ////                           parentHeight - track.rclTrack.yTop,
    1435 ////                           track.rclTrack.xRight - track.rclTrack.xLeft,
    1436 ////                           track.rclTrack.yTop - track.rclTrack.yBottom,
    1437 ////                           SWP_NOACTIVATE_W | SWP_NOZORDER_W | SWP_NOACTIVATE_W);
    1438                 WinSetWindowPos(win32wnd->getOS2WindowHandle(),
     1370                WinSetWindowPos(win32wnd->getOS2FrameWindowHandle(),
    14391371                                0, track.rclTrack.xLeft, track.rclTrack.yBottom,
    14401372                                track.rclTrack.xRight - track.rclTrack.xLeft,
     
    14451377        return;
    14461378   }
    1447    if(hpsTrack) WinReleasePS(hpsTrack);
    14481379   return;
    14491380}
  • trunk/src/user32/static.cpp

    r5404 r5685  
    1 /* $Id: static.cpp,v 1.23 2001-03-30 11:14:36 sandervl Exp $ */
     1/* $Id: static.cpp,v 1.24 2001-05-11 08:39:44 sandervl Exp $ */
    22/*
    33 * Static control
     
    413413  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    414414  LRESULT lResult;
    415 
    416 #ifndef ODIN_HITTEST
    417   //SvL: If a static window has children, then we can't return HTTRANSPARENT
    418   //     here. For some reason PM then sends all mouse messages to the parent
    419   //     of the static window; even if they are intended for the children of
    420   //     the static window.
    421   //     TODO: This could break some win32 apps (parent not receiving mouse
    422   //           message for static window (non-child) area)
    423   if(GetWindow(hwnd, GW_HWNDFIRST) != 0) {
    424        return HTCLIENT;
    425   }
    426 #endif
    427415
    428416  if (dwStyle & SS_NOTIFY)
  • trunk/src/user32/win32dlg.cpp

    r5473 r5685  
    1 /* $Id: win32dlg.cpp,v 1.61 2001-04-04 09:32:25 sandervl Exp $ */
     1/* $Id: win32dlg.cpp,v 1.62 2001-05-11 08:39:44 sandervl Exp $ */
    22/*
    33 * Win32 Dialog Code for OS/2
    44 *
    5  * Copyright 1999 Sander van Leeuwen (sandervl@xs4all.nl) (Wine port & OS/2 adaption)
     5 * Copyright 1999-2001 Sander van Leeuwen (sandervl@xs4all.nl) (Wine port & OS/2 adaption)
    66 *
    77 * Based on Wine code (990815; windows\dialog.c)
     
    2424#include "controls.h"
    2525#include "syscolor.h"
     26#include "hook.h"
    2627#include <math.h>
    2728#include <unicode.h>
     
    317318        topOwner->setModalDialogOwner(TRUE);
    318319        hwndOldDialog = topOwner->getOS2HwndModalDialog();
    319         topOwner->setOS2HwndModalDialog(OS2Hwnd);
     320        topOwner->setOS2HwndModalDialog(OS2HwndFrame);
    320321        ShowWindow(SW_SHOW);
    321322
     
    328329        while (TRUE)
    329330        {
    330           if (!OSLibWinPeekMsg(&msg,0,0,0,PM_NOREMOVE))
     331          if (!PeekMessageA(&msg,0,0,0,PM_NOREMOVE))
    331332          {
    332333                if(!(getStyle() & DS_NOIDLEMSG))
    333334                    topOwner->SendMessageA(WM_ENTERIDLE,MSGF_DIALOGBOX,getWindowHandle());
    334                 OSLibWinGetMsg(&msg,0,0,0);
     335                GetMessageA(&msg,0,0,0);
    335336          }
    336           else  OSLibWinPeekMsg(&msg,0,0,0,PM_REMOVE);
     337          else  PeekMessageA(&msg,0,0,0,PM_REMOVE);
     338
     339          /* Call message filters */
     340          if (HOOK_IsHooked( WH_SYSMSGFILTER ) || HOOK_IsHooked( WH_MSGFILTER ))
     341          {
     342            LPMSG pmsg = (LPMSG)HeapAlloc( GetProcessHeap(), 0, sizeof(MSG) );
     343            if (pmsg)
     344            {
     345                BOOL ret;
     346                *pmsg = msg;
     347                ret = (HOOK_CallHooksA( WH_SYSMSGFILTER, MSGF_DIALOGBOX, 0,
     348                                          (LPARAM) pmsg ) ||
     349                       HOOK_CallHooksA( WH_MSGFILTER, MSGF_DIALOGBOX, 0,
     350                                          (LPARAM) pmsg ));
     351                       
     352                HeapFree( GetProcessHeap(), 0, pmsg );
     353                if (ret)
     354                {
     355                    /* Message filtered -> remove it from the queue */
     356                    /* if it's still there. */
     357                    continue;
     358                }
     359            }
     360          }
    337361
    338362          if(msg.message == WM_QUIT)
  • trunk/src/user32/win32wbase.cpp

    r5646 r5685  
    1 /* $Id: win32wbase.cpp,v 1.254 2001-05-03 17:51:01 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.255 2001-05-11 08:39:45 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
    44 *
    5  * Copyright 1998-2000 Sander van Leeuwen (sandervl@xs4all.nl)
     5 * Copyright 1998-2001 Sander van Leeuwen (sandervl@xs4all.nl)
    66 * Copyright 1999      Daniela Engert (dani@ngrt.de)
    77 * Copyright 1999-2000 Christoph Bratschi (cbratschi@datacomm.ch)
     
    106106  fCreationFinished= FALSE;
    107107  fMinMaxChange    = FALSE;
    108   fOwnDCDirty      = FALSE;
     108  fVisibleRegionChanged = FALSE;
     109  fEraseBkgndFlag  = TRUE;
    109110
    110111  windowNameA      = NULL;
     
    116117  magic            = WIN32PM_MAGIC;
    117118  OS2Hwnd          = 0;
     119  OS2HwndFrame     = 0;
    118120  hSysMenu         = 0;
    119121  Win32Hwnd        = 0;
     
    146148  hIcon              = 0;
    147149  hIconSm            = 0;
    148 
    149   EraseBkgndFlag     = TRUE;
    150150
    151151  horzScrollInfo     = NULL;
     
    467467                                   (owner) ? owner->getOS2WindowHandle() : ((getParent()) ? getParent()->getOS2WindowHandle() : OSLIB_HWND_DESKTOP),
    468468                                   (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
    469                                    0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle());
     469                                   0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle(), &OS2HwndFrame);
    470470    if(OS2Hwnd == 0) {
    471471        dprintf(("Window creation failed!! OS LastError %0x", OSLibWinGetLastError()));
     
    688688
    689689    if(fTaskList) {
    690         hTaskList = OSLibWinAddToTaskList(OS2Hwnd, windowNameA, (cs->style & WS_VISIBLE) ? 1 : 0);
     690        hTaskList = OSLibWinAddToTaskList(OS2HwndFrame, windowNameA, (cs->style & WS_VISIBLE) ? 1 : 0);
    691691    }
    692692
     
    871871    else setStyle(getStyle() & ~WS_VISIBLE);
    872872
    873     return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0);
     873    //already sent from ShowWindow
     874////    return SendInternalMessageA(WM_SHOWWINDOW, fShow, 0);
     875    return 0;
    874876}
    875877//******************************************************************************
     
    897899//******************************************************************************
    898900//******************************************************************************
    899 #if 0
    900 ULONG Win32BaseWindow::MsgMinMax()
    901 {
    902 
    903 }
    904 #endif
    905 //******************************************************************************
    906 //******************************************************************************
    907901ULONG Win32BaseWindow::MsgScroll(ULONG msg, ULONG scrollCode, ULONG scrollPos)
    908902{
     
    911905  return SendInternalMessageA(msg, MAKELONG(scrollCode, scrollPos), 0);
    912906}
    913 //******************************************************************************
    914 //******************************************************************************
    915 #ifndef ODIN_HITTEST
    916 ULONG Win32BaseWindow::MsgHitTest(MSG *msg)
    917 {
    918   lastHitTestVal = DispatchMsgA(msg);
    919 
    920   dprintf2(("MsgHitTest %x (%d,%d) (%d,%d) (%d,%d) returned %x", getWindowHandle(), LOWORD(msg->lParam), HIWORD(msg->lParam), rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom, lastHitTestVal));
    921 
    922   if (lastHitTestVal == HTTRANSPARENT)
    923     return HTOS_TRANSPARENT;
    924   else
    925     return HTOS_NORMAL;
    926 }
    927 #endif
    928907//******************************************************************************
    929908//******************************************************************************
     
    957936
    958937    if(hwndOS2Win) {
    959             threadidhwnd = O32_GetWindowThreadProcessId(hwndOS2Win, &procidhwnd);
    960     }
    961 //Warning: temporary hack to force focus to newly created window
    962 //RealPlayer 8 does not pass WM_ACTIVATE to defwindowproc and doesn't call
    963 //setfocus -> keyboard focus not set
    964 //TODO: Find real cause!!
     938        threadidhwnd = O32_GetWindowThreadProcessId(hwndOS2Win, &procidhwnd);
     939    }
     940    //Warning: temporary hack to force focus to newly created window
     941    //RealPlayer 8 does not pass WM_ACTIVATE to defwindowproc and doesn't call
     942    //setfocus -> keyboard focus not set
     943    //TODO: Find real cause!!
    965944    if(GetFocus() == 0 && fActivate) {
    966945        if(!(getStyle() & WS_MINIMIZE))
    967946            SetFocus(getWindowHandle());
    968947    }
    969 //Warning: temporary hack to force focus to newly created window
     948    //Warning: temporary hack to force focus to newly created window
    970949
    971950    if(fActivate) {
    972             SendInternalMessageA(WM_ACTIVATEAPP, 1, dwThreadId);    //activate; specify window thread id
    973     }
    974     else    SendInternalMessageA(WM_ACTIVATEAPP, 0, threadidhwnd);  //deactivate; specify thread id of other process
     951         SendInternalMessageA(WM_ACTIVATEAPP, 1, dwThreadId);    //activate; specify window thread id
     952    }
     953    else SendInternalMessageA(WM_ACTIVATEAPP, 0, threadidhwnd);  //deactivate; specify thread id of other process
    975954    return rc;
    976955}
     
    10671046
    10681047                    //SvL: Calling OSLibSetActiveWindow(hwndTop); causes focus problems
    1069                     if (win32top) OSLibWinSetFocus(win32top->getOS2WindowHandle());
     1048                    if (win32top) OSLibWinSetFocus(win32top->getOS2FrameWindowHandle());
    10701049                }
    10711050        }
     
    11221101}
    11231102//******************************************************************************
    1124 //******************************************************************************
    1125 ULONG Win32BaseWindow::MsgNCPaint()
    1126 {
    1127   RECT rect;
    1128 
    1129   if(GetOS2UpdateRect(this,&rect))
    1130   {
     1103//TODO: Should use update region, not rectangle
     1104//******************************************************************************
     1105ULONG Win32BaseWindow::MsgNCPaint(PRECT pUpdateRect)
     1106{
    11311107    HRGN hrgn;
    11321108    ULONG rc;
    11331109    RECT client = rectClient;
    11341110
    1135         if ((rect.left >= client.left) && (rect.left < client.right) &&
    1136            (rect.right >= client.left) && (rect.right < client.right) &&
    1137            (rect.top  >= client.top) && (rect.top < client.bottom) &&
    1138            (rect.bottom >= client.top) && (rect.bottom < client.bottom))
    1139         {
    1140                 return 0;
    1141         }
    1142 
    1143         dprintf(("MsgNCPaint (%d,%d)(%d,%d)", rect.left, rect.top, rect.right, rect.bottom));
    1144         hrgn = CreateRectRgnIndirect(&rect);
    1145         if (!hrgn) return 0;
    1146 
    1147         rc = SendInternalMessageA(WM_NCPAINT, hrgn, 0);
    1148 
    1149         DeleteObject(hrgn);
    1150 
    1151         return rc;
    1152   }
    1153   else  return 0;
     1111    if ((pUpdateRect->left >= client.left) && (pUpdateRect->left < client.right) &&
     1112       (pUpdateRect->right >= client.left) && (pUpdateRect->right < client.right) &&
     1113       (pUpdateRect->top  >= client.top) && (pUpdateRect->top < client.bottom) &&
     1114       (pUpdateRect->bottom >= client.top) && (pUpdateRect->bottom < client.bottom))
     1115    {
     1116        return 0;
     1117    }
     1118
     1119    dprintf(("MsgNCPaint (%d,%d)(%d,%d)", pUpdateRect->left, pUpdateRect->top, pUpdateRect->right, pUpdateRect->bottom));
     1120    hrgn = CreateRectRgnIndirect(pUpdateRect);
     1121
     1122    rc = SendInternalMessageA(WM_NCPAINT, hrgn, 0);
     1123
     1124    DeleteObject(hrgn);
     1125
     1126    return rc;
    11541127}
    11551128//******************************************************************************
     
    11641137  ULONG rc;
    11651138
    1166   if(lpWndPos)
    1167   {
     1139    if(lpWndPos)
     1140    {
    11681141        //set new window rectangle
    11691142        setWindowRect(lpWndPos->x, lpWndPos->y, lpWndPos->x+lpWndPos->cx,
    11701143                      lpWndPos->y+lpWndPos->cy);
    11711144        newWindowRect = rectWindow;
    1172   }
    1173   else {
     1145    }
     1146    else {
    11741147        wndPos.hwnd  = getWindowHandle();
    11751148        wndPos.hwndInsertAfter = 0;
     
    11811154        wndPos.flags = SWP_FRAMECHANGED;
    11821155        lpWndPos     = &wndPos;
    1183   }
    1184 
    1185   newClientRect = rectClient;
    1186   rc = SendNCCalcSize(TRUE, &newWindowRect,  &oldWindowRect, &client, lpWndPos, &newClientRect);
    1187   rectClient = newClientRect; //must update rectClient here
    1188 
    1189   dprintf(("MsgFormatFrame: old client rect (%d,%d)(%d,%d), new client (%d,%d)(%d,%d)", client.left, client.top, client.right, client.bottom, rectClient.left, rectClient.top, rectClient.right, rectClient.bottom));
    1190   dprintf(("MsgFormatFrame: old window rect (%d,%d)(%d,%d), new window (%d,%d)(%d,%d)", oldWindowRect.left, oldWindowRect.top, oldWindowRect.right, oldWindowRect.bottom, rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom));
     1156    }
     1157
     1158    newClientRect = rectClient;
     1159    rc = SendNCCalcSize(TRUE, &newWindowRect,  &oldWindowRect, &client, lpWndPos, &newClientRect);
     1160    rectClient = newClientRect; //must update rectClient here
     1161
     1162    dprintf(("MsgFormatFrame: old client rect (%d,%d)(%d,%d), new client (%d,%d)(%d,%d)", client.left, client.top, client.right, client.bottom, rectClient.left, rectClient.top, rectClient.right, rectClient.bottom));
     1163    dprintf(("MsgFormatFrame: old window rect (%d,%d)(%d,%d), new window (%d,%d)(%d,%d)", oldWindowRect.left, oldWindowRect.top, oldWindowRect.right, oldWindowRect.bottom, rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom));
     1164
     1165    if(fNoSizeMsg || !EqualRect(&client, &rectClient)) {
     1166        OSLibWinSetClientPos(getOS2WindowHandle(), rectClient.left, rectClient.top, getClientWidth(), getClientHeight(), getWindowHeight());
     1167    }
    11911168
    11921169#if 1
     
    14301407            HandleNCPaint((HRGN)1);
    14311408            if(hTaskList) {
    1432                 OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
     1409                OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
    14331410            }
    14341411        }
     
    15901567          return 1;
    15911568        }
    1592        
     1569
    15931570        if (!windowClass || !windowClass->getBackgroundBrush()) return 0;
    15941571
     
    19171894        if ((dwStyle & WS_CAPTION) == WS_CAPTION)
    19181895        {
    1919           HandleNCPaint((HRGN)1);
    1920           if(hTaskList) {
    1921         OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
    1922       }
     1896            HandleNCPaint((HRGN)1);
     1897            if(hTaskList) {
     1898                OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
     1899            }
    19231900        }
    19241901
     
    22312208    case SW_HIDE:
    22322209        if (!wasVisible) goto END;
    2233             swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE |
    2234         SWP_NOACTIVATE | SWP_NOZORDER;
     2210
     2211        swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER;
    22352212        break;
    22362213
     
    22422219        /* fall through */
    22432220    case SW_MINIMIZE:
    2244         if(!(getStyle() & WS_CHILD))
    2245         {
    2246             if( !(getStyle() & WS_MINIMIZE) )
    2247                  swp |= MinMaximize(SW_MINIMIZE, &newPos );
    2248 
    2249             swp |= SWP_NOSIZE | SWP_NOMOVE | SWP_HIDEWINDOW;
    2250         }
    2251         else {
    2252             swp |= SWP_FRAMECHANGED;
    2253             if( !(getStyle() & WS_MINIMIZE) ) {
    2254                  swp |= MinMaximize(SW_MINIMIZE, &newPos );
    2255                  fMinMaxChange = TRUE; //-> invalidate entire window in WM_CALCINVALIDRECT
    2256             }
    2257             else swp |= SWP_NOSIZE | SWP_NOMOVE;
    2258         }
     2221        swp |= SWP_FRAMECHANGED;
     2222        if( !(getStyle() & WS_MINIMIZE) ) {
     2223             swp |= MinMaximize(SW_MINIMIZE, &newPos );
     2224             fMinMaxChange = TRUE; //-> invalidate entire window in WM_CALCINVALIDRECT
     2225        }
     2226        else swp |= SWP_NOSIZE | SWP_NOMOVE;
    22592227        break;
    22602228
     
    23172285
    23182286    if(!(swp & SWP_NOACTIVATE)) {
    2319         OSLibWinSetActiveWindow(OS2Hwnd);
     2287        OSLibWinSetActiveWindow(OS2HwndFrame);
    23202288    }
    23212289
     
    24542422            }
    24552423        }
    2456         OSLibWinQueryWindowPos(OS2Hwnd, &swpOld);
     2424        OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
    24572425    }
    24582426
    24592427    if(getParent()) {
    2460           OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, getParent()->getWindowHeight(),
    2461                                  getParent()->getClientRectPtr()->left,
    2462                                  getParent()->getClientRectPtr()->top,
    2463                                  OS2Hwnd);
    2464     }
    2465     else  OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, OSLibQueryScreenHeight(), 0, 0, OS2Hwnd);
     2428          OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, getParent()->getClientHeight(),
     2429                                      OS2HwndFrame);
     2430    }
     2431    else  OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, OSLibQueryScreenHeight(), OS2HwndFrame);
     2432
    24662433    if (swp.fl == 0) {
    24672434        if(fuFlags & SWP_FRAMECHANGED)
     
    24772444        Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
    24782445        if(wndBehind) {
    2479             swp.hwndInsertBehind   = wndBehind->getOS2WindowHandle();
     2446            swp.hwndInsertBehind   = wndBehind->getOS2FrameWindowHandle();
    24802447        }
    24812448        else {
     
    24842451        }
    24852452    }
    2486     swp.hwnd = OS2Hwnd;
     2453    swp.hwnd = OS2HwndFrame;
    24872454
    24882455    if(fuFlags & SWP_SHOWWINDOW && !IsWindowVisible(getWindowHandle())) {
     
    24902457        if(hTaskList) {
    24912458            dprintf(("Adding window %x to tasklist", getWindowHandle()));
    2492             OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), 1);
     2459            OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), 1);
    24932460        }
    24942461    }
     
    24982465        if(hTaskList && !(getStyle() & WS_MINIMIZE)) {
    24992466            dprintf(("Removing window %x from tasklist", getWindowHandle()));
    2500             OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), 0);
     2467            OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), 0);
    25012468        }
    25022469    }
     
    25102477    }
    25112478
    2512     //Restore window origin of parent window with CS_OWNDC style
    2513     //(fixes paint offset problems in Opera windows)
    2514     if(getParent() && getParent()->isOwnDC()) {
    2515         dprintfOrigin(getParent()->getOwnDC());
    2516         selectClientArea(getParent(), getParent()->getOwnDC());
    2517     }
    2518 
    25192479    if((fuFlags & SWP_FRAMECHANGED) && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE)))
    25202480    {
    2521             NotifyFrameChanged(&wpos, &oldClientRect);
     2481        NotifyFrameChanged(&wpos, &oldClientRect);
    25222482    }
    25232483    return (rc);
     
    27132673
    27142674    fDestroyWindowCalled = TRUE;
    2715     return OSLibWinDestroyWindow(OS2Hwnd);
     2675    return OSLibWinDestroyWindow(OS2HwndFrame);
    27162676}
    27172677//******************************************************************************
     
    27702730        setParent(newparent);
    27712731        getParent()->addChild(this);
    2772         OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
     2732        OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
    27732733        if(!(getStyle() & WS_CHILD))
    27742734        {
     
    27762736            setStyle(getStyle() | WS_CHILD);
    27772737            if(getWindowId())
    2778                 {
    2779                         DestroyMenu( (HMENU) getWindowId() );
    2780                         setWindowId(0);
    2781                 }
     2738            {
     2739                DestroyMenu( (HMENU) getWindowId() );
     2740                setWindowId(0);
     2741            }
    27822742        }
    27832743   }
     
    27852745        setParent(windowDesktop);
    27862746        windowDesktop->addChild(this);
    2787         OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
     2747        OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
    27882748
    27892749    //TODO: Send WM_STYLECHANGED msg?
     
    28242784
    28252785    hwndTop = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
    2826     if(!isDesktopWindow()) {
    2827     topwindow = GetWindowFromOS2Handle(hwndTop);
    2828     if(topwindow) {
    2829         return topwindow->getWindowHandle();
    2830     }
    2831     return 0;
     2786    if(!isDesktopWindow())
     2787    {
     2788        topwindow = GetWindowFromOS2FrameHandle(hwndTop);
     2789        if(topwindow) {
     2790            return topwindow->getWindowHandle();
     2791        }
     2792        return 0;
    28322793    }
    28332794    while(hwndTop) {
    2834     topwindow = GetWindowFromOS2Handle(hwndTop);
    2835     if(topwindow) {
    2836         return topwindow->getWindowHandle();
    2837     }
     2795        topwindow = GetWindowFromOS2FrameHandle(hwndTop);
     2796        if(topwindow) {
     2797            return topwindow->getWindowHandle();
     2798        }
    28382799        hwndTop = OSLibWinQueryWindow(hwndTop, QWOS_NEXT);
    28392800    }
     
    30112972        while(hwnd)
    30122973        {
    3013             wnd = GetWindowFromOS2Handle(hwnd);
     2974            wnd = GetWindowFromOS2FrameHandle(hwnd);
    30142975            if(wnd == NULL) {
    30152976                hwnd = OSLibWinQueryClientWindow(hwnd);
     
    30413002 Win32BaseWindow *window;
    30423003
    3043 #if 1
    30443004    switch(uCmd)
    30453005    {
     
    30493009            window = (Win32BaseWindow *)getParent();
    30503010            hwndRelated = OSLibWinQueryWindow(window->getOS2WindowHandle(), QWOS_TOP);
    3051             window = GetWindowFromOS2Handle(hwndRelated);
     3011            window = GetWindowFromOS2FrameHandle(hwndRelated);
    30523012            if(window) {
    3053                   hwndRelated = window->getWindowHandle();
     3013                 hwndRelated = window->getWindowHandle();
    30543014            }
    30553015            else hwndRelated = 0;
    30563016        }
    3057         else hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
     3017        else {
     3018            dprintf(("WARNING: GW_HWNDFIRST not correctly implemented for toplevel/most windows!"));
     3019            hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
     3020        }
    30583021        break;
    30593022
    30603023    case GW_HWNDLAST:
    3061         hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_BOTTOM);
    3062         window = GetWindowFromOS2Handle(hwndRelated);
    3063         if(window) {
    3064              hwndRelated = window->getWindowHandle();
    3065         }
    3066         else hwndRelated = 0;
     3024        if(getParent()) {
     3025            window = (Win32BaseWindow *)getParent();
     3026            hwndRelated = OSLibWinQueryWindow(window->getOS2WindowHandle(), QWOS_BOTTOM);
     3027            dprintf(("os2 handle %x", hwndRelated));
     3028            window = GetWindowFromOS2FrameHandle(hwndRelated);
     3029            if(window) {
     3030                 hwndRelated = window->getWindowHandle();
     3031            }
     3032            else hwndRelated = 0;
     3033        }
     3034        else {
     3035            dprintf(("WARNING: GW_HWNDLAST not correctly implemented for toplevel/most windows!"));
     3036            hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
     3037        }
    30673038        break;
    30683039
    30693040    case GW_HWNDNEXT:
    3070         hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_NEXT);
    3071         window = GetWindowFromOS2Handle(hwndRelated);
    3072         if(window) {
    3073              hwndRelated = window->getWindowHandle();
    3074         }
    3075         else hwndRelated = 0;
     3041        if(getParent()) {
     3042            hwndRelated = OSLibWinQueryWindow(getOS2FrameWindowHandle(), QWOS_NEXT);
     3043            window = GetWindowFromOS2FrameHandle(hwndRelated);
     3044            if(window) {
     3045                 hwndRelated = window->getWindowHandle();
     3046            }
     3047            else hwndRelated = 0;
     3048        }
     3049        else {
     3050            dprintf(("WARNING: GW_HWNDNEXT not correctly implemented for toplevel/most windows!"));
     3051            hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
     3052        }
    30763053        break;
    30773054
    30783055    case GW_HWNDPREV:
    3079         hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_PREV);
    3080         window = GetWindowFromOS2Handle(hwndRelated);
    3081         if(window) {
    3082              hwndRelated = window->getWindowHandle();
    3083         }
    3084         else hwndRelated = 0;
     3056        if(getParent()) {
     3057            hwndRelated = OSLibWinQueryWindow(getOS2FrameWindowHandle(), QWOS_PREV);
     3058            window = GetWindowFromOS2FrameHandle(hwndRelated);
     3059            if(window) {
     3060                 hwndRelated = window->getWindowHandle();
     3061            }
     3062            else hwndRelated = 0;
     3063        }
     3064        else {
     3065            dprintf(("WARNING: GW_HWNDPREV not correctly implemented for toplevel/most windows!"));
     3066            hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
     3067        }
    30853068        break;
    30863069
     
    30933076    case GW_CHILD:
    30943077        hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
    3095         window = GetWindowFromOS2Handle(hwndRelated);
     3078        window = GetWindowFromOS2FrameHandle(hwndRelated);
    30963079        if(window) {
    30973080             hwndRelated = window->getWindowHandle();
     
    31003083        break;
    31013084    }
    3102 #else
    3103     switch(uCmd)
    3104     {
    3105     case GW_HWNDFIRST:
    3106         if(getParent()) {
    3107             window = (Win32BaseWindow *)getParent()->getFirstChild();
    3108             hwndRelated = window->getWindowHandle();
    3109         }
    3110         break;
    3111 
    3112     case GW_HWNDLAST:
    3113         if(!getParent())
    3114         {
    3115             goto end;
    3116         }
    3117 
    3118         window = this;
    3119         while(window->getNextChild())
    3120         {
    3121             window = (Win32BaseWindow *)window->getNextChild();
    3122         }
    3123         hwndRelated = window->getWindowHandle();
    3124         break;
    3125 
    3126     case GW_HWNDNEXT:
    3127         window = (Win32BaseWindow *)getNextChild();
    3128         if(window) {
    3129             hwndRelated = window->getWindowHandle();
    3130         }
    3131         break;
    3132 
    3133     case GW_HWNDPREV:
    3134         if(!getParent())
    3135         {
    3136             goto end;
    3137         }
    3138         window = (Win32BaseWindow *)(getParent()->getFirstChild()); /* First sibling */
    3139         if(window == this)
    3140         {
    3141             hwndRelated = 0;  /* First in list */
    3142             goto end;
    3143         }
    3144         while(window->getNextChild())
    3145         {
    3146             if (window->getNextChild() == this)
    3147             {
    3148                 hwndRelated = window->getWindowHandle();
    3149                 goto end;
    3150             }
    3151             window = (Win32BaseWindow *)window->getNextChild();
    3152         }
    3153         break;
    3154 
    3155     case GW_OWNER:
    3156         if(getOwner()) {
    3157             hwndRelated = getOwner()->getWindowHandle();
    3158         }
    3159         break;
    3160 
    3161     case GW_CHILD:
    3162         if(getFirstChild()) {
    3163             hwndRelated = ((Win32BaseWindow *)getFirstChild())->getWindowHandle();
    3164         }
    3165         break;
    3166     }
    3167 #endif
    31683085end:
    31693086    dprintf(("GetWindow %x %d returned %x", getWindowHandle(), uCmd, hwndRelated));
     
    32273144        SendMessageA(WM_CANCELMODE, 0, 0);
    32283145  }
    3229   OSLibWinEnableWindow(OS2Hwnd, fEnable);
     3146  OSLibWinEnableWindow(OS2HwndFrame, fEnable);
    32303147  if(fEnable == FALSE) {
    32313148        //SvL: No need to clear focus as PM already does this
     
    34363353                setStyle(ss.styleNew);
    34373354                SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
    3438                 OSLibSetWindowStyle(getOS2WindowHandle(), getStyle(), getExStyle());
     3355                OSLibSetWindowStyle(getOS2FrameWindowHandle(), getOS2WindowHandle(), getStyle(), getExStyle());
    34393356#ifdef DEBUG
    34403357                PrintWindowStyle(ss.styleNew, 0);
     
    36073524//  dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd));
    36083525    return 0;
     3526}
     3527//******************************************************************************
     3528//******************************************************************************
     3529Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
     3530{
     3531    return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
    36093532}
    36103533//******************************************************************************
     
    38083731            return window->getWindowHandle();
    38093732    }
     3733    window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
     3734    if(window) {
     3735            return window->getWindowHandle();
     3736    }
     3737
    38103738//    dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
    38113739    return 0;
  • trunk/src/user32/win32wbase.h

    r5606 r5685  
    1 /* $Id: win32wbase.h,v 1.115 2001-04-27 17:36:39 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.116 2001-05-11 08:39:45 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    134134         ULONG  MsgPaint(ULONG tmp1, BOOL select = TRUE);
    135135         ULONG  MsgEraseBackGround(HDC hdc);
    136 #ifndef ODIN_HITTEST
    137          ULONG  MsgHitTest(MSG *msg);
    138 #endif
    139          ULONG  MsgNCPaint();
     136         ULONG  MsgNCPaint(PRECT pUpdateRect);
    140137         ULONG  MsgFormatFrame(WINDOWPOS *lpWndPos);
    141138         ULONG  DispatchMsgA(MSG *msg);
     
    160157         HWND   getWindowHandle()               { return Win32Hwnd; };
    161158         HWND   getOS2WindowHandle()            { return OS2Hwnd; };
     159         HWND   getOS2FrameWindowHandle()       { return OS2HwndFrame; };
    162160
    163161 Win32WndClass *getWindowClass()                { return windowClass; };
     
    260258         BOOL   IsMixMaxStateChanging()       { return fMinMaxChange; };
    261259
     260         void   SetVisibleRegionChanged(BOOL changed) { fVisibleRegionChanged = changed; };
     261         BOOL   IsVisibleRegionChanged()              { return fVisibleRegionChanged; };
     262
    262263         int    GetWindowTextLength(BOOL fUnicode);
    263264         int    GetWindowTextLengthA() { return GetWindowTextLength(FALSE); };
     
    317318static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
    318319static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
     320static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
    319321
    320322    static void DestroyAll();
     
    334336    PROPERTY   *findWindowProperty(LPCSTR str);
    335337
    336         HWND    OS2Hwnd;
     338        HWND    OS2Hwnd, OS2HwndFrame;
    337339        HMENU   hSysMenu;
    338340        HWND    Win32Hwnd;
     
    358360        HWND    OS2HwndModalDialog;
    359361
    360         unsigned fFirstShow:1;
    361         unsigned fIsDialog:1;
    362         unsigned fIsModalDialog:1;
    363         unsigned fIsModalDialogOwner:1;
    364         unsigned fInternalMsg:1;         //Used to distinguish between messages
     362        ULONG    fFirstShow:1,
     363                 fIsDialog:1,
     364                 fIsModalDialog:1,
     365                 fIsModalDialogOwner:1,
     366                 fInternalMsg:1,         //Used to distinguish between messages
    365367                                         //sent by PM and those sent by apps
    366         unsigned fNoSizeMsg:1;
    367         unsigned fIsDestroyed:1;
    368         unsigned fDestroyWindowCalled:1; //DestroyWindow was called for this window
    369         unsigned fCreated:1;
    370         unsigned fCreationFinished:1;    //True when window or dialog has been created successfully
     368                 fNoSizeMsg:1,
     369                 fIsDestroyed:1,
     370                 fDestroyWindowCalled:1, //DestroyWindow was called for this window
     371                 fCreated:1,
     372                 fCreationFinished:1,    //True when window or dialog has been created successfully
    371373                                         //Needed to prevent DestroyWindow from deleting the window
    372374                                         //object during construction
    373         unsigned fTaskList:1;            //should be listed in PM tasklist or not
    374         unsigned fXDefault:1;
    375         unsigned fCXDefault:1;
    376         unsigned fParentDC:1;
    377         unsigned fComingToTop:1;
    378         unsigned fCreateSetWindowPos:1;  //FALSE -> SetWindowPos in Win32BaseWindow::MsgCreate not yet called
    379         unsigned isUnicode:1;
    380         unsigned fMinMaxChange:1;        //set when switching between min/max/restored state
    381         unsigned fOwnDCDirty:1;          //set when selectClientArea must reset the origin + visible region
     375                 fTaskList:1,            //should be listed in PM tasklist or not
     376                 fXDefault:1,
     377                 fCXDefault:1,
     378                 fParentDC:1,
     379                 fComingToTop:1,
     380                 fCreateSetWindowPos:1,  //FALSE -> SetWindowPos in Win32BaseWindow::MsgCreate not yet called
     381                 isUnicode:1,
     382                 fMinMaxChange:1,        //set when switching between min/max/restored state
     383                 fVisibleRegionChanged:1, //set when visible region has changed -> erase background must be sent during next BeginPaint
     384                 fEraseBkgndFlag:1;
    382385
    383386        HRGN    hWindowRegion;
     
    469472         BOOL   isOwnDC() { return (windowClass && windowClass->getStyle() & CS_OWNDC_W); }
    470473#endif
    471          void   invalidateOwnDC() { fOwnDCDirty = TRUE; };
    472          void   validateOwnDC()   { fOwnDCDirty = FALSE; };
    473          BOOL   isOwnDCDirty()    { return fOwnDCDirty; };
    474474
    475475         HDC    getOwnDC() { return ownDC; }
     
    478478         HDC    ownDC;
    479479
    480          ULONG  EraseBkgndFlag:1,
    481                 filler:31;
    482480public:
    483          VOID   setEraseBkgnd (BOOL erase)      { EraseBkgndFlag = erase; }
    484          BOOL   needsEraseBkgnd()               { return EraseBkgndFlag; }
     481         VOID   setEraseBkgnd (BOOL erase)      { fEraseBkgndFlag = erase; }
     482         BOOL   needsEraseBkgnd()               { return fEraseBkgndFlag; }
    485483};
    486484
  • trunk/src/user32/win32wbasepos.cpp

    r5655 r5685  
    1 /* $Id: win32wbasepos.cpp,v 1.23 2001-05-04 17:02:52 sandervl Exp $ */
     1/* $Id: win32wbasepos.cpp,v 1.24 2001-05-11 08:39:45 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2 (nonclient/position methods)
     
    5959    if(!(getStyle() & (WS_POPUP | WS_CHILD))) {
    6060        RECT rect;
    61         OSLibWinGetMaxPosition(getOS2WindowHandle(), &rect);
     61        OSLibWinGetMaxPosition(getOS2FrameWindowHandle(), &rect);
    6262        MinMax.ptMaxPosition.x = rect.left;
    6363        MinMax.ptMaxPosition.y = rect.top;
  • trunk/src/user32/win32wdesktop.cpp

    r4757 r5685  
    1 /* $Id: win32wdesktop.cpp,v 1.15 2000-12-05 13:05:52 sandervl Exp $ */
     1/* $Id: win32wdesktop.cpp,v 1.16 2001-05-11 08:39:46 sandervl Exp $ */
    22/*
    33 * Win32 Desktop Window for OS/2
     
    5252
    5353  OS2Hwnd      = OSLIB_HWND_DESKTOP;
     54  OS2HwndFrame = OSLIB_HWND_DESKTOP;
    5455  rectClient   = rectWindow;
    5556
  • trunk/src/user32/win32wndhandle.cpp

    r4866 r5685  
    1 /* $Id: win32wndhandle.cpp,v 1.8 2001-01-02 18:14:59 sandervl Exp $ */
     1/* $Id: win32wndhandle.cpp,v 1.9 2001-05-11 08:39:46 sandervl Exp $ */
    22/*
    33 * Win32 Handle Management Code for OS/2
     
    6464  WindowHandleTable[lastIndex] = dwUserData;
    6565
     66  lastIndex++;
    6667  tableMutex.leave(&hGlobalTableMutex);
    6768  return TRUE;
  • trunk/src/user32/window.cpp

    r5586 r5685  
    1 /* $Id: window.cpp,v 1.94 2001-04-25 20:53:39 sandervl Exp $ */
     1/* $Id: window.cpp,v 1.95 2001-05-11 08:39:46 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    404404
    405405    if(hwnd == HWND_DESKTOP) {
    406     window = windowDesktop;
     406        window = windowDesktop;
    407407    }
    408408    else {
     
    412412            SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    413413            return 0;
    414     }
     414        }
    415415    }
    416416    hwndTop = window->GetTopWindow();
     
    947947    if (!pRect)
    948948    {
    949       SetLastError(ERROR_INVALID_PARAMETER);
    950       return FALSE;
     949        SetLastError(ERROR_INVALID_PARAMETER);
     950        return FALSE;
    951951    }
    952952    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    973973    if(style == 0 && menu == FALSE && exStyle == 0) {
    974974        dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d) -> no change required", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
    975     return TRUE;    //nothing needs to be changed (VERIFIED in NT 4)
     975        return TRUE;    //nothing needs to be changed (VERIFIED in NT 4)
    976976    }
    977977    dprintf(("AdjustWindowRectEx %x %x %d (%d,%d)(%d,%d)\n", style, exStyle, menu, rect->left, rect->top, rect->right, rect->bottom));
     
    988988    //Adjust rect outer (Win32BaseWindow::AdjustRectOuter)
    989989    if (HAS_THICKFRAME(style,exStyle))
    990       InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
     990        InflateRect( rect, GetSystemMetrics(SM_CXFRAME), GetSystemMetrics(SM_CYFRAME) );
    991991    else
    992       if (HAS_DLGFRAME(style,exStyle))
     992    if (HAS_DLGFRAME(style,exStyle))
    993993        InflateRect(rect, GetSystemMetrics(SM_CXDLGFRAME), GetSystemMetrics(SM_CYDLGFRAME) );
    994       else
    995         if (HAS_THINFRAME(style))
    996           InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
     994    else
     995    if (HAS_THINFRAME(style))
     996        InflateRect( rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
    997997
    998998    if ((style & WS_CAPTION) == WS_CAPTION)
    999999    {
    1000       if (exStyle & WS_EX_TOOLWINDOW)
    1001         rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
    1002       else
    1003         rect->top -= GetSystemMetrics(SM_CYCAPTION);
     1000        if (exStyle & WS_EX_TOOLWINDOW)
     1001            rect->top -= GetSystemMetrics(SM_CYSMCAPTION);
     1002        else
     1003            rect->top -= GetSystemMetrics(SM_CYCAPTION);
    10041004    }
    10051005
    10061006    if (menu)
    1007       rect->top -= GetSystemMetrics(SM_CYMENU);
     1007        rect->top -= GetSystemMetrics(SM_CYMENU);
    10081008
    10091009    //Adjust rect inner (Win32BaseWindow::AdjustRectInner)
    10101010    if(!(style & WS_ICONIC)) {
    1011     if (exStyle & WS_EX_CLIENTEDGE)
     1011        if (exStyle & WS_EX_CLIENTEDGE)
    10121012            InflateRect (rect, GetSystemMetrics(SM_CXEDGE), GetSystemMetrics(SM_CYEDGE));
    10131013
    1014     if (exStyle & WS_EX_STATICEDGE)
     1014        if (exStyle & WS_EX_STATICEDGE)
    10151015            InflateRect (rect, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
    10161016
    1017     //SvL: scrollbars aren't checked *UNLESS* the style includes a border (any border)
     1017        //SvL: scrollbars aren't checked *UNLESS* the style includes a border (any border)
    10181018        //     --> VERIFIED IN NT4, SP6 (fixes MFC apps with scrollbars + bar controls)
    1019     if(style & (WS_THICKFRAME|WS_BORDER|WS_DLGFRAME)) {
     1019        if(style & (WS_THICKFRAME|WS_BORDER|WS_DLGFRAME)) {
    10201020            if (style & WS_VSCROLL) rect->right  += GetSystemMetrics(SM_CXVSCROLL);
    10211021            if (style & WS_HSCROLL) rect->bottom += GetSystemMetrics(SM_CYHSCROLL);
    1022     }
     1022        }
    10231023    }
    10241024
     
    16871687        return FALSE;
    16881688  }
    1689   dprintf(("USER32: ShowOwnedPopups %x %d", hwnd, fShow));
     1689  dprintf(("USER32: ShowOwnedPopups %x %d", hwndOwner, fShow));
    16901690
    16911691  hwnd = GetWindow(GetDesktopWindow(), GW_CHILD);
Note: See TracChangeset for help on using the changeset viewer.