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

Major rewrite: frame/client -> frame

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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)
Note: See TracChangeset for help on using the changeset viewer.