Changeset 4497 for trunk/src


Ignore:
Timestamp:
Oct 18, 2000, 7:10:50 PM (25 years ago)
Author:
sandervl
Message:

Get/SetWindowPlacement fixes

Location:
trunk/src/user32
Files:
2 edited

Legend:

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

    r4485 r4497  
    1 /* $Id: win32wbase.cpp,v 1.217 2000-10-16 11:02:50 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.218 2000-10-18 17:10:49 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    157157
    158158  memset(&windowpos, 0, sizeof(windowpos));
     159  //min and max position are initially -1 (verified in NT4, SP6)
     160  windowpos.ptMinPosition.x = -1;
     161  windowpos.ptMinPosition.y = -1;
     162  windowpos.ptMaxPosition.x = -1;
     163  windowpos.ptMaxPosition.y = -1;
    159164}
    160165//******************************************************************************
     
    164169{
    165170    if(hTaskList) {
    166         OSLibWinRemoveFromTasklist(hTaskList);
     171    OSLibWinRemoveFromTasklist(hTaskList);
    167172    }
    168173
     
    380385        SetParent(cs->hwndParent);
    381386//        owner = GetWindowFromHandle(cs->hwndParent);
    382         owner = 0;
     387    owner = 0;
    383388/*        if(owner == NULL)
    384389        {
     
    652657
    653658  if(fTaskList) {
    654         hTaskList = OSLibWinAddToTaskList(OS2Hwnd, windowNameA, (cs->style & WS_VISIBLE) ? 1 : 0);
     659    hTaskList = OSLibWinAddToTaskList(OS2Hwnd, windowNameA, (cs->style & WS_VISIBLE) ? 1 : 0);
    655660  }
    656661
     
    700705                if(getParent() && getParent()->IsWindowDestroyed() == FALSE)
    701706                {
    702                         getParent()->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle());
    703                 }
     707                    getParent()->SendInternalMessageA(WM_PARENTNOTIFY, MAKEWPARAM(WM_CREATE, getWindowId()), (LPARAM)getWindowHandle());
     708        }
    704709                if(!::IsWindow(getWindowHandle()))
    705710                {
     
    710715
    711716            if(cs->style & WS_VISIBLE) {
    712                 dwStyle &= ~WS_VISIBLE;
    713                 ShowWindow(sw);
     717        dwStyle &= ~WS_VISIBLE;
     718        ShowWindow(sw);
    714719            }
    715720
     
    870875    if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate)
    871876    {
    872         dprintf(("WARNING: WM_NCACTIVATE return code = FALSE -> cancel processing"));
     877    dprintf(("WARNING: WM_NCACTIVATE return code = FALSE -> cancel processing"));
    873878        return 0;
    874879    }
     
    10821087  if(lpWndPos)
    10831088  {
    1084         //set new window rectangle
    1085         setWindowRect(lpWndPos->x, lpWndPos->y, lpWndPos->x+lpWndPos->cx,
     1089        //set new window rectangle
     1090        setWindowRect(lpWndPos->x, lpWndPos->y, lpWndPos->x+lpWndPos->cx,
    10861091                      lpWndPos->y+lpWndPos->cy);
    1087         newWindowRect = rectWindow;
     1092        newWindowRect = rectWindow;
    10881093  }
    10891094  else {
    1090         wndPos.hwnd  = getWindowHandle();
    1091         wndPos.hwndInsertAfter = 0;
    1092         newWindowRect= rectWindow;
    1093         wndPos.x     = newWindowRect.left;
    1094         wndPos.y     = newWindowRect.top;
    1095         wndPos.cx    = newWindowRect.right - newWindowRect.left;
    1096         wndPos.cy    = newWindowRect.bottom - newWindowRect.top;
    1097         wndPos.flags = SWP_FRAMECHANGED;
    1098         lpWndPos     = &wndPos;
     1095        wndPos.hwnd  = getWindowHandle();
     1096        wndPos.hwndInsertAfter = 0;
     1097        newWindowRect= rectWindow;
     1098        wndPos.x     = newWindowRect.left;
     1099        wndPos.y     = newWindowRect.top;
     1100        wndPos.cx    = newWindowRect.right - newWindowRect.left;
     1101        wndPos.cy    = newWindowRect.bottom - newWindowRect.top;
     1102        wndPos.flags = SWP_FRAMECHANGED;
     1103        lpWndPos     = &wndPos;
    10991104  }
    11001105
     
    11051110
    11061111#if 1
    1107 //this doesn't always work 
    1108 //  if(!fNoSizeMsg && (client.left != rectClient.left || client.top != rectClient.top)) 
    1109   if(!fNoSizeMsg && ((oldWindowRect.right - oldWindowRect.left < rectClient.left 
     1112//this doesn't always work
     1113//  if(!fNoSizeMsg && (client.left != rectClient.left || client.top != rectClient.top))
     1114  if(!fNoSizeMsg && ((oldWindowRect.right - oldWindowRect.left < rectClient.left
    11101115                  || oldWindowRect.bottom - oldWindowRect.top < rectClient.top) ||
    11111116     (EqualRect(&oldWindowRect, &rectWindow) && (client.left != rectClient.left || client.top != rectClient.top))))
     
    11131118   Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild();
    11141119
    1115         //client rectangle has moved -> inform children
    1116         dprintf(("MsgFormatFrame -> client rectangle has changed, move children"));
    1117         while(child) {
    1118                 ::SetWindowPos(child->getWindowHandle(),
    1119                                HWND_TOP, child->getWindowRect()->left, 
    1120                                child->getWindowRect()->top, 0, 0, 
     1120    //client rectangle has moved -> inform children
     1121    dprintf(("MsgFormatFrame -> client rectangle has changed, move children"));
     1122    while(child) {
     1123        ::SetWindowPos(child->getWindowHandle(),
     1124                               HWND_TOP, child->getWindowRect()->left,
     1125                               child->getWindowRect()->top, 0, 0,
    11211126                               SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOZORDER);
    1122                 child = (Win32BaseWindow *)child->getNextChild();
    1123         }
     1127        child = (Win32BaseWindow *)child->getNextChild();
     1128    }
    11241129  }
    11251130#endif
     
    13471352          HandleNCPaint((HRGN)1);
    13481353          if(hTaskList) {
    1349                 OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
    1350           }
     1354        OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
     1355      }
    13511356        }
    13521357
     
    14051410
    14061411    case WM_ACTIVATE:
    1407         /* The default action in Windows is to set the keyboard focus to
    1408         * the window, if it's being activated and not minimized */
    1409         if (LOWORD(wParam) != WA_INACTIVE) {
    1410                 if(!(getStyle() & WS_MINIMIZE))
    1411                         SetFocus(getWindowHandle());
    1412         }
    1413         return 0;
     1412    /* The default action in Windows is to set the keyboard focus to
     1413    * the window, if it's being activated and not minimized */
     1414        if (LOWORD(wParam) != WA_INACTIVE) {
     1415        if(!(getStyle() & WS_MINIMIZE))
     1416            SetFocus(getWindowHandle());
     1417        }
     1418        return 0;
    14141419
    14151420    case WM_SETCURSOR:
     
    18101815          HandleNCPaint((HRGN)1);
    18111816          if(hTaskList) {
    1812                 OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
    1813           }
     1817        OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
     1818      }
    18141819        }
    18151820
     
    18811886                if (getParent())
    18821887                {
    1883                         POINTS pt = MAKEPOINTS(lParam);
    1884                         POINT point;
    1885 
    1886                         point.x = pt.x;
    1887                         point.y = pt.y;
    1888                         MapWindowPoints(getWindowHandle(), getParent()->getWindowHandle(), &point, 1);
    1889                         NotifyParent(Msg,wParam,MAKELPARAM(point.x,point.y));
     1888                    POINTS pt = MAKEPOINTS(lParam);
     1889                    POINT point;
     1890
     1891                    point.x = pt.x;
     1892                    point.y = pt.y;
     1893            MapWindowPoints(getWindowHandle(), getParent()->getWindowHandle(), &point, 1);
     1894                    NotifyParent(Msg,wParam,MAKELPARAM(point.x,point.y));
    18901895                }
    18911896                rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam);
     
    19871992            if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
    19881993            {
    1989 
    19901994                if(type == BROADCAST_SEND) {
    19911995                        ::SendMessageA(window->getWindowHandle(), msg, wParam, lParam);
     
    20122016            if ((window->getStyle() & WS_POPUP) || ((window->getStyle() & WS_CAPTION) == WS_CAPTION))
    20132017            {
    2014 
    20152018                if(type == BROADCAST_SEND) {
    20162019                        ::SendMessageW(window->getWindowHandle(), msg, wParam, lParam);
     
    20542057  if (fType == ICON_BIG)
    20552058  {
    2056     if (hIcon) hWndIcon = hIcon;
    2057     else if (windowClass && windowClass->getIcon()) hWndIcon = windowClass->getIcon();
    2058     else if (!(dwStyle & DS_MODALFRAME))
    2059       hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR);
     2059    if (hIcon)
     2060        hWndIcon = hIcon;
     2061    else
     2062    if (windowClass && windowClass->getIcon())
     2063        hWndIcon = windowClass->getIcon();
     2064    else
     2065    if (!(dwStyle & DS_MODALFRAME))
     2066         hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR);
    20602067    else hWndIcon = 0;
    2061   } else
     2068  }
     2069  else
    20622070  {
    2063     if (hIconSm) hWndIcon = hIconSm;
    2064     else if (hIcon) hWndIcon = hIcon;
    2065     else if (windowClass && windowClass->getIconSm()) hWndIcon = windowClass->getIconSm();
    2066     else if (windowClass && windowClass->getIcon()) hWndIcon = windowClass->getIcon();
    2067     else if (!(dwStyle & DS_MODALFRAME))
    2068       hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR);
     2071    if (hIconSm)
     2072        hWndIcon = hIconSm;
     2073    else
     2074    if (hIcon)
     2075        hWndIcon = hIcon;
     2076    else
     2077    if (windowClass && windowClass->getIconSm())
     2078        hWndIcon = windowClass->getIconSm();
     2079    else
     2080    if (windowClass && windowClass->getIcon())
     2081        hWndIcon = windowClass->getIcon();
     2082    else
     2083    if (!(dwStyle & DS_MODALFRAME))
     2084         hWndIcon = LoadImageA(0,MAKEINTRESOURCEA(OIC_ODINICON),IMAGE_ICON,0,0,LR_DEFAULTCOLOR);
    20692085    else hWndIcon = 0;
    20702086  }
     
    20862102    switch(nCmdShow)
    20872103    {
    2088         case SW_HIDE:
    2089             if (!wasVisible) goto END;
    2090             swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE |
    2091                    SWP_NOACTIVATE | SWP_NOZORDER;
    2092             break;
    2093 
    2094         case SW_SHOWMINNOACTIVE:
     2104    case SW_HIDE:
     2105        if (!wasVisible) goto END;
     2106            swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE |
     2107        SWP_NOACTIVATE | SWP_NOZORDER;
     2108        break;
     2109
     2110    case SW_SHOWMINNOACTIVE:
     2111        swp |= SWP_NOACTIVATE | SWP_NOZORDER;
     2112        /* fall through */
     2113    case SW_SHOWMINIMIZED:
     2114        swp |= SWP_SHOWWINDOW;
     2115        /* fall through */
     2116    case SW_MINIMIZE:
     2117        swp |= SWP_FRAMECHANGED;
     2118        if( !(getStyle() & WS_MINIMIZE) )
     2119             swp |= MinMaximize(SW_MINIMIZE, &newPos );
     2120        else swp |= SWP_NOSIZE | SWP_NOMOVE;
     2121        break;
     2122
     2123    case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
     2124            swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
     2125            if( !(getStyle() & WS_MAXIMIZE) )
     2126         swp |= MinMaximize(SW_MAXIMIZE, &newPos );
     2127            else swp |= SWP_NOSIZE | SWP_NOMOVE;
     2128            break;
     2129
     2130    case SW_SHOWNA:
    20952131            swp |= SWP_NOACTIVATE | SWP_NOZORDER;
    20962132            /* fall through */
    2097         case SW_SHOWMINIMIZED:
    2098             swp |= SWP_SHOWWINDOW;
    2099             /* fall through */
    2100         case SW_MINIMIZE:
    2101             swp |= SWP_FRAMECHANGED;
    2102             if( !(getStyle() & WS_MINIMIZE) )
    2103                  swp |= MinMaximize(SW_MINIMIZE, &newPos );
    2104             else swp |= SWP_NOSIZE | SWP_NOMOVE;
    2105             break;
    2106 
    2107         case SW_SHOWMAXIMIZED: /* same as SW_MAXIMIZE */
    2108             swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
    2109             if( !(getStyle() & WS_MAXIMIZE) )
    2110                  swp |= MinMaximize(SW_MAXIMIZE, &newPos );
    2111             else swp |= SWP_NOSIZE | SWP_NOMOVE;
    2112             break;
    2113 
    2114         case SW_SHOWNA:
    2115             swp |= SWP_NOACTIVATE | SWP_NOZORDER;
    2116             /* fall through */
    2117         case SW_SHOW:
    2118             swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
    2119 
    2120             /*
    2121              * ShowWindow has a little peculiar behavior that if the
    2122              * window is already the topmost window, it will not
    2123              * activate it.
    2124              */
    2125             if (::GetTopWindow((HWND)0)==getWindowHandle() && (wasVisible || GetActiveWindow() == getWindowHandle()))
    2126               swp |= SWP_NOACTIVATE;
    2127 
    2128             break;
    2129 
    2130         case SW_SHOWNOACTIVATE:
    2131             swp |= SWP_NOZORDER;
    2132             if (GetActiveWindow()) swp |= SWP_NOACTIVATE;
    2133             /* fall through */
    2134         case SW_SHOWNORMAL:  /* same as SW_NORMAL: */
    2135         case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
    2136         case SW_RESTORE:
    2137             //TODO: WIN_RESTORE_MAX flag!!!!!!!!!!!!!!
    2138             swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
    2139 
    2140             if( getStyle() & (WS_MINIMIZE | WS_MAXIMIZE) )
    2141                  swp |= MinMaximize(SW_RESTORE, &newPos );
    2142             else swp |= SWP_NOSIZE | SWP_NOMOVE;
    2143             break;
     2133    case SW_SHOW:
     2134        swp |= SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
     2135
     2136        /*
     2137         * ShowWindow has a little peculiar behavior that if the
     2138         * window is already the topmost window, it will not
     2139         * activate it.
     2140         */
     2141        if (::GetTopWindow((HWND)0)==getWindowHandle() && (wasVisible || GetActiveWindow() == getWindowHandle()))
     2142            swp |= SWP_NOACTIVATE;
     2143
     2144        break;
     2145
     2146    case SW_SHOWNOACTIVATE:
     2147        swp |= SWP_NOZORDER;
     2148        if (GetActiveWindow())
     2149            swp |= SWP_NOACTIVATE;
     2150        /* fall through */
     2151    case SW_SHOWNORMAL:  /* same as SW_NORMAL: */
     2152    case SW_SHOWDEFAULT: /* FIXME: should have its own handler */
     2153    case SW_RESTORE:
     2154         //TODO: WIN_RESTORE_MAX flag!!!!!!!!!!!!!!
     2155         swp |= SWP_SHOWWINDOW | SWP_FRAMECHANGED;
     2156
     2157         if( getStyle() & (WS_MINIMIZE | WS_MAXIMIZE) )
     2158              swp |= MinMaximize(SW_RESTORE, &newPos );
     2159         else swp |= SWP_NOSIZE | SWP_NOMOVE;
     2160         break;
    21442161    }
    21452162
     
    21582175
    21592176    if(!(swp & SWP_NOACTIVATE)) {
    2160         OSLibWinSetActiveWindow(OS2Hwnd);
     2177    OSLibWinSetActiveWindow(OS2Hwnd);
    21612178    }
    21622179
     
    22562273        {
    22572274            if(!getParent()) {
    2258                 dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
     2275                dprintf(("WARNING: Win32BaseWindow::SetWindowPos window %x is child but has no parent!!", getWindowHandle()));
    22592276            }
    22602277        }
     
    22672284                                 getParent()->getClientRectPtr()->top,
    22682285                                 OS2Hwnd);
    2269     } 
     2286    }
    22702287    else  OSLibMapWINDOWPOStoSWP(&wpos, &swp, &swpOld, OSLibQueryScreenHeight(), 0, 0, OS2Hwnd);
    22712288    if (swp.fl == 0) {
    22722289        if(fuFlags & SWP_FRAMECHANGED)
    2273         {           
    2274                 MsgFormatFrame(NULL);
    2275                 UnionRect(&oldClientRect, &oldClientRect, &rectClient);
    2276                 OffsetRect(&oldClientRect, -rectClient.left, -rectClient.top);
    2277                 InvalidateRect(getWindowHandle(), &oldClientRect, TRUE);
     2290        {
     2291            MsgFormatFrame(NULL);
     2292            UnionRect(&oldClientRect, &oldClientRect, &rectClient);
     2293            OffsetRect(&oldClientRect, -rectClient.left, -rectClient.top);
     2294            InvalidateRect(getWindowHandle(), &oldClientRect, TRUE);
    22782295        }
    22792296        return TRUE;
     
    22962313    if(fuFlags & SWP_SHOWWINDOW && !IsWindowVisible()) {
    22972314        setStyle(getStyle() | WS_VISIBLE);
    2298         if(hTaskList) {
    2299                 dprintf(("Adding window %x to tasklist", getWindowHandle()));
    2300                 OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
    2301         }
     2315        if(hTaskList) {
     2316            dprintf(("Adding window %x to tasklist", getWindowHandle()));
     2317            OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
     2318        }
    23022319    }
    23032320    else
    23042321    if(fuFlags & SWP_HIDEWINDOW && IsWindowVisible()) {
    23052322        setStyle(getStyle() & ~WS_VISIBLE);
    2306         if(hTaskList) {
    2307                 dprintf(("Removing window %x from tasklist", getWindowHandle()));
    2308                 OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
    2309         }
     2323        if(hTaskList) {
     2324            dprintf(("Removing window %x from tasklist", getWindowHandle()));
     2325            OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);
     2326        }
    23102327    }
    23112328    dprintf (("WinSetWindowPos %x %x (%d,%d)(%d,%d) %x", swp.hwnd, swp.hwndInsertBehind, swp.x, swp.y, swp.cx, swp.cy, swp.fl));
     
    23152332    {
    23162333        dprintf(("OSLibWinSetMultWindowPos failed! Error %x",OSLibWinGetLastError()));
    2317         return 0;
     2334        return 0;
    23182335    }
    23192336
    23202337    if((fuFlags & SWP_FRAMECHANGED) && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE)))
    23212338    {
    2322         UnionRect(&oldClientRect, &oldClientRect, &rectClient);
     2339        UnionRect(&oldClientRect, &oldClientRect, &rectClient);
    23232340        OffsetRect(&oldClientRect, -rectClient.left, -rectClient.top);
    2324         InvalidateRect(getWindowHandle(), &oldClientRect, TRUE);
     2341        InvalidateRect(getWindowHandle(), &oldClientRect, TRUE);
    23252342    }
    23262343    return (rc);
     
    23282345//******************************************************************************
    23292346//TODO: Check how this api really works in NT
    2330 //      This implemention doesn't make a lot of sense to me (compared to the
    2331 //      description in the SDK docs)
    23322347//******************************************************************************
    23332348BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *wndpl)
     
    23392354   if(getStyle() & WS_MINIMIZE )
    23402355   {
    2341         //TODO: Why can't this be (0,0)?
    2342         if(wndpl->flags & WPF_SETMINPOSITION && !(!windowpos.ptMinPosition.x && !windowpos.ptMinPosition.y)) {
    2343                 SetWindowPos(0, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
    2344                              0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
    2345         }
     2356    //TODO: Why can't this be (0,0)?
     2357    if(wndpl->flags & WPF_SETMINPOSITION && !(!windowpos.ptMinPosition.x && !windowpos.ptMinPosition.y)) {
     2358        SetWindowPos(0, windowpos.ptMinPosition.x, windowpos.ptMinPosition.y,
     2359                     0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     2360    }
    23462361   }
    23472362   else
    23482363   if(getStyle() & WS_MAXIMIZE )
    23492364   {
    2350         //TODO: Why can't this be (0,0)?
    2351         if(windowpos.ptMaxPosition.x != 0 || windowpos.ptMaxPosition.y != 0 )
    2352                 SetWindowPos(0, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y,
    2353                              0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
     2365        //TODO: Why can't this be (0,0)?
     2366        if(windowpos.ptMaxPosition.x != 0 || windowpos.ptMaxPosition.y != 0 )
     2367            SetWindowPos(0, windowpos.ptMaxPosition.x, windowpos.ptMaxPosition.y,
     2368                         0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
    23542369   }
    23552370   else {
    2356         //Papyrus calls this api with rcNormalPosition set to 0
    2357         //So the rcNormalPosition should probably not affect the current position
    2358 #if 0
    23592371        SetWindowPos(0, windowpos.rcNormalPosition.left, windowpos.rcNormalPosition.top,
    2360                      windowpos.rcNormalPosition.right - windowpos.rcNormalPosition.left,
    2361                      windowpos.rcNormalPosition.bottom - windowpos.rcNormalPosition.top,
    2362                      SWP_NOZORDER | SWP_NOACTIVATE );
    2363 #endif
     2372             windowpos.rcNormalPosition.right - windowpos.rcNormalPosition.left,
     2373             windowpos.rcNormalPosition.bottom - windowpos.rcNormalPosition.top,
     2374             SWP_NOZORDER | SWP_NOACTIVATE );
    23642375   }
    23652376   ShowWindow(wndpl->showCmd);
    23662377   if( ::IsWindow(getWindowHandle()) && getStyle() & WS_MINIMIZE )
    23672378   {
    2368         /* SDK: ...valid only the next time... */
    2369         if(wndpl->flags & WPF_RESTORETOMAXIMIZED)
    2370                 setFlags(getFlags() | WIN_RESTORE_MAX);
     2379        /* SDK: ...valid only the next time... */
     2380        if(wndpl->flags & WPF_RESTORETOMAXIMIZED)
     2381        setFlags(getFlags() | WIN_RESTORE_MAX);
    23712382   }
    23722383   return TRUE;
     
    23762387BOOL Win32BaseWindow::GetWindowPlacement(LPWINDOWPLACEMENT wndpl)
    23772388{
    2378    wndpl->length  = sizeof(*wndpl);
     2389   wndpl->length = sizeof(*wndpl);
    23792390   if(getStyle() & WS_MINIMIZE )
    2380         wndpl->showCmd = SW_SHOWMINIMIZED;
     2391        wndpl->showCmd = SW_SHOWMINIMIZED;
    23812392   else wndpl->showCmd = (getStyle() & WS_MAXIMIZE) ? SW_SHOWMAXIMIZED : SW_SHOWNORMAL;
    23822393
     2394   //TODO: Verify if this is correct -> SDK docs claim this flag must always be set to 0
    23832395   if(getFlags() & WIN_RESTORE_MAX )
    23842396        wndpl->flags = WPF_RESTORETOMAXIMIZED;
     
    23872399   wndpl->ptMinPosition    = windowpos.ptMinPosition;
    23882400   wndpl->ptMaxPosition    = windowpos.ptMaxPosition;
    2389    wndpl->rcNormalPosition = windowpos.rcNormalPosition;
     2401   //Must be in parent coordinates (or screen if no parent); verified in NT4, SP6
     2402   wndpl->rcNormalPosition = rectWindow;
    23902403
    23912404   return TRUE;
     
    24522465{
    24532466  if((!(getStyle() & (WS_POPUP|WS_CHILD)))) {
    2454         return 0;
     2467    return 0;
    24552468  }
    24562469
     
    24582471
    24592472  if(getStyle() & WS_CHILD) {
    2460         if(wndparent) {
    2461                 return wndparent->getWindowHandle();
    2462         }
    2463         dprintf(("WARNING: GetParent: WS_CHILD but no parent!!"));
    2464         DebugInt3();
    2465         return 0;
    2466   }
    2467   else  return (getOwner()) ? getOwner()->getWindowHandle() : 0;
     2473    if(wndparent) {
     2474        return wndparent->getWindowHandle();
     2475    }
     2476    dprintf(("WARNING: GetParent: WS_CHILD but no parent!!"));
     2477    DebugInt3();
     2478    return 0;
     2479  }
     2480  else  return (getOwner()) ? getOwner()->getWindowHandle() : 0;
    24682481}
    24692482//******************************************************************************
     
    24852498    * including the WM_SHOWWINDOW messages and all */
    24862499   if(fCreated && (getStyle() & WS_VISIBLE)) {
    2487         ShowWindow(SW_HIDE);
    2488         fShow = TRUE;
     2500        ShowWindow(SW_HIDE);
     2501    fShow = TRUE;
    24892502   }
    24902503
     
    24972510        if(!(getStyle() & WS_CHILD))
    24982511        {
    2499                 //TODO: Send WM_STYLECHANGED msg?
    2500                 setStyle(getStyle() | WS_CHILD);
    2501                 if(getWindowId())
     2512        //TODO: Send WM_STYLECHANGED msg?
     2513            setStyle(getStyle() | WS_CHILD);
     2514            if(getWindowId())
    25022515                {
    25032516                        DestroyMenu( (HMENU) getWindowId() );
     
    25102523        windowDesktop->addChild(this);
    25112524        OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP);
    2512        
    2513         //TODO: Send WM_STYLECHANGED msg?
    2514         setStyle(getStyle() & ~WS_CHILD);
     2525
     2526    //TODO: Send WM_STYLECHANGED msg?
     2527        setStyle(getStyle() & ~WS_CHILD);
    25152528        setWindowId(0);
    25162529   }
    25172530   /* SetParent additionally needs to make hwndChild the topmost window
    25182531      in the x-order and send the expected WM_WINDOWPOSCHANGING and
    2519       WM_WINDOWPOSCHANGED notification messages. 
     2532      WM_WINDOWPOSCHANGED notification messages.
    25202533   */
    25212534   if(fCreated) {
    2522         SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0,
    2523                      SWP_NOMOVE|SWP_NOSIZE|(fShow? SWP_SHOWWINDOW : 0));
     2535    SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0,
     2536                 SWP_NOMOVE|SWP_NOSIZE|(fShow? SWP_SHOWWINDOW : 0));
    25242537
    25252538   /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
     
    25462559    hwndTop = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
    25472560    if(!isDesktopWindow()) {
    2548         topwindow = GetWindowFromOS2Handle(hwndTop);
    2549         if(topwindow) {
    2550                 return topwindow->getWindowHandle();
    2551         }
    2552         return 0;       
     2561    topwindow = GetWindowFromOS2Handle(hwndTop);
     2562    if(topwindow) {
     2563        return topwindow->getWindowHandle();
     2564    }
     2565    return 0;
    25532566    }
    25542567    while(hwndTop) {
    2555         topwindow = GetWindowFromOS2Handle(hwndTop);
    2556         if(topwindow) {
    2557                 return topwindow->getWindowHandle();
    2558         }
    2559         hwndTop = OSLibWinQueryWindow(hwndTop, QWOS_NEXT);
     2568    topwindow = GetWindowFromOS2Handle(hwndTop);
     2569    if(topwindow) {
     2570        return topwindow->getWindowHandle();
     2571    }
     2572        hwndTop = OSLibWinQueryWindow(hwndTop, QWOS_NEXT);
    25602573    }
    25612574
     
    27692782             window = (Win32BaseWindow *)getParent();
    27702783             hwndRelated = OSLibWinQueryWindow(window->getOS2WindowHandle(), QWOS_TOP);
    2771              window = GetWindowFromOS2Handle(hwndRelated);
    2772              if(window) {
     2784             window = GetWindowFromOS2Handle(hwndRelated);
     2785         if(window) {
    27732786                  hwndRelated = window->getWindowHandle();
    27742787             }
    27752788             else hwndRelated = 0;
    27762789        }
    2777         else hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
     2790    else hwndRelated = 0; //TODO: not correct; should get first child in z-order of desktop
    27782791        break;
    27792792
    27802793    case GW_HWNDLAST:
    2781         hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_BOTTOM);
    2782         window = GetWindowFromOS2Handle(hwndRelated);
    2783         if(window) {
     2794        hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_BOTTOM);
     2795    window = GetWindowFromOS2Handle(hwndRelated);
     2796    if(window) {
    27842797             hwndRelated = window->getWindowHandle();
    27852798        }
    2786         else hwndRelated = 0;
     2799    else hwndRelated = 0;
    27872800        break;
    27882801
    27892802    case GW_HWNDNEXT:
    2790         hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_NEXT);
    2791         window = GetWindowFromOS2Handle(hwndRelated);
    2792         if(window) {
     2803        hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_NEXT);
     2804    window = GetWindowFromOS2Handle(hwndRelated);
     2805    if(window) {
    27932806             hwndRelated = window->getWindowHandle();
    27942807        }
    2795         else hwndRelated = 0;
     2808    else hwndRelated = 0;
    27962809        break;
    27972810
    27982811    case GW_HWNDPREV:
    2799         hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_PREV);
    2800         window = GetWindowFromOS2Handle(hwndRelated);
    2801         if(window) {
     2812        hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_PREV);
     2813    window = GetWindowFromOS2Handle(hwndRelated);
     2814    if(window) {
    28022815             hwndRelated = window->getWindowHandle();
    28032816        }
    2804         else hwndRelated = 0;
     2817    else hwndRelated = 0;
    28052818        break;
    28062819
     
    28122825
    28132826    case GW_CHILD:
    2814         hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
    2815         window = GetWindowFromOS2Handle(hwndRelated);
    2816         if(window) {
     2827        hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
     2828    window = GetWindowFromOS2Handle(hwndRelated);
     2829    if(window) {
    28172830             hwndRelated = window->getWindowHandle();
    28182831        }
    2819         else hwndRelated = 0;
     2832    else hwndRelated = 0;
    28202833        break;
    28212834    }
     
    30833096
    30843097                if(dwExStyle == value) {
    3085                         oldval = value;
    3086                         break;
    3087                 }
     3098            oldval = value;
     3099                    break;
     3100        }
    30883101                ss.styleOld = dwExStyle;
    30893102                ss.styleNew = value;
     
    30933106                SendInternalMessageA(WM_STYLECHANGED,GWL_EXSTYLE,(LPARAM)&ss);
    30943107                oldval = ss.styleOld;
    3095                 break;
     3108        break;
    30963109        }
    30973110        case GWL_STYLE:
     
    31023115
    31033116                if(dwStyle == value) {
    3104                         oldval = value;
    3105                         break;
     3117            oldval = value;
     3118                    break;
    31063119                }
    31073120                value &= ~(WS_CHILD|WS_VISIBLE);      /* Some bits can't be changed this way (WINE) */
     
    31223135        case GWL_WNDPROC:
    31233136        {
    3124                 //Note: Type of SetWindowLong determines new window proc type
     3137        //Note: Type of SetWindowLong determines new window proc type
    31253138                //      UNLESS the new window proc has already been registered
    31263139                //      (use the old type in that case)
    31273140                //      (VERIFIED in NT 4, SP6)
    31283141                WINDOWPROCTYPE type = WINPROC_GetProcType((HWINDOWPROC)value);
    3129                 if(type == WIN_PROC_INVALID) {
    3130                         type = (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A;
    3131                 }
    3132                 oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
     3142        if(type == WIN_PROC_INVALID) {
     3143            type = (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A;
     3144        }
     3145            oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
    31333146                WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, type, WIN_PROC_WINDOW);
    31343147                break;
     
    31583171                        oldval = userWindowLong[index/4];
    31593172                        userWindowLong[index/4] = value;
    3160                         break;
     3173                    break;
    31613174                }
    3162                 dprintf(("WARNING: SetWindowLong%c %x %d %x returned %x INVALID index!", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
     3175            dprintf(("WARNING: SetWindowLong%c %x %d %x returned %x INVALID index!", (fUnicode) ? 'W' : 'A', getWindowHandle(), index, value));
    31633176                SetLastError(ERROR_INVALID_PARAMETER);
    31643177                return 0;
     
    31883201        break;
    31893202    case GWL_HWNDPARENT:
    3190         value = GetParent();
     3203    value = GetParent();
    31913204        break;
    31923205    case GWL_ID:
  • trunk/src/user32/window.cpp

    r4463 r4497  
    1 /* $Id: window.cpp,v 1.80 2000-10-09 17:26:55 sandervl Exp $ */
     1/* $Id: window.cpp,v 1.81 2000-10-18 17:10:50 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    486486    if( IsWindow(hwnd) )
    487487    {
    488     WINDOWPLACEMENT wndpl;
    489     UINT flags;
     488        WINDOWPLACEMENT wndpl;
     489        UINT flags;
    490490
    491491        GetWindowPlacement(hwnd, &wndpl);
    492     wndpl.length  = sizeof(wndpl);
    493     wndpl.showCmd = showCmd;
    494     wndpl.flags = 0;
    495 
    496     if(lpPoint)
    497     {
     492        wndpl.length  = sizeof(wndpl);
     493        wndpl.showCmd = showCmd;
     494        wndpl.flags = 0;
     495
     496        if(lpPoint)
     497        {
    498498            wndpl.flags |= WPF_SETMINPOSITION;
    499         wndpl.ptMinPosition = *lpPoint;
    500     }
    501     if(lpRect)
    502     {
     499            wndpl.ptMinPosition = *lpPoint;
     500        }
     501        if(lpRect)
     502        {
    503503            wndpl.rcNormalPosition = *lpRect;
    504     }
     504        }
    505505        SetWindowPlacement( hwnd, &wndpl);
    506506    }
     
    593593}
    594594//******************************************************************************
     595//NOTE: length must equal structure size or else api fails (verified in NT4, SP6)
    595596//******************************************************************************
    596597BOOL WIN32API SetWindowPlacement(HWND hwnd, const WINDOWPLACEMENT *winpos)
     
    604605        return FALSE;
    605606    }
    606     if(!winpos) {
     607    if(!winpos || winpos->length != sizeof(WINDOWPLACEMENT)) {
    607608        dprintf(("SetWindowPlacement %x invalid parameter", hwnd));
    608609        SetLastError(ERROR_INVALID_PARAMETER);
     
    613614}
    614615//******************************************************************************
     616//NOTE: Length does not need to be correct (even though the SDK docs claim otherwise)
     617//      (Verified in NT4, SP6)
    615618//******************************************************************************
    616619BOOL WIN32API GetWindowPlacement(HWND hwnd, LPWINDOWPLACEMENT winpos)
     
    16301633 HWND hwnd;
    16311634
    1632     hWnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
    1633 
    1634     hwnd = Win32BaseWindow::OS2ToWin32Handle(O32_GetLastActivePopup(hWnd));
     1635    hwnd = Win32BaseWindow::Win32ToOS2Handle(hWnd);
     1636    hwnd = Win32BaseWindow::OS2ToWin32Handle(O32_GetLastActivePopup(hwnd));
    16351637
    16361638    dprintf(("GetLastActivePopup %x returned %x NOT CORRECTLY IMPLEMENTED", hWnd, hwnd));
Note: See TracChangeset for help on using the changeset viewer.