Changeset 3662 for trunk/src/user32/win32wbase.cpp
- Timestamp:
- Jun 7, 2000, 4:51:33 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/win32wbase.cpp
r3641 r3662 1 /* $Id: win32wbase.cpp,v 1.19 7 2000-06-01 11:27:57sandervl Exp $ */1 /* $Id: win32wbase.cpp,v 1.198 2000-06-07 14:51:30 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Base Class for OS/2 … … 15 15 * TODO: Not thread/process safe 16 16 * 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) 18 20 * 19 21 * Project Odin Software License can be found in LICENSE.TXT … … 39 41 #include "win32wndhandle.h" 40 42 #include "dc.h" 41 #include "pmframe.h"42 43 #include "win32wdesktop.h" 43 44 #include "pmwindow.h" … … 104 105 magic = WIN32PM_MAGIC; 105 106 OS2Hwnd = 0; 106 OS2HwndFrame = 0;107 107 hSysMenu = 0; 108 108 Win32Hwnd = 0; … … 126 126 hotkey = 0; 127 127 128 pOldFrameProc = NULL;129 128 130 129 hwndLinkAfter = HWND_BOTTOM; … … 156 155 dwThreadId = GetCurrentThreadId(); 157 156 dwProcessId = currentProcessId; 157 158 memset(&windowpos, 0, sizeof(windowpos)); 158 159 } 159 160 //****************************************************************************** … … 166 167 } 167 168 168 OSLibWinSetVisibleRegionNotify(OS2Hwnd Frame, FALSE);169 OSLibWinSetVisibleRegionNotify(OS2Hwnd, FALSE); 169 170 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0); 170 171 OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0); … … 412 413 413 414 hwndLinkAfter = HWND_TOP; 415 #if 1 414 416 if(CONTROLS_IsControl(this, BUTTON_CONTROL) && ((dwStyle & 0x0f) == BS_GROUPBOX)) 415 417 { … … 418 420 } 419 421 else 422 #endif 420 423 if(CONTROLS_IsControl(this, STATIC_CONTROL) && !(dwStyle & WS_GROUP)) { 421 424 dwStyle |= WS_CLIPSIBLINGS; … … 515 518 (owner) ? owner->getOS2WindowHandle() : OSLIB_HWND_DESKTOP, 516 519 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE, 517 &OS2HwndFrame,0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle());520 0, fTaskList,fXDefault | fCXDefault,windowClass->getStyle()); 518 521 if(OS2Hwnd == 0) { 519 522 dprintf(("Window creation failed!!")); … … 521 524 return FALSE; 522 525 } 523 OSLibWinSetVisibleRegionNotify(OS2Hwnd Frame, TRUE);526 OSLibWinSetVisibleRegionNotify(OS2Hwnd, TRUE); 524 527 SetLastError(0); 525 528 return TRUE; … … 527 530 //****************************************************************************** 528 531 //****************************************************************************** 529 BOOL Win32BaseWindow::MsgCreate(HWND hwnd Frame, HWND hwndClient)532 BOOL Win32BaseWindow::MsgCreate(HWND hwndOS2) 530 533 { 531 534 CREATESTRUCTA *cs = tmpcs; //pointer to CREATESTRUCT used in CreateWindowExA method 532 535 POINT maxSize, maxPos, minTrack, maxTrack; 533 536 534 OS2Hwnd = hwndClient; 535 OS2HwndFrame = hwndFrame; 537 OS2Hwnd = hwndOS2; 536 538 537 539 fNoSizeMsg = TRUE; … … 556 558 557 559 //SvL: Returns invalid rectangle (not the expected shell default size) 558 OSLibWinQueryWindowRect(OS2Hwnd Frame,&rect,RELATIVE_TO_SCREEN);560 OSLibWinQueryWindowRect(OS2Hwnd,&rect,RELATIVE_TO_SCREEN); 559 561 if (getParent()) mapWin32Rect(OSLIB_HWND_DESKTOP,getParent()->getOS2WindowHandle(),&rect); 560 562 if (fXDefault) … … 575 577 #endif 576 578 577 OSLibWinSetOwner(OS2Hwnd, OS2HwndFrame);578 579 579 fakeWinBase.hwndThis = OS2Hwnd; 580 580 fakeWinBase.pWindowClass = windowClass; … … 582 582 //Set icon from window or class 583 583 if (hIcon) 584 OSLibWinSetIcon(OS2Hwnd Frame,hIcon);584 OSLibWinSetIcon(OS2Hwnd,hIcon); 585 585 else if (windowClass->getIcon()) 586 OSLibWinSetIcon(OS2Hwnd Frame,windowClass->getIcon());586 OSLibWinSetIcon(OS2Hwnd,windowClass->getIcon()); 587 587 588 588 /* Get class or window DC if needed */ 589 589 if(windowClass->getStyle() & CS_OWNDC) { 590 590 dprintf(("Class with CS_OWNDC style")); 591 ownDC = GetDC (getWindowHandle()); //TODO: or GetWindowDC???591 ownDC = GetDCEx(getWindowHandle(), NULL, DCX_USESTYLE); 592 592 } 593 593 else 594 594 if (windowClass->getStyle() & CS_PARENTDC) { 595 dprintf(("WARNING: Class with CS_PARENTDC style!"));596 595 fParentDC = TRUE; 597 596 ownDC = 0; … … 624 623 hSysMenu = (dwStyle & WS_SYSMENU) ? MENU_GetSysMenu(Win32Hwnd,0):0; 625 624 626 // Subclass frame627 pOldFrameProc = FrameSubclassFrameWindow(this);628 629 625 /* Send the WM_GETMINMAXINFO message and fix the size if needed */ 630 626 if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD))) … … 656 652 OffsetRect(&rectClient, -rectClient.left, -rectClient.top); 657 653 658 if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow);659 654 /* Send the WM_CREATE message 660 655 * Perhaps we shouldn't allow width/height changes as well. … … 667 662 668 663 if(fTaskList) { 669 hTaskList = OSLibWinAddToTaskList(OS2Hwnd Frame, windowNameA, (cs->style & WS_VISIBLE) ? 1 : 0);664 hTaskList = OSLibWinAddToTaskList(OS2Hwnd, windowNameA, (cs->style & WS_VISIBLE) ? 1 : 0); 670 665 } 671 666 … … 690 685 rectWindow.bottom = cs->y+cs->cy; 691 686 tmpRect = rectWindow; 692 if (getParent()) mapWin32Rect(getParent()->getOS2WindowHandle(),OSLIB_HWND_DESKTOP,&rectWindow);693 OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top);694 687 695 688 rectClient = rectWindow; 696 689 OffsetRect(&rectClient, -rectClient.left, -rectClient.top); 690 OffsetRect(&rectWindow, maxPos.x - rectWindow.left, maxPos.y - rectWindow.top); 697 691 698 692 //set the window size and update the client … … 855 849 ULONG Win32BaseWindow::MsgHitTest(MSG *msg) 856 850 { 857 lastHitTestVal = DispatchM essageA(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)); 860 854 861 855 if (lastHitTestVal == HTTRANSPARENT) … … 878 872 //default processing is cancelled 879 873 //TODO: According to Wine we should proceed anyway if window is sysmodal 880 #if 0881 874 if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate) 882 875 { 876 dprintf(("WARNING: WM_NCACTIVATE return code = FALSE -> cancel processing")); 883 877 return 0; 884 878 } 885 #endif886 879 /* child windows get WM_CHILDACTIVATE message */ 887 880 if((getStyle() & (WS_CHILD | WS_POPUP)) == WS_CHILD ) … … 995 988 996 989 //SvL: Calling OSLibSetActiveWindow(hwndTop); causes focus problems 997 if (win32top) OSLibWinSetFocus(win32top->getOS2 FrameWindowHandle());990 if (win32top) OSLibWinSetFocus(win32top->getOS2WindowHandle()); 998 991 } 999 992 } … … 1023 1016 1024 1017 if (hdcErase == 0) 1025 hdcErase = O32_GetDC(OS2Hwnd);1018 hdcErase = GetDC(getWindowHandle()); 1026 1019 1027 1020 if(IsWindowIconic()) … … 1030 1023 rc = SendInternalMessageA(WM_ERASEBKGND, hdcErase, 0); 1031 1024 if (hdc == 0) 1032 O32_ReleaseDC(OS2Hwnd, hdcErase);1025 ReleaseDC(getWindowHandle(), hdcErase); 1033 1026 return (rc); 1034 1027 } … … 1055 1048 RECT rect; 1056 1049 1057 if (GetOS2UpdateRect(OS2HwndFrame,&rect))1050 if(GetOS2UpdateRect(this,&rect)) 1058 1051 { 1059 1052 HRGN hrgn; … … 1073 1066 if (!hrgn) return 0; 1074 1067 1075 rc = SendInternalMessageA(WM_NCPAINT, hrgn,0);1068 rc = SendInternalMessageA(WM_NCPAINT, hrgn, 0); 1076 1069 1077 1070 DeleteObject(hrgn); … … 1093 1086 if(lpWndPos) 1094 1087 { 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; 1104 1092 } 1105 1093 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; 1122 1103 } 1123 1104 … … 1125 1106 1126 1107 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)); 1127 1109 return rc; 1128 1110 } … … 1169 1151 BOOL Win32BaseWindow::isFrameWindow() 1170 1152 { 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) 1173 1154 return TRUE; 1174 1155 … … 1343 1324 HandleNCPaint((HRGN)1); 1344 1325 if(hTaskList) { 1345 OSLibWinChangeTaskList(hTaskList, OS2Hwnd Frame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);1326 OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0); 1346 1327 } 1347 1328 } … … 1355 1336 { 1356 1337 setStyle(getStyle() | WS_VISIBLE); 1357 OSLibWinEnableWindowUpdate(OS2Hwnd Frame,TRUE);1338 OSLibWinEnableWindowUpdate(OS2Hwnd,TRUE); 1358 1339 } 1359 1340 else … … 1362 1343 { 1363 1344 setStyle(getStyle() & ~WS_VISIBLE); 1364 OSLibWinEnableWindowUpdate(OS2Hwnd Frame,FALSE);1345 OSLibWinEnableWindowUpdate(OS2Hwnd,FALSE); 1365 1346 } 1366 1347 } … … 1742 1723 hIcon = (HICON)lParam; 1743 1724 if ((dwStyle & WS_CAPTION) == WS_CAPTION) 1744 OSLibWinSetIcon(OS2Hwnd Frame,hIcon);1725 OSLibWinSetIcon(OS2Hwnd,hIcon); 1745 1726 } 1746 1727 } … … 1803 1784 HandleNCPaint((HRGN)1); 1804 1785 if(hTaskList) { 1805 OSLibWinChangeTaskList(hTaskList, OS2Hwnd Frame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);1786 OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0); 1806 1787 } 1807 1788 } … … 1868 1849 if (getParent()) 1869 1850 { 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)); 1877 1858 } 1878 1859 rc = win32wndproc(getWindowHandle(), Msg, wParam, lParam); … … 2057 2038 BOOL Win32BaseWindow::ShowWindow(ULONG nCmdShow) 2058 2039 { 2059 ULONG s howstate= 0;2040 ULONG swp = 0; 2060 2041 HWND hWinAfter; 2061 2042 BOOL rc,wasVisible,showFlag; 2043 RECT newPos = {0, 0, 0, 0}; 2062 2044 2063 2045 dprintf(("ShowWindow %x %x", getWindowHandle(), nCmdShow)); 2064 2046 2047 wasVisible = (getStyle() & WS_VISIBLE) != 0; 2048 2065 2049 switch(nCmdShow) 2066 2050 { 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 */ 2105 2116 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)); 2134 2120 2135 2121 if (flags & WIN_NEED_SIZE) … … 2150 2136 SendInternalMessageA(WM_MOVE,0,MAKELONG(rectClient.left,rectClient.top)); 2151 2137 } 2152 2153 return rc;2138 END: 2139 return wasVisible; 2154 2140 } 2155 2141 //****************************************************************************** … … 2160 2146 Win32BaseWindow *window; 2161 2147 HWND hParent = 0; 2148 RECT oldClientRect = rectClient; 2162 2149 2163 2150 if (fuFlags & … … 2224 2211 if(~fuFlags & (SWP_NOMOVE | SWP_NOSIZE)) 2225 2212 { 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); 2238 2229 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!! 2242 2236 } 2243 2237 return TRUE; … … 2249 2243 Win32BaseWindow *wndBehind = Win32BaseWindow::GetWindowFromHandle(swp.hwndInsertBehind); 2250 2244 if(wndBehind) { 2251 swp.hwndInsertBehind = wndBehind->getOS2 FrameWindowHandle();2245 swp.hwndInsertBehind = wndBehind->getOS2WindowHandle(); 2252 2246 } 2253 2247 else { … … 2256 2250 } 2257 2251 } 2258 swp.hwnd = OS2Hwnd Frame;2252 swp.hwnd = OS2Hwnd; 2259 2253 2260 2254 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); 2261 2256 2262 2257 if(fuFlags & SWP_SHOWWINDOW && !IsWindowVisible()) { 2263 2258 setStyle(getStyle() | WS_VISIBLE); 2264 //SvL: TODO: Send WM_SHOWWINDOW??2265 OSLibWinShowWindow(OS2Hwnd, SWPOS_SHOW);2266 2259 if(hTaskList) { 2267 OSLibWinChangeTaskList(hTaskList, OS2Hwnd Frame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);2260 OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0); 2268 2261 } 2269 2262 } … … 2271 2264 if(fuFlags & SWP_HIDEWINDOW && IsWindowVisible()) { 2272 2265 setStyle(getStyle() & ~WS_VISIBLE); 2273 //SvL: TODO: Send WM_SHOWWINDOW??2274 OSLibWinShowWindow(OS2Hwnd, SWPOS_HIDE);2275 2266 if(hTaskList) { 2276 OSLibWinChangeTaskList(hTaskList, OS2Hwnd Frame, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0);2267 OSLibWinChangeTaskList(hTaskList, OS2Hwnd, getWindowNameA(), (getStyle() & WS_VISIBLE) ? 1 : 0); 2277 2268 } 2278 2269 } 2279 rc = OSLibWinSetMultWindowPos(&swp, 1);2280 2270 2281 2271 if(rc == FALSE) … … 2287 2277 if((fuFlags & SWP_FRAMECHANGED) && (fuFlags & (SWP_NOMOVE | SWP_NOSIZE) == (SWP_NOMOVE | SWP_NOSIZE))) 2288 2278 { 2289 FrameUpdateClient(this); 2279 UnionRect(&oldClientRect, &oldClientRect, &rectClient); 2280 InvalidateRect(getWindowHandle(), &oldClientRect, TRUE); 2281 //TODO: move child windows!! 2290 2282 } 2291 2283 return (rc); 2292 2284 } 2293 2285 //****************************************************************************** 2294 //TODO: WPF_RESTOREMAXIMIZED 2295 //****************************************************************************** 2296 BOOL Win32BaseWindow::SetWindowPlacement(WINDOWPLACEMENT *winpos) 2297 { 2298 if(isFrameWindow()) 2286 //****************************************************************************** 2287 BOOL 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 ) 2299 2294 { 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 } 2310 2300 } 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 //****************************************************************************** 2326 BOOL 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; 2313 2342 } 2314 2343 //****************************************************************************** … … 2360 2389 2361 2390 fDestroyWindowCalled = TRUE; 2362 return OSLibWinDestroyWindow(OS2Hwnd Frame);2391 return OSLibWinDestroyWindow(OS2Hwnd); 2363 2392 } 2364 2393 //****************************************************************************** … … 2373 2402 HWND Win32BaseWindow::GetParent() 2374 2403 { 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; 2384 2412 } 2385 2413 //****************************************************************************** … … 2390 2418 Win32BaseWindow *newparent; 2391 2419 Win32BaseWindow *oldparent = (Win32BaseWindow *)ChildWindow::GetParent(); 2420 BOOL fShow = FALSE; 2392 2421 2393 2422 if(oldparent) { … … 2397 2426 else oldhwnd = 0; 2398 2427 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 2399 2435 newparent = GetWindowFromHandle(hwndNewParent); 2400 2436 if(newparent) … … 2402 2438 setParent(newparent); 2403 2439 getParent()->AddChild(this); 2404 OSLibWinSetParent(getOS2FrameWindowHandle(), getParent()->getOS2WindowHandle()); 2405 return oldhwnd; 2440 OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle()); 2406 2441 } 2407 2442 else { 2408 2443 setParent(windowDesktop); 2409 2444 windowDesktop->AddChild(this); 2410 OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP); 2411 return oldhwnd; 2445 OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP); 2412 2446 } 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; 2413 2459 } 2414 2460 //****************************************************************************** … … 2601 2647 hwnd = OSLibWinQueryClientWindow(hwnd); 2602 2648 if(hwnd) wnd = GetWindowFromOS2Handle(hwnd); 2603 if(!hwnd) wnd = GetWindowFromOS2FrameHandle(hwnd);2604 2649 } 2605 2650 … … 2703 2748 2704 2749 dprintf(("SetActiveWindow %x", getWindowHandle())); 2705 if(OSLibWinSetActiveWindow(OS2Hwnd Frame) == FALSE) {2706 dprintf(("OSLibWinSetActiveWindow %x returned FALSE!", OS2Hwnd Frame));2750 if(OSLibWinSetActiveWindow(OS2Hwnd) == FALSE) { 2751 dprintf(("OSLibWinSetActiveWindow %x returned FALSE!", OS2Hwnd)); 2707 2752 } 2708 2753 hwndActive = GetActiveWindow(); … … 2721 2766 SendMessageA(WM_CANCELMODE, 0, 0); 2722 2767 } 2723 OSLibWinEnableWindow(OS2Hwnd Frame, fEnable);2768 OSLibWinEnableWindow(OS2Hwnd, fEnable); 2724 2769 if(fEnable == FALSE) { 2725 2770 //SvL: No need to clear focus as PM already does this … … 2735 2780 BOOL Win32BaseWindow::CloseWindow() 2736 2781 { 2737 return OSLibWinMinimizeWindow(OS2Hwnd Frame);2782 return OSLibWinMinimizeWindow(OS2Hwnd); 2738 2783 } 2739 2784 //****************************************************************************** … … 2756 2801 BOOL Win32BaseWindow::IsWindowEnabled() 2757 2802 { 2758 return OSLibWinIsWindowEnabled(OS2Hwnd Frame);2803 return OSLibWinIsWindowEnabled(OS2Hwnd); 2759 2804 } 2760 2805 //****************************************************************************** … … 2762 2807 BOOL Win32BaseWindow::IsWindowVisible() 2763 2808 { 2809 //TODO: Do we have to check the state of the parent window? (as Wine does) 2764 2810 #if 1 2765 2811 return (dwStyle & WS_VISIBLE) == WS_VISIBLE; 2766 2812 #else 2767 return OSLibWinIsWindowVisible(OS2Hwnd Frame);2813 return OSLibWinIsWindowVisible(OS2Hwnd); 2768 2814 #endif 2769 2815 } … … 2900 2946 setStyle(ss.styleNew); 2901 2947 SendInternalMessageA(WM_STYLECHANGED,GWL_STYLE,(LPARAM)&ss); 2902 //// OSLibSetWindowStyle(getOS2 FrameWindowHandle(), getStyle(), getExStyle(),2948 //// OSLibSetWindowStyle(getOS2WindowHandle(), getStyle(), getExStyle(), 2903 2949 //// windowClass->getStyle() & CS_SAVEBITS); 2904 2950 #ifdef DEBUG … … 2961 3007 break; 2962 3008 case GWL_HWNDPARENT: 2963 if(getParent()) { 2964 value = getParent()->getWindowHandle(); 2965 } 2966 else value = 0; 3009 value = GetParent(); 2967 3010 break; 2968 3011 case GWL_ID: … … 3029 3072 } 3030 3073 //****************************************************************************** 3031 //Note: Should return NULL if window is frame window! (IsOS2FrameWindowHandle depends on this3032 // behaviour)3033 3074 //****************************************************************************** 3034 3075 Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd) … … 3053 3094 //****************************************************************************** 3054 3095 //****************************************************************************** 3055 Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)3056 {3057 return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));3058 }3059 //******************************************************************************3060 //******************************************************************************3061 3096 HWND Win32BaseWindow::Win32ToOS2Handle(HWND hwnd) 3062 3097 { … … 3071 3106 //****************************************************************************** 3072 3107 //****************************************************************************** 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 //******************************************************************************3085 3108 HWND Win32BaseWindow::OS2ToWin32Handle(HWND hwnd) 3086 3109 { 3087 3110 Win32BaseWindow *window = GetWindowFromOS2Handle(hwnd); 3088 3111 3089 if(window) {3090 return window->getWindowHandle();3091 }3092 window = GetWindowFromOS2FrameHandle(hwnd);3093 3112 if(window) { 3094 3113 return window->getWindowHandle(); … … 3099 3118 } 3100 3119 //****************************************************************************** 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)3113 3120 //****************************************************************************** 3114 3121 HWND Win32BaseWindow::getNextDlgTabItem(HWND hwndCtrl, BOOL fPrevious)
Note:
See TracChangeset
for help on using the changeset viewer.