Changeset 314 for trunk/src/user32/new/win32wnd.cpp
- Timestamp:
- Jul 16, 1999, 1:32:10 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/new/win32wnd.cpp
r309 r314 1 /* $Id: win32wnd.cpp,v 1. 3 1999-07-15 18:03:02sandervl Exp $ */1 /* $Id: win32wnd.cpp,v 1.4 1999-07-16 11:32:09 sandervl Exp $ */ 2 2 /* 3 3 * Win32 Window Code for OS/2 … … 45 45 //****************************************************************************** 46 46 Win32Window::Win32Window(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode) 47 : GenericObject(&windows, OBJTYPE_WINDOW) 47 : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow() 48 48 { 49 49 Init(); … … 68 68 magic = WIN32PM_MAGIC; 69 69 OS2Hwnd = 0; 70 OS2HwndMenu = 0; 70 71 Win32Hwnd = 0; 71 72 … … 76 77 DebugInt3(); 77 78 } 79 Win32Hwnd &= 0xFFFF; 80 Win32Hwnd |= 0x68000000; 81 78 82 posx = posy = 0; 79 83 width = height = 0; … … 83 87 win32wndproc = 0; 84 88 hInstance = 0; 85 parent = 0;86 89 windowId = 0xFFFFFFFF; //default = -1 87 90 userData = 0; … … 110 113 { 111 114 char buffer[256]; 112 DWORD tmp;113 115 INT sw = SW_SHOW; 114 116 POINT maxSize, maxPos, minTrack, maxTrack; … … 220 222 if ((cs->style & WS_CHILD) && cs->hwndParent) 221 223 { 222 if(HMHandleTranslateToOS2(cs->hwndParent, &tmp) != NO_ERROR) 223 { 224 dprintf(("HMHandleTranslateToOS2 couldn't find parent window %x!!!", cs->hwndParent)); 225 return FALSE; 226 } 227 parent = (Win32Window *)tmp; 224 SetParent(cs->hwndParent); 228 225 } 229 226 else 230 227 { 231 parent = NULL; //desktop232 228 if (!cs->hwndParent) { 233 229 owner = NULL; … … 235 231 else 236 232 { 237 if(HMHandleTranslateToOS2(cs->hwndParent, &tmp) != NO_ERROR) 233 owner = GetWindowFromHandle(cs->hwndParent); 234 if(owner == NULL) 238 235 { 239 236 dprintf(("HMHandleTranslateToOS2 couldn't find owner window %x!!!", cs->hwndParent)); 240 237 return FALSE; 241 238 } 242 owner = (Win32Window *)tmp;243 239 } 244 240 } … … 251 247 hwndLinkAfter = ((cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD) 252 248 ? HWND_BOTTOM : HWND_TOP; 249 250 #if 0 251 //TODO 252 /* Call the WH_CBT hook */ 253 254 if (HOOK_IsHooked( WH_CBT )) 255 { 256 CBT_CREATEWNDA cbtc; 257 LRESULT ret; 258 259 cbtc.lpcs = cs; 260 cbtc.hwndInsertAfter = hwndLinkAfter; 261 ret = unicode ? HOOK_CallHooksW(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc) 262 : HOOK_CallHooksA(WH_CBT, HCBT_CREATEWND, Win32Hwnd, (LPARAM)&cbtc); 263 if (ret) 264 { 265 TRACE_(win)("CBT-hook returned 0\n"); 266 wndPtr->pDriver->pFinalize(wndPtr); 267 retvalue = 0; 268 goto end; 269 } 270 } 271 #endif 253 272 254 273 /* Increment class window counter */ … … 296 315 } 297 316 298 /* Set the window menu */ 299 if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION ) 300 { 301 if (cs->hMenu) SetMenu(getWindowHandle(), cs->hMenu); 302 else 303 { 304 if (windowClass->getMenuNameA()) { 305 cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA()); 306 if (cs->hMenu) SetMenu( getWindowHandle(), cs->hMenu ); 307 } 308 } 309 } 310 else windowId = (UINT)cs->hMenu; 317 rectWindow.left = cs->x; 318 rectWindow.top = cs->y; 319 rectWindow.right = cs->x + cs->cx; 320 rectWindow.bottom = cs->y + cs->cy; 321 rectClient = rectWindow; 311 322 312 323 DWORD dwOSWinStyle, dwOSFrameStyle; … … 314 325 OSLibWinConvertStyle(cs->style, &dwOSWinStyle, &dwOSFrameStyle); 315 326 316 OS2Hwnd = OSLibWinCreateWindow(( parent) ? parent->getOS2WindowHandle() : 0,327 OS2Hwnd = OSLibWinCreateWindow((getParent()) ? getParent()->getOS2WindowHandle() : 0, 317 328 dwOSWinStyle, dwOSFrameStyle, (char *)cs->lpszName, 318 329 cs->x, cs->y, cs->cx, cs->cy, … … 333 344 } 334 345 335 return TRUE; 336 } 346 /* Set the window menu */ 347 if ((dwStyle & (WS_CAPTION | WS_CHILD)) == WS_CAPTION ) 348 { 349 if (cs->hMenu) SetMenu(cs->hMenu); 350 else 351 { 352 if (windowClass->getMenuNameA()) { 353 cs->hMenu = LoadMenuA(cs->hInstance, windowClass->getMenuNameA()); 354 if (cs->hMenu) SetMenu(cs->hMenu ); 355 } 356 } 357 } 358 else windowId = (UINT)cs->hMenu; 359 360 /* Send the WM_CREATE message 361 * Perhaps we shouldn't allow width/height changes as well. 362 * See p327 in "Internals". 363 */ 364 maxPos.x = rectWindow.left; maxPos.y = rectWindow.top; 365 366 if(sendMessage(WM_NCCREATE, 0, (LPARAM)cs) ) 367 { 368 SendNCCalcSize(FALSE, &rectWindow, NULL, NULL, 0, &rectClient ); 369 OffsetRect(&rectWindow, maxPos.x - rectWindow.left, 370 maxPos.y - rectWindow.top); 371 dprintf(("Sending WM_CREATE")); 372 if( (sendMessage(WM_CREATE, 0, (LPARAM)cs )) != -1 ) 373 { 374 /* Send the size messages */ 375 dprintf(("Sent WM_CREATE")); 376 377 if (!(flags & WIN_NEED_SIZE)) 378 { 379 /* send it anyway */ 380 if (((rectClient.right-rectClient.left) <0) 381 ||((rectClient.bottom-rectClient.top)<0)) 382 dprintf(("sending bogus WM_SIZE message 0x%08lx\n", 383 MAKELONG(rectClient.right-rectClient.left, 384 rectClient.bottom-rectClient.top))); 385 SendMessageA(WM_SIZE, SIZE_RESTORED, 386 MAKELONG(rectClient.right-rectClient.left, 387 rectClient.bottom-rectClient.top)); 388 SendMessageA(WM_MOVE, 0, 389 MAKELONG( rectClient.left, 390 rectClient.top ) ); 391 } 392 393 #if 0 394 /* Show the window, maximizing or minimizing if needed */ 395 396 if (dwStyle & (WS_MINIMIZE | WS_MAXIMIZE)) 397 { 398 RECT16 newPos; 399 UINT16 swFlag = (dwStyle & WS_MINIMIZE) ? SW_MINIMIZE : SW_MAXIMIZE; 400 dwStyle &= ~(WS_MAXIMIZE | WS_MINIMIZE); 401 WINPOS_MinMaximize(swFlag, &newPos ); 402 swFlag = ((dwStyle & WS_CHILD) || GetActiveWindow()) 403 ? SWP_NOACTIVATE | SWP_NOZORDER | SWP_FRAMECHANGED 404 : SWP_NOZORDER | SWP_FRAMECHANGED; 405 SetWindowPos(0, newPos.left, newPos.top, 406 newPos.right, newPos.bottom, swFlag ); 407 } 408 #endif 409 410 if( dwStyle & WS_CHILD && !(dwExStyle & WS_EX_NOPARENTNOTIFY) ) 411 { 412 /* Notify the parent window only */ 413 414 NotifyParent(WM_CREATE, 0, 0); 415 if( !IsWindow(Win32Hwnd) ) 416 { 417 return FALSE; 418 } 419 } 420 421 if (cs->style & WS_VISIBLE) ShowWindow( sw ); 422 423 #if 0 424 /* Call WH_SHELL hook */ 425 426 if (!(dwStyle & WS_CHILD) && !owner) 427 HOOK_CallHooks16( WH_SHELL, HSHELL_WINDOWCREATED, hwnd, 0 ); 428 #endif 429 return TRUE; 430 } 431 } 432 return FALSE; 433 } 434 #if 0 435 /*********************************************************************** 436 * WINPOS_MinMaximize 437 * 438 * Fill in lpRect and return additional flags to be used with SetWindowPos(). 439 * This function assumes that 'cmd' is different from the current window 440 * state. 441 */ 442 UINT Win32Window::MinMaximize(UINT16 cmd, LPRECT16 lpRect ) 443 { 444 UINT swpFlags = 0; 445 POINT pt, size; 446 LPINTERNALPOS lpPos; 447 448 size.x = rectWindow.left; size.y = rectWindow.top; 449 lpPos = WINPOS_InitInternalPos( wndPtr, size, &rectWindow ); 450 451 if (lpPos && !HOOK_CallHooks16(WH_CBT, HCBT_MINMAX, hwndSelf, cmd)) 452 { 453 if( dwStyle & WS_MINIMIZE ) 454 { 455 if( !SendMessageA(WM_QUERYOPEN, 0, 0L ) ) 456 return (SWP_NOSIZE | SWP_NOMOVE); 457 swpFlags |= SWP_NOCOPYBITS; 458 } 459 switch( cmd ) 460 { 461 case SW_MINIMIZE: 462 if( dwStyle & WS_MAXIMIZE) 463 { 464 flags |= WIN_RESTORE_MAX; 465 dwStyle &= ~WS_MAXIMIZE; 466 } 467 else 468 flags &= ~WIN_RESTORE_MAX; 469 dwStyle |= WS_MINIMIZE; 470 471 #if 0 472 if( flags & WIN_NATIVE ) 473 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, TRUE ) ) 474 swpFlags |= MINMAX_NOSWP; 475 #endif 476 477 lpPos->ptIconPos = WINPOS_FindIconPos( wndPtr, lpPos->ptIconPos ); 478 479 SetRect(lpRect, lpPos->ptIconPos.x, lpPos->ptIconPos.y, 480 GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON) ); 481 swpFlags |= SWP_NOCOPYBITS; 482 break; 483 484 case SW_MAXIMIZE: 485 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt ); 486 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL ); 487 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos ); 488 489 if( dwStyle & WS_MINIMIZE ) 490 { 491 if( flags & WIN_NATIVE ) 492 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) ) 493 swpFlags |= MINMAX_NOSWP; 494 495 WINPOS_ShowIconTitle( wndPtr, FALSE ); 496 dwStyle &= ~WS_MINIMIZE; 497 } 498 dwStyle |= WS_MAXIMIZE; 499 500 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, 501 size.x, size.y ); 502 break; 503 504 case SW_RESTORE: 505 if( dwStyle & WS_MINIMIZE ) 506 { 507 if( flags & WIN_NATIVE ) 508 if( pDriver->pSetHostAttr( wndPtr, HAK_ICONICSTATE, FALSE ) ) 509 swpFlags |= MINMAX_NOSWP; 510 511 dwStyle &= ~WS_MINIMIZE; 512 WINPOS_ShowIconTitle( wndPtr, FALSE ); 513 514 if( flags & WIN_RESTORE_MAX) 515 { 516 /* Restore to maximized position */ 517 CONV_POINT16TO32( &lpPos->ptMaxPos, &pt ); 518 WINPOS_GetMinMaxInfo( wndPtr, &size, &pt, NULL, NULL); 519 CONV_POINT32TO16( &pt, &lpPos->ptMaxPos ); 520 dwStyle |= WS_MAXIMIZE; 521 SetRect16( lpRect, lpPos->ptMaxPos.x, lpPos->ptMaxPos.y, size.x, size.y ); 522 break; 523 } 524 } 525 else 526 if( !(dwStyle & WS_MAXIMIZE) ) return (UINT16)(-1); 527 else dwStyle &= ~WS_MAXIMIZE; 528 529 /* Restore to normal position */ 530 531 *lpRect = lpPos->rectNormal; 532 lpRect->right -= lpRect->left; 533 lpRect->bottom -= lpRect->top; 534 535 break; 536 } 537 } else swpFlags |= SWP_NOSIZE | SWP_NOMOVE; 538 return swpFlags; 539 } 540 #endif 337 541 /******************************************************************* 338 542 * GetMinMaxInfo … … 379 583 380 584 #if 0 381 lpPos = (LPINTERNALPOS)GetPropA( wndPtr->hwndSelf, atomInternalPos );585 lpPos = (LPINTERNALPOS)GetPropA( hwndSelf, atomInternalPos ); 382 586 if( lpPos && !EMPTYPOINT(lpPos->ptMaxPos) ) 383 587 CONV_POINT16TO32( &lpPos->ptMaxPos, &MinMax.ptMaxPosition ); … … 407 611 if (minTrack) *minTrack = MinMax.ptMinTrackSize; 408 612 if (maxTrack) *maxTrack = MinMax.ptMaxTrackSize; 613 } 614 /*********************************************************************** 615 * WINPOS_SendNCCalcSize 616 * 617 * Send a WM_NCCALCSIZE message to a window. 618 * All parameters are read-only except newClientRect. 619 * oldWindowRect, oldClientRect and winpos must be non-NULL only 620 * when calcValidRect is TRUE. 621 */ 622 LONG Win32Window::SendNCCalcSize(BOOL calcValidRect, 623 RECT *newWindowRect, RECT *oldWindowRect, 624 RECT *oldClientRect, WINDOWPOS *winpos, 625 RECT *newClientRect ) 626 { 627 NCCALCSIZE_PARAMS params; 628 WINDOWPOS winposCopy; 629 LONG result; 630 631 params.rgrc[0] = *newWindowRect; 632 if (calcValidRect) 633 { 634 winposCopy = *winpos; 635 params.rgrc[1] = *oldWindowRect; 636 params.rgrc[2] = *oldClientRect; 637 params.lppos = &winposCopy; 638 } 639 result = SendMessageA(WM_NCCALCSIZE, calcValidRect, 640 (LPARAM)¶ms ); 641 *newClientRect = params.rgrc[0]; 642 return result; 409 643 } 410 644 //****************************************************************************** … … 613 847 //****************************************************************************** 614 848 //****************************************************************************** 615 LRESULTWin32Window::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam)849 BOOL Win32Window::PostMessageA(ULONG msg, WPARAM wParam, LPARAM lParam) 616 850 { 617 851 POSTMSG_PACKET *postmsg; … … 620 854 if(postmsg == NULL) { 621 855 dprintf(("Win32Window::PostMessageA: malloc returned NULL!!")); 856 return 0; 622 857 } 623 858 postmsg->Msg = msg; … … 628 863 //****************************************************************************** 629 864 //****************************************************************************** 630 LRESULTWin32Window::PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam)865 BOOL Win32Window::PostMessageW(ULONG msg, WPARAM wParam, LPARAM lParam) 631 866 { 632 867 POSTMSG_PACKET *postmsg; … … 635 870 if(postmsg == NULL) { 636 871 dprintf(("Win32Window::PostMessageW: malloc returned NULL!!")); 872 return 0; 637 873 } 638 874 postmsg->Msg = msg; … … 642 878 } 643 879 //****************************************************************************** 880 //TODO: do we need to inform the parent of the parent (etc) of the child window? 644 881 //****************************************************************************** 645 882 void Win32Window::NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam) … … 665 902 window = parentwindow; 666 903 } 904 } 905 //****************************************************************************** 906 //****************************************************************************** 907 BOOL Win32Window::SetMenu(ULONG hMenu) 908 { 909 PVOID menutemplate; 910 911 if(HMHandleTranslateToOS2(hMenu, (PULONG)&menutemplate) == NO_ERROR) 912 { 913 OS2HwndMenu = OSLibWinCreateMenu(OS2Hwnd, menutemplate); 914 if(OS2HwndMenu == 0) { 915 dprintf(("Win32Window::SetMenu OS2HwndMenu == 0")); 916 return FALSE; 917 } 918 } 919 dprintf(("Win32Window::SetMenu unknown hMenu (%x)", hMenu)); 920 return FALSE; 921 } 922 //****************************************************************************** 923 //****************************************************************************** 924 BOOL Win32Window::ShowWindow(ULONG nCmdShow) 925 { 926 return O32_ShowWindow(OS2Hwnd, nCmdShow); 927 } 928 //****************************************************************************** 929 //****************************************************************************** 930 BOOL Win32Window::SetWindowPos(HWND hwndInsertAfter, int x, int y, int cx, int cy, UINT fuFlags) 931 { 932 Win32Window *window; 933 934 switch(hwndInsertAfter) { 935 case HWND_BOTTOM: 936 case HWND_TOP: 937 case HWND_TOPMOST: 938 case HWND_NOTOPMOST: 939 break; 940 default: 941 window = GetWindowFromHandle(hwndInsertAfter); 942 if(window) { 943 hwndInsertAfter = window->getOS2WindowHandle(); 944 } 945 else { 946 dprintf(("Win32Window::SetWindowPos, unknown hwndInsertAfter %x", hwndInsertAfter)); 947 hwndInsertAfter = 0; 948 } 949 break; 950 951 } 952 return O32_SetWindowPos(OS2Hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags); 953 } 954 //****************************************************************************** 955 BOOL Win32Window::DestroyWindow() 956 { 957 return TRUE; 958 } 959 //****************************************************************************** 960 //TODO: 961 //****************************************************************************** 962 HWND Win32Window::SetActiveWindow() 963 { 964 return O32_SetActiveWindow(OS2Hwnd); 965 } 966 //****************************************************************************** 967 //****************************************************************************** 968 HWND Win32Window::GetParent() 969 { 970 if(getParent()) { 971 return getParent()->getWindowHandle(); 972 } 973 else return 0; 974 } 975 //****************************************************************************** 976 //****************************************************************************** 977 HWND Win32Window::SetParent(HWND hwndNewParent) 978 { 979 HWND oldhwnd; 980 Win32Window *newparent; 981 982 if(getParent()) { 983 oldhwnd = getParent()->getWindowHandle(); 984 } 985 else oldhwnd = 0; 986 987 if(hwndNewParent == 0) {//desktop window = parent 988 setParent(NULL); 989 OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP); 990 return oldhwnd; 991 } 992 newparent = GetWindowFromHandle(hwndNewParent); 993 if(newparent) 994 { 995 setParent(newparent); 996 OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle()); 997 return oldhwnd; 998 } 999 SetLastError(ERROR_INVALID_PARAMETER); 1000 return 0; 1001 } 1002 //****************************************************************************** 1003 //****************************************************************************** 1004 BOOL Win32Window::IsChild(HWND hwndParent) 1005 { 1006 if(getParent()) { 1007 return getParent()->getWindowHandle() == hwndParent; 1008 } 1009 else return 0; 1010 } 1011 //****************************************************************************** 1012 //****************************************************************************** 1013 HWND Win32Window::GetTopWindow() 1014 { 1015 HWND topchild; 1016 1017 topchild = OSLibWinQueryTopMostChildWindow(OS2Hwnd); 1018 if(topchild) 1019 {//TODO 1020 return topchild; 1021 } 1022 else return 0; 1023 } 1024 //****************************************************************************** 1025 //TODO 1026 //****************************************************************************** 1027 BOOL Win32Window::UpdateWindow() 1028 { 1029 return TRUE; 1030 } 1031 //****************************************************************************** 1032 //TODO 1033 //****************************************************************************** 1034 BOOL Win32Window::IsIconic() 1035 { 1036 return FALSE; 667 1037 } 668 1038 //****************************************************************************** … … 690 1060 return oldval; 691 1061 case GWL_HWNDPARENT: 692 { 693 ULONG tmp; 694 695 if(getParent()) { 696 oldval = getParent()->getWindowHandle(); 697 } 698 else oldval = 0; 699 700 if(value == 0) {//desktop window = parent 701 setParent(NULL); 702 OSLibWinSetParent(getOS2WindowHandle(), OSLIB_HWND_DESKTOP); 703 return oldval; 704 } 705 if(HMHandleTranslateToOS2(value, &tmp) == NO_ERROR) 706 { 707 setParent((Win32Window *)tmp); 708 OSLibWinSetParent(getOS2WindowHandle(), getParent()->getOS2WindowHandle()); 709 return oldval; 710 } 711 SetLastError(ERROR_INVALID_PARAMETER); 712 return 0; 713 } 1062 return SetParent((HWND)value); 1063 714 1064 case GWL_ID: 715 1065 oldval = getWindowId(); … … 790 1140 //****************************************************************************** 791 1141 //****************************************************************************** 1142 Win32Window *Win32Window::GetWindowFromHandle(HWND hwnd) 1143 { 1144 Win32Window *window; 1145 1146 if(HIWORD(hwnd) != 0x6800) 1147 return NULL; 1148 1149 if(HMHandleTranslateToOS2(LOWORD(hwnd), (PULONG)&window) == NO_ERROR) { 1150 return window; 1151 } 1152 else return NULL; 1153 } 1154 //****************************************************************************** 1155 //****************************************************************************** 792 1156 GenericObject *Win32Window::windows = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.