Changeset 327 for trunk/src/user32/new/win32wnd.cpp
- Timestamp:
- Jul 18, 1999, 3:57:48 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/win32wnd.cpp
r325 r327 1 /* $Id: win32wnd.cpp,v 1. 9 1999-07-18 10:39:51 sandervlExp $ */1 /* $Id: win32wnd.cpp,v 1.10 1999-07-18 13:57:48 cbratschi Exp $ */ 2 2 /* 3 3 * Win32 Window Code for OS/2 … … 124 124 if (cs->hwndParent) 125 125 { 126 127 126 Win32Window *window = GetWindowFromHandle(cs->hwndParent); 127 if(!window) { 128 128 dprintf(("Bad parent %04x\n", cs->hwndParent )); 129 129 SetLastError(ERROR_INVALID_PARAMETER); 130 131 130 return FALSE; 131 } 132 132 /* Make sure parent is valid */ 133 133 if (!window->IsWindow() ) … … 231 231 if ((cs->style & WS_CHILD) && cs->hwndParent) 232 232 { 233 233 SetParent(cs->hwndParent); 234 234 } 235 235 else … … 240 240 else 241 241 { 242 242 owner = GetWindowFromHandle(cs->hwndParent); 243 243 if(owner == NULL) 244 244 { … … 263 263 if (HOOK_IsHooked( WH_CBT )) 264 264 { 265 265 CBT_CREATEWNDA cbtc; 266 266 LRESULT ret; 267 267 268 269 268 cbtc.lpcs = cs; 269 cbtc.hwndInsertAfter = hwndLinkAfter; 270 270 ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc) 271 271 : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc); 272 272 if (ret) 273 274 275 273 { 274 TRACE_(win)("CBT-hook returned 0\n"); 275 wndPtr->pDriver->pFinalize(wndPtr); 276 276 retvalue = 0; 277 277 goto end; 278 278 } 279 279 } 280 280 #endif … … 337 337 dwOSWinStyle, dwOSFrameStyle, (char *)cs->lpszName, 338 338 (owner) ? owner->getOS2WindowHandle() : 0, 339 339 (hwndLinkAfter == HWND_BOTTOM) ? TRUE : FALSE, 340 340 &OS2HwndFrame); 341 341 … … 354 354 #if 0 355 355 if(OS2Hwnd != OS2HwndFrame) { 356 357 358 359 360 361 362 363 356 if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) { 357 dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2HwndFrame)); 358 return FALSE; 359 } 360 if(OSLibWinSetWindowULong(OS2HwndFrame, OFFSET_WIN32PM_MAGIC, WIN32PM_MAGIC) == FALSE) { 361 dprintf(("WM_CREATE: WinSetWindowULong2 %X failed!!", OS2HwndFrame)); 362 return FALSE; 363 } 364 364 } 365 365 #endif … … 378 378 else windowId = (UINT)cs->hMenu; 379 379 380 /* Send the WM_CREATE message 381 * Perhaps we shouldn't allow width/height changes as well. 382 * See p327 in "Internals". 380 /* Send the WM_CREATE message 381 * Perhaps we shouldn't allow width/height changes as well. 382 * See p327 in "Internals". 383 383 */ 384 384 maxPos.x = rectWindow.left; maxPos.y = rectWindow.top; … … 389 389 OffsetRect(&rectWindow, maxPos.x - rectWindow.left, 390 390 maxPos.y - rectWindow.top); 391 391 dprintf(("Sending WM_CREATE")); 392 392 if( (SendInternalMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 ) 393 393 { 394 394 SetWindowPos(HWND_TOP, rectClient.left, rectClient.top, 395 rectClient.right-rectClient.left, 396 397 395 rectClient.right-rectClient.left, 396 rectClient.bottom-rectClient.top, 397 SWP_NOACTIVATE); 398 398 399 399 if (cs->style & WS_VISIBLE) ShowWindow( sw ); … … 405 405 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 ); 406 406 #endif 407 407 return TRUE; 408 408 } 409 409 } … … 429 429 if (lpPos && !HOOK_CallHooks16(WH_CBT, HCBT_MINMAX, hwndSelf, cmd)) 430 430 { 431 432 433 434 435 436 437 438 439 440 441 442 443 431 if( dwStyle & WS_MINIMIZE ) 432 { 433 if( !SendInternalMessageA(WM_QUERYOPEN, 0, 0L ) ) 434 return (SWP_NOSIZE | SWP_NOMOVE); 435 swpFlags |= SWP_NOCOPYBITS; 436 } 437 switch( cmd ) 438 { 439 case SW_MINIMIZE: 440 if( dwStyle & WS_MAXIMIZE) 441 { 442 flags |= WIN_RESTORE_MAX; 443 dwStyle &= ~WS_MAXIMIZE; 444 444 } 445 445 else 446 447 446 flags &= ~WIN_RESTORE_MAX; 447 dwStyle |= WS_MINIMIZE; 448 448 449 449 #if 0 450 451 452 450 if( flags & WIN_NATIVE ) 451 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) ) 452 swpFlags |= MINMAX_NOSWP; 453 453 #endif 454 454 455 456 457 458 459 460 461 462 455 lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos ); 456 457 SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y, 458 GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) ); 459 swpFlags |= SWP_NOCOPYBITS; 460 break; 461 462 case SW_MAXIMIZE: 463 463 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt ); 464 464 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL ); 465 465 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos ); 466 466 467 468 469 470 471 472 473 474 475 467 if( dwStyle & WS_MINIMIZE ) 468 { 469 if( flags & WIN_NATIVE ) 470 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) ) 471 swpFlags |= MINMAX_NOSWP; 472 473 WINPOS_ShowIconTitle( wndPtr, FALSE ); 474 dwStyle &= ~WS_MINIMIZE; 475 } 476 476 dwStyle |= WS_MAXIMIZE; 477 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 478 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, 479 size.x, size.y ); 480 break; 481 482 case SW_RESTORE: 483 if( dwStyle & WS_MINIMIZE ) 484 { 485 if( flags & WIN_NATIVE ) 486 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) ) 487 swpFlags |= MINMAX_NOSWP; 488 489 dwStyle &= ~WS_MINIMIZE; 490 WINPOS_ShowIconTitle( wndPtr, FALSE ); 491 492 if( flags & WIN_RESTORE_MAX) 493 { 494 /* Restore to maximized position */ 495 495 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt ); 496 496 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL); 497 497 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos ); 498 499 500 501 502 } 503 else 504 505 506 507 508 509 *lpRect = lpPos->rectNormal; 510 lpRect->right -= lpRect->left; 511 512 513 514 498 dwStyle |= WS_MAXIMIZE; 499 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y ); 500 break; 501 } 502 } 503 else 504 if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1); 505 else dwStyle &= ~WS_MAXIMIZE; 506 507 /* Restore to normal position */ 508 509 *lpRect = lpPos->rectNormal; 510 lpRect->right -= lpRect->left; 511 lpRect->bottom -= lpRect->top; 512 513 break; 514 } 515 515 } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE; 516 516 return swpFlags; … … 611 611 { 612 612 winposCopy = *winpos; 613 614 615 613 params.rgrc[1] = *oldWindowRect; 614 params.rgrc[2] = *oldClientRect; 615 params.lppos = &winposCopy; 616 616 } 617 617 result = SendInternalMessageA(WM_NCCALCSIZE, calcValidRect, … … 752 752 { 753 753 if(isUnicode) { 754 755 } 756 else 754 return SendInternalMessageW(WM_SETTEXT, 0, (LPARAM)lpsz); 755 } 756 else return SendInternalMessageA(WM_SETTEXT, 0, (LPARAM)lpsz); 757 757 } 758 758 //****************************************************************************** … … 843 843 { 844 844 if(PostSpyMessage(getWindowHandle(), Msg, wParam, lParam) == FALSE) 845 845 846 dprintf(("SendInternalMessageA %s for %x %x %x", GetMsgText(Msg), getWindowHandle(), wParam, lParam)); 846 847 … … 928 929 postmsg = (POSTMSG_PACKET *)malloc(sizeof(POSTMSG_PACKET)); 929 930 if(postmsg == NULL) { 930 931 931 dprintf(("Win32Window::PostMessageA: malloc returned NULL!!")); 932 return 0; 932 933 } 933 934 postmsg->Msg = msg; … … 944 945 postmsg = (POSTMSG_PACKET *)malloc(sizeof(POSTMSG_PACKET)); 945 946 if(postmsg == NULL) { 946 947 947 dprintf(("Win32Window::PostMessageW: malloc returned NULL!!")); 948 return 0; 948 949 } 949 950 postmsg->Msg = msg; … … 984 985 PVOID menutemplate; 985 986 986 if(HMHandleTranslateToOS2(hMenu, (PULONG)&menutemplate) == NO_ERROR) 987 if(HMHandleTranslateToOS2(hMenu, (PULONG)&menutemplate) == NO_ERROR) 987 988 { 988 989 990 991 992 989 OS2HwndMenu = OSLibWinCreateMenu(OS2HwndFrame, menutemplate); 990 if(OS2HwndMenu == 0) { 991 dprintf(("Win32Window::SetMenu OS2HwndMenu == 0")); 992 return FALSE; 993 } 993 994 } 994 995 dprintf(("Win32Window::SetMenu unknown hMenu (%x)", hMenu)); … … 1004 1005 switch(nCmdShow) 1005 1006 { 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1007 case SW_SHOW: 1008 case SW_SHOWDEFAULT: //todo 1009 showstate = SWPOS_SHOW | SWPOS_ACTIVATE; 1010 break; 1011 case SW_HIDE: 1012 showstate = SWPOS_HIDE; 1013 break; 1014 case SW_RESTORE: 1015 showstate = SWPOS_RESTORE | SWPOS_SHOW | SWPOS_ACTIVATE; 1016 break; 1017 case SW_MINIMIZE: 1018 showstate = SWPOS_MINIMIZE; 1019 break; 1020 case SW_SHOWMAXIMIZED: 1021 showstate = SWPOS_MAXIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE; 1022 break; 1023 case SW_SHOWMINIMIZED: 1024 showstate = SWPOS_MINIMIZE | SWPOS_SHOW | SWPOS_ACTIVATE; 1025 break; 1026 case SW_SHOWMINNOACTIVE: 1027 showstate = SWPOS_MINIMIZE | SWPOS_SHOW; 1028 break; 1029 case SW_SHOWNA: 1030 showstate = SWPOS_SHOW; 1031 break; 1032 case SW_SHOWNOACTIVATE: 1033 showstate = SWPOS_SHOW; 1034 break; 1035 case SW_SHOWNORMAL: 1036 showstate = SWPOS_RESTORE | SWPOS_ACTIVATE | SWPOS_SHOW; 1037 break; 1037 1038 } 1038 1039 return OSLibWinShowWindow(OS2HwndFrame, showstate); … … 1046 1047 1047 1048 switch(hwndInsertAfter) { 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1049 case HWND_BOTTOM: 1050 hwndInsertAfter = HWNDOS_BOTTOM; 1051 break; 1052 case HWND_TOPMOST: //TODO: 1053 case HWND_NOTOPMOST: //TODO: 1054 case HWND_TOP: 1055 hwndInsertAfter = HWNDOS_TOP; 1056 break; 1057 default: 1058 window = GetWindowFromHandle(hwndInsertAfter); 1059 if(window) { 1060 hwndInsertAfter = window->getOS2WindowHandle(); 1061 } 1062 else { 1063 dprintf(("Win32Window::SetWindowPos, unknown hwndInsertAfter %x", hwndInsertAfter)); 1064 hwndInsertAfter = 0; 1065 } 1066 break; 1067 1067 1068 } 1068 1069 setstate = SWPOS_MOVE | SWPOS_SIZE | SWPOS_ACTIVATE | SWPOS_ZORDER; 1069 1070 if(fuFlags & SWP_DRAWFRAME) 1070 1071 setstate |= 0; //TODO 1071 1072 if(fuFlags & SWP_FRAMECHANGED) 1072 1073 setstate |= 0; //TODO 1073 1074 if(fuFlags & SWP_HIDEWINDOW) 1074 1075 setstate &= ~SWPOS_ZORDER; 1075 1076 if(fuFlags & SWP_NOACTIVATE) 1076 1077 setstate &= ~SWPOS_ACTIVATE; 1077 1078 if(fuFlags & SWP_NOCOPYBITS) 1078 setstate |= 0;//TODO1079 setstate |= 0; //TODO 1079 1080 if(fuFlags & SWP_NOMOVE) 1080 1081 setstate &= ~SWPOS_MOVE; 1081 1082 if(fuFlags & SWP_NOSIZE) 1082 1083 setstate &= ~SWPOS_SIZE; 1083 1084 if(fuFlags & SWP_NOREDRAW) 1084 1085 setstate |= SWPOS_NOREDRAW; 1085 1086 if(fuFlags & SWP_NOZORDER) 1086 1087 setstate &= ~SWPOS_ZORDER; 1087 1088 if(fuFlags & SWP_SHOWWINDOW) 1088 1089 setstate |= SWPOS_SHOW; 1089 1090 1090 1091 return OSLibWinSetWindowPos(OS2HwndFrame, hwndInsertAfter, x, y, cx, cy, setstate); … … 1102 1103 { 1103 1104 if(getParent()) { 1104 1105 } 1106 else 1105 return getParent()->getWindowHandle(); 1106 } 1107 else return 0; 1107 1108 } 1108 1109 //****************************************************************************** … … 1114 1115 1115 1116 if(getParent()) { 1116 1117 oldhwnd = getParent()->getWindowHandle(); 1117 1118 } 1118 1119 else oldhwnd = 0; 1119 1120 1120 1121 if(hwndNewParent == 0) {//desktop window = parent 1121 1122 setParent(NULL); 1122 1123 OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP); 1123 1124 return oldhwnd; … … 1138 1139 { 1139 1140 if(getParent()) { 1140 1141 } 1142 else 1141 return getParent()->getWindowHandle() == hwndParent; 1142 } 1143 else return 0; 1143 1144 } 1144 1145 //****************************************************************************** … … 1154 1155 //****************************************************************************** 1155 1156 BOOL Win32Window::UpdateWindow() 1156 { 1157 RECTrect;1157 { 1158 OSRECTL rect; 1158 1159 1159 1160 if(OSLibWinQueryUpdateRect(OS2Hwnd, &rect)) 1160 1161 {//update region not empty 1161 1162 SendInternalMessageA((isIcon) ? WM_PAINTICON : WM_PAINT, 0, 0); 1162 1163 } 1163 1164 return TRUE; … … 1182 1183 switch(uCmd) 1183 1184 { 1184 1185 1186 1187 1188 1189 1190 1191 elsegetcmd = QWOS_TOP; //TODO1192 1193 1194 1195 1196 1197 elsegetcmd = QWOS_BOTTOM; //TODO1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 elsereturn 0;1185 case GW_CHILD: 1186 getcmd = QWOS_TOP; 1187 break; 1188 case GW_HWNDFIRST: 1189 if(getParent()) { 1190 getcmd = QWOS_TOP; //top of child windows 1191 } 1192 else getcmd = QWOS_TOP; //TODO 1193 break; 1194 case GW_HWNDLAST: 1195 if(getParent()) { 1196 getcmd = QWOS_BOTTOM; //bottom of child windows 1197 } 1198 else getcmd = QWOS_BOTTOM; //TODO 1199 break; 1200 case GW_HWNDNEXT: 1201 getcmd = QWOS_NEXT; 1202 break; 1203 case GW_HWNDPREV: 1204 getcmd = QWOS_PREV; 1205 break; 1206 case GW_OWNER: 1207 if(owner) { 1208 return owner->getWindowHandle(); 1209 } 1210 else return 0; 1210 1211 } 1211 1212 hwndRelated = OSLibWinQueryWindow(OS2Hwnd, getcmd); 1212 if(hwndRelated) 1213 { 1214 1215 1216 1217 1218 1219 1213 if(hwndRelated) 1214 { 1215 win32wnd = (Win32Window *)OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32WNDPTR); 1216 magic = OSLibWinGetWindowULong(hwndRelated, OFFSET_WIN32PM_MAGIC); 1217 if(CheckMagicDword(magic) && win32wnd) 1218 { 1219 return win32wnd->getWindowHandle(); 1220 } 1220 1221 } 1221 1222 return 0; … … 1254 1255 if(CheckMagicDword(magic) && win32wnd) 1255 1256 { 1256 1257 return win32wnd->getWindowHandle(); 1257 1258 } 1258 1259 return hwndActive; … … 1324 1325 return oldval; 1325 1326 case GWL_HWNDPARENT: 1326 1327 return SetParent((HWND)value); 1327 1328 1328 1329 case GWL_ID: … … 1409 1410 1410 1411 if(HIWORD(hwnd) != 0x6800) { 1411 1412 return NULL; 1412 1413 } 1413 1414 1414 1415 if(HMHandleTranslateToOS2(LOWORD(hwnd), (PULONG)&window) == NO_ERROR) { 1415 1416 return window; 1416 1417 } 1417 1418 else return NULL; … … 1419 1420 //****************************************************************************** 1420 1421 //****************************************************************************** 1422 Win32Window *Win32Window::GetWindowFromOS2Handle(HWND hwnd) 1423 { 1424 ULONG winHandle; 1425 Win32Window *window; 1426 1427 //CB: returns index, not handle! 1428 if(HMHandleTranslateToWin(hwnd,(PULONG)&winHandle) == NO_ERROR) 1429 { 1430 if (HMHandleTranslateToOS2(LOWORD(winHandle),(PULONG)&window) == NO_ERROR) 1431 { 1432 return window; 1433 } else return NULL; 1434 } else return NULL; 1435 } 1436 //****************************************************************************** 1437 //****************************************************************************** 1421 1438 GenericObject *Win32Window::windows = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.