Changeset 5935 for trunk/src/user32/win32wmdiclient.cpp
- Timestamp:
- Jun 9, 2001, 4:50:26 PM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/win32wmdiclient.cpp
r5258 r5935 1 /* $Id: win32wmdiclient.cpp,v 1.3 4 2001-02-23 14:52:42sandervl Exp $ */1 /* $Id: win32wmdiclient.cpp,v 1.35 2001-06-09 14:50:23 sandervl Exp $ */ 2 2 /* 3 3 * Win32 MDI Client Window Class for OS/2 … … 46 46 frameTitle(NULL), mdiFlags(0), idFirstChild(0), hWindowMenu(0), 47 47 sbRecalc(0), 48 Win32BaseWindow( OBJTYPE_WINDOW)48 Win32BaseWindow() 49 49 { 50 50 Init(); … … 125 125 126 126 case WM_MDIACTIVATE: 127 if( activeChild && activeChild->getWindowHandle()!= (HWND)wParam )127 if(activeChild != (HWND)wParam ) 128 128 { 129 129 mdichild = (Win32MDIChildWindow *)GetWindowFromHandle((HWND)wParam); 130 130 if(mdichild) { 131 131 mdichild->SetWindowPos(0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE); 132 RELEASE_WNDOBJ(mdichild); 132 133 } 133 134 } … … 150 151 if(mdichild) { 151 152 retvalue = destroyChild(mdichild, TRUE ); 153 RELEASE_WNDOBJ(mdichild); 152 154 } 153 155 goto END; 154 156 155 157 case WM_MDIGETACTIVE: 156 dprintf(("WM_MDIGETACTIVE: %x %x", this, (activeChild) ? activeChild->getWindowHandle() : 0));158 dprintf(("WM_MDIGETACTIVE: %x %x", this, activeChild)); 157 159 if (lParam) 158 160 *(BOOL *)lParam = (maximizedChild != 0); 159 161 160 retvalue = (activeChild) ? activeChild->getWindowHandle() : 0;162 retvalue = activeChild; 161 163 goto END; 162 164 … … 178 180 if(mdichild) { 179 181 switchActiveChild(mdichild, (lParam)? FALSE : TRUE ); 182 RELEASE_WNDOBJ(mdichild); 180 183 } 181 184 break; … … 212 215 if( activeChild ) 213 216 { 214 if( !( activeChild->getStyle() & WS_MINIMIZE) )215 ::SetFocus(activeChild ->getWindowHandle());217 if( !(GetWindowLongA(activeChild, GWL_STYLE) & WS_MINIMIZE) ) 218 ::SetFocus(activeChild); 216 219 } 217 220 retvalue = 0; … … 220 223 case WM_NCACTIVATE: 221 224 if( activeChild ) 222 activeChild->SendInternalMessageA(message, wParam, lParam);225 ::SendMessageA(activeChild, message, wParam, lParam); 223 226 break; 224 227 … … 234 237 HWND child = ChildWindowFromPoint(getWindowHandle(), point); 235 238 236 if( child && child != getWindowHandle() && ( !activeChild || activeChild->getWindowHandle()!= child) )239 if( child && child != getWindowHandle() && (activeChild != child) ) 237 240 ::SetWindowPos(child, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE ); 238 241 } … … 241 244 242 245 case WM_SIZE: 243 if( maximizedChild && maximizedChild->IsWindow() )246 if( ::IsWindow(maximizedChild) ) 244 247 { 245 248 RECT rect; … … 250 253 rect.bottom = HIWORD(lParam); 251 254 252 AdjustWindowRectEx(&rect, maximizedChild->getStyle(), 0, maximizedChild->getExStyle());253 ::MoveWindow(maximizedChild ->getWindowHandle(), rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 1);255 AdjustWindowRectEx(&rect, GetWindowLongA(maximizedChild, GWL_STYLE), 0, GetWindowLongA(maximizedChild, GWL_EXSTYLE)); 256 ::MoveWindow(maximizedChild, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 1); 254 257 } 255 258 else postUpdate(SB_BOTH+1); … … 285 288 return 0; 286 289 } 287 return window->MDIClientWndProc(message, wParam, lParam); 290 LRESULT ret = window->MDIClientWndProc(message, wParam, lParam); 291 RELEASE_WNDOBJ(window); 292 return ret; 288 293 } 289 294 /********************************************************************** … … 299 304 dwStyleMask |= WS_DISABLED | WS_VISIBLE; 300 305 301 if( !actchild ) actchild = getActiveChild(); 306 if( !actchild ) { 307 actchild = (Win32MDIChildWindow *)GetWindowFromHandle(getActiveChild()); 308 } 309 else actchild->addRef(); 310 302 311 if( !actchild) return 0; 303 312 313 lock(); 304 314 for ( curchild = (Win32MDIChildWindow *)actchild->getNextChild(); ; curchild = (Win32MDIChildWindow *)curchild->getNextChild()) 305 315 { … … 314 324 } 315 325 } 326 unlock(); 327 RELEASE_WNDOBJ(actchild); 316 328 return lastchild; 317 329 } … … 325 337 BOOL isActiveFrameWnd = 0; 326 338 LONG retvalue; 327 Win32MDIChildWindow *prevActive = activeChild;339 Win32MDIChildWindow *prevActive = (Win32MDIChildWindow *)GetWindowFromHandle(activeChild); 328 340 329 341 if( child && child->getStyle() & WS_DISABLED ) 330 342 { 343 if(prevActive) RELEASE_WNDOBJ(prevActive); 331 344 return 0; 332 345 } … … 334 347 /* Don't activate if it is already active. Might happen 335 348 since ShowWindow DOES activate MDI children */ 336 if(activeChild == child) 337 { 349 if(activeChild == child->getWindowHandle()) 350 { 351 if(prevActive) RELEASE_WNDOBJ(prevActive); 338 352 return 0; 339 353 } … … 358 372 if( maximizedChild) 359 373 { 360 if( maximizedChild != child ) {374 if( maximizedChild != child->getWindowHandle()) { 361 375 if( child ) { 362 activeChild = child ;376 activeChild = child->getWindowHandle(); 363 377 child->ShowWindow(SW_SHOWMAXIMIZED); 364 378 } 365 379 else 366 if(activeChild) activeChild->ShowWindow(SW_SHOWNORMAL );380 if(activeChild) ::ShowWindow(activeChild, SW_SHOWNORMAL ); 367 381 } 368 382 } 369 383 370 384 dprintf(("childActivate: %x %x", this, (child) ? child->getWindowHandle() : 0)); 371 activeChild = child ;385 activeChild = child->getWindowHandle(); 372 386 373 387 /* check if we have any children left */ … … 377 391 SetFocus(getWindowHandle()); 378 392 393 if(prevActive) RELEASE_WNDOBJ(prevActive); 379 394 return 0; 380 395 } … … 400 415 prevActive ? (WPARAM)prevActive->getWindowHandle() : 0, 401 416 child->getWindowHandle()); 417 418 if(prevActive) RELEASE_WNDOBJ(prevActive); 402 419 return TRUE; 403 420 } … … 410 427 void Win32MDIClientWindow::switchActiveChild(Win32MDIChildWindow *nextActiveChild, BOOL bNextWindow ) 411 428 { 412 Win32MDIChildWindow *prevActiveChild = 0;429 HWND prevActiveChild = 0; 413 430 414 431 if ( !nextActiveChild) return; /* no window to switch to */ … … 416 433 prevActiveChild = getActiveChild(); 417 434 418 if ( prevActiveChild != nextActiveChild )435 if ( prevActiveChild != nextActiveChild->getWindowHandle()) 419 436 { 420 437 BOOL bOptimize = 0; … … 429 446 430 447 if( bNextWindow && prevActiveChild ) 431 prevActiveChild->SetWindowPos(HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE );448 ::SetWindowPos(prevActiveChild, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE ); 432 449 433 450 if( bOptimize ) … … 442 459 LRESULT Win32MDIClientWindow::destroyChild(Win32MDIChildWindow *child, BOOL flagDestroy ) 443 460 { 444 if( child == getActiveChild())461 if( child->getWindowHandle() == getActiveChild()) 445 462 { 446 463 switchActiveChild(child, TRUE); 447 464 448 if( child == getActiveChild() )465 if( child->getWindowHandle() == getActiveChild() ) 449 466 { 450 467 ::ShowWindow(child->getWindowHandle(),SW_HIDE); 451 if( child == getMaximizedChild() )468 if( child->getWindowHandle() == getMaximizedChild() ) 452 469 { 453 470 restoreFrameMenu(child); … … 492 509 if (frameTitle) 493 510 { 494 Win32MDIChildWindow *childWnd = getMaximizedChild();511 Win32MDIChildWindow *childWnd = (Win32MDIChildWindow *)GetWindowFromHandle(getMaximizedChild()); 495 512 496 513 if( childWnd && childWnd->getWindowNameA() ) … … 526 543 lpBuffer[MDI_MAXTITLELENGTH]='\0'; 527 544 } 545 if(childWnd) RELEASE_WNDOBJ(childWnd); 528 546 } 529 547 else … … 800 818 801 819 if (getMaximizedChild()) 802 SendInternalMessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild() ->getWindowHandle(), 0);820 SendInternalMessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild(), 0); 803 821 804 822 if (nActiveChildren == 0) return 0; … … 845 863 846 864 if (getMaximizedChild()) 847 SendInternalMessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild() ->getWindowHandle(), 0);865 SendInternalMessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild(), 0); 848 866 849 867 if (nActiveChildren == 0) return TRUE; … … 914 932 * MDI_AugmentFrameMenu 915 933 */ 916 BOOL Win32MDIClientWindow::augmentFrameMenu(Win32MDIChildWindow *child) 917 { 934 BOOL Win32MDIClientWindow::augmentFrameMenu(HWND hwndChild) 935 { 936 Win32MDIChildWindow *child = (Win32MDIChildWindow *)GetWindowFromHandle(hwndChild); 918 937 HMENU hSysPopup = 0,hFrameMenu = ::GetMenu(getParent()->getWindowHandle()),hSysMenu = ::GetSystemMenu(child->getWindowHandle(),FALSE); 919 938 HBITMAP hSysMenuBitmap = 0; 920 939 921 if (!hFrameMenu || !hSysMenu) 940 if (!hFrameMenu || !hSysMenu) { 941 RELEASE_WNDOBJ(child); 922 942 return 0; 923 943 } 924 944 // create a copy of sysmenu popup and insert it into frame menu bar 925 945 926 if (!(hSysPopup = LoadMenuA(GetModuleHandleA("USER32"), "SYSMENU"))) 946 if (!(hSysPopup = LoadMenuA(GetModuleHandleA("USER32"), "SYSMENU"))) { 947 RELEASE_WNDOBJ(child); 927 948 return 0; 949 } 928 950 929 951 //TRACE("\tgot popup %04x in sysmenu %04x\n", … … 936 958 937 959 // In Win 95 look, the system menu is replaced by the child icon 938 960 939 961 /* Find icon */ 940 962 HICON hIcon = child->IconForWindow(ICON_SMALL); … … 966 988 } 967 989 } 990 RELEASE_WNDOBJ(child); 968 991 969 992 if( !InsertMenuA(hFrameMenu,0,MF_BYPOSITION | MF_BITMAP | MF_POPUP, … … 994 1017 * MDI_RestoreFrameMenu 995 1018 */ 996 BOOL Win32MDIClientWindow::restoreFrameMenu( Win32MDIChildWindow *child)1019 BOOL Win32MDIClientWindow::restoreFrameMenu(HWND hwndChild) 997 1020 { 998 1021 MENUITEMINFOA menuInfo; … … 1004 1027 1005 1028 if(!(iId == SC_RESTORE || iId == SC_CLOSE) ) 1006 return 0;1029 return 0; 1007 1030 1008 1031 /* … … 1049 1072 { 1050 1073 Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd); 1074 Win32BaseWindow *child; 1051 1075 SCROLLINFO info; 1052 1076 RECT childRect, clientRect; … … 1059 1083 1060 1084 //TODO: Check if this goes correctly 1061 for (win32wnd = (Win32BaseWindow*)win32wnd->getFirstChild();win32wnd;win32wnd = (Win32BaseWindow*)win32wnd->getNextChild()) 1062 { 1063 if( win32wnd->getStyle() & WS_MAXIMIZE ) 1085 win32wnd->lock(); 1086 for (child = (Win32BaseWindow*)win32wnd->getFirstChild();child;child = (Win32BaseWindow*)child->getNextChild()) 1087 { 1088 if( child->getStyle() & WS_MAXIMIZE ) 1064 1089 { 1090 win32wnd->unlock(); 1091 RELEASE_WNDOBJ(win32wnd); 1065 1092 ShowScrollBar(hwnd, SB_BOTH, FALSE); 1066 1093 return; 1067 1094 } 1068 UnionRect(&childRect,win32wnd->getWindowRect(),&childRect); 1069 } 1095 UnionRect(&childRect,child->getWindowRect(),&childRect); 1096 } 1097 win32wnd->unlock(); 1098 RELEASE_WNDOBJ(win32wnd); 1099 1070 1100 UnionRect( &childRect, &clientRect, &childRect ); 1071 1101 … … 1121 1151 length = win32wnd->getClientWidth()/2; 1122 1152 shift = GetSystemMetrics(SM_CYHSCROLL); 1123 } else if (uMsg == WM_VSCROLL) 1153 } 1154 else if (uMsg == WM_VSCROLL) 1124 1155 { 1125 1156 GetScrollRange(hWnd,SB_VERT,&minPos,&maxPos); … … 1127 1158 length = win32wnd->getClientHeight()/2; 1128 1159 shift = GetSystemMetrics(SM_CXVSCROLL); 1129 } else return; 1160 } 1161 else 1162 { 1163 RELEASE_WNDOBJ(win32wnd); 1164 return; 1165 } 1166 RELEASE_WNDOBJ(win32wnd); 1130 1167 1131 1168 switch( wParam ) … … 1292 1329 } 1293 1330 1294 /* -------- Miscellaneous service functions ---------- 1295 * 1296 * MDI_GetChildByID 1297 */ 1298 Win32MDIChildWindow *Win32MDIClientWindow::getChildByID(INT id) 1299 { 1300 Win32MDIChildWindow *child; 1301 1302 for (child = (Win32MDIChildWindow *)getFirstChild() ; child; child = (Win32MDIChildWindow *)child->getNextChild()) 1303 if (child->getWindowId() == id) return child; 1304 1305 return 0; 1306 } 1331 /* -------- Miscellaneous service functions ---------- */ 1307 1332 1308 1333 void Win32MDIClientWindow::postUpdate(WORD recalc)
Note:
See TracChangeset
for help on using the changeset viewer.