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