| 1 | /* $Id: win32wmdichild.cpp,v 1.9 2000-01-14 13:16:59 sandervl Exp $ */ | 
|---|
| 2 | /* | 
|---|
| 3 | * Win32 MDI Child Window Class for OS/2 | 
|---|
| 4 | * | 
|---|
| 5 | * Copyright 1998-1999 Sander van Leeuwen (sandervl@xs4all.nl) | 
|---|
| 6 | * | 
|---|
| 7 | * Based on Wine (windows\mdi.c) (990815) | 
|---|
| 8 | * | 
|---|
| 9 | * Copyright 1994, Bob Amstadt | 
|---|
| 10 | *           1995,1996 Alex Korobka | 
|---|
| 11 | * Copyright 1993, 1994 Alexandre Julliard | 
|---|
| 12 | * | 
|---|
| 13 | * | 
|---|
| 14 | * | 
|---|
| 15 | * TODO: See #if 0's | 
|---|
| 16 | * | 
|---|
| 17 | * Project Odin Software License can be found in LICENSE.TXT | 
|---|
| 18 | * | 
|---|
| 19 | */ | 
|---|
| 20 | #include <os2win.h> | 
|---|
| 21 | #include <win.h> | 
|---|
| 22 | #include <stdlib.h> | 
|---|
| 23 | #include <stdio.h> | 
|---|
| 24 | #include <string.h> | 
|---|
| 25 | #include <stdarg.h> | 
|---|
| 26 | #include <assert.h> | 
|---|
| 27 | #include <misc.h> | 
|---|
| 28 | #include <heapstring.h> | 
|---|
| 29 | #include <win32wnd.h> | 
|---|
| 30 | #include <win32wmdiclient.h> | 
|---|
| 31 | #include <win32wmdichild.h> | 
|---|
| 32 | #include <spy.h> | 
|---|
| 33 | #include "wndmsg.h" | 
|---|
| 34 | #include <oslibwin.h> | 
|---|
| 35 | #include <oslibutil.h> | 
|---|
| 36 | #include <oslibgdi.h> | 
|---|
| 37 | #include <oslibres.h> | 
|---|
| 38 | #include "oslibdos.h" | 
|---|
| 39 | #include <winres.h> | 
|---|
| 40 | #include "syscolor.h" | 
|---|
| 41 | #include "win32wndhandle.h" | 
|---|
| 42 |  | 
|---|
| 43 |  | 
|---|
| 44 | //****************************************************************************** | 
|---|
| 45 | //****************************************************************************** | 
|---|
| 46 | Win32MDIChildWindow::Win32MDIChildWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL fUnicode) | 
|---|
| 47 | : Win32BaseWindow(OBJTYPE_WINDOW) | 
|---|
| 48 | { | 
|---|
| 49 | isUnicode = fUnicode; | 
|---|
| 50 | CreateWindowExA(lpCreateStructA, classAtom); | 
|---|
| 51 | } | 
|---|
| 52 | //****************************************************************************** | 
|---|
| 53 | //****************************************************************************** | 
|---|
| 54 | Win32MDIChildWindow::~Win32MDIChildWindow() | 
|---|
| 55 | { | 
|---|
| 56 | } | 
|---|
| 57 | //****************************************************************************** | 
|---|
| 58 | //****************************************************************************** | 
|---|
| 59 | ULONG Win32MDIChildWindow::MsgActivate(BOOL fActivate, BOOL fMinimized, HWND hwnd, HWND hwndOS2Win) | 
|---|
| 60 | { | 
|---|
| 61 | ULONG rc, procidhwnd = -1, threadidhwnd = 0; | 
|---|
| 62 |  | 
|---|
| 63 | //According to SDK docs, if app returns FALSE & window is being deactivated, | 
|---|
| 64 | //default processing is cancelled | 
|---|
| 65 | //TODO: According to Wine we should proceed anyway if window is sysmodal | 
|---|
| 66 | #if 0 | 
|---|
| 67 | if(SendInternalMessageA(WM_NCACTIVATE, fActivate, 0) == FALSE && !fActivate) | 
|---|
| 68 | { | 
|---|
| 69 | return 0; | 
|---|
| 70 | } | 
|---|
| 71 | #endif | 
|---|
| 72 |  | 
|---|
| 73 | if(fActivate) | 
|---|
| 74 | { | 
|---|
| 75 | rc = SendInternalMessageA(WM_CHILDACTIVATE, MAKELONG((fActivate) ? WA_ACTIVE : WA_INACTIVE, fMinimized), hwnd); | 
|---|
| 76 | if(hwndOS2Win) { | 
|---|
| 77 | threadidhwnd = O32_GetWindowThreadProcessId(hwndOS2Win, &procidhwnd); | 
|---|
| 78 | } | 
|---|
| 79 |  | 
|---|
| 80 | if(fActivate) { | 
|---|
| 81 | SendInternalMessageA(WM_ACTIVATEAPP, 1, dwThreadId);    //activate; specify window thread id | 
|---|
| 82 | } | 
|---|
| 83 | else   SendInternalMessageA(WM_ACTIVATEAPP, 0, threadidhwnd);  //deactivate; specify thread id of other process | 
|---|
| 84 | return rc; | 
|---|
| 85 | } | 
|---|
| 86 | else return 1; | 
|---|
| 87 | } | 
|---|
| 88 | //****************************************************************************** | 
|---|
| 89 | //****************************************************************************** | 
|---|
| 90 | BOOL Win32MDIChildWindow::isMDIChild() | 
|---|
| 91 | { | 
|---|
| 92 | return TRUE; | 
|---|
| 93 | } | 
|---|
| 94 | //****************************************************************************** | 
|---|
| 95 | //****************************************************************************** | 
|---|
| 96 | LRESULT Win32MDIChildWindow::DefMDIChildProcA(UINT Msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 97 | { | 
|---|
| 98 | Win32MDIClientWindow *client = (Win32MDIClientWindow *)getParent(); | 
|---|
| 99 |  | 
|---|
| 100 | switch (Msg) | 
|---|
| 101 | { | 
|---|
| 102 | case WM_SETTEXT: | 
|---|
| 103 | DefWindowProcA(Msg, wParam, lParam); | 
|---|
| 104 | menuModifyItem(); | 
|---|
| 105 | if( client->getMaximizedChild() == this ) | 
|---|
| 106 | client->updateFrameText(MDI_REPAINTFRAME, NULL); | 
|---|
| 107 | return 0; | 
|---|
| 108 |  | 
|---|
| 109 | case WM_GETMINMAXINFO: | 
|---|
| 110 | { | 
|---|
| 111 | childGetMinMaxInfo((MINMAXINFO *)lParam); | 
|---|
| 112 | return 0; | 
|---|
| 113 | } | 
|---|
| 114 |  | 
|---|
| 115 | case WM_MENUCHAR: | 
|---|
| 116 | /* MDI children don't have menu bars */ | 
|---|
| 117 | PostMessageA(client->getWindowHandle(), WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)LOWORD(wParam) ); | 
|---|
| 118 | return 0x00010000L; | 
|---|
| 119 |  | 
|---|
| 120 | case WM_CLOSE: | 
|---|
| 121 | client->SendMessageA(WM_MDIDESTROY,(WPARAM)getWindowHandle(), 0L); | 
|---|
| 122 | return 0; | 
|---|
| 123 |  | 
|---|
| 124 | case WM_SETFOCUS: | 
|---|
| 125 | if(client->getActiveChild() != this ) | 
|---|
| 126 | client->childActivate(this); | 
|---|
| 127 | break; | 
|---|
| 128 |  | 
|---|
| 129 | case WM_CHILDACTIVATE: | 
|---|
| 130 | client->childActivate(this); | 
|---|
| 131 | return 0; | 
|---|
| 132 |  | 
|---|
| 133 | case WM_NCPAINT: | 
|---|
| 134 | break; | 
|---|
| 135 |  | 
|---|
| 136 | case WM_SYSCOMMAND: | 
|---|
| 137 | switch( wParam ) | 
|---|
| 138 | { | 
|---|
| 139 | case SC_MOVE: | 
|---|
| 140 | if( client->getMaximizedChild() == this) | 
|---|
| 141 | { | 
|---|
| 142 | return 0; | 
|---|
| 143 | } | 
|---|
| 144 | break; | 
|---|
| 145 | case SC_RESTORE: | 
|---|
| 146 | case SC_MINIMIZE: | 
|---|
| 147 | setStyle(getStyle() | WS_SYSMENU); | 
|---|
| 148 | break; | 
|---|
| 149 |  | 
|---|
| 150 | case SC_MAXIMIZE: | 
|---|
| 151 | if( client->getMaximizedChild() == this) | 
|---|
| 152 | { | 
|---|
| 153 | return client->SendMessageA(Msg, wParam, lParam); | 
|---|
| 154 | } | 
|---|
| 155 | setStyle(getStyle() & ~WS_SYSMENU); | 
|---|
| 156 | break; | 
|---|
| 157 |  | 
|---|
| 158 | case SC_NEXTWINDOW: | 
|---|
| 159 | client->SendMessageA(WM_MDINEXT, 0, 0); | 
|---|
| 160 | return 0; | 
|---|
| 161 |  | 
|---|
| 162 | case SC_PREVWINDOW: //WM_MDINEXT?? | 
|---|
| 163 | client->SendMessageA(WM_MDINEXT, 0, 0); | 
|---|
| 164 | return 0; | 
|---|
| 165 | } | 
|---|
| 166 | break; | 
|---|
| 167 |  | 
|---|
| 168 | case WM_SETVISIBLE: | 
|---|
| 169 | if( client->getMaximizedChild()) { | 
|---|
| 170 | client->setMdiFlags(client->getMdiFlags() & ~MDIF_NEEDUPDATE); | 
|---|
| 171 | } | 
|---|
| 172 | else    client->postUpdate(SB_BOTH+1); | 
|---|
| 173 | break; | 
|---|
| 174 |  | 
|---|
| 175 | case WM_SIZE: | 
|---|
| 176 | /* do not change */ | 
|---|
| 177 | if( client->getActiveChild() == this && wParam != SIZE_MAXIMIZED ) | 
|---|
| 178 | { | 
|---|
| 179 | client->setMaximizedChild(NULL); | 
|---|
| 180 | client->restoreFrameMenu(this); | 
|---|
| 181 | client->updateFrameText(MDI_REPAINTFRAME, NULL ); | 
|---|
| 182 | } | 
|---|
| 183 |  | 
|---|
| 184 | if( wParam == SIZE_MAXIMIZED ) | 
|---|
| 185 | { | 
|---|
| 186 | Win32MDIChildWindow *maxChild = client->getMaximizedChild(); | 
|---|
| 187 |  | 
|---|
| 188 | if( maxChild == this ) break; | 
|---|
| 189 |  | 
|---|
| 190 | if( maxChild) | 
|---|
| 191 | { | 
|---|
| 192 | maxChild->SendMessageA(WM_SETREDRAW, FALSE, 0L ); | 
|---|
| 193 | client->restoreFrameMenu(maxChild); | 
|---|
| 194 | maxChild->ShowWindow(SW_SHOWNOACTIVATE); | 
|---|
| 195 |  | 
|---|
| 196 | maxChild->SendMessageA(WM_SETREDRAW, TRUE, 0L ); | 
|---|
| 197 | } | 
|---|
| 198 |  | 
|---|
| 199 | client->setMaximizedChild(this); | 
|---|
| 200 | client->setActiveChild(this); | 
|---|
| 201 |  | 
|---|
| 202 | client->augmentFrameMenu(this); | 
|---|
| 203 |  | 
|---|
| 204 | client->updateFrameText(MDI_REPAINTFRAME, NULL ); | 
|---|
| 205 | } | 
|---|
| 206 |  | 
|---|
| 207 | if( wParam == SIZE_MINIMIZED ) | 
|---|
| 208 | { | 
|---|
| 209 | Win32MDIChildWindow *switchTo = client->getWindow(this, TRUE, WS_MINIMIZE); | 
|---|
| 210 |  | 
|---|
| 211 | if( switchTo ) | 
|---|
| 212 | switchTo->SendMessageA(WM_CHILDACTIVATE, 0, 0L); | 
|---|
| 213 | } | 
|---|
| 214 |  | 
|---|
| 215 | client->postUpdate(SB_BOTH+1); | 
|---|
| 216 | break; | 
|---|
| 217 |  | 
|---|
| 218 | #if 0 | 
|---|
| 219 | case WM_NEXTMENU: | 
|---|
| 220 | if( wParam == VK_LEFT )     /* switch to frame system menu */ | 
|---|
| 221 | { | 
|---|
| 222 | return MAKELONG( GetSubMenu(clientWnd->parent->hSysMenu, 0), | 
|---|
| 223 | clientWnd->parent->hwndSelf ); | 
|---|
| 224 | goto END; | 
|---|
| 225 | } | 
|---|
| 226 | if( wParam == VK_RIGHT )    /* to frame menu bar */ | 
|---|
| 227 | { | 
|---|
| 228 | retvalue = MAKELONG( clientWnd->parent->wIDmenu, | 
|---|
| 229 | clientWnd->parent->hwndSelf ); | 
|---|
| 230 | goto END; | 
|---|
| 231 | } | 
|---|
| 232 | #endif | 
|---|
| 233 | case WM_SYSCHAR: | 
|---|
| 234 | if (wParam == '-') | 
|---|
| 235 | { | 
|---|
| 236 | SendInternalMessageA(WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)VK_SPACE); | 
|---|
| 237 | return 0; | 
|---|
| 238 | } | 
|---|
| 239 | } | 
|---|
| 240 | return DefWindowProcA(Msg, wParam, lParam); | 
|---|
| 241 | } | 
|---|
| 242 | //****************************************************************************** | 
|---|
| 243 | //****************************************************************************** | 
|---|
| 244 | LRESULT Win32MDIChildWindow::DefMDIChildProcW(UINT Msg, WPARAM wParam, LPARAM lParam) | 
|---|
| 245 | { | 
|---|
| 246 | Win32MDIClientWindow *client = (Win32MDIClientWindow *)getParent(); | 
|---|
| 247 |  | 
|---|
| 248 | switch (Msg) | 
|---|
| 249 | { | 
|---|
| 250 | case WM_SETTEXT: | 
|---|
| 251 | DefWindowProcW(Msg, wParam, lParam); | 
|---|
| 252 | menuModifyItem(); | 
|---|
| 253 | if( client->getMaximizedChild() == this ) | 
|---|
| 254 | client->updateFrameText(MDI_REPAINTFRAME, NULL ); | 
|---|
| 255 |  | 
|---|
| 256 | return 0; | 
|---|
| 257 |  | 
|---|
| 258 | case WM_GETMINMAXINFO: | 
|---|
| 259 | case WM_MENUCHAR: | 
|---|
| 260 | case WM_CLOSE: | 
|---|
| 261 | case WM_SETFOCUS: | 
|---|
| 262 | case WM_CHILDACTIVATE: | 
|---|
| 263 | case WM_NCPAINT: | 
|---|
| 264 | case WM_SYSCOMMAND: | 
|---|
| 265 | case WM_SETVISIBLE: | 
|---|
| 266 | case WM_SIZE: | 
|---|
| 267 | case WM_NEXTMENU: | 
|---|
| 268 | return DefMDIChildProcA(Msg, wParam, lParam ); | 
|---|
| 269 |  | 
|---|
| 270 | case WM_SYSCHAR: | 
|---|
| 271 | if (wParam == '-') | 
|---|
| 272 | { | 
|---|
| 273 | SendInternalMessageW(WM_SYSCOMMAND, SC_KEYMENU, (LPARAM)(DWORD)VK_SPACE); | 
|---|
| 274 | return 0; | 
|---|
| 275 | } | 
|---|
| 276 | break; | 
|---|
| 277 | } | 
|---|
| 278 | return DefWindowProcW(Msg, wParam, lParam); | 
|---|
| 279 | } | 
|---|
| 280 | /********************************************************************** | 
|---|
| 281 | *                  MDICreateChild | 
|---|
| 282 | */ | 
|---|
| 283 | HWND Win32MDIChildWindow::createChild(Win32MDIClientWindow *client, LPMDICREATESTRUCTA cs ) | 
|---|
| 284 | { | 
|---|
| 285 | POINT        pos[2]; | 
|---|
| 286 | DWORD        style = cs->style | (WS_CHILD | WS_CLIPSIBLINGS); | 
|---|
| 287 | WORD         wIDmenu = client->getFirstChildId() + client->getNrOfChildren(); | 
|---|
| 288 | char         lpstrDef[]="junk!"; | 
|---|
| 289 | Win32MDIChildWindow *maximizedChild, *newchild; | 
|---|
| 290 | CREATESTRUCTA createstruct; | 
|---|
| 291 | ATOM         classAtom; | 
|---|
| 292 | char         tmpClassA[20] = ""; | 
|---|
| 293 | WCHAR        tmpClassW[20]; | 
|---|
| 294 | LPSTR        className; | 
|---|
| 295 |  | 
|---|
| 296 | dprintf(("Win32MDIChildWindow::createChild %i,%i - dim %i,%i, style %08x\n", | 
|---|
| 297 | cs->x, cs->y, cs->cx, cs->cy, (unsigned)cs->style)); | 
|---|
| 298 |  | 
|---|
| 299 | /* calculate placement */ | 
|---|
| 300 | calcDefaultChildPos(client, client->incTotalCreated()-1, pos, 0); | 
|---|
| 301 |  | 
|---|
| 302 | if (cs->cx == CW_USEDEFAULT || !cs->cx) cs->cx = pos[1].x; | 
|---|
| 303 | if (cs->cy == CW_USEDEFAULT || !cs->cy) cs->cy = pos[1].y; | 
|---|
| 304 |  | 
|---|
| 305 | if( cs->x == CW_USEDEFAULT ) | 
|---|
| 306 | { | 
|---|
| 307 | cs->x = pos[0].x; | 
|---|
| 308 | cs->y = pos[0].y; | 
|---|
| 309 | } | 
|---|
| 310 |  | 
|---|
| 311 | /* restore current maximized child */ | 
|---|
| 312 | if( style & WS_VISIBLE && client->getMaximizedChild() ) | 
|---|
| 313 | { | 
|---|
| 314 | if( style & WS_MAXIMIZE ) | 
|---|
| 315 | client->SendMessageA(WM_SETREDRAW, FALSE, 0L ); | 
|---|
| 316 |  | 
|---|
| 317 | maximizedChild = client->getMaximizedChild(); | 
|---|
| 318 |  | 
|---|
| 319 | maximizedChild->ShowWindow( SW_SHOWNOACTIVATE ); | 
|---|
| 320 |  | 
|---|
| 321 | if( style & WS_MAXIMIZE ) | 
|---|
| 322 | client->SendMessageA(WM_SETREDRAW, TRUE, 0L ); | 
|---|
| 323 | } | 
|---|
| 324 |  | 
|---|
| 325 | /* this menu is needed to set a check mark in MDI_ChildActivate */ | 
|---|
| 326 | AppendMenuA(client->getMDIMenu(), MF_STRING ,wIDmenu, lpstrDef ); | 
|---|
| 327 |  | 
|---|
| 328 | client->incNrActiveChildren(); | 
|---|
| 329 |  | 
|---|
| 330 | /* fix window style */ | 
|---|
| 331 | if( !(client->getStyle() & MDIS_ALLCHILDSTYLES) ) | 
|---|
| 332 | { | 
|---|
| 333 | style &= (WS_CHILD | WS_CLIPSIBLINGS | WS_MINIMIZE | WS_MAXIMIZE | | 
|---|
| 334 | WS_CLIPCHILDREN | WS_DISABLED | WS_VSCROLL | WS_HSCROLL ); | 
|---|
| 335 | style |= (WS_VISIBLE | WS_OVERLAPPEDWINDOW); | 
|---|
| 336 | } | 
|---|
| 337 |  | 
|---|
| 338 | createstruct.lpszName  = cs->szTitle; | 
|---|
| 339 | createstruct.style     = style; | 
|---|
| 340 | createstruct.dwExStyle = 0; | 
|---|
| 341 | createstruct.x         = cs->x; | 
|---|
| 342 | createstruct.y         = cs->y; | 
|---|
| 343 | createstruct.cx        = cs->cx; | 
|---|
| 344 | createstruct.cy        = cs->cy; | 
|---|
| 345 | createstruct.hInstance = cs->hOwner; | 
|---|
| 346 | createstruct.hMenu     = wIDmenu; | 
|---|
| 347 | createstruct.hwndParent= client->getWindowHandle(); | 
|---|
| 348 | createstruct.lpCreateParams = (LPVOID)cs; | 
|---|
| 349 |  | 
|---|
| 350 | className = (LPSTR)cs->szClass; | 
|---|
| 351 | /* Find the class atom */ | 
|---|
| 352 | classAtom = GlobalFindAtomA(cs->szClass); | 
|---|
| 353 | if(classAtom == 0) | 
|---|
| 354 | { | 
|---|
| 355 | if (!HIWORD(cs->szClass)) | 
|---|
| 356 | { | 
|---|
| 357 | sprintf(tmpClassA,"#%d", (int) className); | 
|---|
| 358 | classAtom = GlobalFindAtomA(tmpClassA); | 
|---|
| 359 | className = tmpClassA; | 
|---|
| 360 | } | 
|---|
| 361 | if (!classAtom) | 
|---|
| 362 | { | 
|---|
| 363 | if (!HIWORD(cs->szClass)) { | 
|---|
| 364 | dprintf(("createChild: bad class name %04x\n", LOWORD(className))); | 
|---|
| 365 | } | 
|---|
| 366 | else    dprintf(("createChild: bad class name '%s'\n", tmpClassA )); | 
|---|
| 367 |  | 
|---|
| 368 | SetLastError(ERROR_INVALID_PARAMETER); | 
|---|
| 369 | return 0; | 
|---|
| 370 | } | 
|---|
| 371 | } | 
|---|
| 372 | createstruct.lpszClass = className; | 
|---|
| 373 |  | 
|---|
| 374 | newchild = new Win32MDIChildWindow(&createstruct, classAtom, FALSE); | 
|---|
| 375 |  | 
|---|
| 376 | if(newchild && GetLastError() == 0) | 
|---|
| 377 | { | 
|---|
| 378 | newchild->menuModifyItem(); | 
|---|
| 379 |  | 
|---|
| 380 | if( newchild->getStyle() & WS_MINIMIZE && client->getActiveChild()) { | 
|---|
| 381 | newchild->ShowWindow(SW_SHOWMINNOACTIVE); | 
|---|
| 382 | } | 
|---|
| 383 | else | 
|---|
| 384 | { | 
|---|
| 385 | /* WS_VISIBLE is clear if a) the MDI client has | 
|---|
| 386 | * MDIS_ALLCHILDSTYLES style and 2) the flag is cleared in the | 
|---|
| 387 | * MDICreateStruct. If so the created window is not shown nor | 
|---|
| 388 | * activated. | 
|---|
| 389 | */ | 
|---|
| 390 | int showflag = newchild->getStyle() & WS_VISIBLE; | 
|---|
| 391 | /* clear visible flag, otherwise SetWindoPos32 ignores | 
|---|
| 392 | * the SWP_SHOWWINDOW command. | 
|---|
| 393 | */ | 
|---|
| 394 | //SvL: Not here. This causes problems in OS/2 | 
|---|
| 395 | //            newchild->SetWindowLongA(GWL_STYLE, showflag & ~WS_VISIBLE); | 
|---|
| 396 | if(showflag){ | 
|---|
| 397 | newchild->SetWindowPos(0, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE ); | 
|---|
| 398 |  | 
|---|
| 399 | /* Set maximized state here in case hwnd didn't receive WM_SIZE | 
|---|
| 400 | * during CreateWindow - bad! | 
|---|
| 401 | */ | 
|---|
| 402 |  | 
|---|
| 403 | if((newchild->getStyle() & WS_MAXIMIZE) && !client->getMaximizedChild() ) | 
|---|
| 404 | { | 
|---|
| 405 | client->setMaximizedChild(newchild); | 
|---|
| 406 |  | 
|---|
| 407 | client->augmentFrameMenu(newchild); | 
|---|
| 408 |  | 
|---|
| 409 | client->updateFrameText(MDI_REPAINTFRAME, NULL ); | 
|---|
| 410 | } | 
|---|
| 411 | } | 
|---|
| 412 | else | 
|---|
| 413 | /* needed, harmless ? */ | 
|---|
| 414 | newchild->SetWindowPos(0, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE ); | 
|---|
| 415 |  | 
|---|
| 416 | } | 
|---|
| 417 | } | 
|---|
| 418 | else | 
|---|
| 419 | { | 
|---|
| 420 | client->decNrActiveChildren(); | 
|---|
| 421 | DeleteMenu(client->getMDIMenu(), wIDmenu,MF_BYCOMMAND); | 
|---|
| 422 |  | 
|---|
| 423 | maximizedChild = client->getMaximizedChild(); | 
|---|
| 424 | if( maximizedChild && maximizedChild->IsWindow() ) | 
|---|
| 425 | maximizedChild->ShowWindow(SW_SHOWMAXIMIZED); | 
|---|
| 426 |  | 
|---|
| 427 | dprintf(("MDI child creation failed!!")); | 
|---|
| 428 | return 0; | 
|---|
| 429 | } | 
|---|
| 430 | return newchild->getWindowHandle(); | 
|---|
| 431 | } | 
|---|
| 432 | /********************************************************************** | 
|---|
| 433 | *          MDI_MenuModifyItem | 
|---|
| 434 | */ | 
|---|
| 435 | BOOL Win32MDIChildWindow::menuModifyItem() | 
|---|
| 436 | { | 
|---|
| 437 | Win32MDIClientWindow *client = (Win32MDIClientWindow *)getParent(); | 
|---|
| 438 | char   buffer[128]; | 
|---|
| 439 | UINT   id   = getWindowId()-client->getFirstChildId()+1; | 
|---|
| 440 | UINT   n    = sprintf(buffer,(id > 9) ? "%d":"&%d ",id); | 
|---|
| 441 | BOOL   bRet = 0; | 
|---|
| 442 |  | 
|---|
| 443 | if( !client->getMDIMenu() ) | 
|---|
| 444 | { | 
|---|
| 445 | return FALSE; | 
|---|
| 446 | } | 
|---|
| 447 |  | 
|---|
| 448 | if (getWindowNameA()) lstrcpynA(buffer + n, getWindowNameA(), sizeof(buffer) - n ); | 
|---|
| 449 |  | 
|---|
| 450 | n    = GetMenuState(client->getMDIMenu(), getWindowId() ,MF_BYCOMMAND); | 
|---|
| 451 | bRet = ModifyMenuA(client->getMDIMenu() , getWindowId(), | 
|---|
| 452 | MF_BYCOMMAND | MF_STRING, getWindowId(), buffer ); | 
|---|
| 453 | CheckMenuItem(client->getMDIMenu(), getWindowId() , n & MF_CHECKED); | 
|---|
| 454 |  | 
|---|
| 455 | return bRet; | 
|---|
| 456 | } | 
|---|
| 457 |  | 
|---|
| 458 | /********************************************************************** | 
|---|
| 459 | *          MDI_MenuDeleteItem | 
|---|
| 460 | */ | 
|---|
| 461 | BOOL Win32MDIChildWindow::menuDeleteItem() | 
|---|
| 462 | { | 
|---|
| 463 | Win32MDIClientWindow *client = (Win32MDIClientWindow *)getParent(); | 
|---|
| 464 | char    buffer[128]; | 
|---|
| 465 | UINT    index      = 0,id,n; | 
|---|
| 466 | BOOL    retvalue; | 
|---|
| 467 |  | 
|---|
| 468 | if( !client->getNrOfChildren() || | 
|---|
| 469 | !client->getMDIMenu()) | 
|---|
| 470 | { | 
|---|
| 471 | return FALSE; | 
|---|
| 472 | } | 
|---|
| 473 |  | 
|---|
| 474 | id = getWindowId(); | 
|---|
| 475 | DeleteMenu(client->getMDIMenu(),id,MF_BYCOMMAND); | 
|---|
| 476 |  | 
|---|
| 477 | /* walk the rest of MDI children to prevent gaps in the id | 
|---|
| 478 | * sequence and in the menu child list */ | 
|---|
| 479 |  | 
|---|
| 480 | for( index = id+1; index <= client->getNrOfChildren() + | 
|---|
| 481 | client->getFirstChildId(); index++ ) | 
|---|
| 482 | { | 
|---|
| 483 | Win32MDIChildWindow *tmpWnd = client->getChildByID(index); | 
|---|
| 484 | if( !tmpWnd ) | 
|---|
| 485 | { | 
|---|
| 486 | dprintf(("no window for id=%i\n",index)); | 
|---|
| 487 | continue; | 
|---|
| 488 | } | 
|---|
| 489 |  | 
|---|
| 490 | /* set correct id */ | 
|---|
| 491 | tmpWnd->setWindowId(tmpWnd->getWindowId()-1); | 
|---|
| 492 |  | 
|---|
| 493 | n = sprintf(buffer, "%d ",index - client->getFirstChildId()); | 
|---|
| 494 | if (tmpWnd->getWindowNameA()) | 
|---|
| 495 | lstrcpynA(buffer + n, tmpWnd->getWindowNameA(), sizeof(buffer) - n ); | 
|---|
| 496 |  | 
|---|
| 497 | /* change menu */ | 
|---|
| 498 | ModifyMenuA(client->getMDIMenu(), index ,MF_BYCOMMAND | MF_STRING, | 
|---|
| 499 | index - 1 , buffer ); | 
|---|
| 500 | } | 
|---|
| 501 | return TRUE; | 
|---|
| 502 | } | 
|---|
| 503 | /********************************************************************** | 
|---|
| 504 | *          MDI_CalcDefaultChildPos | 
|---|
| 505 | * | 
|---|
| 506 | *  It seems that the default height is about 2/3 of the client rect | 
|---|
| 507 | */ | 
|---|
| 508 | void Win32MDIChildWindow::calcDefaultChildPos(Win32MDIClientWindow *client, WORD n, LPPOINT lpPos, INT delta) | 
|---|
| 509 | { | 
|---|
| 510 | INT  nstagger; | 
|---|
| 511 | RECT rect; | 
|---|
| 512 | INT  spacing = GetSystemMetrics(SM_CYCAPTION) + | 
|---|
| 513 | GetSystemMetrics(SM_CYFRAME) - 1; | 
|---|
| 514 |  | 
|---|
| 515 | client->getClientRect(&rect); | 
|---|
| 516 | if( rect.bottom - rect.top - delta >= spacing ) | 
|---|
| 517 | rect.bottom -= delta; | 
|---|
| 518 |  | 
|---|
| 519 | nstagger = (rect.bottom - rect.top)/(3 * spacing); | 
|---|
| 520 | lpPos[1].x = (rect.right - rect.left - nstagger * spacing); | 
|---|
| 521 | lpPos[1].y = (rect.bottom - rect.top - nstagger * spacing); | 
|---|
| 522 | lpPos[0].x = lpPos[0].y = spacing * (n%(nstagger+1)); | 
|---|
| 523 | } | 
|---|
| 524 |  | 
|---|
| 525 | /********************************************************************** | 
|---|
| 526 | *          MDI_ChildGetMinMaxInfo | 
|---|
| 527 | * | 
|---|
| 528 | * Note: The rule here is that client rect of the maximized MDI child | 
|---|
| 529 | *   is equal to the client rect of the MDI client window. | 
|---|
| 530 | */ | 
|---|
| 531 | void Win32MDIChildWindow::childGetMinMaxInfo(MINMAXINFO* lpMinMax ) | 
|---|
| 532 | { | 
|---|
| 533 | Win32MDIClientWindow *client = (Win32MDIClientWindow *)getParent(); | 
|---|
| 534 | RECT rect; | 
|---|
| 535 |  | 
|---|
| 536 | client->getClientRect(&rect); | 
|---|
| 537 | if(client->getParent() == NULL) { | 
|---|
| 538 | dprintf(("Win32MDIChildWindow::childGetMinMaxInfo:: client parent == NULL!!")); | 
|---|
| 539 | return; | 
|---|
| 540 | } | 
|---|
| 541 | MapWindowPoints(client->getParent()->getWindowHandle(), client->getWindowHandle(), (LPPOINT)&rect, 2); | 
|---|
| 542 |  | 
|---|
| 543 | AdjustWindowRectEx( &rect, getStyle(), 0, getExStyle()); | 
|---|
| 544 |  | 
|---|
| 545 | lpMinMax->ptMaxSize.x = rect.right -= rect.left; | 
|---|
| 546 | lpMinMax->ptMaxSize.y = rect.bottom -= rect.top; | 
|---|
| 547 |  | 
|---|
| 548 | lpMinMax->ptMaxPosition.x = rect.left; | 
|---|
| 549 | lpMinMax->ptMaxPosition.y = rect.top; | 
|---|
| 550 | } | 
|---|
| 551 |  | 
|---|
| 552 | //****************************************************************************** | 
|---|
| 553 | //****************************************************************************** | 
|---|
| 554 |  | 
|---|