Changeset 3662 for trunk/src


Ignore:
Timestamp:
Jun 7, 2000, 4:51:33 PM (25 years ago)
Author:
sandervl
Message:

Major rewrite: frame/client -> frame

Location:
trunk/src/user32
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/Makefile

    r3493 r3662  
    1 # $Id: Makefile,v 1.70 2000-05-05 11:32:35 sandervl Exp $
     1# $Id: Makefile,v 1.71 2000-06-07 14:51:23 sandervl Exp $
    22
    33#
     
    4343$(OBJDIR)\display.obj \
    4444$(OBJDIR)\pmwindow.obj \
    45 $(OBJDIR)\pmframe.obj \
    4645$(OBJDIR)\win32class.obj \
    4746$(OBJDIR)\win32wnd.obj \
  • trunk/src/user32/USER32.DEF

    r3641 r3662  
    1 ; $Id: USER32.DEF,v 1.31 2000-06-01 11:27:55 sandervl Exp $
     1; $Id: USER32.DEF,v 1.32 2000-06-07 14:51:24 sandervl Exp $
    22
    33;Created by BLAST for IBM's compiler
     
    1313    _GpiQueryDCData             = PMGPI.665
    1414    _GpiEnableYInversion        = PMGPI.723
     15    _GpiQueryYInversion         = PMGPI.726
    1516    _HPSToHDC                   = PMWINX.1022
    1617    _DeleteHDC                  = PMWINX.1023
  • trunk/src/user32/button.cpp

    r3641 r3662  
    1 /* $Id: button.cpp,v 1.36 2000-06-01 11:27:56 sandervl Exp $ */
     1/* $Id: button.cpp,v 1.37 2000-06-07 14:51:24 sandervl Exp $ */
    22/* File: button.cpp -- Button type widgets
    33 *
     
    176176static LRESULT BUTTON_EraseBkgnd(HWND hwnd,WPARAM wParam,LPARAM lParam)
    177177{
    178   //SvL: This is wrong: should be
     178  DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & 0x0f;
    179179  //SvL: TODO: NT does something extra for ownerdrawn buttons; check this
    180 //  if(style == BS_OWNERDRAW) {
    181 //        return DefWindowProcA(hwnd, WM_ERASEBKGND, wParam, lParam);
    182 //  }
    183 //  return 1;
    184 
    185   //SvL: Erase background for groupboxes as the paint function only draws
    186   //     a box
    187   DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & 0x0f;
    188 //  if(style == BS_GROUPBOX) {
     180  if(style == BS_OWNERDRAW) {
    189181        return DefWindowProcA(hwnd, WM_ERASEBKGND, wParam, lParam);
    190 //  }
    191 //  return 1;
     182  }
     183  return 1;
    192184}
    193185
     
    325317  DWORD style = GetWindowLongA(hwnd,GWL_STYLE) & 0x0f;
    326318
    327   //if (style == BS_GROUPBOX) return HTTRANSPARENT;
     319  if (style == BS_GROUPBOX) return HTTRANSPARENT;
    328320
    329321  return DefWindowProcA(hwnd,WM_NCHITTEST,wParam,lParam);
     
    12051197    wndClass.cbWndExtra    = sizeof(BUTTONINFO);
    12061198    wndClass.hCursor       = LoadCursorA(0,IDC_ARROWA);
    1207 //    wndClass.hbrBackground = (HBRUSH)0;
    12081199    wndClass.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
    12091200    wndClass.lpszClassName = BUTTONCLASSNAME;
  • trunk/src/user32/clipboard.cpp

    r3462 r3662  
    1 /* $Id: clipboard.cpp,v 1.7 2000-04-29 18:28:34 sandervl Exp $ */
     1/* $Id: clipboard.cpp,v 1.8 2000-06-07 14:51:25 sandervl Exp $ */
    22
    33/*
     
    4040    }
    4141    dprintf(("USER32:  ChangeClipboardChain\n"));
    42     return O32_ChangeClipboardChain(wndRemove->getOS2FrameWindowHandle(),
    43                                     wndNext->getOS2FrameWindowHandle());
     42    return O32_ChangeClipboardChain(wndRemove->getOS2WindowHandle(),
     43                                    wndNext->getOS2WindowHandle());
    4444}
    4545//******************************************************************************
     
    108108    hwndOwner = O32_GetClipboardOwner();
    109109
    110     window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndOwner);
     110    window = Win32BaseWindow::GetWindowFromOS2Handle(hwndOwner);
    111111    if(!window) {
    112112        //an OS/2 window probably owns the clipboard, we pretend nobody owns it
     
    125125    hwndViewer = O32_GetClipboardViewer();
    126126
    127     window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndViewer);
     127    window = Win32BaseWindow::GetWindowFromOS2Handle(hwndViewer);
    128128    if(!window) {
    129129        //probably an OS/2 window, we pretend it's nobody
     
    142142    hwnd = O32_GetOpenClipboardWindow();
    143143
    144     window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
     144    window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    145145    if(!window) {
    146146        //probably an OS/2 window, we pretend it's nobody
     
    176176    }
    177177    dprintf(("USER32:  OpenClipboard\n"));
    178     return O32_OpenClipboard(window->getOS2FrameWindowHandle());
     178    return O32_OpenClipboard(window->getOS2WindowHandle());
    179179}
    180180//******************************************************************************
     
    219219    }
    220220    dprintf(("USER32:  SetClipboardViewer\n"));
    221     hwndOld = O32_SetClipboardViewer(wndnew->getOS2FrameWindowHandle());
    222 
    223     wndold = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwndOld);
     221    hwndOld = O32_SetClipboardViewer(wndnew->getOS2WindowHandle());
     222
     223    wndold = Win32BaseWindow::GetWindowFromOS2Handle(hwndOld);
    224224    if(!wndold) {
    225225        //probably an OS/2 window, so pretend it's nobody
  • trunk/src/user32/dc.cpp

    r3641 r3662  
    1 /* $Id: dc.cpp,v 1.58 2000-06-01 11:27:56 sandervl Exp $ */
     1/* $Id: dc.cpp,v 1.59 2000-06-07 14:51:25 sandervl Exp $ */
    22
    33/*
     
    2222#include <stdlib.h>
    2323
     24#include <string.h>
    2425#include <win32type.h>
    2526#include <win32api.h>
     
    301302//******************************************************************************
    302303//******************************************************************************
     304VOID removeClientArea(pDCData pHps)
     305{
     306 POINTL point;
     307
     308   // This function checks to see if a client area is currently selected, if
     309   // it is the origin plus the visible region of the frame are restored.
     310
     311   pHps->isClient = FALSE;
     312
     313   GreGetDCOrigin(pHps->hps, &point);
     314
     315   if(pHps->isClientArea)
     316   {
     317        dprintf2(("removeClientArea: (%d,%d) -> (%d,%d)", point.x, point.y, pHps->ptlOrigin.x, pHps->ptlOrigin.y));
     318        pHps->isClientArea = FALSE;
     319        GreSetupDC(pHps->hps,
     320                   pHps->hrgnVis,
     321                   pHps->ptlOrigin.x,
     322                   pHps->ptlOrigin.y,
     323                   0,
     324                   SETUPDC_ORIGIN | SETUPDC_VISRGN | SETUPDC_RECALCCLIP);
     325   }
     326   else dprintf(("removeClientArea: (%d,%d)", point.x, point.y));
     327
     328}
     329//******************************************************************************
     330//******************************************************************************
     331HRGN selectClientArea(Win32BaseWindow *window, pDCData pHps, PRECTL prclPaint)
     332{
     333   // This function checks to see if the DC needs to be adjusted to a client
     334   // area and makes the adjustment.
     335   RECTL rcl, rcltemp;
     336   HRGN  hrgnRect, hrgnClip, hrgnOldClip = 0;
     337   HWND  hwnd;
     338   LONG  rc;
     339   PRECT pClient = window->getClientRectPtr();
     340   PRECT pWindow = window->getWindowRect();
     341
     342   if(pClient->left == 0 && pClient->top == 0 &&
     343      window->getClientHeight() == window->getWindowHeight() &&
     344      window->getClientWidth()  == window->getWindowWidth())
     345   {
     346        //client rectangle = frame rectangle -> no change necessary
     347        //only setup the clip region
     348        goto setupclipregion;
     349   }
     350
     351   pHps->isClient = TRUE;
     352
     353   hwnd = window->getOS2WindowHandle();
     354
     355   mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&rcl);
     356
     357   //convert to screen coordinates
     358   GreGetDCOrigin(pHps->hps, (PPOINTL)&rcltemp);
     359   rcl.xLeft   += rcltemp.xLeft;
     360   rcl.xRight  += rcltemp.xLeft;
     361   rcl.yTop    += rcltemp.yBottom;
     362   rcl.yBottom += rcltemp.yBottom;
     363       
     364   pHps->ptlOrigin.x = rcltemp.xLeft;
     365   pHps->ptlOrigin.y = rcltemp.yBottom;
     366 
     367   dprintf2(("selectClientArea: (%d,%d) -> (%d,%d)", rcltemp.xLeft, rcltemp.yBottom, rcl.xLeft, rcl.yBottom));
     368
     369   if(pHps->hrgnVis == 0)
     370        pHps->hrgnVis = GreCreateRectRegion(pHps->hps, &rcl, 1);
     371
     372   hrgnRect = GreCreateRectRegion(pHps->hps, &rcl, 1);
     373
     374   // Query the visible region
     375   GreCopyClipRegion(pHps->hps, pHps->hrgnVis, 0, COPYCRGN_VISRGN);
     376   GpiQueryRegionBox(pHps->hps, pHps->hrgnVis, &rcltemp);
     377   // And the visible region of the frame with the client rectangle
     378   // to get the new visible region
     379   GreCombineRegion(pHps->hps, hrgnRect, pHps->hrgnVis, hrgnRect, CRGN_AND);
     380     
     381   // Set the new origin plus visible region in the DC
     382   GreSetupDC(pHps->hps,
     383              hrgnRect,
     384              rcl.xLeft,
     385              rcl.yBottom,
     386              NULL,
     387              SETUPDC_ORIGIN | SETUPDC_VISRGN | SETUPDC_RECALCCLIP);
     388
     389/*
     390        GpiQueryRegionBox(pHps->hps, hrgnClip, &rcltemp);
     391        GpiQueryRegionBox(pHps->hps, hrgnOldClip, &rcltemp);
     392
     393        GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp);
     394
     395        GreGetDCOrigin(pHps->hps, (PPOINTL)&rcltemp);
     396
     397        GreCopyClipRegion(pHps->hps, hrgnRect, 0, COPYCRGN_VISRGN);
     398        GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp);
     399     
     400        GreCopyClipRegion(pHps->hps, hrgnRect, 0, COPYCRGN_ALLINTERSECT);
     401        GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp);
     402     
     403        GreCopyClipRegion(pHps->hps, hrgnRect, 0, COPYCRGN_CLIPRGN);
     404        GpiQueryRegionBox(pHps->hps, hrgnRect, &rcltemp);
     405*/
     406   pHps->isClientArea = TRUE;
     407
     408   // Destroy the region now we have finished with it.
     409   GreDestroyRegion(pHps->hps, hrgnRect);
     410
     411setupclipregion:
     412   if(prclPaint) {
     413        hrgnClip = GpiQueryClipRegion(pHps->hps);
     414        if(hrgnClip) {
     415                rc = GreIntersectClipRectangle(pHps->hps, prclPaint);
     416                if(rc == RGN_ERROR) {
     417                        dprintf(("selectClientArea: GreIntersectClipRectangle returned RGN_ERROR!"));
     418                }
     419        }
     420        else {
     421                hrgnClip = GreCreateRectRegion(pHps->hps, prclPaint, 1);
     422                GreSelectClipRegion(pHps->hps, hrgnClip, &hrgnOldClip);
     423        }
     424   }
     425
     426   return hrgnOldClip;
     427}
     428//******************************************************************************
     429//******************************************************************************
    303430LONG clientHeight(Win32BaseWindow *wnd, HWND hwnd, pDCData pHps)
    304431{
     
    308435   if ((hwnd != 0) || (pHps == 0))
    309436   {
    310       if (wnd)
    311          return (wnd->getClientHeight());
    312       else
    313          return OSLibQueryScreenHeight();
     437        if(wnd) {
     438                if(pHps && !pHps->isClientArea) {
     439                        return (wnd->getWindowHeight());
     440                }
     441                else    return (wnd->getClientHeight());
     442        }
     443        else    return OSLibQueryScreenHeight();
    314444   }
    315445   else if (pHps->bitmapHandle)
     
    430560//******************************************************************************
    431561//******************************************************************************
    432 #if 0
    433 HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps)
    434 {
    435    HWND     hwnd = hWnd ? hWnd : HWND_DESKTOP;
    436    pDCData  pHps = NULLHANDLE;
    437    RECTL    rect;
    438    HPS      hPS_ownDC = NULLHANDLE;
    439 
    440    if ( !lpps )
    441    {
    442       SetLastError(ERROR_INVALID_PARAMETER_W);
    443       return (HDC)NULLHANDLE;
    444    }
    445 
    446    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    447 
    448 #if 0
    449    if ((hwnd != HWND_DESKTOP) && wnd->isOwnDC())
    450    {
    451         hPS_ownDC = wnd->getOwnDC();
    452         //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
    453         if(hPS_ownDC) {
    454                 pHps = (pDCData)GpiQueryDCData(hPS_ownDC);
    455                 if (!pHps)
    456                 {
    457                         SetLastError(ERROR_INVALID_PARAMETER_W);
    458                         return (HDC)NULLHANDLE;
    459                 }
    460         }
    461    }
    462 #endif
    463 
    464    HWND hwndClient = wnd->getOS2WindowHandle();
    465    HPS  hps = WinBeginPaint(hwndClient, hPS_ownDC, &rect);
    466 
    467    if (!pHps)
    468    {
    469       HDC hdc = HPSToHDC (hwndClient, hps, NULL, NULL);
    470       pHps = (pDCData)GpiQueryDCData(hps);
    471    }
    472 
    473    if (hPS_ownDC == 0)
    474       setMapMode (wnd, pHps, MM_TEXT_W);
    475    else
    476       setPageXForm (wnd, pHps);
    477 
    478    pHps->hdcType = TYPE_3;
    479 
    480    HideCaret(hwnd);
    481 
    482    if(wnd->needsEraseBkgnd()) {
    483         wnd->setEraseBkgnd(FALSE);
    484         lpps->fErase = (wnd->MsgEraseBackGround(pHps->hps) != 0);
    485    }
    486    else lpps->fErase = TRUE;
    487    lpps->hdc = (HDC)hps;
    488 
    489    if (!hPS_ownDC)
    490    {
    491       long height  = wnd->getClientHeight();
    492 
    493       rect.yTop    = height - rect.yTop;
    494       rect.yBottom = height - rect.yBottom;
    495    }
    496    else
    497    {
    498       rect.yTop--;
    499       rect.yBottom--;
    500       GpiConvert(pHps->hps, CVTC_DEVICE, CVTC_WORLD, 2, (PPOINTL)&rect);
    501    }
    502 
    503    WINRECT_FROM_PMRECT(lpps->rcPaint, rect);
    504    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));
    505 
    506    SetLastError(0);
    507    return (HDC)pHps->hps;
    508 }
    509 
    510 BOOL WIN32API EndPaint (HWND hwnd, const PAINTSTRUCT_W *pPaint)
    511 {
    512  pDCData pHps;
    513 
    514    dprintf (("USER32: EndPaint(%x)", hwnd));
    515 
    516    ShowCaret(hwnd);
    517    if (!pPaint || !pPaint->hdc )
    518       return TRUE;
    519 
    520    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    521 
    522    if (!wnd) goto exit;
    523 
    524    //SvL: Hack for memory.exe (doesn't get repainted properly otherwise)
    525    pHps = (pDCData)GpiQueryDCData((HPS)pPaint->hdc);
    526    if (pHps && (pHps->hdcType == TYPE_3)) {
    527           WinEndPaint (pHps->hps);
    528    }
    529    wnd->setEraseBkgnd(TRUE);
    530 
    531 exit:
    532    SetLastError(0);
    533    return TRUE;
    534 }
    535 #else
    536562HDC WIN32API BeginPaint (HWND hWnd, PPAINTSTRUCT_W lpps)
    537563{
     
    540566 HPS      hPS_ownDC = NULLHANDLE, hpsPaint = 0;
    541567 RECTL    rectl = {0, 0, 1, 1};
    542  HRGN     hrgnUpdate, hrgnOld;
     568 HRGN     hrgnUpdate, hrgnOld, hrgnOldClip;
    543569 LONG     lComplexity;
    544 
     570 RECTL    rectlClient;
     571 RECTL    rectlClip;
     572
     573   memset(lpps, 0, sizeof(*lpps));
    545574   Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    546575   if(!lpps || !wnd) {
     
    567596   }
    568597   if(!hpsPaint) {
    569         hpsPaint = GetDCEx(hwnd, 0, DCX_CACHE_W);
     598        hpsPaint = GetDCEx(hwnd, 0, (DCX_CACHE_W|DCX_WINDOW_W|DCX_USESTYLE_W));
    570599        pHps = (pDCData)GpiQueryDCData(hpsPaint);
    571600        if (!pHps)
     
    577606   }
    578607
    579 #if 0
    580    HPS  hps = WinBeginPaint(hwndClient, hPS_ownDC, &rect);
    581 
    582    if (!pHps)
    583    {
    584       HDC hdc = HPSToHDC (hwndClient, hps, NULL, NULL);
    585       pHps = (pDCData)GpiQueryDCData(hps);
    586    }
    587 #endif
    588 
    589    if (hPS_ownDC == 0)
     608   if(WinQueryUpdateRect(hwndClient, &rectl) == FALSE) {
     609        memset(&rectl, 0, sizeof(rectl));
     610        dprintf (("USER32: WARNING: WinQueryUpdateRect failed (error or no update rectangle)!!"));
     611
     612        mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient);
     613        WinOffsetRect(NULL, &rectlClient, -rectlClient.xLeft, -rectlClient.yBottom);
     614
     615        hrgnOldClip = selectClientArea(wnd, pHps, &rectlClient);
     616        //save old clip region (restored for CS_OWNDC windows in EndPaint)
     617        wnd->SetClipRegion(hrgnOldClip);
     618        lComplexity = RGN_NULL;
     619   }
     620   else {
     621        HRGN hrgnTmp = GpiCreateRegion(pHps->hps, 1, &rectl);
     622
     623        WinQueryUpdateRegion(hwndClient, hrgnTmp);
     624
     625        RGNRECT rgnrect = {0, 12, 0, RECTDIR_LFRT_TOPBOT};
     626        RECTL   rectls[12], rcltemp;
     627        GpiQueryRegionRects(pHps->hps, hrgnTmp, &rcltemp, &rgnrect, &rectls[0]);
     628        GpiDestroyRegion(pHps->hps, hrgnTmp);
     629
     630        WinValidateRect(hwndClient, &rectl, FALSE);
     631
     632        mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&rectlClient);
     633        WinIntersectRect(NULL, &rectlClip, &rectl, &rectlClient);
     634        WinOffsetRect(NULL, &rectlClip, -rectlClient.xLeft, -rectlClient.yBottom);
     635 
     636        hrgnOldClip = selectClientArea(wnd, pHps, &rectlClip);
     637
     638        //save old clip region (restored for CS_OWNDC windows in EndPaint)
     639        wnd->SetClipRegion(hrgnOldClip);
     640        memcpy(&rectl, &rectlClip, sizeof(RECTL));
     641        lComplexity = RGN_RECT;
     642   }
     643
     644   if(hPS_ownDC == 0)
    590645      setMapMode (wnd, pHps, MM_TEXT_W);
    591646   else
    592       setPageXForm (wnd, pHps);
     647      setPageXForm(wnd, pHps);
    593648
    594649   pHps->hdcType = TYPE_3;
    595650
    596    hrgnUpdate  = GpiCreateRegion(pHps->hps, 1, &rectl);
    597    lComplexity = WinQueryUpdateRegion(hwndClient, hrgnUpdate);
    598    if(lComplexity == RGN_ERROR) {
    599         dprintf (("USER32: BeginPaint update region error!!"));
    600         SetLastError(ERROR_INVALID_PARAMETER_W);
    601         return 0;
    602    }
    603    WinQueryUpdateRect(hwndClient, &rectl);
    604 
    605    if(lComplexity != RGN_NULL) {
    606         WinValidateRegion(hwndClient, hrgnUpdate, FALSE);
    607 
    608         GpiSetClipRegion(pHps->hps, hrgnUpdate, &hrgnOld);
    609         //save old clip region (restored for CS_OWNDC windows in EndPaint)
    610         wnd->SetClipRegion(hrgnOld);
    611    }
     651   HideCaret(hwnd);
     652   WinShowTrackRect(wnd->getOS2WindowHandle(), FALSE);
    612653
    613654   if(wnd->needsEraseBkgnd() && lComplexity != RGN_NULL) {
     
    631672   }
    632673
    633    HideCaret(hwnd);
    634 
    635674   SetLastError(0);
    636675   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));
     
    657696   if (pHps && (pHps->hdcType == TYPE_3))
    658697   {
    659         GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnOld);
     698        removeClientArea(pHps);
    660699        if(hrgnOld) {
     700                GpiSetClipRegion(pHps->hps, NULLHANDLE, &hrgnOld);
    661701                GpiDestroyRegion(pHps->hps, hrgnOld);
    662702        }
    663703        if(hwnd == HWND_DESKTOP || !wnd->isOwnDC()) {
     704                pHps->hdcType = TYPE_1; //otherwise Open32's ReleaseDC fails
    664705                ReleaseDC(hwnd, pPaint->hdc);
    665706        }
     
    671712                pHps->hdcType = TYPE_1;
    672713        }
    673 
    674 ////    WinEndPaint (pHps->hps);
    675714   }
    676715   else {
     
    679718   wnd->setEraseBkgnd(TRUE);
    680719   ShowCaret(hwnd);
     720   WinShowTrackRect(wnd->getOS2WindowHandle(), TRUE);
    681721
    682722exit:
     
    684724   return TRUE;
    685725}
     726//******************************************************************************
     727//******************************************************************************
     728int WIN32API GetClipBox( HDC hdc, PRECT lpRect)
     729{
     730 pDCData  pHps = (pDCData)GpiQueryDCData((HPS)hdc);
     731 RECTL    rectl;
     732 LONG     lComplexity;
     733 int      rc;
     734
     735    if(!hdc || !lpRect || !pHps) {
     736        dprintf(("GDI32: GetClipBox %x %x ERROR_INVALID_PARAMETER", hdc, lpRect));
     737        SetLastError(ERROR_INVALID_PARAMETER_W);
     738        return ERROR_W;
     739    }
     740    if(pHps->isPrinter)
     741    {
     742        lpRect->left   = 0;
     743        lpRect->top    = 0;
     744        lpRect->right  = GetDeviceCaps( hdc, HORZRES_W);
     745        lpRect->bottom = GetDeviceCaps( hdc, VERTRES_W);
     746
     747        rc = SIMPLEREGION_W;
     748    }
     749    else {
     750        lComplexity = GpiQueryClipBox(pHps->hps, &rectl);
     751        if(lComplexity == RGN_ERROR)
     752        {
     753                rc = ERROR_W;
     754        }
     755        else
     756        if(lComplexity == RGN_NULL)
     757        {
     758                memset(lpRect, 0, sizeof(*lpRect));
     759                rc = NULLREGION_W;
     760        }
     761        else {
     762                lpRect->left   = rectl.xLeft;
     763                lpRect->right  = rectl.xRight;
     764#if 0
     765                lpRect->top    = pHps->height - rectl.yTop;
     766                lpRect->bottom = pHps->height - rectl.yBottom;
     767#else
     768                //No conversion required as GpiQueryClipBox is affected by
     769                //the y-inversion of the window
     770                lpRect->top    = rectl.yBottom;
     771                lpRect->bottom = rectl.yTop;
    686772#endif
    687 //******************************************************************************
    688 //******************************************************************************
    689 int WIN32API GetClipBox( HDC arg1, PRECT  arg2)
     773                //Convert including/including to including/excluding
     774                if(lpRect->left != lpRect->right) {
     775                        lpRect->right++;
     776                }
     777                if(lpRect->top != lpRect->bottom) {
     778                        lpRect->bottom++;
     779                }
     780                rc = (lComplexity == RGN_RECT) ? SIMPLEREGION_W : COMPLEXREGION_W;
     781        }
     782    }
     783    dprintf(("GDI32: GetClipBox of %X returned %d\n", hdc, rc));
     784    return rc;
     785}
     786//******************************************************************************
     787//******************************************************************************
     788int WIN32API GetClipRgn( HDC hdc, HRGN hRgn)
    690789{
    691790 int rc;
    692791
    693   rc = O32_GetClipBox(arg1, arg2);
    694   dprintf(("GDI32: GetClipBox of %X returned %d\n", arg1, rc));
    695   return(rc);
    696 }
    697 //******************************************************************************
    698 //******************************************************************************
    699 int WIN32API GetClipRgn( HDC hdc, HRGN hRgn)
    700 {
    701     dprintf(("GDI32: GetClipRgn"));
    702     return O32_GetClipRgn(hdc, hRgn);
     792    rc = O32_GetClipRgn(hdc, hRgn);
     793    dprintf(("GDI32: GetClipRgn %x %x returned %x", hdc, hRgn, rc));
     794    return rc;
    703795}
    704796//******************************************************************************
     
    708800   if (!hwnd)
    709801   {
    710       SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    711       return FALSE;
     802        dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));
     803        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     804        return FALSE;
    712805   }
    713806
     
    717810   if (!wnd)
    718811   {
    719       SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
    720       return FALSE;
    721    }
     812        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     813        dprintf(("GetUpdateRect %x %x %d -> invalid handle!!", hwnd, pRect, erase));
     814        return FALSE;
     815   }
     816
     817   dprintf(("GetUpdateRect %x %x %d", hwnd, pRect, erase));
    722818
    723819   BOOL updateRegionExists = WinQueryUpdateRect (wnd->getOS2WindowHandle(), pRect ? &rectl : NULL);
     
    781877//******************************************************************************
    782878//******************************************************************************
    783 BOOL SYSTEM GetOS2UpdateRect(HWND hwnd,LPRECT pRect)
     879BOOL GetOS2UpdateRect(Win32BaseWindow *window, LPRECT pRect)
    784880{
    785881   RECTL rectl;
    786    BOOL updateRegionExists = WinQueryUpdateRect(hwnd,pRect ? &rectl:NULL);
     882   BOOL updateRegionExists = WinQueryUpdateRect(window->getOS2WindowHandle(),pRect ? &rectl:NULL);
    787883
    788884   if (!pRect)
     
    793889     //CB: for PM empty rect is valid
    794890     if ((rectl.xLeft == rectl.xRight) || (rectl.yTop == rectl.yBottom)) return FALSE;
    795      mapOS2ToWin32Rect(hwnd,(PRECTLOS2)&rectl,pRect);
     891     mapOS2ToWin32Rect(window->getWindowHeight(), (PRECTLOS2)&rectl,pRect);
    796892   }
    797893   else
     
    836932//      isOwnDC = wnd->isOwnDC() && wnd->getOwnDC();
    837933        isOwnDC = wnd->isOwnDC() && (wnd->getOwnDC() == hdc);
    838    }
    839    if (isOwnDC)
    840       rc = TRUE;
    841    else
    842       rc = O32_ReleaseDC (0, hdc);
     934        if(!isOwnDC)
     935        {
     936                pDCData  pHps = (pDCData)GpiQueryDCData((HPS)hdc);
     937                if(pHps && pHps->psType == MICRO_CACHED) {
     938                        removeClientArea(pHps);
     939                        if(pHps->hrgnVis) {
     940                                GreDestroyRegion(pHps->hps, pHps->hrgnVis);
     941                                pHps->hrgnVis = 0;
     942                        }
     943                }       
     944                else {
     945                        dprintf(("ERROR: ReleaseDC: pHps == NULL!!"));
     946                        DebugInt3();
     947                }
     948        }
     949   }
     950
     951   if(isOwnDC) {
     952        rc = TRUE;
     953   }
     954   else {
     955        rc = O32_ReleaseDC (0, hdc);
     956   }
    843957
    844958   dprintf(("ReleaseDC %x %x", hwnd, hdc));
     
    851965// DCX_EXCLUDERGN (complex regions allowed)
    852966// DCX_INTERSECTRGN (complex regions allowed)
     967// DCX_USESTYLE
     968// DCX_CLIPSIBLINGS
     969// DCX_CLIPCHILDREN
     970// DCX_PARENTCLIP
    853971//
    854972//TODO: WM_SETREDRAW affects drawingAllowed flag!!
     
    880998                return 0;
    881999        }
    882 //SvL: Experimental change (doesn't work right)
    883 #if 0
    884         if(wnd->fHasParentDC() && wnd->getParent()) {
    885                 wnd = wnd->getParent();
    886         }
    887 #endif
    888         if (flags & DCX_WINDOW_W)
    889                 hWindow = wnd->getOS2FrameWindowHandle();
    890         else
    891                 hWindow = wnd->getOS2WindowHandle();
     1000        hWindow = wnd->getOS2WindowHandle();
    8921001   }
    8931002
    8941003   isWindowOwnDC = (((hWindow == HWND_DESKTOP) ? FALSE : (wnd->isOwnDC()))
    895                  && !(flags & (DCX_CACHE_W | DCX_WINDOW_W)));
    896 
    897    if (isWindowOwnDC)
     1004                 && !(flags & DCX_CACHE_W));
     1005
     1006   if(isWindowOwnDC)
    8981007   {
    8991008      hps = wnd->getOwnDC();
     
    9041013            goto error;
    9051014
     1015         if(flags & DCX_WINDOW_W)
     1016            removeClientArea(pHps);
     1017         else
     1018            selectClientArea(wnd, pHps, NULL);
     1019
    9061020         setPageXForm (wnd, pHps);
    907 
    9081021         pHps->hdcType = TYPE_1;
     1022
    9091023         dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps));
    9101024         return (HDC)hps;
     
    9141028   }
    9151029
    916    if (isWindowOwnDC)
     1030   if(isWindowOwnDC)
    9171031   {
    9181032      SIZEL sizel = {0,0};
     
    9241038   else
    9251039   {
    926       if (hWindow == HWND_DESKTOP)
     1040      if (hWindow == HWND_DESKTOP) {
    9271041         hps = WinGetScreenPS (hWindow);
    928       else
    929          hps = WinGetPS (hWindow);
    930 
     1042      }
     1043      else {
     1044        int clipstyle = 0;
     1045        int clipwnd   = HWND_TOP;
     1046        if(flags & (DCX_USESTYLE_W)) {
     1047                int style = wnd->getStyle();
     1048                if(style & WS_CLIPCHILDREN_W) {
     1049                        clipstyle |= PSF_CLIPCHILDREN;
     1050                }
     1051                if(style & WS_CLIPSIBLINGS_W) {
     1052                        clipstyle |= PSF_CLIPSIBLINGS;
     1053                }
     1054                if(wnd->fHasParentDC()) {
     1055                        clipstyle |= PSF_PARENTCLIP;
     1056                }
     1057        }
     1058        if(flags & DCX_CLIPSIBLINGS_W) {
     1059                clipstyle |= PSF_CLIPSIBLINGS;
     1060        }
     1061        if(flags & DCX_CLIPCHILDREN_W) {
     1062                clipstyle |= PSF_CLIPCHILDREN;
     1063        }
     1064        if(flags & DCX_PARENTCLIP_W) {
     1065                clipstyle |= PSF_PARENTCLIP;
     1066        }
     1067        if(clipstyle) {
     1068                dprintf2(("WinGetClipPS style %x", clipstyle));
     1069                hps = WinGetClipPS(hWindow, clipwnd, clipstyle);
     1070        }
     1071        else    hps = WinGetPS (hWindow);
     1072      }
    9311073      psType = MICRO_CACHED;
    9321074   }
     
    9371079   HPSToHDC (hWindow, hps, NULL, NULL);
    9381080   pHps = (pDCData)GpiQueryDCData (hps);
     1081
     1082   if(!(flags & DCX_WINDOW_W))
     1083   {
     1084        selectClientArea(wnd, pHps, NULL);
     1085   }
     1086   else removeClientArea(pHps);
     1087
     1088
     1089   setMapMode(wnd, pHps, MM_TEXT_W);
    9391090
    9401091   if ((flags & DCX_EXCLUDERGN_W) || (flags & DCX_INTERSECTRGN_W))
     
    10371188{
    10381189  if (!hwnd) hwnd = GetDesktopWindow();
    1039   return GetDCEx (hwnd, NULL, DCX_USESTYLE_W | DCX_WINDOW_W);
     1190  return GetDCEx (hwnd, NULL, DCX_WINDOW_W);
    10401191}
    10411192//******************************************************************************
     
    10911242        //TODO: If frame, exclude client window from update
    10921243        if(redraw & RDW_FRAME_W) {
    1093                 hwnd = wnd->getOS2FrameWindowHandle();
     1244                hwnd = wnd->getOS2WindowHandle();
    10941245        }
    10951246        else    hwnd = wnd->getOS2WindowHandle();
     
    12541405}
    12551406//******************************************************************************
     1407//TODO: Change for client rectangle!!!!!
    12561408//******************************************************************************
    12571409BOOL setPMRgnIntoWinRgn (HRGN hrgnPM, HRGN hrgnWin, LONG height)
     
    13131465}
    13141466//******************************************************************************
    1315 //******************************************************************************
    1316 BOOL WIN32API ScrollDC (HDC hDC, int dx, int dy, const RECT *pScroll,
    1317                         const RECT *pClip, HRGN hrgnUpdate, LPRECT pRectUpdate)
     1467//TODO: Check if this one works correctly...
     1468//******************************************************************************
     1469BOOL WIN32API ScrollDC(HDC hDC, int dx, int dy, const RECT *pScroll,
     1470                       const RECT *pClip, HRGN hrgnUpdate, LPRECT pRectUpdate)
    13181471{
    13191472   BOOL rc = TRUE;
    13201473
    1321    dprintf (("USER32:  ScrollDC"));
     1474   dprintf (("USER32: ScrollDC %x (%d,%d), %x %x %x %x", hDC, dx, dy, pScroll, pClip, hrgnUpdate, pRectUpdate));
    13221475
    13231476   if (!hDC)
     
    13411494   dy = (int)(ptl[1].y - ptl[0].y);
    13421495
    1343    RECTL scrollRect;
    1344    RECTL clipRect;
     1496   RECT scrollRect;
     1497   RECT clipRect;
    13451498
    13461499   if (pClip)
    13471500   {
    1348       clipRect.xLeft   = min (pClip->left, pClip->right);
    1349       clipRect.xRight  = max (pClip->left, pClip->right);
    1350       clipRect.yTop    = max (pClip->top,  pClip->bottom);
    1351       clipRect.yBottom = min (pClip->top,  pClip->bottom);
     1501      memcpy(&clipRect, pClip, sizeof(clipRect));
    13521502
    13531503      if ((pHps->graphicsMode == GM_COMPATIBLE_W) &&
    1354           (clipRect.xLeft   != clipRect.xRight)   &&
    1355           (clipRect.yBottom != clipRect.yTop))
     1504          (clipRect.left   != clipRect.right)   &&
     1505          (clipRect.bottom != clipRect.top))
    13561506      {
    13571507          if (abs((int)pHps->viewportXExt) <= abs((int)pHps->windowExt.cx))
    1358               clipRect.xRight -= abs(pHps->worldXDeltaFor1Pixel);
     1508              clipRect.right -= abs(pHps->worldXDeltaFor1Pixel);
    13591509          else
    1360               clipRect.xLeft  += abs(pHps->worldXDeltaFor1Pixel);
     1510              clipRect.left  += abs(pHps->worldXDeltaFor1Pixel);
    13611511
    13621512          if (abs((int)pHps->viewportYExt) <= abs((int)pHps->windowExt.cy))
    1363               clipRect.yTop    -= abs(pHps->worldYDeltaFor1Pixel);
     1513              clipRect.bottom -= abs(pHps->worldYDeltaFor1Pixel);
    13641514          else
    1365               clipRect.yBottom += abs(pHps->worldYDeltaFor1Pixel);
    1366       }
    1367       GpiConvert (pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, (PPOINTL)&clipRect);
    1368       if (clipRect.xRight < clipRect.xLeft) {
    1369          ULONG temp      = clipRect.xLeft;
    1370          clipRect.xLeft  = clipRect.xRight;
    1371          clipRect.xRight = temp;
    1372       }
    1373       if (clipRect.yTop < clipRect.yBottom) {
    1374          ULONG temp       = clipRect.yBottom;
    1375          clipRect.yBottom = clipRect.yTop;
    1376          clipRect.yTop    = temp;
     1515              clipRect.top    += abs(pHps->worldYDeltaFor1Pixel);
     1516      }
     1517      GpiConvert(pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, (PPOINTL)&clipRect);
     1518      if (clipRect.right < clipRect.left) {
     1519         ULONG temp     = clipRect.left;
     1520         clipRect.left  = clipRect.right;
     1521         clipRect.right = temp;
     1522      }
     1523      if (clipRect.bottom < clipRect.top) {
     1524         ULONG temp       = clipRect.top;
     1525         clipRect.top     = clipRect.bottom;
     1526         clipRect.bottom  = temp;
    13771527      }
    13781528   }
     
    13801530   if (pScroll)
    13811531   {
    1382       scrollRect.xLeft   = min (pScroll->left, pScroll->right);
    1383       scrollRect.xRight  = max (pScroll->left, pScroll->right);
    1384       scrollRect.yTop    = max (pScroll->top,  pScroll->bottom);
    1385       scrollRect.yBottom = min (pScroll->top,  pScroll->bottom);
     1532      memcpy(&scrollRect, pScroll, sizeof(scrollRect));
    13861533
    13871534      if ((pHps->graphicsMode == GM_COMPATIBLE_W) &&
    1388           (scrollRect.xLeft   != scrollRect.xRight)   &&
    1389           (scrollRect.yBottom != scrollRect.yTop))
     1535          (scrollRect.left != scrollRect.right)   &&
     1536          (scrollRect.top  != scrollRect.bottom))
    13901537      {
    13911538          if (abs((int)pHps->viewportXExt) <= abs((int)pHps->windowExt.cx))
    1392               scrollRect.xRight -= abs(pHps->worldXDeltaFor1Pixel);
     1539              scrollRect.right -= abs(pHps->worldXDeltaFor1Pixel);
    13931540          else
    1394               scrollRect.xLeft  += abs(pHps->worldXDeltaFor1Pixel);
     1541              scrollRect.left  += abs(pHps->worldXDeltaFor1Pixel);
    13951542
    13961543          if (abs((int)pHps->viewportYExt) <= abs((int)pHps->windowExt.cy))
    1397               scrollRect.yTop    -= abs(pHps->worldYDeltaFor1Pixel);
     1544              scrollRect.bottom  -= abs(pHps->worldYDeltaFor1Pixel);
    13981545          else
    1399               scrollRect.yBottom += abs(pHps->worldYDeltaFor1Pixel);
     1546              scrollRect.top    += abs(pHps->worldYDeltaFor1Pixel);
    14001547      }
    14011548      GpiConvert (pHps->hps, CVTC_WORLD, CVTC_DEVICE, 2, (PPOINTL)&scrollRect);
    1402       if (scrollRect.xRight < scrollRect.xLeft) {
    1403          ULONG temp        = scrollRect.xLeft;
    1404          scrollRect.xLeft  = scrollRect.xRight;
    1405          scrollRect.xRight = temp;
    1406       }
    1407       if (scrollRect.yTop < scrollRect.yBottom) {
    1408          ULONG temp         = scrollRect.yBottom;
    1409          scrollRect.yBottom = scrollRect.yTop;
    1410          scrollRect.yTop    = temp;
    1411       }
    1412    }
    1413    RECTL rectlUpdate;
    1414    HRGN  hrgn;
    1415 
    1416    LONG lComplexity = WinScrollWindow (hwnd, dx, dy, (pScroll) ? &scrollRect : NULL, (pClip) ? &clipRect : NULL, hrgn, &rectlUpdate, 0);
     1549      if (scrollRect.right < scrollRect.left) {
     1550         ULONG temp       = scrollRect.left;
     1551         scrollRect.left  = scrollRect.right;
     1552         scrollRect.right = temp;
     1553      }
     1554      if (scrollRect.bottom < scrollRect.top) {
     1555         ULONG temp        = scrollRect.top;
     1556         scrollRect.top    = scrollRect.bottom;
     1557         scrollRect.bottom = temp;
     1558      }
     1559   }
     1560   RECTL  rectlUpdate;
     1561   HRGN   hrgn;
     1562   RECTL  clientRect;
     1563   RECTL  clipOS2;
     1564   RECTL  scrollOS2;
     1565   PRECTL pScrollOS2 = NULL;
     1566   PRECTL pClipOS2   = NULL;
     1567
     1568   mapWin32ToOS2Rect(wnd->getWindowHeight(), wnd->getClientRectPtr(), (PRECTLOS2)&clientRect);
     1569
     1570   if(pScroll) {
     1571        mapWin32ToOS2RectClientToFrame(wnd, &scrollRect, (PRECTLOS2)&scrollOS2);
     1572        pScrollOS2 = &scrollOS2;
     1573
     1574        //Scroll rectangle relative to client area
     1575        WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect);
     1576   }
     1577   else {
     1578        pScrollOS2 = &clientRect;
     1579   }
     1580
     1581   if(pClip) {
     1582         mapWin32ToOS2RectClientToFrame(wnd, &clipRect, (PRECTLOS2)&clipOS2);
     1583         pClipOS2 = &clipOS2;
     1584
     1585         //Clip rectangle relative to client area
     1586         WinIntersectRect((HAB) 0, pClipOS2, pClipOS2, &clientRect);
     1587   }
     1588   else {
     1589         pClipOS2 = &clientRect;
     1590   }
     1591
     1592   LONG lComplexity = WinScrollWindow(hwnd, dx, dy, pScrollOS2,
     1593                                      pClipOS2, hrgn, &rectlUpdate, 0);
    14171594   if (lComplexity == RGN_ERROR)
    14181595   {
     
    14211598
    14221599   RECT winRectUpdate;
    1423    LONG height = wnd->getClientHeight();
    1424 
    1425    winRectUpdate.left   = rectlUpdate.xLeft;
    1426    winRectUpdate.right  = rectlUpdate.xRight;
    1427    winRectUpdate.top    = height - rectlUpdate.yTop;
    1428    winRectUpdate.bottom = height - rectlUpdate.yBottom;
     1600
     1601   mapOS2ToWin32Rect(wnd->getWindowHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate);
    14291602
    14301603   if (pRectUpdate)
     
    14321605
    14331606   if (hrgnUpdate)
    1434       rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, height);
     1607      rc = setPMRgnIntoWinRgn(hrgn, hrgnUpdate, wnd->getWindowHeight());
    14351608
    14361609   return (rc);
     
    14381611//******************************************************************************
    14391612//******************************************************************************
    1440 #if 1
    1441 BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip)
    1442 {
    1443  Win32BaseWindow *window;
    1444  APIRET  rc;
    1445  RECTL   clientRect;
    1446  PRECT   pClientRect;
    1447  RECTL   scrollRect;
    1448  RECTL   clipRect;
    1449  PRECTL  pScrollRect = NULL;
    1450  PRECTL  pClipRect   = NULL;
    1451  ULONG   scrollFlags = SW_INVALIDATERGN;
    1452 
    1453     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1454     if(!window) {
    1455         dprintf(("ScrollWindow, window %x not found", hwnd));
    1456         return 0;
    1457     }
    1458     dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
    1459 
    1460     pClientRect = window->getClientRectPtr();
    1461     clientRect.xLeft   = 0;
    1462     clientRect.yBottom = 0;
    1463     clientRect.xRight  = pClientRect->right - pClientRect->left;
    1464     clientRect.yTop    = pClientRect->bottom - pClientRect->top;
    1465 
    1466     if(pScroll) {
    1467          mapWin32ToOS2Rect(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
    1468          pScrollRect = &scrollRect;
    1469 
    1470          //Scroll rectangle relative to client area
    1471          WinIntersectRect ((HAB) 0, pScrollRect, pScrollRect, &clientRect);
    1472     }
    1473     else scrollFlags |= SW_SCROLLCHILDREN;
    1474 
    1475     if(pClip) {
    1476          mapWin32ToOS2Rect(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
    1477          pClipRect = &clipRect;
    1478 
    1479          //Clip rectangle relative to client area
    1480          WinIntersectRect ((HAB) 0, pClipRect, pClipRect, &clientRect);
    1481     }
    1482 
    1483     dy = revertDy (window, dy);
    1484 
    1485     rc = WinScrollWindow(window->getOS2WindowHandle(), dx, dy,
    1486                          pScrollRect, pClipRect, NULLHANDLE,
    1487                          NULL, scrollFlags);
    1488 
    1489     return (rc != RGN_ERROR);
    1490 }
    1491 #else
    14921613BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip)
    14931614{
     
    14971618 RECTL   scrollRect;
    14981619 RECTL   clipRect;
    1499  PRECTL  pScrollRect = NULL;
    1500  PRECTL  pClipRect   = NULL;
     1620 PRECTL  pScrollOS2 = NULL;
     1621 PRECTL  pClipOS2   = NULL;
    15011622 ULONG   scrollFlags = SW_INVALIDATERGN;
    15021623
     
    15071628    }
    15081629    dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
    1509     mapWin32ToOS2Rect(window,window->getClientRectPtr(),(PRECTLOS2)&clientRect);
    1510 #if 0
    1511     //Rectangle could be relative to parent window, so fix this
    1512     if(clientRect.yBottom != 0) {
    1513         clientRect.yTop   -= clientRect.yBottom;
    1514         clientRect.yBottom = 0;
    1515     }
    1516     if(clientRect.xLeft != 0) {
    1517         clientRect.xRight -= clientRect.xLeft;
    1518         clientRect.xLeft   = 0;
    1519     }
    1520 #endif
     1630
     1631    mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&clientRect);
     1632
    15211633    if(pScroll) {
    1522          mapWin32ToOS2Rect(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
    1523          pScrollRect = &scrollRect;
    1524 
    1525          //Scroll rectangle relative to client area
    1526          pScrollRect->xLeft   += clientRect.xLeft;
    1527          pScrollRect->xRight  += clientRect.xLeft;
    1528          pScrollRect->yTop    += clientRect.yBottom;
    1529          pScrollRect->yBottom += clientRect.yBottom;
    1530          WinIntersectRect ((HAB) 0, pScrollRect, pScrollRect, &clientRect);
    1531     }
    1532     else scrollFlags |= SW_SCROLLCHILDREN;
     1634        mapWin32ToOS2RectClientToFrame(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
     1635        pScrollOS2 = &scrollRect;
     1636
     1637        //Scroll rectangle relative to client area
     1638        WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect);
     1639    }
     1640    else {
     1641        pScrollOS2 = &clientRect;
     1642        scrollFlags |= SW_SCROLLCHILDREN;
     1643    }
    15331644
    15341645    if(pClip) {
    1535          mapWin32ToOS2Rect(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
    1536          pClipRect = &clipRect;
     1646         mapWin32ToOS2RectClientToFrame(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
     1647         pClipOS2 = &clipRect;
    15371648
    15381649         //Clip rectangle relative to client area
    1539          pClipRect->xLeft     += clientRect.xLeft;
    1540          pClipRect->xRight    += clientRect.xLeft;
    1541          pClipRect->yTop      += clientRect.yBottom;
    1542          pClipRect->yBottom   += clientRect.yBottom;
    1543          WinIntersectRect ((HAB) 0, pClipRect, pClipRect, &clientRect);
     1650         WinIntersectRect ((HAB) 0, pClipOS2, pClipOS2, &clientRect);
     1651    }
     1652    else {
     1653         pClipOS2 = &clientRect;
    15441654    }
    15451655
     
    15471657
    15481658    rc = WinScrollWindow(window->getOS2WindowHandle(), dx, dy,
    1549                          pScrollRect, pClipRect, NULLHANDLE,
     1659                         pScrollOS2, pClipOS2, NULLHANDLE,
    15501660                         NULL, scrollFlags);
    15511661
    15521662    return (rc != RGN_ERROR);
    15531663}
    1554 #endif
    15551664//******************************************************************************
    15561665//******************************************************************************
     
    15581667                            HRGN hrgnUpdate, PRECT pRectUpdate, UINT scrollFlag)
    15591668{
    1560     Win32BaseWindow *window;
    1561     APIRET  rc;
    1562     RECTL   scrollRect;
    1563     RECTL   clipRect;
    1564     ULONG   scrollFlags = 0;
    1565     int     regionType = ERROR_W;
     1669 Win32BaseWindow *window;
     1670 APIRET  rc;
     1671 RECTL   clientRect;
     1672 RECTL   scrollRect;
     1673 RECTL   clipRect;
     1674 PRECTL  pScrollOS2 = NULL;
     1675 PRECTL  pClipOS2   = NULL;
     1676 ULONG   scrollFlags = 0;
     1677 int     regionType = ERROR_W;
    15661678
    15671679    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    15781690    if (scrollFlag & SW_SCROLLCHILDREN_W)  scrollFlags |= SW_SCROLLCHILDREN;
    15791691
    1580     if(pScroll) mapWin32ToOS2Rect(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
    1581     if(pClip)   mapWin32ToOS2Rect(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
     1692    mapWin32ToOS2Rect(window->getWindowHeight(), window->getClientRectPtr(), (PRECTLOS2)&clientRect);
     1693
     1694    if(pScroll) {
     1695        mapWin32ToOS2RectClientToFrame(window,(RECT *)pScroll, (PRECTLOS2)&scrollRect);
     1696        pScrollOS2 = &scrollRect;
     1697
     1698        //Scroll rectangle relative to client area
     1699        WinIntersectRect ((HAB) 0, pScrollOS2, pScrollOS2, &clientRect);
     1700    }
     1701    else {
     1702        pScrollOS2 = &clientRect;
     1703        scrollFlags |= SW_SCROLLCHILDREN;  //TODO: ?????
     1704    }
     1705
     1706    if(pClip) {
     1707         mapWin32ToOS2RectClientToFrame(window,(RECT *)pClip, (PRECTLOS2)&clipRect);
     1708         pClipOS2 = &clipRect;
     1709
     1710         //Clip rectangle relative to client area
     1711         WinIntersectRect ((HAB) 0, pClipOS2, pClipOS2, &clientRect);
     1712    }
     1713    else {
     1714         pClipOS2 = &clientRect;
     1715    }
    15821716
    15831717    RECTL rectlUpdate;
     
    15931727
    15941728    LONG lComplexity = WinScrollWindow (window->getOS2WindowHandle(), dx, dy,
    1595                                         (pScroll) ? &scrollRect : NULL,
    1596                                         (pClip) ? &clipRect : NULL,
     1729                                        pScrollOS2,
     1730                                        pClipOS2,
    15971731                                        hrgn, &rectlUpdate, scrollFlags);
    15981732    if (lComplexity == RGN_ERROR)
     
    16021736
    16031737    RECT winRectUpdate;
    1604     LONG height = window->getClientHeight();
    1605 
    1606     winRectUpdate.left   = rectlUpdate.xLeft;
    1607     winRectUpdate.right  = rectlUpdate.xRight;
    1608     winRectUpdate.top    = height - rectlUpdate.yTop;
    1609     winRectUpdate.bottom = height - rectlUpdate.yBottom;
     1738
     1739    mapOS2ToWin32Rect(window->getWindowHeight(), (PRECTLOS2)&rectlUpdate, &winRectUpdate);
    16101740
    16111741    if (pRectUpdate)
     
    16131743
    16141744    if (hrgnUpdate)
    1615        rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, height);
    1616 
     1745       rc = setPMRgnIntoWinRgn (hrgn, hrgnUpdate, window->getWindowHeight());
     1746
     1747#if 0
    16171748    //SvL: WinScrollWindow already invalidates the area; no need to do it again
    16181749    //(call to invalidateRect was wrong; has to include erase flag)
    1619 #if 0
    16201750    if ((scrollFlag & SW_INVALIDATE_W) &&
    16211751        ((lComplexity == RGN_RECT) || (lComplexity == RGN_COMPLEX)))
  • trunk/src/user32/dc.h

    r3641 r3662  
    1 /* $Id: dc.h,v 1.12 2000-06-01 11:27:57 sandervl Exp $ */
     1/* $Id: dc.h,v 1.13 2000-06-07 14:51:25 sandervl Exp $ */
    22/*
    33 * public dc functions
     
    1717extern void releaseOwnDC (HDC hps);
    1818
     19BOOL GetOS2UpdateRect(Win32BaseWindow *window,LPRECT pRect);
    1920
    2021#ifdef INCLUDED_BY_DC
     
    168169}
    169170
    170 //LONG    APIENTRY GpiQueryYInversion (HPS hps);
     171LONG APIENTRY _GpiQueryYInversion(ULONG hps);
     172
     173inline LONG GpiQueryYInversion(ULONG hps)
     174{
     175 LONG yyrc;
     176 USHORT sel = RestoreOS2FS();
     177
     178    yyrc = _GpiQueryYInversion(hps);
     179    SetFS(sel);
     180
     181    return yyrc;
     182}
    171183
    172184PVOID   APIENTRY _GpiAllocateDCData (HPS GpiH, ULONG size);
     
    446458
    447459    yyrc = _O32_GetClipRgn(a, b);
    448     SetFS(sel);
    449 
    450     return yyrc;
    451 }
    452 
    453 int       OPEN32API _O32_GetClipBox( HDC, PRECT );
    454 
    455 inline int O32_GetClipBox(HDC a, PRECT b)
    456 {
    457  int yyrc;
    458  USHORT sel = RestoreOS2FS();
    459 
    460     yyrc = _O32_GetClipBox(a, b);
    461460    SetFS(sel);
    462461
     
    554553   #define GreCombineRegion(a,b,c,d,e) (INT) _Gre32Entry7((ULONG)(HDC)(a),(ULONG)(HRGN)(b),(ULONG)(HRGN)(c),(ULONG)(HRGN)(d),(ULONG)(ULONG)(e),0L,0x00004065L)
    555554   #define GreDestroyRegion(a,b) (BOOL) _Gre32Entry4((ULONG)(HDC)(a),(ULONG)(HRGN)(b),0L,0x00004063L)
     555   #define GreGetDCOrigin(a,b) (BOOL) _Gre32Entry4((ULONG)(HDC)(a),(ULONG)(PPOINTL)(b),0L,0x000040BAL)
     556   #define GreDeviceSetDCOrigin(a,b) (BOOL) _Gre32Entry4((ULONG)(HDC)(a),(ULONG)(PPOINTL)(b),0L,0x000040BBL)
     557   #define GreSelectClipRegion(a,b,c) (INT) _Gre32Entry5((ULONG)(HDC)(a),(ULONG)(HRGN)(b),(ULONG)(PHRGN)(c),0L,0x00004074L)
     558   #define GreIntersectClipRectangle(a,b) (INT) _Gre32Entry4((ULONG)(HDC)(a),(ULONG)(PRECTL)(b),0L,0x00004075L)
    556559
    557560#endif //INCLUDED_BY_DC
  • trunk/src/user32/oslibgdi.cpp

    r3101 r3662  
    1 /* $Id: oslibgdi.cpp,v 1.11 2000-03-13 13:10:45 sandervl Exp $ */
     1/* $Id: oslibgdi.cpp,v 1.12 2000-06-07 14:51:26 sandervl Exp $ */
    22/*
    33 * Window GDI wrapper functions for OS/2
     
    3030Single y mapping:
    3131 mapScreenY()
    32  mapY()
    33  mapOS2ToWin32Y()
    34  mapWin32ToOS2Y()
    35  mapWin32Y()
     32 mapY()                 //only reverses y
     33 mapOS2ToWin32Y()       //reverse y + subtract parent client offset
     34 mapOS2ToWin32X()       //subtract parent client offset
     35
     36 mapWin32ToOS2Y()       //reverse y + add parent client offset
     37 mapWin32ToOS2Y()       //add parent client offset
    3638
    3739Single point mapping:
    3840 mapScreenPoint()
    39  mapPoint()
    4041 mapOS2ToWin32Point()
    4142 mapWin32ToOS2Point()
     
    5253 copyOS2ToWin32Rect()
    5354 copyWin32ToOS2Rect()
    54 
    55 Child origin:
    56  mapOS2ToWin32ChildOrigin()
    5755*/
    5856
     
    7068{
    7169  return screenH-1-screenPosY;
    72 }
    73 //******************************************************************************
    74 // To translation between OS/2 <-> Win32
    75 //******************************************************************************
    76 INT mapY(HWND os2Client,INT clientPosY)
    77 {
    78   RECTL rect;
    79 
    80   if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //client shouldn't be desktop
    81   if (!WinQueryWindowRect(os2Client,&rect)) return 0;
    82 
    83   return rect.yTop-1-clientPosY;
    84 }
    85 //******************************************************************************
    86 // To translation between OS/2 <-> Win32
    87 //******************************************************************************
    88 INT mapY(Win32BaseWindow *win32wnd,INT clientPosY)
    89 {
    90   if (!win32wnd) return 0;
    91 
    92   return win32wnd->getClientHeight()-1-clientPosY;
    93 }
    94 //******************************************************************************
    95 //******************************************************************************
    96 INT mapOS2ToWin32Y(HWND os2From,HWND os2To,INT fromPosY)
    97 {
    98   POINTL pt;
    99   RECTL rect;
    100 
    101   if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
    102   if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
    103   if (os2From != os2To)
    104   {
    105     pt.x = 0;
    106     pt.y = fromPosY;
    107     if (!WinMapWindowPoints(os2From,os2To,&pt,1)) return 0;
    108   } else pt.y = fromPosY;
    109   if (!WinQueryWindowRect(os2To,&rect)) return 0;
    110 
    111   return rect.yTop-1-pt.y;
    112 }
    113 //******************************************************************************
    114 //******************************************************************************
    115 INT mapOS2ToWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY)
    116 {
    117   POINTL pt;
    118 
    119   if (!wndFrom || !wndTo) return 0;
    120   if (wndFrom != wndTo)
    121   {
    122     pt.x = 0;
    123     pt.y = fromPosY;
    124     if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),&pt,1)) return 0;
    125   } else pt.y = fromPosY;
    126 
    127   return wndTo->getClientHeight()-1-pt.y;
    128 }
    129 //******************************************************************************
    130 //******************************************************************************
    131 INT mapWin32Y(HWND os2From,HWND os2To,INT fromPosY)
    132 {
    133   POINTL pt;
    134   RECTL rect;
    135 
    136   if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
    137   if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
    138   if (os2From == os2To) return fromPosY;
    139   if (!WinQueryWindowRect(os2From,&rect)) return 0;
    140   pt.y = rect.yTop-1-fromPosY;
    141   pt.x = 0;
    142   if (!WinMapWindowPoints(os2From,os2To,&pt,1)) return 0;
    143   if (!WinQueryWindowRect(os2To,&rect)) return 0;
    144 
    145   return rect.yTop-1-pt.y;
    146 }
    147 //******************************************************************************
    148 //******************************************************************************
    149 INT mapWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY)
    150 {
    151   POINTL pt;
    152 
    153   if (!wndFrom || !wndTo) return 0;
    154   if (wndFrom == wndTo) return fromPosY;
    155   pt.y = wndFrom->getClientHeight()-1-fromPosY;
    156   pt.x = 0;
    157   if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),&pt,1)) return 0;
    158 
    159   return wndTo->getClientHeight()-1-pt.y;
    16070}
    16171//******************************************************************************
     
    18292// To translation between OS/2 <-> Win32
    18393//******************************************************************************
    184 BOOL mapPoint(HWND os2Client,OSLIBPOINT *clientPt)
     94BOOL mapOS2ToWin32Rect(int height, PRECTLOS2 rectOS2, PRECT rectWin32)
    18595{
    186   RECTL rect;
    187 
    188   if (!clientPt) return FALSE;
    189   if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //client shouldn't be desktop
    190   if (!WinQueryWindowRect(os2Client,&rect)) return 0;
    191   clientPt->y = rect.yTop-1-clientPt->y;
    192 
    193   return TRUE;
    194 }
    195 //******************************************************************************
    196 // To translation between OS/2 <-> Win32
    197 //******************************************************************************
    198 BOOL mapPoint(Win32BaseWindow *win32wnd,OSLIBPOINT *clientPt)
    199 {
    200   if (!win32wnd || !clientPt) return FALSE;
    201   clientPt->y = win32wnd->getClientHeight()-1-clientPt->y;
    202 
    203   return TRUE;
    204 }
    205 //******************************************************************************
    206 //******************************************************************************
    207 BOOL mapOS2ToWin32Point(HWND os2From,HWND os2To,OSLIBPOINT *fromPt)
    208 {
    209   RECTL rect;
    210 
    211   if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
    212   if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
    213   if (os2From != os2To)
    214   {
    215     if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)fromPt,1)) return FALSE;
     96  if(!rectOS2 || !rectWin32) {
     97        DebugInt3();
     98        return FALSE;
    21699  }
    217   if (!WinQueryWindowRect(os2To,&rect)) return FALSE;
    218   fromPt->y = rect.yTop-1-fromPt->y;
    219 
    220   return TRUE;
    221 }
    222 //******************************************************************************
    223 //******************************************************************************
    224 BOOL mapOS2ToWin32Point(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,OSLIBPOINT *fromPt)
    225 {
    226   if (!wndFrom || !wndTo) return 0;
    227   if (wndFrom != wndTo)
    228   {
    229     if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)fromPt,1)) return FALSE;
    230   }
    231   fromPt->y = wndTo->getClientHeight()-1-fromPt->y;
    232 
    233   return TRUE;
    234 }
    235 //******************************************************************************
    236 //******************************************************************************
    237 BOOL mapWin32Point(HWND os2From,HWND os2To,OSLIBPOINT *fromPt)
    238 {
    239   RECTL rect;
    240 
    241   if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
    242   if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
    243   if (os2From == os2To) return TRUE;
    244   if (!WinQueryWindowRect(os2From,&rect)) return 0;
    245   fromPt->y = rect.yTop-1-fromPt->y;
    246   if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)fromPt,1)) return 0;
    247   if (!WinQueryWindowRect(os2To,&rect)) return 0;
    248   fromPt->y = rect.yTop-1-fromPt->y;
    249 
    250   return TRUE;
    251 }
    252 //******************************************************************************
    253 //******************************************************************************
    254 BOOL mapWin32Point(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,OSLIBPOINT *fromPt)
    255 {
    256   if (!wndFrom || !wndTo) return FALSE;
    257   if (wndFrom == wndTo) return TRUE;
    258   fromPt->y = wndFrom->getClientHeight()-1-fromPt->y;
    259   if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)fromPt,1)) return 0;
    260   fromPt->y = wndTo->getClientHeight()-1-fromPt->y;
    261 
    262   return TRUE;
    263 }
    264 //******************************************************************************
    265 //******************************************************************************
    266 BOOL mapOS2ToWin32ScreenRect(PRECTLOS2 rectOS2,PRECT rectWin32)
    267 {
    268   if (!rectOS2 || !rectWin32) return FALSE;
    269   rectWin32->bottom = ScreenHeight-rectOS2->yBottom;
    270   rectWin32->top    = ScreenHeight-rectOS2->yTop;
     100  rectWin32->bottom = height-rectOS2->yBottom;
     101  rectWin32->top    = height-rectOS2->yTop;
    271102  rectWin32->left   = rectOS2->xLeft;
    272103  rectWin32->right  = rectOS2->xRight;
     
    276107//******************************************************************************
    277108//******************************************************************************
    278 BOOL mapWin32ToOS2ScreenRect(PRECT rectWin32,PRECTLOS2 rectOS2)
     109BOOL mapWin32ToOS2Rect(int height, PRECT rectWin32, PRECTLOS2 rectOS2)
    279110{
    280   if (!rectOS2 || !rectWin32) return FALSE;
    281   rectOS2->yBottom = ScreenHeight-rectWin32->bottom;
    282   rectOS2->yTop    = ScreenHeight-rectWin32->top;
     111  if(!rectOS2 || !rectWin32) {
     112        DebugInt3();
     113        return FALSE;
     114  }
     115  rectOS2->yBottom = height-rectWin32->bottom;
     116  rectOS2->yTop    = height-rectWin32->top;
    283117  rectOS2->xLeft   = rectWin32->left;
    284118  rectOS2->xRight  = rectWin32->right;
     
    288122//******************************************************************************
    289123//******************************************************************************
    290 BOOL mapOS2ToWin32Rect(HWND os2Client,PRECTLOS2 rectOS2,PRECT rectWin32)
     124BOOL mapWin32ToOS2RectClientToFrame(Win32BaseWindow *window, PRECT rectWin32,PRECTLOS2 rectOS2)
    291125{
    292   RECTL rect;
     126 int height;
     127 int xclientorg;
     128 int yclientorg;
    293129
    294   if (!rectOS2 || !rectWin32) return FALSE;
    295   if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //shouldn't be the case
    296   if (!WinQueryWindowRect(os2Client,&rect)) return FALSE;
    297   rectWin32->bottom = rect.yTop-rectOS2->yBottom;
    298   rectWin32->top    = rect.yTop-rectOS2->yTop;
    299   rectWin32->left   = rectOS2->xLeft;
    300   rectWin32->right  = rectOS2->xRight;
     130  if(!window || !rectOS2 || !rectWin32) {
     131        DebugInt3();
     132        return FALSE;
     133  }
     134  height     = window->getWindowHeight();
     135  xclientorg = window->getClientRectPtr()->left;
     136  yclientorg = window->getClientRectPtr()->top;
    301137
    302   return TRUE;
    303 }
    304 //******************************************************************************
    305 //******************************************************************************
    306 BOOL mapOS2ToWin32Rect(Win32BaseWindow *win32wnd,PRECTLOS2 rectOS2,PRECT rectWin32)
    307 {
    308   INT windowH;
    309 
    310   if (!win32wnd || !rectOS2 || !rectWin32) return FALSE;
    311   windowH = win32wnd->getClientHeight();
    312   rectWin32->bottom = windowH-rectOS2->yBottom;
    313   rectWin32->top    = windowH-rectOS2->yTop;
    314   rectWin32->left   = rectOS2->xLeft;
    315   rectWin32->right  = rectOS2->xRight;
    316 
    317   return TRUE;
    318 }
    319 //******************************************************************************
    320 //******************************************************************************
    321 BOOL mapOS2ToWin32Rect(HWND os2From,HWND os2To,PRECTLOS2 rectOS2,PRECT rectWin32)
    322 {
    323   RECTL rect,temp;
    324 
    325   if (!rectOS2 || !rectWin32) return FALSE;
    326   if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
    327   if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
    328   temp = *((PRECTL)rectOS2);
    329   if (os2From != os2To)
    330   {
    331     if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)&temp,2)) return FALSE;
    332   }
    333   if (!WinQueryWindowRect(os2To,&rect)) return FALSE;
    334   rectWin32->bottom = rect.yTop-temp.yBottom;
    335   rectWin32->top    = rect.yTop-temp.yTop;
    336   rectWin32->left   = temp.xLeft;
    337   rectWin32->right  = temp.xRight;
    338 
    339   return TRUE;
    340 }
    341 //******************************************************************************
    342 //******************************************************************************
    343 BOOL mapOS2ToWin32Rect(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,PRECTLOS2 rectOS2,PRECT rectWin32)
    344 {
    345   RECTL temp;
    346   INT windowH;
    347 
    348   if (!wndFrom || !wndTo || !rectOS2 || !rectWin32) return FALSE;
    349   temp = *((PRECTL)rectOS2);
    350   if (wndFrom != wndTo)
    351   {
    352     if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)&temp,2)) return FALSE;
    353   }
    354   windowH = wndTo->getClientHeight();
    355   rectWin32->bottom = windowH-temp.yBottom;
    356   rectWin32->top    = windowH-temp.yTop;
    357   rectWin32->left   = temp.xLeft;
    358   rectWin32->right  = temp.xRight;
    359 
    360   return TRUE;
    361 }
    362 //******************************************************************************
    363 //******************************************************************************
    364 BOOL mapWin32ToOS2Rect(HWND os2Client,PRECT rectWin32,PRECTLOS2 rectOS2)
    365 {
    366   RECTL rect;
    367 
    368   if (!rectOS2 || !rectWin32) return FALSE;
    369   if (os2Client == OSLIB_HWND_DESKTOP) os2Client = HWND_DESKTOP; //shouldn't be the case
    370   if (!WinQueryWindowRect(os2Client,&rect)) return FALSE;
    371   rectOS2->yBottom = rect.yTop-rectWin32->bottom;
    372   rectOS2->yTop    = rect.yTop-rectWin32->top;
    373   rectOS2->xLeft   = rectWin32->left;
    374   rectOS2->xRight  = rectWin32->right;
    375 
    376   return TRUE;
    377 }
    378 //******************************************************************************
    379 //******************************************************************************
    380 BOOL mapWin32ToOS2Rect(Win32BaseWindow *win32wnd,PRECT rectWin32,PRECTLOS2 rectOS2)
    381 {
    382   INT windowH;
    383 
    384   if (!win32wnd || !rectOS2 || !rectWin32) return FALSE;
    385   windowH = win32wnd->getClientHeight();
    386   rectOS2->yBottom = windowH-rectWin32->bottom;
    387   rectOS2->yTop    = windowH-rectWin32->top;
    388   rectOS2->xLeft   = rectWin32->left;
    389   rectOS2->xRight  = rectWin32->right;
    390 
    391   return TRUE;
    392 }
    393 //******************************************************************************
    394 //******************************************************************************
    395 BOOL mapWin32ToOS2Rect(HWND os2From,HWND os2To,PRECT rectWin32,PRECTLOS2 rectOS2)
    396 {
    397   RECTL rect;
    398 
    399   if (!rectOS2 || !rectWin32) return FALSE;
    400   if (os2From == OSLIB_HWND_DESKTOP) os2From = HWND_DESKTOP;
    401   if (os2To == OSLIB_HWND_DESKTOP) os2To = HWND_DESKTOP;
    402   if (!WinQueryWindowRect(os2From,&rect)) return FALSE;
    403   rectOS2->yBottom = rect.yTop-rectWin32->bottom;
    404   rectOS2->yTop    = rect.yTop-rectWin32->top;
    405   rectOS2->xLeft   = rectWin32->left;
    406   rectOS2->xRight  = rectWin32->right;
    407   if (os2From != os2To)
    408   {
    409     if (!WinMapWindowPoints(os2From,os2To,(PPOINTL)rectOS2,2)) return FALSE;
    410   }
    411 
    412   return TRUE;
    413 }
    414 //******************************************************************************
    415 //******************************************************************************
    416 BOOL mapWin32ToOS2Rect(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,PRECT rectWin32,PRECTLOS2 rectOS2)
    417 {
    418   INT windowH;
    419 
    420   if (!wndFrom || !wndTo || !rectOS2 || !rectWin32) return FALSE;
    421   windowH = wndFrom->getClientHeight();
    422   rectOS2->yBottom = windowH-rectWin32->bottom;
    423   rectOS2->yTop    = windowH-rectWin32->top;
    424   rectOS2->xLeft   = rectWin32->left;
    425   rectOS2->xRight  = rectWin32->right;
    426   if (wndFrom != wndTo)
    427   {
    428     if (!WinMapWindowPoints(wndFrom->getOS2WindowHandle(),wndTo->getOS2WindowHandle(),(PPOINTL)rectOS2,2)) return FALSE;
    429   }
    430 
    431   return TRUE;
    432 }
    433 //******************************************************************************
    434 //******************************************************************************
    435 BOOL mapWin32Rect(HWND os2From,HWND os2To,PRECT rectWin32)
    436 {
    437   RECTL rect;
    438 
    439   mapWin32ToOS2Rect(os2From,rectWin32,(PRECTLOS2)&rect);
    440   WinMapWindowPoints((os2From == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP:os2From,(os2To == OSLIB_HWND_DESKTOP) ? HWND_DESKTOP:os2To,(PPOINTL)&rect,2);
    441   mapOS2ToWin32Rect(os2To,(PRECTLOS2)&rect,rectWin32);
     138  rectOS2->yBottom = height - (rectWin32->bottom + yclientorg);
     139  rectOS2->yTop    = height - (rectWin32->top + yclientorg);
     140  rectOS2->xLeft   = rectWin32->left  - xclientorg;
     141  rectOS2->xRight  = rectWin32->right - xclientorg;
    442142
    443143  return TRUE;
     
    467167//******************************************************************************
    468168//******************************************************************************
    469 INT mapOS2ToWin32ChildOrigin(INT parentH,INT parentPosY,INT childH)
    470 {
    471   return parentH-parentPosY-childH;//Does: parentH-1-parentPosY-(childH-1)
    472 }
    473 //******************************************************************************
    474 //******************************************************************************
    475 HDC OSLibWinBeginPaint(HWND hwnd, RECT *rectWin32)
    476 {
    477  RECTL rectl;
    478 
    479     if(WinQueryUpdateRect(hwnd, &rectl) == FALSE)
    480     {
    481         dprintf(("BeginPaint, NO update rectl"));
    482         return 0;
    483     }
    484     mapOS2ToWin32Rect(hwnd,(RECTLOS2 *)&rectl, rectWin32);
    485     return WinBeginPaint(hwnd, NULLHANDLE, &rectl);
    486 }
    487 //******************************************************************************
    488 //******************************************************************************
    489 BOOL OSLibWinEndPaint(HDC hdc)
    490 {
    491   return WinEndPaint((HPS)hdc);
    492 }
    493 //******************************************************************************
    494 //******************************************************************************
    495 HDC OSLibWinGetPS(HWND hwnd)
    496 {
    497   if(hwnd == OSLIB_HWND_DESKTOP)
    498         hwnd = HWND_DESKTOP;
    499 
    500   return (HDC)WinGetPS(hwnd);
    501 }
    502 //******************************************************************************
    503 //******************************************************************************
    504 BOOL OSLibWinReleasePS(HDC hdc)
    505 {
    506   return WinReleasePS((HPS)hdc);
    507 }
    508 //******************************************************************************
    509 //******************************************************************************
    510 BOOL OSLibWinInvalidateRect(HWND hwnd, PRECT pRect, BOOL fIncludeChildren)
    511 {
    512  RECTLOS2 rectl;
    513 
    514     if(pRect) {
    515         mapWin32ToOS2Rect(hwnd,pRect, &rectl);
    516         return WinInvalidateRect(hwnd, (PRECTL)&rectl, fIncludeChildren);
    517     }
    518     return WinInvalidateRect(hwnd, NULL, fIncludeChildren);
    519 }
    520 //******************************************************************************
    521 //Returns rectangle in Win32 window coordinates
    522 //******************************************************************************
    523 BOOL OSLibWinQueryUpdateRect(HWND hwnd, PRECT pRect)
    524 {
    525  BOOL rc;
    526  RECTLOS2 rectl;
    527 
    528   rc = WinQueryUpdateRect(hwnd, (PRECTL)&rectl);
    529   if(rc) {
    530         mapOS2ToWin32Rect(hwnd,&rectl, pRect);
    531   }
    532   else  memset(pRect, 0, sizeof(RECT));
    533   return rc;
    534 }
    535 //******************************************************************************
    536 //******************************************************************************
    537 
  • trunk/src/user32/oslibgdi.h

    r2469 r3662  
    1 /* $Id: oslibgdi.h,v 1.5 2000-01-18 20:08:10 sandervl Exp $ */
     1/* $Id: oslibgdi.h,v 1.6 2000-06-07 14:51:26 sandervl Exp $ */
    22/*
    33 * Window GDI wrapper functions for OS/2
     
    3232} OSLIBPOINT;
    3333
    34 HDC   OSLibWinBeginPaint(HWND hwnd, RECT *pRectl);
    35 BOOL  OSLibWinEndPaint(HDC hdc);
    36 
    37 HDC   OSLibWinGetPS(HWND hwnd);
    38 BOOL  OSLibWinReleasePS(HDC hdc);
    39 
    40 BOOL  OSLibWinInvalidateRect(HWND hwnd, PRECT pRect, BOOL fIncludeChildren); //must be RECTL pointer!
    41 BOOL  OSLibWinQueryUpdateRect(HWND hwnd, PRECT pRect);
    42 
    4334//Mapping functions
    4435
    4536INT  mapScreenY(INT screenPosY);
    4637INT  mapScreenY(INT screenH,INT screenPosY);
    47 INT  mapY(HWND os2Client,INT clientPosY);
    48 INT  mapY(Win32BaseWindow *win32wnd,INT clientPosY);
    49 INT  mapOS2ToWin32Y(HWND os2From,HWND os2To,INT fromPosY);
     38INT inline mapY(INT height, int y)
     39{
     40   return height - 1 - y;
     41}
     42
     43INT inline mapY(Win32BaseWindow *win32wnd,INT y)
     44{
     45   return win32wnd->getWindowHeight() - 1 - y;
     46}
     47
     48INT inline mapOS2ToWin32Y(Win32BaseWindow *win32wnd,INT y)
     49{
     50   return win32wnd->getWindowHeight() - 1 - (y + win32wnd->getClientRectPtr()->top);
     51}
     52
     53INT inline mapOS2ToWin32X(Win32BaseWindow *win32wnd,INT x)
     54{
     55   return x - win32wnd->getClientRectPtr()->left;
     56}
     57
     58INT inline mapWin32ToOS2Y(Win32BaseWindow *win32wnd,INT y)
     59{
     60   if(win32wnd->getParent()) {
     61        return win32wnd->getWindowHeight() - 1 - (y - win32wnd->getParent()->getClientRectPtr()->top);
     62   }
     63   else return y;
     64}
     65
     66INT inline mapWin32ToOS2X(Win32BaseWindow *win32wnd,INT x)
     67{
     68   if(win32wnd->getParent()) {
     69        return x + win32wnd->getParent()->getClientRectPtr()->left;
     70   }
     71   else return x;
     72}
     73
    5074INT  mapOS2ToWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY);
    51 INT  mapWin32Y(HWND os2From,HWND os2To,INT fromPosY);
    5275INT  mapWin32Y(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,INT fromPosY);
    5376BOOL mapScreenPoint(OSLIBPOINT *screenPt);
    5477BOOL mapScreenPoint(INT screenH,OSLIBPOINT *screenPt);
    55 BOOL mapPoint(HWND os2Client,OSLIBPOINT *clientPt);
    56 BOOL mapPoint(Win32BaseWindow *win32wnd,OSLIBPOINT *clientPt);
    57 BOOL mapOS2ToWin32Point(HWND os2From,HWND os2To,OSLIBPOINT *fromPt);
    58 BOOL mapOS2ToWin32Point(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,OSLIBPOINT *fromPt);
    59 BOOL mapWin32Point(HWND os2From,HWND os2To,OSLIBPOINT *fromPt);
    60 BOOL mapWin32Point(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,OSLIBPOINT *fromPt);
    61 BOOL mapOS2ToWin32ScreenRect(PRECTLOS2 rectOS2,PRECT rectWin32);
    62 BOOL mapWin32ToOS2ScreenRect(PRECT rectWin32,PRECTLOS2 rectOS2);
    63 BOOL mapOS2ToWin32Rect(HWND os2Client,PRECTLOS2 rectOS2,PRECT rectWin32);
    64 BOOL mapOS2ToWin32Rect(Win32BaseWindow *win32wnd,PRECTLOS2 rectOS2,PRECT rectWin32);
    65 BOOL mapOS2ToWin32Rect(HWND os2From,HWND os2To,PRECTLOS2 rectOS2,PRECT rectWin32);
    66 BOOL mapOS2ToWin32Rect(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,PRECTLOS2 rectOS2,PRECT rectWin32);
    67 BOOL mapWin32ToOS2Rect(HWND os2Client,PRECT rectWin32,PRECTLOS2 rectOS2);
    68 BOOL mapWin32ToOS2Rect(Win32BaseWindow *win32wnd,PRECT rectWin32,PRECTLOS2 rectOS2);
    69 BOOL mapWin32ToOS2Rect(HWND os2From,HWND os2To,PRECT rectWin32,PRECTLOS2 rectOS2);
    70 BOOL mapWin32ToOS2Rect(Win32BaseWindow *wndFrom,Win32BaseWindow *wndTo,PRECT rectWin32,PRECTLOS2 rectOS2);
    71 BOOL mapWin32Rect(HWND os2From,HWND os2To,PRECT rectWin32);
     78
     79BOOL mapOS2ToWin32Rect(int height, PRECTLOS2 rectOS2, PRECT rectWin32);
     80BOOL mapWin32ToOS2Rect(int height, PRECT rectWin32,PRECTLOS2 rectOS2);
     81
     82BOOL mapWin32ToOS2RectClientToFrame(Win32BaseWindow *window, PRECT rectWin32,PRECTLOS2 rectOS2);
     83
     84#define mapWin32ToOS2RectFrame(window, rectWin32, rectOS2) \
     85        if(window->getParent()) { \
     86                mapWin32ToOS2Rect(window->getParent()->getWindowHeight(), rectWin32, rectOS2); \
     87        } \
     88        else    mapWin32ToOS2Rect(OSLibQueryScreenHeight(), rectWin32, rectOS2);
     89
     90#define mapWin32ToOS2RectClient(window, rectWin32, rectOS2) \
     91        mapWin32ToOS2Rect(window->getClientHeight(), rectWin32, rectOS2)
     92
     93#define mapWin32ToOS2ScreenRect(rectOS2, rectWin32) \
     94        mapWin32ToOS2Rect(OSLibQueryScreenHeight(), rectOS2, rectWin32)
     95
     96#define mapOS2ToWin32RectFrame(window, rectOS2, rectWin32) \
     97        if(window->getParent()) { \
     98                mapOS2ToWin32Rect(window->getParent()->getWindowHeight(), rectOS2, rectWin32); \
     99        } \
     100        else    mapOS2ToWin32Rect(OSLibQueryScreenHeight(), rectOS2, rectWin32);
     101       
     102
     103#define mapOS2ToWin32RectClient(window, rectOS2, rectWin32) \
     104        mapOS2ToWin32Rect(window->getClientHeight(), rectOS2, rectWin32)
     105
     106#define mapOS2ToWin32ScreenRect(rectOS2, rectWin32) \
     107        mapOS2ToWin32Rect(OSLibQueryScreenHeight(), rectOS2, rectWin32)
     108
    72109BOOL copyOS2ToWin32Rect(PRECTLOS2 rectOS2,PRECT rectWin32);
    73110BOOL copyWin32ToOS2WindowRect(PRECT rectWin32,PRECTLOS2 rectOS2);
  • trunk/src/user32/oslibmsgtranslate.cpp

    r3637 r3662  
    1 /* $Id: oslibmsgtranslate.cpp,v 1.33 2000-05-29 22:43:31 sandervl Exp $ */
     1/* $Id: oslibmsgtranslate.cpp,v 1.34 2000-06-07 14:51:26 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    143143  memset(winMsg, 0, sizeof(MSG));
    144144  win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(os2Msg->hwnd);
    145   if (!win32wnd) win32wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(os2Msg->hwnd);
    146145
    147146  //PostThreadMessage posts WIN32APP_POSTMSG msg without window handle
     
    159158    winMsg->hwnd = win32wnd->getWindowHandle();
    160159
    161   if (win32wnd && (os2Msg->hwnd == win32wnd->getOS2FrameWindowHandle()))
    162   {
    163     //special frame messages
    164 
    165     switch (os2Msg->msg)
    166     {
    167       case WM_HITTEST:
    168         winMsg->message = WINWM_NCHITTEST;
    169         winMsg->wParam  = 0;
    170         winMsg->lParam  = MAKELONG(winMsg->pt.x,winMsg->pt.y);
    171 
    172         if(!win32wnd->IsWindowEnabled()) {
    173                 if(win32wnd->getParent()) {
    174                         winMsg->hwnd = win32wnd->getParent()->getWindowHandle();
    175                 }
    176                 else    goto dummymessage; //don't send mouse messages to disabled windows
    177         }
    178         return TRUE;
    179 
    180       case WM_BUTTON1DOWN:
    181       case WM_BUTTON1UP:
    182       case WM_BUTTON1DBLCLK:
    183       case WM_BUTTON2DOWN:
    184       case WM_BUTTON2UP:
    185       case WM_BUTTON2DBLCLK:
    186       case WM_BUTTON3DOWN:
    187       case WM_BUTTON3UP:
    188       case WM_BUTTON3DBLCLK:
    189         //WM_NC*BUTTON* is posted when the cursor is in a non-client area of the window
    190 
    191 #ifdef ODIN_HITTEST
    192         //Send WM_HITTEST message
    193         win32wnd->sendHitTest(MAKELONG(winMsg->pt.x,winMsg->pt.y));
    194 #endif
    195 
    196         //if a window is disabled, it's parent receives the mouse messages
    197         if(!win32wnd->IsWindowEnabled()) {
    198                 if(win32wnd->getParent()) {
    199                         win32wnd = win32wnd->getParent();
    200                 }
    201                 dprintf(("Rerouting mouse messages to parent %x of disabled window %x", win32wnd->getWindowHandle(), winMsg->hwnd));
    202                 fWasDisabled = TRUE;
    203         }
    204 
    205         if (IsNCMouseMsg(win32wnd)) {
    206             winMsg->message = WINWM_NCLBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
    207             winMsg->wParam  = win32wnd->getLastHitTestVal();
    208             winMsg->lParam  = MAKELONG(winMsg->pt.x, winMsg->pt.y); //screen coordinates
    209         }
    210         else {
    211             point.x         = (*(POINTS *)&os2Msg->mp1).x;
    212             point.y         = (*(POINTS *)&os2Msg->mp1).y;
    213             ClientPoint.x   = point.x;
    214             ClientPoint.y   = mapOS2ToWin32Y(os2Msg->hwnd,win32wnd->getOS2WindowHandle(),point.y);
    215 
    216             winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
    217             winMsg->wParam  = GetMouseKeyState();
    218             winMsg->lParam  = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
    219         }
    220         if(ISMOUSE_CAPTURED())
    221         {
    222             if(DInputMouseHandler(win32wnd->getWindowHandle(), winMsg->message, winMsg->pt.x, winMsg->pt.y)) {
    223                 goto dummymessage; //dinput swallowed message
    224             }
    225         }
    226         if(fWasDisabled) {
    227                 if(win32wnd) {
    228                         winMsg->hwnd = win32wnd->getWindowHandle();
    229                 }
    230                 else    goto dummymessage; //don't send mouse messages to disabled windows
    231         }
    232         return TRUE;
    233 
    234       case WM_BUTTON2MOTIONSTART:
    235       case WM_BUTTON2MOTIONEND:
    236       case WM_BUTTON2CLICK:
    237       case WM_BUTTON1MOTIONSTART:
    238       case WM_BUTTON1MOTIONEND:
    239       case WM_BUTTON1CLICK:
    240       case WM_BUTTON3MOTIONSTART:
    241       case WM_BUTTON3MOTIONEND:
    242       case WM_BUTTON3CLICK:
    243         goto dummymessage;
    244 
    245       case WM_MOUSEMOVE:
    246       {
    247         //WM_NCMOUSEMOVE is posted when the cursor moves into a non-client area of the window
    248 
    249 #ifdef ODIN_HITTEST
    250         //Send WM_HITTEST message
    251         win32wnd->sendHitTest(MAKELONG(winMsg->pt.x,winMsg->pt.y));
    252 #endif
    253         //if a window is disabled, it's parent receives the mouse messages
    254         if(!win32wnd->IsWindowEnabled()) {
    255                 if(win32wnd->getParent()) {
    256                         win32wnd = win32wnd->getParent();
    257                 }
    258                 dprintf(("Rerouting mouse messages to parent %x of disabled window %x", win32wnd->getWindowHandle(), winMsg->hwnd));
    259                 fWasDisabled = TRUE;
    260         }
    261         if (IsNCMouseMsg(win32wnd))
    262         {
    263           winMsg->message = WINWM_NCMOUSEMOVE;
    264           winMsg->wParam  = (WPARAM)win32wnd->getLastHitTestVal();
    265           winMsg->lParam  = MAKELONG(winMsg->pt.x,winMsg->pt.y);
    266         }
    267         else
    268         {
    269           winMsg->message = WINWM_MOUSEMOVE;
    270           winMsg->wParam  = GetMouseKeyState();
    271           winMsg->lParam  = MAKELONG(SHORT1FROMMP(os2Msg->mp1),mapOS2ToWin32Y(win32wnd->getOS2FrameWindowHandle(),win32wnd->getOS2WindowHandle(),SHORT2FROMMP(os2Msg->mp1)));
    272         }
    273         if(ISMOUSE_CAPTURED())
    274         {
    275             if(DInputMouseHandler(win32wnd->getWindowHandle(), winMsg->message, winMsg->pt.x, winMsg->pt.y)) {
    276                 goto dummymessage; //dinput swallowed message
    277             }
    278         }
    279         if(fWasDisabled) {
    280                 if(win32wnd) {
    281                         winMsg->hwnd = win32wnd->getWindowHandle();
    282                 }
    283                 else    goto dummymessage; //don't send mouse messages to disabled windows
    284         }
    285         //OS/2 Window coordinates -> Win32 Window coordinates
    286         return TRUE;
    287       }
    288 
    289       case WM_PAINT:
    290       {
    291         winMsg->message = WINWM_NCPAINT;
    292         return TRUE;
    293       }
    294 
    295       case WM_ACTIVATE:
    296       {
    297         winMsg->message = WINWM_NCACTIVATE;
    298         winMsg->wParam  = SHORT1FROMMP(os2Msg->mp1);
    299 
    300         return TRUE;
    301       }
    302       case WM_WINDOWPOSCHANGED:
    303       {
    304         //todo: proper translation
    305         return FALSE;
    306       }
    307     }
    308     //do normal translation for all other messages
    309   }
    310 
    311160  switch(os2Msg->msg)
    312161  {
     
    383232            }
    384233        }
    385         OSLibMapSWPtoWINDOWPOS(pswp, &thdb->wp, &swpOld, hParent, win32wnd->getOS2FrameWindowHandle());
     234        if(win32wnd->getParent()) {
     235              OSLibMapSWPtoWINDOWPOS(pswp, &thdb->wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
     236                                     win32wnd->getParent()->getClientRectPtr()->left,
     237                                     win32wnd->getParent()->getClientRectPtr()->top,
     238                                     win32wnd->getOS2WindowHandle());
     239        }
     240        else  OSLibMapSWPtoWINDOWPOS(pswp, &thdb->wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, win32wnd->getOS2WindowHandle());
    386241
    387242        if (!win32wnd->CanReceiveSizeMsgs())    goto dummymessage;
    388 
    389         ULONG windowStyle = WinQueryWindowULong(os2Msg->hwnd, QWL_STYLE);
    390         win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MAXIMIZE_W|WS_MINIMIZE_W));
    391         if (windowStyle & WS_MINIMIZED) {
    392             win32wnd->setStyle(win32wnd->getStyle() | WS_MINIMIZE_W);
    393         }
    394         else
    395         if (windowStyle & WS_MAXIMIZED) {
    396             win32wnd->setStyle(win32wnd->getStyle() | WS_MAXIMIZE_W);
    397         }
    398243
    399244        if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
    400245                dprintf(("Set client rectangle to (%d,%d)(%d,%d)", swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy));
    401                 win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
     246/////                win32wnd->setClientRect(swpOld.x, swpOld.y, swpOld.x + swpOld.cx, swpOld.y + swpOld.cy);
    402247
    403248                thdb->wp.hwnd = win32wnd->getWindowHandle();
     
    408253                        thdb->wp.hwndInsertAfter = wndAfter->getWindowHandle();
    409254                }
    410 
    411                 PRECT lpRect = win32wnd->getWindowRect();
    412                 //SvL: Only send it when the client has changed & the frame hasn't
    413                 //     If the frame size/position has changed, pmframe.cpp will send
    414                 //     this message
    415                 if(lpRect->right == thdb->wp.x+thdb->wp.cx && lpRect->bottom == thdb->wp.y+thdb->wp.cy) {
    416                         winMsg->message = WINWM_WINDOWPOSCHANGED;
    417                         winMsg->lParam  = (LPARAM)&thdb->wp;
    418                         break;
    419                 }
    420         }
    421         goto dummymessage;
     255        }
     256        winMsg->message = WINWM_WINDOWPOSCHANGED;
     257        winMsg->lParam  = (LPARAM)&thdb->wp;
     258        break;
    422259    }
    423260
     
    434271        }
    435272
    436         if(WinQueryWindowULong(os2Msg->hwnd, QWL_STYLE) & WS_MINIMIZED)
     273        if(win32wnd->getStyle() & WS_MINIMIZE_W)
    437274        {
    438275           fMinimized = TRUE;
     
    497334        win32wnd->sendHitTest(MAKELONG(winMsg->pt.x,winMsg->pt.y));
    498335#endif
     336        win32wnd->sendHitTest(MAKELONG(winMsg->pt.x,winMsg->pt.y));
    499337
    500338        //if a window is disabled, it's parent receives the mouse messages
     
    514352            point.x         = (*(POINTS *)&os2Msg->mp1).x;
    515353            point.y         = (*(POINTS *)&os2Msg->mp1).y;
    516             ClientPoint.x   = point.x;
    517             ClientPoint.y   = mapY(os2Msg->hwnd,point.y);
     354            ClientPoint.x   = mapOS2ToWin32X(win32wnd, point.x);
     355            ClientPoint.y   = mapOS2ToWin32Y(win32wnd, point.y);
    518356
    519357            winMsg->message = WINWM_LBUTTONDOWN + (os2Msg->msg - WM_BUTTON1DOWN);
     
    571409        else
    572410        {
     411          point.x         = (*(POINTS *)&os2Msg->mp1).x;
     412          point.y         = (*(POINTS *)&os2Msg->mp1).y;
     413          ClientPoint.x   = mapOS2ToWin32X(win32wnd, point.x);
     414          ClientPoint.y   = mapOS2ToWin32Y(win32wnd, point.y);
     415
    573416          winMsg->message = WINWM_MOUSEMOVE;
    574417          winMsg->wParam  = GetMouseKeyState();
    575           winMsg->lParam  = MAKELONG(SHORT1FROMMP(os2Msg->mp1),mapY(win32wnd,SHORT2FROMMP(os2Msg->mp1)));
     418          winMsg->lParam  = MAKELONG(ClientPoint.x, ClientPoint.y); //client coordinates
    576419        }
    577420        if((fMsgRemoved == MSG_REMOVE) && ISMOUSE_CAPTURED())
  • trunk/src/user32/oslibwin.cpp

    r3610 r3662  
    1 /* $Id: oslibwin.cpp,v 1.78 2000-05-26 18:43:34 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.79 2000-06-07 14:51:26 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, HWND *hwndFrame,
     55                          char *pszName, HWND Owner, ULONG fHWND_BOTTOM,
    5656                          ULONG id, BOOL fTaskList,BOOL fShellPosition,
    5757                          int classStyle)
    5858{
    5959 HWND  hwndClient;
    60 
    61   dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle));
     60 ULONG dwFrameStyle = 0;
    6261
    6362  if(pszName && *pszName == 0) {
     
    7069        Owner = HWND_DESKTOP;
    7170  }
    72   ULONG dwClientStyle = 0;
    73   ULONG dwFrameStyle = 0;
    74 
    7571  BOOL TopLevel = hwndParent == HWND_DESKTOP;
    76 
    77   FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
    7872
    7973  if(classStyle & CS_SAVEBITS_W) dwWinStyle |= WS_SAVEBITS;
    8074  if(classStyle & CS_PARENTDC_W) dwWinStyle |= WS_PARENTCLIP;
    8175
    82   dwClientStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP | WS_CLIPSIBLINGS);
    83 
    84   dwFrameStyle |= FCF_NOBYTEALIGN;
     76  dwWinStyle = dwWinStyle & ~(WS_TABSTOP | WS_GROUP);
     77
    8578  if(fTaskList)
    8679  {
     
    8982  if (fShellPosition) dwFrameStyle |= FCF_SHELLPOSITION;
    9083
    91   dwWinStyle &= ~WS_CLIPCHILDREN;
     84  FRAMECDATA FCData = {sizeof (FRAMECDATA), 0, 0, 0};
    9285  FCData.flCreateFlags = dwFrameStyle;
    9386
    94   *hwndFrame = WinCreateWindow (hwndParent,
    95                                 TopLevel ? WC_FRAME : WIN32_INNERFRAME,
    96                                 pszName, dwWinStyle, 0, 0, 0, 0,
    97                                 Owner, HWND_TOP,
    98                                 id, &FCData, NULL);
    99 
    100   if (*hwndFrame) {
    101     hwndClient = WinCreateWindow (*hwndFrame, (classStyle & CS_SAVEBITS_W) ? WIN32_STDCLASS2:WIN32_STDCLASS,
    102                                   NULL, dwClientStyle, 0, 0, 0, 0,
    103                                   *hwndFrame, HWND_TOP, FID_CLIENT, NULL, NULL);
    104     return hwndClient;
    105   }
    106   dprintf(("OSLibWinCreateWindow: (FRAME) WinCreateStdWindow failed (%x)", WinGetLastError(GetThreadHAB())));
    107   return 0;
     87  dprintf(("WinCreateWindow %x %s %x task %d shell %d classstyle %x winstyle %x", hwndParent, pszName, id, fTaskList, fShellPosition, classStyle, dwWinStyle));
     88
     89#if 1
     90  return WinCreateWindow (hwndParent,
     91//                          TopLevel ? WIN32_STDFRAMECLASS : WIN32_STDCLASS,
     92                          WIN32_STDFRAMECLASS,
     93                          pszName, dwWinStyle, 0, 0, 0, 0,
     94                          Owner, HWND_TOP,
     95                          id, &FCData, NULL);
     96#else
     97  return WinCreateWindow (hwndParent,
     98                          WIN32_STDCLASS,
     99                          pszName, dwWinStyle, 0, 0, 0, 0,
     100                          Owner, HWND_TOP,
     101                          id, NULL, NULL);
     102#endif
    108103}
    109104//******************************************************************************
     
    258253//******************************************************************************
    259254//******************************************************************************
    260 BOOL OSLibWinQueryWindowRect(HWND hwnd, PRECT pRect, int RelativeTo)
     255#if 0
     256BOOL OSLibWinQueryWindowRect(Win32BaseWindow *window, PRECT pRect, int RelativeTo)
    261257{
    262258 BOOL     rc;
    263259 RECTLOS2 rectl;
    264260
    265   rc = WinQueryWindowRect(hwnd, (PRECTL)&rectl);
     261  rc = WinQueryWindowRect(window->getOS2WindowHandle(), (PRECTL)&rectl);
    266262  if(rc) {
    267263        if(RelativeTo == RELATIVE_TO_SCREEN) {
    268                 mapOS2ToWin32Rect(hwnd,OSLIB_HWND_DESKTOP,&rectl,pRect);
     264                mapOS2ToWin32RectFrame(window,windowDesktop,&rectl,pRect);
    269265        }
    270         else    mapOS2ToWin32Rect(hwnd,&rectl,pRect);
     266        else    mapOS2ToWin32RectFrame(window,&rectl,pRect);
    271267  }
    272268  else  memset(pRect, 0, sizeof(RECT));
    273269  return rc;
    274270}
     271#endif
    275272//******************************************************************************
    276273//******************************************************************************
     
    294291BOOL OSLibWinSetActiveWindow(HWND hwnd)
    295292{
    296   return WinSetActiveWindow(HWND_DESKTOP, hwnd);
     293 BOOL rc;
     294
     295  rc = WinSetActiveWindow(HWND_DESKTOP, hwnd);
     296  if(rc == FALSE) {
     297        dprintf(("WinSetActiveWindow %x failure: %x", hwnd, OSLibWinGetLastError()));
     298  }
     299  return rc;
    297300}
    298301//******************************************************************************
     
    392395//******************************************************************************
    393396//******************************************************************************
    394 void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
     397void OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld,
     398                            int parentHeight, int clientOrgX, int clientOrgY,
     399                            HWND hwnd)
    395400{
    396401   HWND hWindow            = pswp->hwnd;
    397402   HWND hWndInsertAfter    = pswp->hwndInsertBehind;
    398    long x                  = pswp->x;
    399    long y                  = pswp->y;
     403   long x                  = pswp->x - clientOrgX;
     404   long y                  = pswp->y + clientOrgY;
    400405   long cx                 = pswp->cx;
    401406   long cy                 = pswp->cy;
    402407   UINT fuFlags            = (UINT)pswp->fl;
    403    ULONG parentHeight;
    404408
    405409   HWND   hWinAfter;
    406410   ULONG  flags = 0;
    407    SWP    swpFrame, swpClient;
    408    POINTL point;
    409411
    410412   HWND  hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
     
    429431    if (  fuFlags & SWP_NOADJUST)    flags |= SWP_NOSENDCHANGING_W;
    430432
    431     WinQueryWindowPos(hFrame, &swpFrame);
    432 
    433433    if(fuFlags & (SWP_MOVE | SWP_SIZE))
    434434    {
    435         point.x = swpFrame.x;
    436         point.y = swpFrame.y;
    437 
    438         if (hParent)
    439         {
    440           RECTL parentRect;
    441 
    442           WinQueryWindowRect(hParent,&parentRect);
    443           parentHeight = parentRect.yTop;
    444         } else
    445         {
    446           parentHeight = ScreenHeight;
    447         }
    448 
    449         point.y = parentHeight-point.y-swpFrame.cy;
    450 
    451         cy = swpFrame.cy;
    452         cx = swpFrame.cx;
    453         x  = point.x;
    454         y  = point.y;
     435        y  = parentHeight - y - pswp->cy;
    455436
    456437        if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
     
    470451
    471452    pswpOld->x  = pswp->x;
    472     pswpOld->y  = swpFrame.cy-pswp->y-pswp->cy;
     453    pswpOld->y  = parentHeight-pswp->y-pswp->cy;
    473454    pswpOld->cx = pswp->cx;
    474455    pswpOld->cy = pswp->cy;
     
    487468//******************************************************************************
    488469//******************************************************************************
    489 void OSLibMapSWPtoWINDOWPOSFrame(PSWP pswp, struct tagWINDOWPOS *pwpos, PSWP pswpOld, HWND hParent, HWND hFrame)
    490 {
    491    HWND hWindow            = pswp->hwnd;
    492    HWND hWndInsertAfter    = pswp->hwndInsertBehind;
    493    long x                  = pswp->x;
    494    long y                  = pswp->y;
    495    long cx                 = pswp->cx;
    496    long cy                 = pswp->cy;
    497    UINT fuFlags            = (UINT)pswp->fl;
    498    ULONG parentHeight;
    499 
    500    HWND   hWinAfter;
    501    ULONG  flags = 0;
    502    SWP    swpClient;
    503    POINTL point;
    504 
    505    HWND  hWnd = (hWindow == HWND_DESKTOP) ? HWND_DESKTOP_W: hWindow;
    506 
    507     if (hWndInsertAfter == HWND_TOP)
    508         hWinAfter = HWND_TOP_W;
    509     else if (hWndInsertAfter == HWND_BOTTOM)
    510         hWinAfter = HWND_BOTTOM_W;
    511     else
    512         hWinAfter = (HWND) hWndInsertAfter;
    513 
    514     //***********************************
    515     // convert PM flags to Windows flags
    516     //***********************************
    517     if (!(fuFlags & SWP_SIZE))       flags |= SWP_NOSIZE_W;
    518     if (!(fuFlags & SWP_MOVE))       flags |= SWP_NOMOVE_W;
    519     if (!(fuFlags & SWP_ZORDER))     flags |= SWP_NOZORDER_W;
    520     if (  fuFlags & SWP_NOREDRAW)    flags |= SWP_NOREDRAW_W;
    521     if (!(fuFlags & SWP_ACTIVATE))   flags |= SWP_NOACTIVATE_W;
    522     if (  fuFlags & SWP_SHOW)        flags |= SWP_SHOWWINDOW_W;
    523     if (  fuFlags & SWP_HIDE)        flags |= SWP_HIDEWINDOW_W;
    524     if (  fuFlags & SWP_NOADJUST)    flags |= SWP_NOSENDCHANGING_W;
    525 
    526     WinQueryWindowPos(WinWindowFromID(hFrame, FID_CLIENT), &swpClient);
    527 
    528     if(fuFlags & (SWP_MOVE | SWP_SIZE))
    529     {
    530         if (hParent)
    531         {
    532           RECTL parentRect;
    533 
    534           WinQueryWindowRect(hParent,&parentRect);
    535           parentHeight = parentRect.yTop;
    536         } else
    537         {
    538           parentHeight = ScreenHeight;
    539         }
    540 
    541         point.x = x;
    542         point.y = parentHeight-y-cy;
    543 
    544         x  = point.x;
    545         y  = point.y;
    546 
    547         if ((pswp->x == pswpOld->x) && (pswp->y == pswpOld->y))
    548             flags |= SWP_NOMOVE_W;
    549 
    550         if ((pswp->cx == pswpOld->cx) && (pswp->cy == pswpOld->cy))
    551             flags |= SWP_NOSIZE_W;
    552 
    553         if (fuFlags & SWP_SIZE)
    554         {
    555             if (pswp->cy != pswpOld->cy)
    556             {
    557                 flags &= ~SWP_NOMOVE_W;
    558             }
    559         }
    560     }
    561 
    562     pswpOld->x  = swpClient.x;
    563     pswpOld->y  = pswp->cy-swpClient.y-swpClient.cy;
    564     pswpOld->cx = swpClient.cx;
    565     pswpOld->cy = swpClient.cy;
    566 
    567     dprintf(("window (%d,%d)(%d,%d)  client (%d,%d)(%d,%d)",
    568              x,y,cx,cy, pswpOld->x,pswpOld->y,pswpOld->cx,pswpOld->cy));
    569 
    570     pwpos->flags            = (UINT)flags;
    571     pwpos->cy               = cy;
    572     pwpos->cx               = cx;
    573     pwpos->x                = x;
    574     pwpos->y                = y;
    575     pwpos->hwndInsertAfter  = hWinAfter;
    576     pwpos->hwnd             = hWindow;
    577 }
    578 //******************************************************************************
    579 //******************************************************************************
    580 void OSLibMapWINDOWPOStoSWP(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
     470void OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld,
     471                            int parentHeight, int clientOrgX, int clientOrgY, HWND hFrame)
    581472{
    582473 BOOL fCvt = FALSE;
     
    584475   HWND hWnd            = pwpos->hwnd;
    585476   HWND hWndInsertAfter = pwpos->hwndInsertAfter;
    586    long x               = pwpos->x;
    587    long y               = pwpos->y;
     477   long x               = pwpos->x + clientOrgX;
     478   long y               = pwpos->y + clientOrgY;
    588479   long cx              = pwpos->cx;
    589480   long cy              = pwpos->cy;
    590481   UINT fuFlags         = pwpos->flags;
    591    ULONG parentHeight;
    592482
    593483   HWND  hWinAfter;
     
    617507   if (  fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
    618508
    619    if (flags & (SWP_MOVE | SWP_SIZE))
     509   if(flags & (SWP_MOVE | SWP_SIZE))
    620510   {
    621       if (hParent == NULLHANDLE)
    622         parentHeight = ScreenHeight;
    623       else
    624         parentHeight = OSLibGetWindowHeight(hParent);
    625 
    626       if ((flags & SWP_MOVE) == 0)
     511      if((flags & SWP_MOVE) == 0)
    627512      {
    628513         x = pswpOld->x;
    629514         y = pswpOld->y;
    630515
    631          y = parentHeight-y-pswpOld->cy;
    632       }
    633 
    634       if (flags & SWP_SIZE)
     516         y = parentHeight - y - pswpOld->cy;
     517     }
     518
     519      if(flags & SWP_SIZE)
    635520      {
    636521         if (cy != pswpOld->cy)
     
    642527         cy = pswpOld->cy;
    643528      }
    644       y  = parentHeight-y-cy;
     529      y = parentHeight - y - cy;
    645530
    646531      if ((pswpOld->x == x) && (pswpOld->y == y))
     
    664549//Position in screen coordinates
    665550//******************************************************************************
    666 void OSLibMapWINDOWPOStoSWPFrame(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame)
    667 {
    668  BOOL fCvt = FALSE;
    669 
    670    HWND hWnd            = pwpos->hwnd;
    671    HWND hWndInsertAfter = pwpos->hwndInsertAfter;
    672    long x               = pwpos->x;
    673    long y               = pwpos->y;
    674    long cx              = pwpos->cx;
    675    long cy              = pwpos->cy;
    676    UINT fuFlags         = pwpos->flags;
    677    ULONG parentHeight;
    678 
    679    HWND  hWinAfter;
    680    ULONG flags = 0;
    681    HWND  hWindow = hWnd ? (HWND)hWnd : HWND_DESKTOP;
    682 
    683    if (hWndInsertAfter == HWND_TOPMOST_W)
    684 //      hWinAfter = HWND_TOPMOST;
    685       hWinAfter = HWND_TOP;
    686    else if (hWndInsertAfter == HWND_NOTOPMOST_W)
    687 //      hWinAfter = HWND_NOTOPMOST;
    688       hWinAfter = HWND_TOP;
    689    else if (hWndInsertAfter == HWND_TOP_W)
    690       hWinAfter = HWND_TOP;
    691    else if (hWndInsertAfter == HWND_BOTTOM_W)
    692       hWinAfter = HWND_BOTTOM;
    693    else
    694       hWinAfter = (HWND) hWndInsertAfter;
    695 
    696    if (!(fuFlags & SWP_NOSIZE_W    )) flags |= SWP_SIZE;
    697    if (!(fuFlags & SWP_NOMOVE_W    )) flags |= SWP_MOVE;
    698    if (!(fuFlags & SWP_NOZORDER_W  )) flags |= SWP_ZORDER;
    699    if (  fuFlags & SWP_NOREDRAW_W  )  flags |= SWP_NOREDRAW;
    700    if (!(fuFlags & SWP_NOACTIVATE_W)) flags |= SWP_ACTIVATE;
    701    if (  fuFlags & SWP_SHOWWINDOW_W)  flags |= SWP_SHOW;
    702    if (  fuFlags & SWP_HIDEWINDOW_W)  flags |= SWP_HIDE;
    703    if (  fuFlags & SWP_NOSENDCHANGING_W) flags |= SWP_NOADJUST;
    704 
    705    if (flags & (SWP_MOVE | SWP_SIZE))
    706    {
    707       if (hParent)
    708       {
    709         RECTL parentRect;
    710 
    711         WinQueryWindowRect(hParent,&parentRect);
    712         parentHeight = parentRect.yTop;
    713       } else
    714       {
    715         parentHeight = ScreenHeight;
    716       }
    717 
    718       if (flags & SWP_SIZE)
    719       {
    720          if (cy != pswpOld->cy)
    721             flags |= SWP_MOVE;
    722       }
    723       else
    724       {
    725          cx = pswpOld->cx;
    726          cy = pswpOld->cy;
    727       }
    728       y  = parentHeight-y-cy;
    729 
    730       if ((pswpOld->x == x) && (pswpOld->y == y))
    731          flags &= ~SWP_MOVE;
    732 
    733       if ((pswpOld->cx == cx) && (pswpOld->cy == cy))
    734          flags &= ~SWP_SIZE;
    735    }
    736 
    737    pswp->fl               = flags;
    738    pswp->cy               = cy;
    739    pswp->cx               = cx;
    740    pswp->x                = x;
    741    pswp->y                = y;
    742    pswp->hwndInsertBehind = hWinAfter;
    743    pswp->hwnd             = hWindow;
    744    pswp->ulReserved1      = 0;
    745    pswp->ulReserved2      = 0;
    746 }
    747 //******************************************************************************
    748 //******************************************************************************
    749 BOOL  OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
     551BOOL OSLibWinCalcFrameRect(HWND hwndFrame, RECT *pRect, BOOL fClient)
    750552{
    751553 BOOL rc;
  • trunk/src/user32/oslibwin.h

    r3610 r3662  
    1 /* $Id: oslibwin.h,v 1.45 2000-05-26 18:43:34 sandervl Exp $ */
     1/* $Id: oslibwin.h,v 1.46 2000-06-07 14:51:27 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    4040HWND  OSLibWinCreateWindow(HWND hwndParent,ULONG dwWinStyle,
    4141                           char *pszName, HWND Owner, ULONG fBottom,
    42                            HWND *hwndFrame, ULONG id, BOOL fTaskList,BOOL fShellPosition, int classStyle);
     42                           ULONG id, BOOL fTaskList,BOOL fShellPosition, int classStyle);
    4343
    4444BOOL  OSLibWinConvertStyle(ULONG dwStyle, ULONG dwExStyle, ULONG *OSWinStyle);
     
    7373ULONG OSLibGetWindowHeight(HWND hwnd); //for point transformation
    7474
    75 extern ULONG ScreenHeight;
     75extern ULONG ScreenHeight, ScreenWidth;
    7676inline ULONG OSLibQueryScreenHeight(void) { return (ScreenHeight); }
     77inline ULONG OSLibQueryScreenWidth(void)  { return (ScreenWidth); }
    7778
    7879//reserved deleted
     
    220221#define RELATIVE_TO_WINDOW 0
    221222#define RELATIVE_TO_SCREEN 1
    222 BOOL  OSLibWinQueryWindowRect(HWND hwnd, PRECT pRect, int RelativeTo = RELATIVE_TO_WINDOW);
     223BOOL  OSLibWinQueryWindowRect(Win32BaseWindow *window, PRECT pRect, int RelativeTo = RELATIVE_TO_WINDOW);
    223224BOOL  OSLibWinCalcFrameRect(HWND hwnd, RECT *pRect, BOOL fClient);
    224225BOOL  OSLibGetMinMaxInfo(HWND hwndFrame, MINMAXINFO *pMinMax);
     
    247248
    248249BOOL  OSLibWinQueryWindowPos (HWND hwnd, PSWP pswp);
    249 void  OSLibMapSWPtoWINDOWPOS(PSWP pswp, struct tagWINDOWPOS *pwpos, PSWP pswpOld, HWND hParent, HWND hFrame);
    250 void  OSLibMapSWPtoWINDOWPOSFrame(PSWP pswp, struct tagWINDOWPOS *pwpos, PSWP pswpOld, HWND hParent, HWND hFrame);
    251 void  OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame);
    252 void  OSLibMapWINDOWPOStoSWPFrame(PWINDOWPOS pwpos, PSWP pswp, PSWP pswpOld, HWND hParent, HWND hFrame);
     250void  OSLibMapSWPtoWINDOWPOS(PSWP pswp, PWINDOWPOS pwpos, PSWP pswpOld,
     251                            int parentHeight, int clientOrgX, int clientOrgY,
     252                            HWND hwnd);
     253void  OSLibMapWINDOWPOStoSWP(struct tagWINDOWPOS *pwpos, PSWP pswp, PSWP pswpOld,
     254                             int parentHeight, int clientOrgX, int clientOrgY, HWND hFrame);
    253255
    254256HWND  OSLibWinBeginEnumWindows(HWND hwnd);
  • trunk/src/user32/pmwindow.cpp

    r3603 r3662  
    1 /* $Id: pmwindow.cpp,v 1.91 2000-05-24 19:30:06 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.92 2000-06-07 14:51:27 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    1515#define INCL_GPICONTROL         /* GPI control Functions        */
    1616#define INCL_DOSPROCESS
     17#define INCL_WINTRACKRECT
    1718
    1819#include <os2wrap.h>
     
    5253MRESULT EXPENTRY Win32WindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2);
    5354
     55PFNWP PMFrameWindowProc = 0;
     56
    5457//******************************************************************************
    5558//Initialize PM; create hab, message queue and register special Win32 window classes
     
    5760BOOL InitPM()
    5861{
    59   CLASSINFO FrameClassInfo;
    60 
     62 
    6163  hab = WinInitialize(0);
    6264  dprintf(("Winitialize returned %x", hab));
     
    9698     (PSZ)WIN32_STDCLASS,               /* Window class name            */
    9799     (PFNWP)Win32WindowProc,            /* Address of window procedure  */
    98 #ifdef ODIN_HITTEST
    99      0,
    100 #else
    101100     CS_HITTEST,
    102 #endif
    103101     NROF_WIN32WNDBYTES)) {
    104102        dprintf(("WinRegisterClass Win32BaseWindow failed"));
    105103        return(FALSE);
    106    }
     104  }
     105
     106  CLASSINFO FrameClassInfo;
     107  if(!WinQueryClassInfo (hab, WC_FRAME, &FrameClassInfo)) {
     108     dprintf (("WinQueryClassInfo WC_FRAME failed"));
     109     return (FALSE);
     110  }
     111  dprintf(("WC_FRAME style %x", FrameClassInfo.flClassStyle));
     112
     113  PMFrameWindowProc = FrameClassInfo.pfnWindowProc;
    107114  if(!WinRegisterClass(                 /* Register window class        */
    108115     hab,                               /* Anchor block handle          */
    109      (PSZ)WIN32_STDCLASS2,              /* Window class name            */
     116     (PSZ)WIN32_STDFRAMECLASS,          /* Window class name            */
    110117     (PFNWP)Win32WindowProc,            /* Address of window procedure  */
    111 #ifdef ODIN_HITTEST
    112      CS_SAVEBITS,
    113 #else
    114      CS_SAVEBITS | CS_HITTEST,
    115 #endif
    116      NROF_WIN32WNDBYTES)) {
    117         dprintf(("WinRegisterClass Win32BaseWindow failed"));
     118     CS_HITTEST | CS_FRAME,
     119     FrameClassInfo.cbWindowData+NROF_WIN32WNDBYTES)) {
     120        dprintf(("WinRegisterClass Win32BaseWindow failed %x", WinGetLastError(hab)));
    118121        return(FALSE);
    119    }
    120    if (!WinQueryClassInfo (hab, WC_FRAME, &FrameClassInfo)) {
    121      dprintf (("WinQueryClassInfo WC_FRAME failed"));
    122      return (FALSE);
    123    }
    124    FrameClassInfo.flClassStyle &= ~(CS_PUBLIC | CS_CLIPSIBLINGS);
    125    if (!WinRegisterClass (hab,
    126                           WIN32_INNERFRAME,
    127                           FrameClassInfo.pfnWindowProc,
    128 #ifdef ODIN_HITTEST
    129                           FrameClassInfo.flClassStyle,
    130 #else
    131                           FrameClassInfo.flClassStyle | CS_HITTEST,
    132 #endif
    133                           FrameClassInfo.cbWindowData)) {
    134      dprintf (("WinRegisterClass Win32InnerFrame failed"));
    135      return (FALSE);
    136    }
    137 
    138    WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
    139    ScreenWidth  = desktopRectl.xRight;
    140    ScreenHeight = desktopRectl.yTop;
    141 
    142 
    143    HDC   hdc;              /* Device-context handle                */
    144    /* context data structure */
    145    DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
    146                        NULL, NULL, NULL};
    147 
    148    /* create memory device context */
    149    hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
    150    DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, (PLONG)&ScreenBitsPerPel);
    151    DevCloseDC(hdc);
    152 
    153    dprintf(("InitPM: Desktop (%d,%d)", ScreenWidth, ScreenHeight));
    154    return TRUE;
     122  }
     123
     124  WinQueryWindowRect(HWND_DESKTOP, &desktopRectl);
     125  ScreenWidth  = desktopRectl.xRight;
     126  ScreenHeight = desktopRectl.yTop;
     127
     128  HDC   hdc;              /* Device-context handle                */
     129  /* context data structure */
     130  DEVOPENSTRUC dop = {NULL, "DISPLAY", NULL, NULL, NULL, NULL,
     131                     NULL, NULL, NULL};
     132
     133  /* create memory device context */
     134  hdc = DevOpenDC(hab, OD_MEMORY, "*", 5L, (PDEVOPENDATA)&dop, NULLHANDLE);
     135  DevQueryCaps(hdc, CAPS_COLOR_BITCOUNT, 1, (PLONG)&ScreenBitsPerPel);
     136  DevCloseDC(hdc);
     137
     138  dprintf(("InitPM: Desktop (%d,%d)", ScreenWidth, ScreenHeight));
     139  return TRUE;
    155140} /* End of main */
    156141//******************************************************************************
     
    223208        win32wnd = (Win32BaseWindow *)thdb->newWindow;
    224209        thdb->newWindow = 0;
    225 
    226         if(win32wnd->MsgCreate(WinQueryWindow(hwnd, QW_PARENT), hwnd) == FALSE)
     210        if(win32wnd->MsgCreate(hwnd) == FALSE)
    227211        {
    228212            RestoreOS2TIB();
    229213            return (MRESULT)TRUE; //discontinue window creation
    230214        }
     215        RestoreOS2TIB();
     216        PMFrameWindowProc(hwnd, msg, mp1, mp2);
     217        SetWin32TIB();
    231218    createfail:
    232219        RestoreOS2TIB();
     
    247234        dprintf(("OS2: WM_DESTROY %x", hwnd));
    248235        win32wnd->MsgDestroy();
    249         break;
     236        WinSetVisibleRegionNotify(hwnd, FALSE);
     237        goto RunDefWndProc;
    250238
    251239    case WM_ENABLE:
     
    261249    case WM_ADJUSTWINDOWPOS:
    262250    {
    263       PSWP      pswp   = (PSWP)mp1;
    264         dprintf(("PMWINDOW: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
    265         goto RunDefWndProc;
     251      PSWP     pswp = (PSWP)mp1;
     252      SWP      swpOld;
     253      WINDOWPOS wp,wpOld;
     254      HWND      hParent = NULLHANDLE, hwndAfter;
     255
     256        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));
     257
     258        //CB: show dialog in front of owner
     259        if (win32wnd->IsModalDialogOwner())
     260        {
     261          pswp->fl |= SWP_ZORDER;
     262          pswp->hwndInsertBehind = win32wnd->getOS2HwndModalDialog();
     263          if (pswp->fl & SWP_ACTIVATE)
     264          {
     265            pswp->fl &= ~SWP_ACTIVATE;
     266            WinSetWindowPos(win32wnd->getOS2HwndModalDialog(),0,0,0,0,0,SWP_ACTIVATE);
     267          }
     268        }
     269
     270        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
     271            goto RunDefWndProc;
     272
     273        if(!win32wnd->CanReceiveSizeMsgs())
     274            break;
     275
     276        WinQueryWindowPos(hwnd, &swpOld);
     277        if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
     278            if (win32wnd->isChild()) {
     279                if(win32wnd->getParent()) {
     280                        hParent = win32wnd->getParent()->getOS2WindowHandle();
     281                }
     282                else    goto RunDefWndProc;
     283            }
     284        }
     285        hwndAfter = pswp->hwndInsertBehind;
     286        if(win32wnd->getParent()) {
     287              OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
     288                                     win32wnd->getParent()->getClientRectPtr()->left,
     289                                     win32wnd->getParent()->getClientRectPtr()->top,
     290                                     hwnd);
     291        }
     292        else  OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
     293
     294        wp.hwnd = win32wnd->getWindowHandle();
     295        if ((pswp->fl & SWP_ZORDER) && (pswp->hwndInsertBehind > HWND_BOTTOM))
     296        {
     297           Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
     298           if(wndAfter) wp.hwndInsertAfter = wndAfter->getWindowHandle();
     299        }
     300
     301        wpOld = wp;
     302        win32wnd->MsgPosChanging((LPARAM)&wp);
     303
     304        if ((wp.hwndInsertAfter != wpOld.hwndInsertAfter) ||
     305            (wp.x != wpOld.x) || (wp.y != wpOld.y) || (wp.cx != wpOld.cx) || (wp.cy != wpOld.cy) || (wp.flags != wpOld.flags))
     306        {
     307          dprintf(("OS2: WM_ADJUSTWINDOWPOS, app changed windowpos struct"));
     308          dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     309
     310          if(win32wnd->getParent()) {
     311                OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, win32wnd->getParent()->getWindowHeight(),
     312                                       win32wnd->getParent()->getClientRectPtr()->left,
     313                                       win32wnd->getParent()->getClientRectPtr()->top,
     314                                       hwnd);
     315          }
     316          else  OSLibMapWINDOWPOStoSWP(&wp, pswp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
     317
     318          dprintf(("%x (%d,%d), (%d,%d)", pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     319          pswp->fl |= SWP_NOADJUST;
     320          pswp->hwndInsertBehind = hwndAfter;
     321          pswp->hwnd = hwnd;
     322
     323          RestoreOS2TIB();
     324          return (MRESULT)0xf;
     325        }
     326        RestoreOS2TIB();
     327        return (MRESULT)0;
    266328    }
    267329
    268330    case WM_WINDOWPOSCHANGED:
    269331    {
    270         if(pWinMsg->message != 0)
    271                 win32wnd->MsgPosChanged((LPARAM)&thdb->wp);
    272         goto RunDefWndProc;
     332      PSWP      pswp   = (PSWP)mp1,pswpOld = pswp+1;
     333      SWP       swpOld = *(pswp + 1);
     334      WINDOWPOS wp;
     335      HWND      hParent = NULLHANDLE;
     336      RECTL rect;
     337
     338        dprintf(("OS2: WM_WINDOWPOSCHANGED (%x) %x %x (%d,%d) (%d,%d)", mp2, win32wnd->getWindowHandle(), pswp->fl, pswp->x, pswp->y, pswp->cx, pswp->cy));
     339
     340        if ((pswp->fl & (SWP_SIZE | SWP_MOVE | SWP_ZORDER)) == 0)
     341        {
     342                goto RunDefWndProc;
     343        }
     344
     345        if(pswp->fl & (SWP_MOVE | SWP_SIZE)) {
     346            if(win32wnd->isChild()) {
     347                if(win32wnd->getParent()) {
     348                        hParent = win32wnd->getParent()->getOS2WindowHandle();
     349                }
     350                else    goto PosChangedEnd; //parent has just been destroyed
     351            }
     352        }
     353
     354
     355        if(win32wnd->getParent()) {
     356              OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, win32wnd->getParent()->getWindowHeight(),
     357                                     win32wnd->getParent()->getClientRectPtr()->left,
     358                                     win32wnd->getParent()->getClientRectPtr()->top,
     359                                     hwnd);
     360        }
     361        else  OSLibMapSWPtoWINDOWPOS(pswp, &wp, &swpOld, OSLibQueryScreenHeight(), 0, 0, hwnd);
     362
     363        if((pswp->fl & (SWP_MOVE | SWP_SIZE)) && !(win32wnd->getStyle() & WS_MINIMIZE_W))
     364        {
     365          //Note: Also updates the new window rectangle
     366          win32wnd->MsgFormatFrame(&wp);
     367
     368          //CB: todo: use result for WM_CALCVALIDRECTS
     369          mapWin32ToOS2RectFrame(win32wnd, win32wnd->getClientRectPtr(), (PRECTLOS2)&rect);
     370
     371          if(win32wnd->CanReceiveSizeMsgs())
     372            win32wnd->MsgPosChanged((LPARAM)&wp);
     373
     374          if((pswp->fl & SWP_SIZE) && ((pswp->cx != pswpOld->cx) || (pswp->cy != pswpOld->cy)))
     375          {
     376            //redraw the frame (to prevent unnecessary client updates)
     377            BOOL redrawAll = FALSE;
     378
     379            if (win32wnd->getWindowClass())
     380            {
     381              DWORD dwStyle = win32wnd->getWindowClass()->getClassLongA(GCL_STYLE_W);
     382
     383              if ((dwStyle & CS_HREDRAW_W) && (pswp->cx != pswpOld->cx))
     384                redrawAll = TRUE;
     385              else if ((dwStyle & CS_VREDRAW_W) && (pswp->cy != pswpOld->cy))
     386                redrawAll = TRUE;
     387            } else redrawAll = TRUE;
     388
     389            if (redrawAll)
     390            {
     391              //CB: redraw all children for now
     392              //    -> problems with update region if we don't do it
     393              //       todo: rewrite whole handling
     394              WinInvalidateRect(hwnd,NULL,TRUE);
     395            }
     396            else
     397            {
     398              HPS hps = WinGetPS(hwnd);
     399              RECTL frame,client,arcl[4];
     400
     401              WinQueryWindowRect(hwnd,&frame);
     402               //top
     403              arcl[0].xLeft = 0;
     404              arcl[0].xRight = frame.xRight;
     405              arcl[0].yBottom = rect.yTop;
     406              arcl[0].yTop = frame.yTop;
     407               //right
     408              arcl[1].xLeft = rect.xRight;
     409              arcl[1].xRight = frame.xRight;
     410              arcl[1].yBottom = 0;
     411              arcl[1].yTop = frame.yTop;
     412               //left
     413              arcl[2].xLeft = 0;
     414              arcl[2].xRight = rect.xLeft;
     415              arcl[2].yBottom = 0;
     416              arcl[2].yTop = frame.yTop;
     417               //bottom
     418              arcl[3].xLeft = 0;
     419              arcl[3].xRight = frame.xRight;
     420              arcl[3].yBottom = 0;
     421              arcl[3].yTop = rect.yBottom;
     422
     423              HRGN hrgn = GpiCreateRegion(hps,4,(PRECTL)&arcl);
     424
     425              WinInvalidateRegion(hwnd,hrgn,FALSE);
     426              GpiDestroyRegion(hps,hrgn);
     427              WinReleasePS(hps);
     428            }
     429          }
     430        }
     431        else
     432        {
     433          if(win32wnd->CanReceiveSizeMsgs())
     434            win32wnd->MsgPosChanged((LPARAM)&wp);
     435        }
     436
     437PosChangedEnd:
     438        RestoreOS2TIB();
     439        return (MRESULT)FALSE;
    273440    }
    274441
    275442    case WM_ACTIVATE:
    276443    {
     444        USHORT flags = WinQueryWindowUShort(hwnd,QWS_FLAGS);
     445
    277446        dprintf(("OS2: WM_ACTIVATE %x %x %x", hwnd, mp1, mp2));
    278447
    279         if(win32wnd->IsWindowCreated())
     448        if(win32wnd->IsWindowCreated())
     449        {
     450          WinSetWindowUShort(hwnd,QWS_FLAGS,mp1 ? (flags | FF_ACTIVE):(flags & ~FF_ACTIVE));
    280451          win32wnd->MsgActivate((LOWORD(pWinMsg->wParam) == WA_ACTIVE_W) ? 1 : 0, HIWORD(pWinMsg->wParam), pWinMsg->lParam, (HWND)mp2);
    281452
     453          //CB: show owner behind the dialog
     454          if(win32wnd->IsModalDialog())
     455          {
     456            Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
     457
     458            if(topOwner) WinSetWindowPos(topOwner->getOS2WindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
     459          }
     460        }
     461
    282462        break;
    283463    }
     
    289469    }
    290470
     471
    291472    case WM_MINMAXFRAME:
    292473    {
    293         dprintf(("OS2: WM_MINMAXFRAME"));
    294         break;
     474      PSWP swp = (PSWP)mp1;
     475
     476      if (!win32wnd->IsWindowCreated()) goto RunDefFrameProc;
     477      dprintf(("OS2: WM_MINMAXFRAME %x",hwnd));
     478      if ((swp->fl & SWP_MAXIMIZE) == SWP_MAXIMIZE)
     479      {
     480        win32wnd->setStyle((win32wnd->getStyle() & ~WS_MINIMIZE_W) | WS_MAXIMIZE_W);
     481
     482        RECT rect;
     483
     484        rect.left = rect.top = rect.right = rect.bottom = 0;
     485        win32wnd->AdjustMaximizedRect(&rect);
     486        swp->x += rect.left;
     487        swp->cx += rect.right-rect.left;
     488        swp->y -= rect.bottom;
     489        swp->cy += rect.bottom-rect.top;
     490      }
     491      else if ((swp->fl & SWP_MINIMIZE) == SWP_MINIMIZE)
     492      {
     493        win32wnd->setStyle((win32wnd->getStyle() & ~WS_MAXIMIZE_W) | WS_MINIMIZE_W);
     494      }
     495      else if ((swp->fl & SWP_RESTORE) == SWP_RESTORE)
     496      {
     497        win32wnd->setStyle(win32wnd->getStyle() & ~(WS_MINIMIZE_W | WS_MAXIMIZE_W));
     498      }
     499      goto RunDefFrameProc;
    295500    }
    296501
     
    322527    }
    323528#else
    324       dprintf(("PMWINDOW: WM_CALCVALIDRECTS"));
     529      dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
    325530      RestoreOS2TIB();
    326531      return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
    327532#endif
     533
     534    case WM_VRNENABLED:
     535        if(!win32wnd->isComingToTop() && ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == WS_EX_TOPMOST_W))
     536        {
     537                HWND hwndrelated;
     538                Win32BaseWindow *topwindow;
     539
     540                win32wnd->setComingToTop(TRUE);
     541
     542                hwndrelated = WinQueryWindow(hwnd, QW_PREV);
     543                dprintf(("WM_VRNENABLED hwndrelated = %x (hwnd=%x)", hwndrelated, hwnd));
     544                topwindow = Win32BaseWindow::GetWindowFromOS2Handle(hwndrelated);
     545                if(topwindow == NULL || ((win32wnd->getExStyle() & WS_EX_TOPMOST_W) == 0)) {
     546                        //put window at the top of z order
     547                        WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
     548                }
     549
     550                win32wnd->setComingToTop(FALSE);
     551                break;
     552        }
     553        goto RunDefWndProc;
    328554
    329555    case WM_SETFOCUS:
     
    350576    //**************************************************************************
    351577    case WM_HITTEST:
    352         if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
    353                 win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    354         }
    355         if(win32wnd)
    356                 rc = win32wnd->MsgHitTest(pWinMsg);
    357         break;
    358 
     578    {
     579        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     580                win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
     581        }
     582        if(win32wnd && win32wnd->IsWindowCreated())
     583        {
     584          MRESULT rc;
     585
     586          rc = (MRESULT)win32wnd->MsgHitTest(pWinMsg);
     587          RestoreOS2TIB();
     588          return rc;
     589        }
     590        return (MRESULT)HT_NORMAL;
     591    }
    359592
    360593    case WM_BUTTON1DOWN:
     
    452685    case WM_PAINT:
    453686    {
    454 //     RECTL rectl;
    455 
    456         dprintf(("OS2: WM_PAINT"));
    457         win32wnd->DispatchMsgA(pWinMsg);
     687      RECTL rectl;
     688
     689        WinQueryUpdateRect(hwnd, &rectl);
     690        dprintf(("OS2: WM_PAINT (%d,%d) (%d,%d)", rectl.xLeft, rectl.yBottom, rectl.xRight, rectl.yTop));
     691        if(win32wnd->IsWindowCreated())
     692        {
     693                PRECT pClient = win32wnd->getClientRectPtr();
     694                PRECT pWindow = win32wnd->getWindowRect();
     695
     696                if(!(pClient->left == 0 && pClient->top == 0 &&
     697                   win32wnd->getClientHeight() == win32wnd->getWindowHeight() &&
     698                   win32wnd->getClientWidth()  == win32wnd->getWindowWidth()))
     699                {
     700                        win32wnd->MsgNCPaint();
     701                }
     702                win32wnd->DispatchMsgA(pWinMsg);
     703        }
    458704        //SvL: Not calling the default window procedure causes all sorts of
    459705        //     strange problems (redraw & hanging app)
     706        //     -> check what WinBeginPaint does what we're forgetting in BeginPaint
    460707//      WinQueryUpdateRect(hwnd, &rectl);
    461708//        if(rectl.xLeft == 0 && rectl.yTop == 0 && rectl.xRight == 0 && rectl.yBottom == 0) {
     
    465712//      dprintf(("Update rectangle (%d,%d)(%d,%d) not empty, msg %x", rectl.xLeft, rectl.yTop, rectl.xRight, rectl.yBottom, pWinMsg->message));
    466713        goto RunDefWndProc;
    467     }
    468 
    469     case WM_CONTEXTMENU:
    470     {
    471         win32wnd->DispatchMsgA(pWinMsg);
    472 
    473         RestoreOS2TIB();
    474         return (MRESULT)TRUE;
     714//        break;
    475715    }
    476716
     
    482722    }
    483723
     724#if 0
     725    case WM_CONTEXTMENU:
     726    {
     727        win32wnd->DispatchMsgA(pWinMsg);
     728
     729        RestoreOS2TIB();
     730        return (MRESULT)TRUE;
     731    }
     732#endif
     733
    484734    case WM_FOCUSCHANGE:
    485735        dprintf(("OS2: WM_FOCUSCHANGE %x", win32wnd->getWindowHandle()));
    486736        goto RunDefWndProc;
     737
     738    case WM_QUERYTRACKINFO:
     739    {
     740      PTRACKINFO trackInfo = (PTRACKINFO)mp2;
     741
     742        dprintf(("OS2: WM_QUERYTRACKINFO %x", win32wnd->getWindowHandle()));
     743        RestoreOS2TIB();
     744        PMFrameWindowProc(hwnd,msg,mp1,mp2);
     745        SetWin32TIB();
     746        trackInfo->cxBorder = 4;
     747        trackInfo->cyBorder = 4;
     748        win32wnd->AdjustTrackInfo((PPOINT)&trackInfo->ptlMinTrackSize,(PPOINT)&trackInfo->ptlMaxTrackSize);
     749        RestoreOS2TIB();
     750        return (MRESULT)TRUE;
     751    }
     752
     753    case WM_QUERYBORDERSIZE:
     754    {
     755      PWPOINT size = (PWPOINT)mp1;
     756
     757      dprintf(("OS2: WM_QUERYBORDERSIZE %x", win32wnd->getWindowHandle()));
     758
     759      size->x = 0;
     760      size->y = 0;
     761      RestoreOS2TIB();
     762      return (MRESULT)TRUE;
     763    }
     764
     765    case WM_FORMATFRAME:
     766        dprintf(("OS2: WM_FORMATFRAME %x", win32wnd->getWindowHandle()));
     767        break;
     768
     769#if 0
     770    case WM_ADJUSTFRAMEPOS:
     771        dprintf(("OS2: WM_ADJUSTFRAMEPOS %x", win32wnd->getWindowHandle()));
     772        break;
     773
     774    case WM_QUERYFRAMEINFO:
     775        dprintf(("OS2: WM_QUERYFRAMEINFO %x", win32wnd->getWindowHandle()));
     776        return (MRESULT)(FI_FRAME|FI_ACTIVATEOK);
     777
     778    case WM_QUERYFOCUSCHAIN:
     779    {
     780      USHORT fsCmd = SHORT1FROMMP(mp1);
     781
     782        dprintf(("OS2: WM_QUERYFOCUSCHAIN %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
     783        switch(fsCmd) {
     784        case QFC_NEXTINCHAIN:
     785                break;
     786        case QFC_ACTIVE:
     787        case QFC_FRAME:
     788                if(win32wnd->GetTopParent()) {
     789                        dprintf(("Frame = %x", win32wnd->GetTopParent()->getOS2WindowHandle()));
     790                        return (MRESULT)win32wnd->GetTopParent()->getOS2WindowHandle();
     791                }
     792                break;
     793        case QFC_SELECTACTIVE:
     794                break;
     795        case QFC_PARTOFCHAIN:
     796                return (MRESULT)TRUE;
     797        }
     798        break;
     799    }
     800#endif
    487801
    488802    case WM_INITMENU:
     
    511825    case WM_SEMANTICEVENT:
    512826    default:
    513         //dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
     827//        dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
    514828        RestoreOS2TIB();
    515         return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     829        return PMFrameWindowProc(hwnd, msg, mp1, mp2);
     830//        return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    516831  }
    517832  RestoreOS2TIB();
    518833  return (MRESULT)rc;
    519834
     835RunDefFrameProc:
     836  RestoreOS2TIB();
     837  return PMFrameWindowProc(hwnd, msg, mp1, mp2);
     838
    520839RunDefWndProc:
    521840//  dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
    522841  RestoreOS2TIB();
    523 
    524   return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     842  return PMFrameWindowProc(hwnd, msg, mp1, mp2);
     843//  return WinDefWindowProc( hwnd, msg, mp1, mp2 );
    525844} /* End of Win32WindowProc */
    526845//******************************************************************************
     846//TODO: Quickly moving a window two times doesn't force a repaint (1st time)
    527847//******************************************************************************
     848VOID FrameTrackFrame(Win32BaseWindow *win32wnd,DWORD flags)
     849{
     850  TRACKINFO track;
     851  RECTL     rcl;
     852  PRECT     pWindowRect;
     853  HWND      hwndTracking;
     854  HPS       hpsTrack;
     855  LONG      parentHeight, parentWidth;
     856
     857   track.cxBorder = 4;
     858   track.cyBorder = 4;  /* 4 pel wide lines used for rectangle */
     859   track.cxGrid = 1;
     860   track.cyGrid = 1;    /* smooth tracking with mouse */
     861   track.cxKeyboard = 8;
     862   track.cyKeyboard = 8; /* faster tracking using cursor keys */
     863
     864   pWindowRect = win32wnd->getWindowRect();
     865   if(win32wnd->getParent()) {
     866        parentHeight = win32wnd->getParent()->getWindowHeight();
     867        parentWidth  = win32wnd->getParent()->getWindowWidth();
     868        hwndTracking = win32wnd->getParent()->getOS2WindowHandle();
     869        hpsTrack     = WinGetPS(hwndTracking); 
     870   }
     871   else {
     872        parentHeight = OSLibQueryScreenHeight();
     873        parentWidth  = OSLibQueryScreenWidth();
     874        hwndTracking = HWND_DESKTOP;
     875        hpsTrack     = NULL;
     876   }
     877
     878   rcl.xLeft   = pWindowRect->left;
     879   rcl.yTop    = OSLibQueryScreenHeight() - pWindowRect->top;
     880   rcl.xRight  = pWindowRect->right;
     881   rcl.yBottom = OSLibQueryScreenHeight() - pWindowRect->bottom;
     882   if(hwndTracking != HWND_DESKTOP) {
     883        WinMapWindowPoints(win32wnd->getOS2WindowHandle(), HWND_DESKTOP, (PPOINTL)&rcl, 2);
     884   }
     885   WinCopyRect(hab, &track.rclTrack, &rcl);   /* starting point */
     886 
     887   WinSetRect(hab, &track.rclBoundary, 0, 0, parentWidth, parentHeight); /* bounding rectangle */
     888 
     889   track.ptlMinTrackSize.x = 10;
     890   track.ptlMinTrackSize.y = 10;  /* set smallest allowed size of rectangle */
     891   track.ptlMaxTrackSize.x = parentWidth;
     892   track.ptlMaxTrackSize.y = parentHeight; /* set largest allowed size of rectangle */
     893
     894   win32wnd->AdjustTrackInfo((PPOINT)&track.ptlMinTrackSize, (PPOINT)&track.ptlMaxTrackSize);
     895 
     896   track.fs = flags;
     897 
     898   if(WinTrackRect(HWND_DESKTOP, NULL, &track) )
     899   {
     900        if(hpsTrack)    WinReleasePS(hpsTrack);
     901
     902        /* if successful copy final position back */
     903        if(!WinEqualRect(0, &rcl, &track.rclTrack)) {
     904                if(flags == TF_MOVE) {
     905                        WinSetWindowPos(win32wnd->getOS2WindowHandle(),
     906                                        0, track.rclTrack.xLeft, track.rclTrack.yBottom,
     907                                        0, 0, SWP_MOVE);
     908                }
     909                else {
     910                        WinSetWindowPos(win32wnd->getOS2WindowHandle(),
     911                                        0, track.rclTrack.xLeft, track.rclTrack.yBottom,
     912                                        track.rclTrack.xRight - track.rclTrack.xLeft,
     913                                        track.rclTrack.yTop - track.rclTrack.yBottom,
     914                                        SWP_SIZE|SWP_MOVE);
     915                }
     916        }
     917        return;
     918   }
     919   if(hpsTrack) WinReleasePS(hpsTrack);
     920   return;
     921}
     922//******************************************************************************
     923//******************************************************************************
  • trunk/src/user32/pmwindow.h

    r2469 r3662  
    1 /* $Id: pmwindow.h,v 1.8 2000-01-18 20:08:13 sandervl Exp $ */
     1/* $Id: pmwindow.h,v 1.9 2000-06-07 14:51:27 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    99#define __PMWINDOW_H__
    1010
    11 #define WIN32_STDCLASS   "Win32WindowClass"
    12 #define WIN32_STDCLASS2  "Win32WindowClass2"
    13 #define WIN32_INNERFRAME "Win32InnerFrameClass"
     11#define WIN32_STDCLASS      "Win32WindowClass"
     12#define WIN32_STDFRAMECLASS "Win32FrameClass"
    1413
    1514BOOL InitPM();
    16 
    17 PVOID SubclassWithDefHandler(HWND hwnd);
    1815
    1916void RegisterSystemClasses(ULONG hModule);
  • trunk/src/user32/unknown.cpp

    r2804 r3662  
    1 /* $Id: unknown.cpp,v 1.8 2000-02-16 14:34:38 sandervl Exp $ */
     1/* $Id: unknown.cpp,v 1.9 2000-06-07 14:51:28 sandervl Exp $ */
    22
    33/*
     
    180180
    181181
    182 /***********************************************************************
    183  *           SetInternalWindowPos   (USER32.483)
    184  */
    185 void WIN32API SetInternalWindowPos(HWND    hwnd,
    186                                    UINT    showCmd,
    187                                    LPRECT  rect,
    188                                    LPPOINT pt )
    189 {
    190   dprintf(("USER32: SetInternalWindowPos(%08xh,%08xh,%08xh,%08xh) not implemented.\n",
    191            hwnd,
    192            showCmd,
    193            rect,
    194            pt));
    195 }
    196182
  • trunk/src/user32/user32.cpp

    r3628 r3662  
    1 /* $Id: user32.cpp,v 1.82 2000-05-28 19:50:54 sandervl Exp $ */
     1/* $Id: user32.cpp,v 1.83 2000-06-07 14:51:28 sandervl Exp $ */
    22
    33/*
     
    17061706int WIN32API FillRect(HDC hDC, const RECT * lprc, HBRUSH hbr)
    17071707{
    1708     dprintf2(("USER32:  FillRect (%d,%d)(%d,%d) brush %X\n", lprc->left, lprc->top, lprc->right, lprc->bottom, hbr));
     1708    dprintf(("USER32:  FillRect (%d,%d)(%d,%d) brush %X\n", lprc->left, lprc->top, lprc->right, lprc->bottom, hbr));
    17091709    return O32_FillRect(hDC,lprc,hbr);
    17101710}
  • trunk/src/user32/win32dlg.cpp

    r3488 r3662  
    1 /* $Id: win32dlg.cpp,v 1.49 2000-05-03 18:35:53 sandervl Exp $ */
     1/* $Id: win32dlg.cpp,v 1.50 2000-06-07 14:51:29 sandervl Exp $ */
    22/*
    33 * Win32 Dialog Code for OS/2
     
    212212//******************************************************************************
    213213//******************************************************************************
    214 ULONG Win32Dialog::MsgCreate(HWND hwndFrame, HWND hwndClient)
     214ULONG Win32Dialog::MsgCreate(HWND hwndOS2)
    215215{
    216216 CREATESTRUCTA  *cs = tmpcs;  //pointer to CREATESTRUCT used in CreateWindowExA method
     
    218218 LPSTR  dlgTemplate = tmpDlgTemplate;
    219219
    220     Win32BaseWindow::MsgCreate(hwndFrame, hwndClient);
     220    Win32BaseWindow::MsgCreate(hwndOS2);
    221221
    222222    if(!isUnicode) {
     
    303303        topOwner->setModalDialogOwner(TRUE);
    304304        hwndOldDialog = topOwner->getOS2HwndModalDialog();
    305         topOwner->setOS2HwndModalDialog(OS2HwndFrame);
     305        topOwner->setOS2HwndModalDialog(OS2Hwnd);
    306306        ShowWindow(SW_SHOW);
    307307
  • trunk/src/user32/win32dlg.h

    r2469 r3662  
    1 /* $Id: win32dlg.h,v 1.10 2000-01-18 20:08:16 sandervl Exp $ */
     1/* $Id: win32dlg.h,v 1.11 2000-06-07 14:51:30 sandervl Exp $ */
    22/*
    33 * Win32 Dialog Code for OS/2
     
    7373         BOOL   MapDialogRect(LPRECT rect);
    7474
    75 virtual  ULONG  MsgCreate(HWND hwndFrame, HWND hwndClient);
     75virtual  ULONG  MsgCreate(HWND hwndOS2);
    7676
    7777virtual  LONG   SetWindowLongA(int index, ULONG value, BOOL fUnicode = FALSE);
  • trunk/src/user32/win32wbase.cpp

    r3641 r3662  
    1 /* $Id: win32wbase.cpp,v 1.197 2000-06-01 11:27:57 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.198 2000-06-07 14:51:30 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    1515 * TODO: Not thread/process safe
    1616 *
    17  * NOTE: Client rectangle always relative to frame window; window rectangle in screen coordinates
     17 * NOTE: Client rectangle always relative to frame window
     18 *       Window rectangle in parent coordinates (relative to parent's client window)
     19 *       (screen coord. if no parent)
    1820 *
    1921 * Project Odin Software License can be found in LICENSE.TXT
     
    3941#include "win32wndhandle.h"
    4042#include "dc.h"
    41 #include "pmframe.h"
    4243#include "win32wdesktop.h"
    4344#include "pmwindow.h"
     
    104105  magic            = WIN32PM_MAGIC;
    105106  OS2Hwnd          = 0;
    106   OS2HwndFrame     = 0;
    107107  hSysMenu         = 0;
    108108  Win32Hwnd        = 0;
     
    126126  hotkey           = 0;
    127127
    128   pOldFrameProc = NULL;
    129128
    130129  hwndLinkAfter    = HWND_BOTTOM;
     
    156155  dwThreadId         = GetCurrentThreadId();
    157156  dwProcessId        = currentProcessId;
     157
     158  memset(&windowpos, 0, sizeof(windowpos));
    158159}
    159160//******************************************************************************
     
    166167    }
    167168
    168     OSLibWinSetVisibleRegionNotify(OS2HwndFrame, FALSE);
     169    OSLibWinSetVisibleRegionNotify(OS2Hwnd, FALSE);
    169170    OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
    170171    OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
     
    412413
    413414  hwndLinkAfter = HWND_TOP;
     415#if 1
    414416  if(CONTROLS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX))
    415417  {
     
    418420  }
    419421  else
     422#endif
    420423  if(CONTROLS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) {
    421424        dwStyle |= WS_CLIPSIBLINGS;
     
    515518                                 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP,
    516519                                 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE,
    517                                  &OS2HwndFrame, 0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle());
     520                                 0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle());
    518521  if(OS2Hwnd == 0) {
    519522        dprintf(("Window creation failed!!"));
     
    521524        return FALSE;
    522525  }
    523   OSLibWinSetVisibleRegionNotify(OS2HwndFrame, TRUE);
     526  OSLibWinSetVisibleRegionNotify(OS2Hwnd, TRUE);
    524527  SetLastError(0);
    525528  return TRUE;
     
    527530//******************************************************************************
    528531//******************************************************************************
    529 BOOL Win32BaseWindow::MsgCreate(HWND hwndFrame, HWND hwndClient)
     532BOOL Win32BaseWindow::MsgCreate(HWND hwndOS2)
    530533{
    531534 CREATESTRUCTA  *cs = tmpcs;  //pointer to CREATESTRUCT used in CreateWindowExA method
    532535 POINT maxSize, maxPos, minTrack, maxTrack;
    533536
    534   OS2Hwnd      = hwndClient;
    535   OS2HwndFrame = hwndFrame;
     537  OS2Hwnd      = hwndOS2;
    536538
    537539  fNoSizeMsg = TRUE;
     
    556558
    557559    //SvL: Returns invalid rectangle (not the expected shell default size)
    558     OSLibWinQueryWindowRect(OS2HwndFrame,&rect,RELATIVE_TO_SCREEN);
     560    OSLibWinQueryWindowRect(OS2Hwnd,&rect,RELATIVE_TO_SCREEN);
    559561    if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rect);
    560562    if (fXDefault)
     
    575577#endif
    576578
    577   OSLibWinSetOwner(OS2Hwnd, OS2HwndFrame);
    578 
    579579  fakeWinBase.hwndThis     = OS2Hwnd;
    580580  fakeWinBase.pWindowClass = windowClass;
     
    582582  //Set icon from window or class
    583583  if (hIcon)
    584     OSLibWinSetIcon(OS2HwndFrame,hIcon);
     584    OSLibWinSetIcon(OS2Hwnd,hIcon);
    585585  else if (windowClass->getIcon())
    586     OSLibWinSetIcon(OS2HwndFrame,windowClass->getIcon());
     586    OSLibWinSetIcon(OS2Hwnd,windowClass->getIcon());
    587587
    588588  /* Get class or window DC if needed */
    589589  if(windowClass->getStyle() & CS_OWNDC) {
    590590        dprintf(("Class with CS_OWNDC style"));
    591         ownDC = GetDC(getWindowHandle()); //TODO: or GetWindowDC???
     591        ownDC = GetDCEx(getWindowHandle(), NULL, DCX_USESTYLE);
    592592  }
    593593  else
    594594  if (windowClass->getStyle() & CS_PARENTDC)  {
    595         dprintf(("WARNING: Class with CS_PARENTDC style!"));
    596595        fParentDC = TRUE;
    597596        ownDC = 0;
     
    624623  hSysMenu = (dwStyle & WS_SYSMENU) ? MENU_GetSysMenu(Win32Hwnd,0):0;
    625624
    626   // Subclass frame
    627   pOldFrameProc = FrameSubclassFrameWindow(this);
    628 
    629625  /* Send the WM_GETMINMAXINFO message and fix the size if needed */
    630626  if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
     
    656652  OffsetRect(&rectClient, -rectClient.left, -rectClient.top);
    657653
    658   if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow);
    659654  /* Send the WM_CREATE message
    660655   * Perhaps we shouldn't allow width/height changes as well.
     
    667662
    668663  if(fTaskList) {
    669         hTaskList = OSLibWinAddToTaskList(OS2HwndFrame, windowNameA, (cs->style & WS_VISIBLE) ? 1 : 0);
     664        hTaskList = OSLibWinAddToTaskList(OS2Hwnd, windowNameA, (cs->style & WS_VISIBLE) ? 1 : 0);
    670665  }
    671666
     
    690685        rectWindow.bottom = cs->y+cs->cy;
    691686        tmpRect = rectWindow;
    692         if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow);
    693         OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
    694687
    695688        rectClient = rectWindow;
    696689        OffsetRect(&rectClient, -rectClient.left, -rectClient.top);
     690        OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);
    697691
    698692        //set the window size and update the client
     
    855849ULONG Win32BaseWindow::MsgHitTest(MSG *msg)
    856850{
    857   lastHitTestVal = DispatchMessageA(msg);
    858 
    859   dprintf2(("MsgHitTest %x (%d,%d) (%d,%d) (%d,%d) returned %x", getWindowHandle(), LOWORD(msg->lParam), HIWORD(msg->lParam), rectWindow.left, rectWindow.right, rectWindow.top, rectWindow.bottom, lastHitTestVal));
     851  lastHitTestVal = DispatchMsgA(msg);
     852
     853  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));
    860854
    861855  if (lastHitTestVal == HTTRANSPARENT)
     
    878872    //default processing is cancelled
    879873    //TODO: According to Wine we should proceed anyway if window is sysmodal
    880 #if 0
    881874    if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
    882875    {
     876        dprintf(("WARNING: WM_NCACTIVATE return code = FALSE -> cancel processing"));
    883877        return 0;
    884878    }
    885 #endif
    886879    /* child windows get WM_CHILDACTIVATE message */
    887880    if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD )
     
    995988
    996989                    //SvL: Calling OSLibSetActiveWindow(hwndTop); causes focus problems
    997                     if (win32top) OSLibWinSetFocus(win32top->getOS2FrameWindowHandle());
     990                    if (win32top) OSLibWinSetFocus(win32top->getOS2WindowHandle());
    998991                }
    999992        }
     
    10231016
    10241017    if (hdcErase == 0)
    1025         hdcErase = O32_GetDC(OS2Hwnd);
     1018        hdcErase = GetDC(getWindowHandle());
    10261019
    10271020    if(IsWindowIconic())
     
    10301023        rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0);
    10311024    if (hdc == 0)
    1032         O32_ReleaseDC(OS2Hwnd, hdcErase);
     1025        ReleaseDC(getWindowHandle(), hdcErase);
    10331026    return (rc);
    10341027}
     
    10551048  RECT rect;
    10561049
    1057   if (GetOS2UpdateRect(OS2HwndFrame,&rect))
     1050  if(GetOS2UpdateRect(this,&rect))
    10581051  {
    10591052    HRGN hrgn;
     
    10731066        if (!hrgn) return 0;
    10741067
    1075         rc = SendInternalMessageA(WM_NCPAINT,hrgn,0);
     1068        rc = SendInternalMessageA(WM_NCPAINT, hrgn, 0);
    10761069
    10771070        DeleteObject(hrgn);
     
    10931086  if(lpWndPos)
    10941087  {
    1095     POINT point;
    1096 
    1097     //set new window rectangle
    1098     point.x = lpWndPos->x;
    1099     point.y = lpWndPos->y;
    1100     if (getParent()) ClientToScreen(getParent()->getWindowHandle(),&point);
    1101 
    1102     setWindowRect(point.x,point.y,point.x+lpWndPos->cx,point.y+lpWndPos->cy);
    1103     newWindowRect = rectWindow;
     1088        //set new window rectangle
     1089        setWindowRect(lpWndPos->x, lpWndPos->y, lpWndPos->x+lpWndPos->cx,
     1090                      lpWndPos->y+lpWndPos->cy);
     1091        newWindowRect = rectWindow;
    11041092  }
    11051093  else {
    1106     wndPos.hwnd  = getWindowHandle();
    1107     wndPos.hwndInsertAfter = 0;
    1108     newWindowRect= rectWindow;
    1109     if (getParent()) {
    1110         mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&newWindowRect);
    1111     }
    1112     wndPos.x     = newWindowRect.left;
    1113     wndPos.y     = newWindowRect.top;
    1114     wndPos.cx    = newWindowRect.right - newWindowRect.left;
    1115     wndPos.cy    = newWindowRect.bottom - newWindowRect.top;
    1116     wndPos.flags = SWP_FRAMECHANGED;
    1117     lpWndPos     = &wndPos;
    1118 
    1119     if (getParent()) {
    1120         newWindowRect= rectWindow; //reset; was modified
    1121     }
     1094        wndPos.hwnd  = getWindowHandle();
     1095        wndPos.hwndInsertAfter = 0;
     1096        newWindowRect= rectWindow;
     1097        wndPos.x     = newWindowRect.left;
     1098        wndPos.y     = newWindowRect.top;
     1099        wndPos.cx    = newWindowRect.right - newWindowRect.left;
     1100        wndPos.cy    = newWindowRect.bottom - newWindowRect.top;
     1101        wndPos.flags = SWP_FRAMECHANGED;
     1102        lpWndPos     = &wndPos;
    11221103  }
    11231104
     
    11251106
    11261107  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));
     1108  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));
    11271109  return rc;
    11281110}
     
    11691151BOOL Win32BaseWindow::isFrameWindow()
    11701152{
    1171 //    if(isMDIChild() || IsDialog() || (getParent() == NULL || getParent() == windowDesktop) && ((dwStyle & WS_CAPTION) == WS_CAPTION))
    1172     if((dwStyle & WS_CAPTION) == WS_CAPTION || dwStyle & (WS_VSCROLL|WS_HSCROLL))
     1153    if(getParent() == NULL)
    11731154        return TRUE;
    11741155
     
    13431324          HandleNCPaint((HRGN)1);
    13441325          if(hTaskList) {
    1345                 OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
     1326                OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
    13461327          }
    13471328        }
     
    13551336      {
    13561337        setStyle(getStyle() | WS_VISIBLE);
    1357         OSLibWinEnableWindowUpdate(OS2HwndFrame,TRUE);
     1338        OSLibWinEnableWindowUpdate(OS2Hwnd,TRUE);
    13581339      }
    13591340      else
     
    13621343        {
    13631344          setStyle(getStyle() & ~WS_VISIBLE);
    1364           OSLibWinEnableWindowUpdate(OS2HwndFrame,FALSE);
     1345          OSLibWinEnableWindowUpdate(OS2Hwnd,FALSE);
    13651346        }
    13661347      }
     
    17421723              hIcon = (HICON)lParam;
    17431724              if ((dwStyle & WS_CAPTION) == WS_CAPTION)
    1744                 OSLibWinSetIcon(OS2HwndFrame,hIcon);
     1725                OSLibWinSetIcon(OS2Hwnd,hIcon);
    17451726            }
    17461727          }
     
    18031784          HandleNCPaint((HRGN)1);
    18041785          if(hTaskList) {
    1805                 OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
     1786                OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
    18061787          }
    18071788        }
     
    18681849                if (getParent())
    18691850                {
    1870                   POINTS pt = MAKEPOINTS(lParam);
    1871                   POINT point;
    1872 
    1873                   point.x = pt.x;
    1874                   point.y = pt.y;
    1875                   mapWin32Point(OS2Hwnd,getParent()->getOS2WindowHandle(),(OSLIBPOINT*)&point);
    1876                   NotifyParent(Msg,wParam,MAKELPARAM(point.x,point.y));
     1851                        POINTS pt = MAKEPOINTS(lParam);
     1852                        POINT point;
     1853
     1854                        point.x = pt.x;
     1855                        point.y = pt.y;
     1856                        MapWindowPoints(getWindowHandle(), getParent()->getWindowHandle(), &point, 1);
     1857                        NotifyParent(Msg,wParam,MAKELPARAM(point.x,point.y));
    18771858                }
    18781859                rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     
    20572038BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow)
    20582039{
    2059  ULONG showstate = 0;
     2040 ULONG swp = 0;
    20602041 HWND  hWinAfter;
    20612042 BOOL  rc,wasVisible,showFlag;
     2043 RECT  newPos = {0, 0, 0, 0};
    20622044
    20632045    dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow));
    20642046
     2047    wasVisible = (getStyle() & WS_VISIBLE) != 0;
     2048
    20652049    switch(nCmdShow)
    20662050    {
    2067     case SW_SHOW:
    2068     case SW_SHOWDEFAULT: //todo
    2069         showstate = SWPOS_SHOW | SWPOS_ACTIVATE;
    2070         break;
    2071     case SW_HIDE:
    2072         if (!wasVisible) return wasVisible;
    2073          if(GetCapture() == getWindowHandle() || IsChild(GetCapture()))
    2074            ReleaseCapture();
    2075 
    2076         showstate = SWPOS_HIDE;
    2077         break;
    2078     case SW_RESTORE:
    2079         showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE;
    2080         break;
    2081     case SW_MINIMIZE:
    2082         showstate = SWPOS_MINIMIZE;
    2083         break;
    2084     case SW_SHOWMAXIMIZED:
    2085         showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
    2086         break;
    2087     case SW_SHOWMINIMIZED:
    2088         showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE;
    2089         break;
    2090     case SW_SHOWMINNOACTIVE:
    2091         showstate = SWPOS_MINIMIZE | SWPOS_SHOW;
    2092         break;
    2093     case SW_SHOWNA:
    2094         showstate = SWPOS_SHOW;
    2095         break;
    2096     case SW_SHOWNOACTIVATE:
    2097         showstate = SWPOS_SHOW;
    2098         break;
    2099     case SW_SHOWNORMAL:
    2100         showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW;
    2101         break;
    2102     }
    2103 
    2104     /* We can't activate a child window (WINE) */
     2051        case SW_HIDE:
     2052            if (!wasVisible) goto END;
     2053            swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE |
     2054                   SWP_NOACTIVATE | SWP_NOZORDER;
     2055            break;
     2056
     2057        case SW_SHOWMINNOACTIVE:
     2058            swp |= SWP_NOACTIVATE | SWP_NOZORDER;
     2059            /* fall through */
     2060        case SW_SHOWMINIMIZED:
     2061            swp |= SWP_SHOWWINDOW;
     2062            /* fall through */
     2063        case SW_MINIMIZE:
     2064            swp |= SWP_FRAMECHANGED;
     2065            if( !(getStyle() & WS_MINIMIZE) )
     2066                 swp |= MinMaximize(SW_MINIMIZE, &newPos );
     2067            else swp |= SWP_NOSIZE | SWP_NOMOVE;
     2068            break;
     2069
     2070        case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
     2071            swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
     2072            if( !(getStyle() & WS_MAXIMIZE) )
     2073                 swp |= MinMaximize(SW_MAXIMIZE, &newPos );
     2074            else swp |= SWP_NOSIZE | SWP_NOMOVE;
     2075            break;
     2076
     2077        case SW_SHOWNA:
     2078            swp |= SWP_NOACTIVATE | SWP_NOZORDER;
     2079            /* fall through */
     2080        case SW_SHOW:
     2081            swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
     2082
     2083            /*
     2084             * ShowWindow has a little peculiar behavior that if the
     2085             * window is already the topmost window, it will not
     2086             * activate it.
     2087             */
     2088            if (::GetTopWindow((HWND)0)==getWindowHandle() && (wasVisible || GetActiveWindow() == getWindowHandle()))
     2089              swp |= SWP_NOACTIVATE;
     2090
     2091            break;
     2092
     2093        case SW_SHOWNOACTIVATE:
     2094            swp |= SWP_NOZORDER;
     2095            if (GetActiveWindow()) swp |= SWP_NOACTIVATE;
     2096            /* fall through */
     2097        case SW_SHOWNORMAL:  /* same as SW_NORMAL: */
     2098        case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
     2099        case SW_RESTORE:
     2100            swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
     2101
     2102            if( getStyle() & (WS_MINIMIZE | WS_MAXIMIZE) )
     2103                 swp |= MinMaximize(SW_RESTORE, &newPos );
     2104            else swp |= SWP_NOSIZE | SWP_NOMOVE;
     2105            break;
     2106    }
     2107
     2108    showFlag = (nCmdShow != SW_HIDE);
     2109    if (showFlag != wasVisible)
     2110    {
     2111        SendInternalMessageA(WM_SHOWWINDOW, showFlag, 0 );
     2112        if (!::IsWindow( getWindowHandle() )) goto END;
     2113    }
     2114
     2115    /* We can't activate a child window */
    21052116    if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_MDICHILD))
    2106         showstate &= ~SWPOS_ACTIVATE;
    2107 
    2108     if(showstate & SWPOS_SHOW) {
    2109          setStyle(getStyle() | WS_VISIBLE);
    2110          if(hTaskList) {
    2111                 OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
    2112          }
    2113     }
    2114     else {
    2115         if(hTaskList) {
    2116                 OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
    2117         }
    2118         setStyle(getStyle() & ~WS_VISIBLE);
    2119     }
    2120     showFlag = (nCmdShow != SW_HIDE);
    2121 
    2122     rc = OSLibWinShowWindow(OS2HwndFrame, showstate);
    2123     OSLibWinShowWindow(OS2Hwnd, showstate);
    2124 
    2125     SendInternalMessageA(WM_SHOWWINDOW, (showstate & SWPOS_SHOW) ? 1 : 0, 0);
    2126 
    2127     //CB: PMFrame: WM_MINMAXFRAME SWP_* handling isn't always successful!
    2128     if ((showstate & SWPOS_MAXIMIZE) == SWPOS_MAXIMIZE)
    2129       setStyle((getStyle() & ~WS_MINIMIZE) | WS_MAXIMIZE);
    2130     else if ((showstate & SWPOS_MINIMIZE) == SWPOS_MINIMIZE)
    2131       setStyle((getStyle() & ~WS_MAXIMIZE) | WS_MINIMIZE);
    2132     else if ((showstate & SWPOS_RESTORE) == SWPOS_RESTORE)
    2133       setStyle(getStyle() & ~(WS_MINIMIZE | WS_MAXIMIZE));
     2117        swp |= SWP_NOACTIVATE | SWP_NOZORDER;
     2118
     2119    SetWindowPos(HWND_TOP, newPos.left, newPos.top, newPos.right, newPos.bottom, LOWORD(swp));
    21342120
    21352121    if (flags & WIN_NEED_SIZE)
     
    21502136        SendInternalMessageA(WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top));
    21512137    }
    2152 
    2153     return rc;
     2138END:
     2139    return wasVisible;
    21542140}
    21552141//******************************************************************************
     
    21602146   Win32BaseWindow *window;
    21612147   HWND hParent = 0;
     2148   RECT oldClientRect = rectClient;
    21622149
    21632150    if (fuFlags &
     
    22242211    if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE))
    22252212    {
    2226        if (isChild())
    2227        {
    2228             Win32BaseWindow *windowParent = getParent();
    2229             if(windowParent) {
    2230                 hParent = getParent()->getOS2WindowHandle();
    2231         }
    2232         else    dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
    2233        }
    2234        OSLibWinQueryWindowPos(OS2HwndFrame, &swpOld);
    2235     }
    2236 
    2237     OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, hParent, OS2HwndFrame);
     2213        if (isChild())
     2214        {
     2215            if(!getParent()) {
     2216                dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
     2217            }
     2218        }
     2219        OSLibWinQueryWindowPos(OS2Hwnd, &swpOld);
     2220    }
     2221
     2222    if(getParent()) {
     2223          OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, getParent()->getWindowHeight(),
     2224                                 getParent()->getClientRectPtr()->left,
     2225                                 getParent()->getClientRectPtr()->top,
     2226                                 OS2Hwnd);
     2227    }
     2228    else  OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, OSLibQueryScreenHeight(), 0, 0, OS2Hwnd);
    22382229    if (swp.fl == 0) {
    2239         if (fuFlags & SWP_FRAMECHANGED)
    2240         {
    2241             FrameUpdateClient(this);
     2230        if(fuFlags & SWP_FRAMECHANGED)
     2231        {           
     2232                MsgFormatFrame(NULL);
     2233                UnionRect(&oldClientRect, &oldClientRect, &rectClient);
     2234                InvalidateRect(getWindowHandle(), &oldClientRect, TRUE);
     2235//TODO: move child windows!!
    22422236        }
    22432237        return TRUE;
     
    22492243        Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind);
    22502244        if(wndBehind) {
    2251             swp.hwndInsertBehind   = wndBehind->getOS2FrameWindowHandle();
     2245            swp.hwndInsertBehind   = wndBehind->getOS2WindowHandle();
    22522246        }
    22532247        else {
     
    22562250        }
    22572251    }
    2258     swp.hwnd = OS2HwndFrame;
     2252    swp.hwnd = OS2Hwnd;
    22592253
    22602254    dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
     2255    rc = OSLibWinSetMultWindowPos(&swp, 1);
    22612256
    22622257    if(fuFlags & SWP_SHOWWINDOW && !IsWindowVisible()) {
    22632258        setStyle(getStyle() | WS_VISIBLE);
    2264         //SvL: TODO: Send WM_SHOWWINDOW??
    2265         OSLibWinShowWindow(OS2Hwnd, SWPOS_SHOW);
    22662259        if(hTaskList) {
    2267                 OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
     2260                OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
    22682261        }
    22692262    }
     
    22712264    if(fuFlags & SWP_HIDEWINDOW && IsWindowVisible()) {
    22722265        setStyle(getStyle() & ~WS_VISIBLE);
    2273         //SvL: TODO: Send WM_SHOWWINDOW??
    2274         OSLibWinShowWindow(OS2Hwnd, SWPOS_HIDE);
    22752266        if(hTaskList) {
    2276                 OSLibWinChangeTaskList(hTaskList, OS2HwndFrame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
     2267                OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
    22772268        }
    22782269    }
    2279     rc = OSLibWinSetMultWindowPos(&swp, 1);
    22802270
    22812271    if(rc == FALSE)
     
    22872277    if((fuFlags & SWP_FRAMECHANGED) && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE)))
    22882278    {
    2289         FrameUpdateClient(this);
     2279        UnionRect(&oldClientRect, &oldClientRect, &rectClient);
     2280        InvalidateRect(getWindowHandle(), &oldClientRect, TRUE);
     2281//TODO: move child windows!!
    22902282    }
    22912283    return (rc);
    22922284}
    22932285//******************************************************************************
    2294 //TODO: WPF_RESTOREMAXIMIZED
    2295 //******************************************************************************
    2296 BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *winpos)
    2297 {
    2298    if(isFrameWindow())
     2286//******************************************************************************
     2287BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *wndpl)
     2288{
     2289   windowpos.ptMinPosition    = wndpl->ptMinPosition;
     2290   windowpos.ptMaxPosition    = wndpl->ptMaxPosition;
     2291   windowpos.rcNormalPosition = wndpl->rcNormalPosition;
     2292
     2293   if(getStyle() & WS_MINIMIZE )
    22992294   {
    2300       // Set the minimized position
    2301       if (winpos->flags & WPF_SETMINPOSITION)
    2302       {
    2303          OSLibSetWindowMinPos(OS2HwndFrame, winpos->ptMinPosition.x, winpos->ptMinPosition.y);
    2304       }
    2305 
    2306       //TODO: Max position
    2307 
    2308       // Set the new restore position.
    2309       OSLibSetWindowRestoreRect(OS2HwndFrame, &winpos->rcNormalPosition);
     2295        //TODO: Why can't this be (0,0)?
     2296        if(wndpl->flags & WPF_SETMINPOSITION && !(!windowpos.ptMinPosition.x && !windowpos.ptMinPosition.y)) {
     2297                SetWindowPos(0, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
     2298                             0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     2299        }
    23102300   }
    2311 
    2312    return ShowWindow(winpos->showCmd);
     2301   else
     2302   if(getStyle() & WS_MAXIMIZE )
     2303   {
     2304        //TODO: Why can't this be (0,0)?
     2305        if(windowpos.ptMaxPosition.x != 0 || windowpos.ptMaxPosition.y != 0 )
     2306                SetWindowPos(0, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y,
     2307                             0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     2308   }
     2309   else {
     2310        SetWindowPos(0, windowpos.rcNormalPosition.left, windowpos.rcNormalPosition.top,
     2311                     windowpos.rcNormalPosition.right - windowpos.rcNormalPosition.left,
     2312                     windowpos.rcNormalPosition.bottom - windowpos.rcNormalPosition.top,
     2313                     SWP_NOZORDER | SWP_NOACTIVATE );
     2314   }
     2315   ShowWindow(wndpl->showCmd);
     2316   if( ::IsWindow(getWindowHandle()) && getStyle() & WS_MINIMIZE )
     2317   {
     2318        /* SDK: ...valid only the next time... */
     2319        if(wndpl->flags & WPF_RESTORETOMAXIMIZED)
     2320                setFlags(getFlags() | WIN_RESTORE_MAX);
     2321   }
     2322   return TRUE;
     2323}
     2324//******************************************************************************
     2325//******************************************************************************
     2326BOOL Win32BaseWindow::GetWindowPlacement(LPWINDOWPLACEMENT wndpl)
     2327{
     2328   wndpl->length  = sizeof(*wndpl);
     2329   if(getStyle() & WS_MINIMIZE )
     2330        wndpl->showCmd = SW_SHOWMINIMIZED;
     2331   else wndpl->showCmd = (getStyle() & WS_MAXIMIZE) ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL;
     2332
     2333   if(getFlags() & WIN_RESTORE_MAX )
     2334        wndpl->flags = WPF_RESTORETOMAXIMIZED;
     2335   else wndpl->flags = 0;
     2336
     2337   wndpl->ptMinPosition    = windowpos.ptMinPosition;
     2338   wndpl->ptMaxPosition    = windowpos.ptMaxPosition;
     2339   wndpl->rcNormalPosition = windowpos.rcNormalPosition;
     2340
     2341   return TRUE;
    23132342}
    23142343//******************************************************************************
     
    23602389
    23612390    fDestroyWindowCalled = TRUE;
    2362     return OSLibWinDestroyWindow(OS2HwndFrame);
     2391    return OSLibWinDestroyWindow(OS2Hwnd);
    23632392}
    23642393//******************************************************************************
     
    23732402HWND Win32BaseWindow::GetParent()
    23742403{
    2375  Win32BaseWindow *wndparent;
    2376 
    2377     if ((!(getStyle() & (WS_POPUP|WS_CHILD))))
    2378     {
    2379         return 0;
    2380     }
    2381     wndparent = ((getStyle() & WS_CHILD) ? getParent() : getOwner());
    2382 
    2383     return (wndparent) ? wndparent->getWindowHandle() : 0;
     2404  if(getStyle() & WS_CHILD) {
     2405        if(getParent()) {
     2406                return getParent()->getWindowHandle();
     2407        }
     2408        DebugInt3();
     2409        return 0;
     2410  }
     2411  else  return (getOwner()) ? getOwner()->getWindowHandle() : 0;
    23842412}
    23852413//******************************************************************************
     
    23902418 Win32BaseWindow *newparent;
    23912419 Win32BaseWindow *oldparent = (Win32BaseWindow *)ChildWindow::GetParent();
     2420 BOOL fShow = FALSE;
    23922421
    23932422   if(oldparent) {
     
    23972426   else oldhwnd = 0;
    23982427
     2428   /* Windows hides the window first, then shows it again
     2429    * including the WM_SHOWWINDOW messages and all */
     2430   if(fCreated && (getStyle() & WS_VISIBLE)) {
     2431        ShowWindow(SW_HIDE);
     2432        fShow = TRUE;
     2433   }
     2434
    23992435   newparent = GetWindowFromHandle(hwndNewParent);
    24002436   if(newparent)
     
    24022438        setParent(newparent);
    24032439        getParent()->AddChild(this);
    2404         OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle());
    2405         return oldhwnd;
     2440        OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle());
    24062441   }
    24072442   else {
    24082443        setParent(windowDesktop);
    24092444        windowDesktop->AddChild(this);
    2410         OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
    2411         return oldhwnd;
     2445        OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
    24122446   }
     2447   /* SetParent additionally needs to make hwndChild the topmost window
     2448      in the x-order and send the expected WM_WINDOWPOSCHANGING and
     2449      WM_WINDOWPOSCHANGED notification messages.
     2450   */
     2451   if(fCreated) {
     2452        SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0,
     2453                     SWP_NOMOVE|SWP_NOSIZE|(fShow? SWP_SHOWWINDOW : 0));
     2454
     2455   /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
     2456    * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */
     2457   }
     2458   return oldhwnd;
    24132459}
    24142460//******************************************************************************
     
    26012647                hwnd = OSLibWinQueryClientWindow(hwnd);
    26022648                if(hwnd)  wnd = GetWindowFromOS2Handle(hwnd);
    2603                 if(!hwnd) wnd = GetWindowFromOS2FrameHandle(hwnd);
    26042649            }
    26052650
     
    27032748
    27042749    dprintf(("SetActiveWindow %x", getWindowHandle()));
    2705     if(OSLibWinSetActiveWindow(OS2HwndFrame) == FALSE) {
    2706         dprintf(("OSLibWinSetActiveWindow %x returned FALSE!", OS2HwndFrame));
     2750    if(OSLibWinSetActiveWindow(OS2Hwnd) == FALSE) {
     2751        dprintf(("OSLibWinSetActiveWindow %x returned FALSE!", OS2Hwnd));
    27072752    }
    27082753    hwndActive = GetActiveWindow();
     
    27212766        SendMessageA(WM_CANCELMODE, 0, 0);
    27222767  }
    2723   OSLibWinEnableWindow(OS2HwndFrame, fEnable);
     2768  OSLibWinEnableWindow(OS2Hwnd, fEnable);
    27242769  if(fEnable == FALSE) {
    27252770        //SvL: No need to clear focus as PM already does this
     
    27352780BOOL Win32BaseWindow::CloseWindow()
    27362781{
    2737   return OSLibWinMinimizeWindow(OS2HwndFrame);
     2782  return OSLibWinMinimizeWindow(OS2Hwnd);
    27382783}
    27392784//******************************************************************************
     
    27562801BOOL Win32BaseWindow::IsWindowEnabled()
    27572802{
    2758     return OSLibWinIsWindowEnabled(OS2HwndFrame);
     2803    return OSLibWinIsWindowEnabled(OS2Hwnd);
    27592804}
    27602805//******************************************************************************
     
    27622807BOOL Win32BaseWindow::IsWindowVisible()
    27632808{
     2809    //TODO: Do we have to check the state of the parent window? (as Wine does)
    27642810#if 1
    27652811    return (dwStyle & WS_VISIBLE) == WS_VISIBLE;
    27662812#else
    2767     return OSLibWinIsWindowVisible(OS2HwndFrame);
     2813    return OSLibWinIsWindowVisible(OS2Hwnd);
    27682814#endif
    27692815}
     
    29002946                setStyle(ss.styleNew);
    29012947                SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss);
    2902 ////                OSLibSetWindowStyle(getOS2FrameWindowHandle(), getStyle(), getExStyle(),
     2948////                OSLibSetWindowStyle(getOS2WindowHandle(), getStyle(), getExStyle(),
    29032949////                                    windowClass->getStyle() & CS_SAVEBITS);
    29042950#ifdef DEBUG
     
    29613007        break;
    29623008    case GWL_HWNDPARENT:
    2963         if(getParent()) {
    2964             value = getParent()->getWindowHandle();
    2965         }
    2966         else value = 0;
     3009        value = GetParent();
    29673010        break;
    29683011    case GWL_ID:
     
    30293072}
    30303073//******************************************************************************
    3031 //Note: Should return NULL if window is frame window! (IsOS2FrameWindowHandle depends on this
    3032 //      behaviour)
    30333074//******************************************************************************
    30343075Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
     
    30533094//******************************************************************************
    30543095//******************************************************************************
    3055 Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
    3056 {
    3057     return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
    3058 }
    3059 //******************************************************************************
    3060 //******************************************************************************
    30613096HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd)
    30623097{
     
    30713106//******************************************************************************
    30723107//******************************************************************************
    3073 HWND Win32BaseWindow::Win32ToOS2FrameHandle(HWND hwnd)
    3074 {
    3075     Win32BaseWindow *window = GetWindowFromHandle(hwnd);
    3076 
    3077     if(window) {
    3078             return window->getOS2FrameWindowHandle();
    3079     }
    3080 //    dprintf2(("Win32BaseWindow::Win32ToOS2FrameHandle: not a win32 window %x", hwnd));
    3081     return hwnd;
    3082 }
    3083 //******************************************************************************
    3084 //******************************************************************************
    30853108HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd)
    30863109{
    30873110    Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd);
    30883111
    3089     if(window) {
    3090             return window->getWindowHandle();
    3091     }
    3092     window = GetWindowFromOS2FrameHandle(hwnd);
    30933112    if(window) {
    30943113            return window->getWindowHandle();
     
    30993118}
    31003119//******************************************************************************
    3101 //******************************************************************************
    3102 BOOL Win32BaseWindow::IsOS2FrameWindowHandle(HWND hwndWin32, HWND hwndOS2)
    3103 {
    3104  Win32BaseWindow *window = GetWindowFromHandle(hwndWin32);
    3105 
    3106     if(window->getOS2FrameWindowHandle() == hwndOS2) {
    3107         return TRUE;
    3108     }
    3109     return FALSE;
    3110 }
    3111 //******************************************************************************
    3112 // GetNextDlgTabItem32   (USER32.276)
    31133120//******************************************************************************
    31143121HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
  • trunk/src/user32/win32wbase.h

    r3610 r3662  
    1 /* $Id: win32wbase.h,v 1.96 2000-05-26 18:43:35 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.97 2000-06-07 14:51:31 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    104104virtual        ~Win32BaseWindow();
    105105
    106 virtual  ULONG  MsgCreate(HWND hwndFrame, HWND hwndClient);
     106virtual  ULONG  MsgCreate(HWND hwndOS2);
    107107         ULONG  MsgQuit();
    108108         ULONG  MsgClose();
     
    145145         HWND   getWindowHandle()               { return Win32Hwnd; };
    146146         HWND   getOS2WindowHandle()            { return OS2Hwnd; };
    147          HWND   getOS2FrameWindowHandle()       { return OS2HwndFrame; };
    148147 Win32WndClass *getWindowClass()                { return windowClass; };
    149148
     
    212211         BOOL   SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags);
    213212         BOOL   SetWindowPlacement(WINDOWPLACEMENT *winpos);
     213         BOOL   GetWindowPlacement(LPWINDOWPLACEMENT winpos);
    214214         BOOL   DestroyWindow();
    215215         HWND   SetActiveWindow();
     
    297297
    298298    static HWND Win32ToOS2Handle(HWND hwnd);
    299     static HWND Win32ToOS2FrameHandle(HWND hwnd);
    300299    static HWND OS2ToWin32Handle(HWND hwnd);
    301     static BOOL IsOS2FrameWindowHandle(HWND hwndWin32, HWND hwndOS2);
    302300
    303301static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
    304302static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
    305 static Win32BaseWindow *GetWindowFromOS2FrameHandle(HWND hwnd);
    306303
    307304    static void DestroyAll();
    308 
    309        PVOID getOldFrameProc() { return pOldFrameProc; };
    310        VOID  setOldFrameProc(PVOID aOldFrameProc) { pOldFrameProc = aOldFrameProc; };
    311 
    312        PVOID getOldWndProc() { return pOldWndProc; }
    313        VOID  setOldWndProc(PVOID aOldWndProc) { pOldWndProc = aOldWndProc; }
    314305
    315306protected:
     
    326317
    327318        HWND    OS2Hwnd;
    328         HWND    OS2HwndFrame;
    329319        HMENU   hSysMenu;
    330320        HWND    Win32Hwnd;
     
    371361        DWORD   dwThreadId;             //id of thread that created this window
    372362        DWORD   dwProcessId;            //id of process that created this window
    373         PVOID   pOldFrameProc;
    374 
    375         PVOID   pOldWndProc;
    376363
    377364   Win32BaseWindow *owner;
     
    385372        ULONG   nrUserWindowLong;
    386373
    387         RECT    rectWindow; //relative to screen
    388         RECT    rectClient;  //relative to parent
     374        RECT    rectWindow; //relative to parent
     375        RECT    rectClient;  //relative to frame
     376WINDOWPLACEMENT windowpos;
    389377
    390378    PROPERTY   *propertyList;
     
    405393#ifndef OS2_INCLUDED
    406394        void  GetMinMaxInfo(POINT *maxSize, POINT *maxPos, POINT *minTrack, POINT *maxTrack );
     395        UINT  MinMaximize(UINT cmd, LPRECT lpRect);
    407396        LONG  HandleWindowPosChanging(WINDOWPOS *winpos);
    408397        LONG  HandleNCActivate(WPARAM wParam);
  • trunk/src/user32/win32wbasenonclient.cpp

    r3625 r3662  
    1 /* $Id: win32wbasenonclient.cpp,v 1.23 2000-05-28 16:43:47 sandervl Exp $ */
     1/* $Id: win32wbasenonclient.cpp,v 1.24 2000-06-07 14:51:32 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2 (non-client methods)
     
    211211  }
    212212
    213   pt.x -= rectWindow.left;
    214   pt.y -= rectWindow.top;
    215   SCROLL_HandleScrollEvent(Win32Hwnd,0,MAKELONG(pt.x,pt.y),scrollbar,WM_LBUTTONDOWN);
     213  ScreenToClient(getWindowHandle(), &pt);
     214  pt.x += rectClient.left;
     215  pt.y += rectClient.top;
     216
     217  SCROLL_HandleScrollEvent(getWindowHandle(),0,MAKELONG(pt.x,pt.y),scrollbar,WM_LBUTTONDOWN);
    216218  if (GetCapture() != Win32Hwnd) return;
    217219  do
     
    224226        case WM_LBUTTONUP:
    225227        case WM_MOUSEMOVE:
    226             pt.x = msg.pt.x-rectWindow.left;
    227             pt.y = msg.pt.y-rectWindow.top;
     228            pt.x = msg.pt.x;
     229            pt.y = msg.pt.y;
     230            ScreenToClient(getWindowHandle(), &pt);
     231            pt.x += rectClient.left;
     232            pt.y += rectClient.top;
    228233            msg.lParam = MAKELONG(pt.x,pt.y);
    229234
     
    262267        {
    263268            //SvL: Calling topparent->SetActiveWindow() causes focus problems
    264             OSLibWinSetFocus(topparent->getOS2FrameWindowHandle());
     269//          topparent->SetActiveWindow();
     270            OSLibWinSetFocus(topparent->getOS2WindowHandle());
    265271        }
    266272
    267273        if (GetActiveWindow() == topparent->getWindowHandle())
    268274            SendInternalMessageA(WM_SYSCOMMAND,SC_MOVE+HTCAPTION,lParam);
     275        else dprintf(("ACtive window (%x) != toplevel wnd %x", OSLibWinQueryActiveWindow(), topparent->getWindowHandle()));
    269276        break;
    270277    }
     
    425432LONG Win32BaseWindow::HandleNCHitTest(POINT pt)
    426433{
    427   RECT rect = rectWindow;
     434  RECT rect;
    428435
    429436  if (dwStyle & WS_MINIMIZE) return HTCAPTION;
     437
     438  GetWindowRect(getWindowHandle(), &rect);
    430439
    431440  if (!PtInRect(&rect,pt)) return HTNOWHERE;
     
    10071016    //only redraw caption
    10081017    GetRgnBox(clip,&rectClip);
     1018#if 1
    10091019    //SvL: I'm getting paint problems when clipping a dc created in GetDCEx
    10101020    //     with a region that covers the entire window (RealPlayer 7 Update 1)
     
    10161026        rectClip = rect;
    10171027    }
     1028#endif
    10181029  }
    10191030  else
     
    11221133  }
    11231134
    1124   ReleaseDC(Win32Hwnd,hdc);
     1135  ReleaseDC(getWindowHandle(),hdc);
    11251136  IncreaseLogCount();
    11261137  dprintf(("**DoNCPaint %x DONE", getWindowHandle()));
     
    13051316
    13061317    case SC_TASKLIST:
    1307         OSLibWinShowTaskList(getOS2FrameWindowHandle());
     1318        OSLibWinShowTaskList(getOS2WindowHandle());
    13081319        break;
    13091320
  • trunk/src/user32/win32wbasepos.cpp

    r3625 r3662  
    1 /* $Id: win32wbasepos.cpp,v 1.14 2000-05-28 16:43:47 sandervl Exp $ */
     1/* $Id: win32wbasepos.cpp,v 1.15 2000-06-07 14:51:32 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2 (nonclient/position methods)
     
    3737#include "pmframe.h"
    3838#include "win32wdesktop.h"
     39#include <win\hook.h>
    3940
    4041#define DBG_LOCALLOG    DBG_win32wbasepos
     
    130131   LONG result;
    131132
    132    params.rgrc[0] = *newWindowRect;
    133    if (calcValidRect)
    134    {
    135         winposCopy = *winpos;
    136         params.rgrc[1] = *oldWindowRect;
    137         if(getParent()) {//in parent coordinates
    138             MapWindowPoints(getWindowHandle(), getParent()->getWindowHandle(), (POINT *)oldClientRect, 2);
    139         }
    140         else {//in screen coordinates (just add window rectangle origin (already in screen coordinates))
    141             OffsetRect(oldClientRect, rectWindow.left, rectWindow.top);
    142         }
    143         params.rgrc[2] = *oldClientRect;
    144         params.lppos = &winposCopy;
    145    }
    146    result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect, (LPARAM)&params );
    147 
    148    /* If the application send back garbage, ignore it */
    149    if (params.rgrc[0].left <= params.rgrc[0].right && params.rgrc[0].top <= params.rgrc[0].bottom)
    150    {
    151         *newClientRect = params.rgrc[0];
    152         //client rectangle now in screen coordinates; convert to 'frame' coordinates
    153         OffsetRect(newClientRect, -rectWindow.left, -rectWindow.top);
    154    }
    155 
     133   /* Send WM_NCCALCSIZE message to get new client area */
     134//   if((winpos->flags & (SWP_FRAMECHANGED | SWP_NOSIZE)) != SWP_NOSIZE )
     135//   {
     136        params.rgrc[0] = *newWindowRect;
     137        if(calcValidRect)
     138        {
     139                winposCopy = *winpos;
     140                params.rgrc[1] = *oldWindowRect;
     141                //client rectangel must be in parent coordinates
     142                OffsetRect(oldClientRect, rectWindow.left, rectWindow.top);
     143
     144                params.rgrc[2] = *oldClientRect;
     145                params.lppos = &winposCopy;
     146        }
     147        result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect, (LPARAM)&params );
     148
     149        /* If the application send back garbage, ignore it */
     150        if(params.rgrc[0].left <= params.rgrc[0].right && params.rgrc[0].top <= params.rgrc[0].bottom)
     151        {
     152                *newClientRect = params.rgrc[0];
     153                //client rectangle now in parent coordinates; convert to 'frame' coordinates
     154                OffsetRect(newClientRect, -rectWindow.left, -rectWindow.top);
     155        }
     156
     157        /* FIXME: WVR_ALIGNxxx */
     158        if(newClientRect->left != rectClient.left || newClientRect->top  != rectClient.top)
     159           winpos->flags &= ~SWP_NOCLIENTMOVE;
     160
     161        if((newClientRect->right - newClientRect->left != rectClient.right - rectClient.left) ||
     162           (newClientRect->bottom - newClientRect->top != rectClient.bottom - rectClient.top))
     163             winpos->flags &= ~SWP_NOCLIENTSIZE;
     164
     165//   }
     166//   else
     167//   if(!(winpos->flags & SWP_NOMOVE) &&
     168//       (newClientRect->left != rectClient.left || newClientRect->top != rectClient.top)) {
     169//            winpos->flags &= ~SWP_NOCLIENTMOVE;
     170//   }
    156171   return result;
    157172}
     
    175190    return 0;
    176191}
     192/******************************************************************************
     193 *           WINPOS_MinMaximize
     194 *
     195 * Fill in lpRect and return additional flags to be used with SetWindowPos().
     196 * This function assumes that 'cmd' is different from the current window
     197 * state.
     198 */
     199UINT Win32BaseWindow::MinMaximize(UINT cmd, LPRECT lpRect)
     200{
     201    UINT swpFlags = 0;
     202    POINT size;
     203
     204    size.x = rectWindow.left;
     205    size.y = rectWindow.top;
     206
     207    if(IsRectEmpty(&windowpos.rcNormalPosition)) {
     208        CopyRect(&windowpos.rcNormalPosition, &rectWindow);
     209    }
     210    if(!HOOK_CallHooksA(WH_CBT, HCBT_MINMAX, getWindowHandle(), cmd))
     211    {
     212        if(getStyle() & WS_MINIMIZE )
     213        {
     214            if(!SendInternalMessageA(WM_QUERYOPEN, 0, 0L))
     215                return (SWP_NOSIZE | SWP_NOMOVE);
     216        }
     217        switch( cmd )
     218        {
     219            case SW_MINIMIZE:
     220                if( getStyle() & WS_MAXIMIZE)
     221                {
     222                        setFlags(getFlags() | WIN_RESTORE_MAX);
     223                        setStyle(getStyle() & ~WS_MAXIMIZE);
     224                }
     225                else    setFlags(getFlags() & ~WIN_RESTORE_MAX);
     226
     227                setStyle(getStyle() | WS_MINIMIZE);
     228
     229                SetRect(lpRect, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
     230                        GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) );
     231                break;
     232
     233            case SW_MAXIMIZE:
     234                GetMinMaxInfo(&size, &windowpos.ptMaxPosition, NULL, NULL );
     235
     236                if(getStyle() & WS_MINIMIZE )
     237                {
     238                     setStyle(getStyle() & ~WS_MINIMIZE);
     239                }
     240                setStyle(getStyle() | WS_MAXIMIZE);
     241
     242                SetRect(lpRect, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y,
     243                        size.x, size.y );
     244                break;
     245
     246            case SW_RESTORE:
     247                if(getStyle() & WS_MINIMIZE)
     248                {
     249                        setStyle(getStyle() & ~WS_MINIMIZE);
     250
     251                        if( getFlags() & WIN_RESTORE_MAX)
     252                        {
     253                                /* Restore to maximized position */
     254                                GetMinMaxInfo(&size, &windowpos.ptMaxPosition, NULL, NULL);
     255                                setStyle(getStyle() | WS_MAXIMIZE);
     256                                SetRect(lpRect, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y, size.x, size.y);
     257                                break;
     258                        }
     259                }
     260                else
     261                if( !(getStyle() & WS_MAXIMIZE) )
     262                        return 0;
     263                else    setStyle(getStyle() & ~WS_MAXIMIZE);
     264
     265                /* Restore to normal position */
     266
     267                *lpRect = windowpos.rcNormalPosition;
     268                lpRect->right -= lpRect->left;
     269                lpRect->bottom -= lpRect->top;
     270                break;
     271        }
     272    }
     273    else swpFlags |= SWP_NOSIZE | SWP_NOMOVE;
     274
     275    return swpFlags;
     276}
    177277//******************************************************************************
    178278//******************************************************************************
    179 
  • trunk/src/user32/win32wdesktop.cpp

    r2803 r3662  
    1 /* $Id: win32wdesktop.cpp,v 1.12 2000-02-16 14:28:24 sandervl Exp $ */
     1/* $Id: win32wdesktop.cpp,v 1.13 2000-06-07 14:51:33 sandervl Exp $ */
    22/*
    33 * Win32 Desktop Window for OS/2
     
    4646Win32Desktop::Win32Desktop() : Win32BaseWindow(OBJTYPE_WINDOW)
    4747{
    48   OSLibWinQueryWindowRect(OSLIB_HWND_DESKTOP, &rectWindow, RELATIVE_TO_SCREEN);
     48  rectWindow.left   = 0;
     49  rectWindow.top    = 0;
     50  rectWindow.right  = OSLibQueryScreenWidth();
     51  rectWindow.bottom = OSLibQueryScreenHeight();
     52
    4953  OS2Hwnd      = OSLIB_HWND_DESKTOP;
    50   OS2HwndFrame = OSLIB_HWND_DESKTOP;
    5154  rectClient   = rectWindow;
    5255
  • trunk/src/user32/win32wmdiclient.cpp

    r3625 r3662  
    1 /* $Id: win32wmdiclient.cpp,v 1.28 2000-05-28 16:43:47 sandervl Exp $ */
     1/* $Id: win32wmdiclient.cpp,v 1.29 2000-06-07 14:51:33 sandervl Exp $ */
    22/*
    33 * Win32 MDI Client Window Class for OS/2
     
    985985    SetRectEmpty( &childRect );
    986986
     987    //TODO: Check if this goes correctly
    987988    for (win32wnd = (Win32BaseWindow*)win32wnd->getFirstChild();win32wnd;win32wnd = (Win32BaseWindow*)win32wnd->getNextChild())
    988989    {
  • trunk/src/user32/window.cpp

    r3513 r3662  
    1 /* $Id: window.cpp,v 1.67 2000-05-10 13:14:44 sandervl Exp $ */
     1/* $Id: window.cpp,v 1.68 2000-06-07 14:51:33 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    77 * Copyright 2000 Christoph Bratschi (cbratschi@datacomm.ch)
    88 *
    9  * Parts based on Wine Windows code (windows\win.c, windows\property.c)
     9 * Parts based on Wine Windows code (windows\win.c, windows\property.c, windows\winpos.c)
    1010 *
    11  * Copyright 1993, 1994 Alexandre Julliard
     11 * Copyright 1993, 1994, 1995 Alexandre Julliard
     12 *           1995, 1996, 1999 Alex Korobka
    1213 *
    1314 * Project Odin Software License can be found in LICENSE.TXT
     
    445446{
    446447    return SetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE );
     448}
     449/***********************************************************************
     450 *           SetInternalWindowPos   (USER32.483)
     451 */
     452void WIN32API SetInternalWindowPos(HWND    hwnd,
     453                                   UINT    showCmd,
     454                                   LPRECT  lpRect,
     455                                   LPPOINT lpPoint )
     456{
     457    dprintf(("USER32: SetInternalWindowPos(%08xh,%08xh,%08xh,%08xh)",
     458           hwnd, showCmd, lpRect, lpPoint));
     459
     460    if( IsWindow(hwnd) )
     461    {
     462        WINDOWPLACEMENT wndpl;
     463        UINT flags;
     464
     465        GetWindowPlacement(hwnd, &wndpl);
     466        wndpl.length  = sizeof(wndpl);
     467        wndpl.showCmd = showCmd;
     468        wndpl.flags = 0;
     469
     470        if(lpPoint)
     471        {
     472            wndpl.flags |= WPF_SETMINPOSITION;
     473            wndpl.ptMinPosition = *lpPoint;
     474        }
     475        if(lpRect)
     476        {
     477            wndpl.rcNormalPosition = *lpRect;
     478        }
     479        SetWindowPlacement( hwnd, &wndpl);
     480    }
     481
     482}
     483/***********************************************************************
     484 *           GetInternalWindowPos   (USER32.245)
     485 */
     486UINT WIN32API GetInternalWindowPos(HWND    hwnd,
     487                                   LPRECT  rectWnd,
     488                                   LPPOINT ptIcon )
     489{
     490    WINDOWPLACEMENT wndpl;
     491
     492    dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
     493             hwnd,
     494             rectWnd,
     495             ptIcon));
     496
     497    if(GetWindowPlacement( hwnd, &wndpl ))
     498    {
     499        if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
     500        if (ptIcon)  *ptIcon = wndpl.ptMinPosition;
     501        return wndpl.showCmd;
     502    }
     503    return 0;
    447504}
    448505//******************************************************************************
     
    519576        dprintf(("SetWindowPlacement, window %x not found", hwnd));
    520577        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    521         return 0;
    522     }
     578        return FALSE;
     579    }
     580    if(!winpos) {
     581        dprintf(("SetWindowPlacement %x invalid parameter", hwnd));
     582        SetLastError(ERROR_INVALID_PARAMETER);
     583        return FALSE;
     584    }
     585    dprintf(("USER32: SetWindowPlacement %x %x", hwnd, winpos));
    523586    return window->SetWindowPlacement((WINDOWPLACEMENT *)winpos);
    524587}
    525588//******************************************************************************
    526589//******************************************************************************
    527 BOOL WIN32API GetWindowPlacement(HWND hwnd, LPWINDOWPLACEMENT arg2)
    528 {
    529     dprintf(("USER32:  GetWindowPlacement\n"));
    530     return O32_GetWindowPlacement(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd), arg2);
     590BOOL WIN32API GetWindowPlacement(HWND hwnd, LPWINDOWPLACEMENT winpos)
     591{
     592  Win32BaseWindow *window;
     593
     594    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     595    if(!window) {
     596        dprintf(("GetWindowPlacement, window %x not found", hwnd));
     597        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     598        return FALSE;
     599    }
     600    if(!winpos) {
     601        dprintf(("GetWindowPlacement %x invalid parameter", hwnd));
     602        SetLastError(ERROR_INVALID_PARAMETER);
     603        return FALSE;
     604    }
     605    dprintf(("USER32: GetWindowPlacement %x %x", hwnd, winpos));
     606    return window->GetWindowPlacement(winpos);
    531607}
    532608//******************************************************************************
     
    609685//******************************************************************************
    610686//******************************************************************************
    611 /***********************************************************************
    612  *           GetInternalWindowPos   (USER32.245)
    613  */
    614 UINT WIN32API GetInternalWindowPos(HWND    hwnd,
    615                                    LPRECT  rectWnd,
    616                                    LPPOINT ptIcon )
    617 {
    618     WINDOWPLACEMENT wndpl;
    619 
    620     dprintf(("USER32: GetInternalWindowPos(%08xh,%08xh,%08xh)\n",
    621              hwnd,
    622              rectWnd,
    623              ptIcon));
    624 
    625     if (GetWindowPlacement( hwnd, &wndpl ))
    626     {
    627         if (rectWnd) *rectWnd = wndpl.rcNormalPosition;
    628         if (ptIcon)  *ptIcon = wndpl.ptMinPosition;
    629         return wndpl.showCmd;
    630     }
    631     return 0;
    632 }
    633 //******************************************************************************
    634 //******************************************************************************
    635687BOOL WIN32API IsZoomed(HWND hwnd)
    636688{
    637689    dprintf(("USER32:  IsZoomed\n"));
    638     return O32_IsZoomed(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd));
     690    return O32_IsZoomed(Win32BaseWindow::Win32ToOS2Handle(hwnd));
    639691}
    640692//******************************************************************************
     
    643695{
    644696    dprintf(("USER32:  LockWindowUpdate\n"));
    645     return O32_LockWindowUpdate(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd));
     697    return O32_LockWindowUpdate(Win32BaseWindow::Win32ToOS2Handle(hwnd));
    646698}
    647699//******************************************************************************
     
    665717        return FALSE;
    666718    }
    667     *pRect = *window->getWindowRect(); //always in screen coordinates
     719    *pRect = *window->getWindowRect();
     720
     721    //convert from parent coordinates to screen (if necessary)
     722    if(window->getParent()) {
     723         MapWindowPoints(window->getParent()->getWindowHandle(), 0, (PPOINT)pRect, 2);
     724    }
    668725
    669726    dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
     
    862919/* Coordinate Space and Transformation Functions */
    863920//******************************************************************************
     921/*******************************************************************
     922 *         WINPOS_GetWinOffset
     923 *
     924 * Calculate the offset between the origin of the two windows. Used
     925 * to implement MapWindowPoints.
     926 */
     927static void WINPOS_GetWinOffset( Win32BaseWindow *wndFrom, Win32BaseWindow *wndTo,
     928                                 POINT *offset )
     929{
     930 Win32BaseWindow *window;
     931
     932    offset->x = offset->y = 0;
     933
     934    /* Translate source window origin to screen coords */
     935    if(wndFrom != windowDesktop)
     936    {
     937        window = wndFrom;
     938        while(window)
     939        {
     940            offset->x += window->getClientRectPtr()->left + window->getWindowRect()->left;
     941            offset->y += window->getClientRectPtr()->top + window->getWindowRect()->top;
     942            window = window->getParent();
     943        }
     944    }
     945
     946    /* Translate origin to destination window coords */
     947    if(wndTo != windowDesktop)
     948    {
     949        window = wndTo;
     950        while(window)
     951        {
     952            offset->x -= window->getClientRectPtr()->left + window->getWindowRect()->left;
     953            offset->y -= window->getClientRectPtr()->top + window->getWindowRect()->top;
     954            window = window->getParent();
     955        }
     956    }
     957}
     958//******************************************************************************
     959//******************************************************************************
    864960int WIN32API MapWindowPoints(HWND hwndFrom, HWND hwndTo, LPPOINT lpPoints,
    865961                             UINT cPoints)
     
    867963 Win32BaseWindow *wndfrom, *wndto;
    868964 int retval = 0;
    869  OSLIBPOINT point;
     965 POINT offset;
    870966
    871967    SetLastError(0);
     
    899995        return 0; //nothing to do
    900996
    901     dprintf(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
    902     point.x = lpPoints->x;
    903     point.y = lpPoints->y;
    904     if (!mapWin32Point(wndfrom,wndto,&point))
    905     {
    906         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    907         return 0;
    908     }
    909 
    910     short int xinc = point.x - lpPoints->x;
    911     short int yinc = point.y - lpPoints->y;
     997    dprintf2(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
     998    WINPOS_GetWinOffset(wndfrom, wndto, &offset);
    912999
    9131000    for(int i=0;i<cPoints;i++)
    9141001    {
    915         lpPoints[i].x += xinc;
    916         lpPoints[i].y += yinc;
    917     }
    918     retval = ((LONG)yinc << 16) | xinc;
     1002        lpPoints[i].x += offset.x;
     1003        lpPoints[i].y += offset.y;
     1004    }
     1005    retval = ((LONG)offset.y << 16) | offset.x;
    9191006    return retval;
    9201007}
     
    9271014    BOOL rc;
    9281015
    929     if (!hwnd) return (TRUE);
     1016    if(!hwnd) {
     1017        return (TRUE);
     1018    }
    9301019    wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
    9311020    if (!wnd) {
     
    9381027    POINT tmp = *pt;
    9391028#endif
    940     rc = mapWin32Point(OSLIB_HWND_DESKTOP, wnd->getOS2WindowHandle(), (OSLIBPOINT*)pt);
    941     dprintf(("ScreenToClient %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
    942     return rc;
     1029    MapWindowPoints(0, hwnd, pt, 1);
     1030    dprintf2(("ScreenToClient %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
     1031    return TRUE;
    9431032}
    9441033//******************************************************************************
     
    10491138    Win32BaseWindow *wnd;
    10501139    PRECT rcl;
    1051     BOOL rc;
    10521140
    10531141    if (!hwnd) {
     
    10641152    POINT tmp = *pt;
    10651153#endif
    1066     rc = mapWin32Point(wnd->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,(OSLIBPOINT*)pt);
    1067     dprintf(("ClientToScreen %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
    1068 
    1069     return rc;
     1154    MapWindowPoints(hwnd, 0, pt, 1);
     1155    dprintf2(("ClientToScreen %x (%d,%d) -> (%d,%d)", hwnd, tmp.x, tmp.y, pt->x, pt->y));
     1156
     1157    return TRUE;
    10701158}
    10711159//******************************************************************************
     
    13971485{
    13981486    dprintf(("USER32:  ArrangeIconicWindows %x", hwnd));
    1399     return O32_ArrangeIconicWindows(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd));
     1487    return O32_ArrangeIconicWindows(Win32BaseWindow::Win32ToOS2Handle(hwnd));
    14001488}
    14011489//******************************************************************************
     
    14161504{
    14171505    dprintf(("USER32:  ShowOwnedPopups (OPEN32: todo) %x", hwnd));
    1418     return O32_ShowOwnedPopups(Win32BaseWindow::Win32ToOS2FrameHandle(hwnd), arg2);
     1506    return O32_ShowOwnedPopups(Win32BaseWindow::Win32ToOS2Handle(hwnd), arg2);
    14191507}
    14201508//******************************************************************************
Note: See TracChangeset for help on using the changeset viewer.