3 * Copyright 1994, Bob Amstadt
4 * 1995,1996 Alex Korobka
6 * This file contains routines to support MDI features.
8 * Notes: Fairly complete implementation. Any volunteers for
9 * "More windows..." stuff?
11 * Also, Excel and WinWord do _not_ use MDI so if you're trying
12 * to fix them look elsewhere.
23 #include "nonclient.h"
29 #include "sysmetrics.h"
33 #define MDIF_NEEDUPDATE 0x0001
36 static HBITMAP16 hBmpClose
= 0;
37 static HBITMAP16 hBmpRestore
= 0;
39 DWORD
SCROLL_SetNCSbState(WND
*,int,int,int,int,int,int);
41 /* ----------------- declarations ----------------- */
42 static void MDI_UpdateFrameText(WND
*, HWND16
, BOOL32
, LPCSTR
);
43 static BOOL32
MDI_AugmentFrameMenu(MDICLIENTINFO
*, WND
*, HWND16
);
44 static BOOL32
MDI_RestoreFrameMenu(WND
*, HWND16
);
46 static LONG
MDI_ChildActivate(WND
* ,HWND16
);
48 /* -------- Miscellaneous service functions ----------
53 static HWND16
MDI_GetChildByID(WND
* wndPtr
,int id
)
55 for (wndPtr
= wndPtr
->child
; wndPtr
; wndPtr
= wndPtr
->next
)
56 if (wndPtr
->wIDmenu
== id
) return wndPtr
->hwndSelf
;
60 static void MDI_PostUpdate(HWND16 hwnd
, MDICLIENTINFO
* ci
, WORD recalc
)
62 if( !(ci
->mdiFlags
& MDIF_NEEDUPDATE
) )
64 ci
->mdiFlags
|= MDIF_NEEDUPDATE
;
65 PostMessage16( hwnd
, WM_MDICALCCHILDSCROLL
, 0, 0);
67 ci
->sbRecalc
= recalc
;
70 /**********************************************************************
73 #ifdef SUPERFLUOUS_FUNCTIONS
74 static BOOL32
MDI_MenuAppendItem(WND
*clientWnd
, HWND16 hWndChild
)
77 MDICLIENTINFO
*clientInfo
= (MDICLIENTINFO
*)clientWnd
->wExtra
;
78 WND
*wndPtr
= WIN_FindWndPtr(hWndChild
);
79 int n
= sprintf(buffer
, "%d ",
80 clientInfo
->nActiveChildren
);
82 if( !clientInfo
->hWindowMenu
) return 0;
84 if (wndPtr
->text
) strncpy(buffer
+ n
, wndPtr
->text
, sizeof(buffer
) - n
- 1);
85 return AppendMenu32A( clientInfo
->hWindowMenu
, MF_STRING
,
86 wndPtr
->wIDmenu
, buffer
);
90 /**********************************************************************
93 static BOOL32
MDI_MenuModifyItem(WND
* clientWnd
, HWND16 hWndChild
)
96 MDICLIENTINFO
*clientInfo
= (MDICLIENTINFO
*)clientWnd
->wExtra
;
97 WND
*wndPtr
= WIN_FindWndPtr(hWndChild
);
98 UINT32 n
= sprintf(buffer
, "%d ",
99 wndPtr
->wIDmenu
- clientInfo
->idFirstChild
+ 1);
102 if( !clientInfo
->hWindowMenu
) return 0;
104 if (wndPtr
->text
) lstrcpyn32A(buffer
+ n
, wndPtr
->text
, sizeof(buffer
) - n
);
106 n
= GetMenuState32(clientInfo
->hWindowMenu
,wndPtr
->wIDmenu
,MF_BYCOMMAND
);
107 bRet
= ModifyMenu32A(clientInfo
->hWindowMenu
, wndPtr
->wIDmenu
,
108 MF_BYCOMMAND
| MF_STRING
, wndPtr
->wIDmenu
, buffer
);
109 CheckMenuItem32(clientInfo
->hWindowMenu
,wndPtr
->wIDmenu
, n
& MF_CHECKED
);
113 /**********************************************************************
116 static BOOL32
MDI_MenuDeleteItem(WND
* clientWnd
, HWND16 hWndChild
)
119 MDICLIENTINFO
*clientInfo
= (MDICLIENTINFO
*)clientWnd
->wExtra
;
120 WND
*wndPtr
= WIN_FindWndPtr(hWndChild
);
121 UINT32 index
= 0,id
,n
;
123 if( !clientInfo
->nActiveChildren
||
124 !clientInfo
->hWindowMenu
) return 0;
126 id
= wndPtr
->wIDmenu
;
127 DeleteMenu32(clientInfo
->hWindowMenu
,id
,MF_BYCOMMAND
);
129 /* walk the rest of MDI children to prevent gaps in the id
130 * sequence and in the menu child list */
132 for( index
= id
+1; index
<= clientInfo
->nActiveChildren
+
133 clientInfo
->idFirstChild
; index
++ )
135 wndPtr
= WIN_FindWndPtr(MDI_GetChildByID(clientWnd
,index
));
138 dprintf_mdi(stddeb
,"MDIMenuDeleteItem: no window for id=%i\n",index
);
145 n
= sprintf(buffer
, "%d ",index
- clientInfo
->idFirstChild
);
147 lstrcpyn32A(buffer
+ n
, wndPtr
->text
, sizeof(buffer
) - n
);
150 ModifyMenu32A(clientInfo
->hWindowMenu
,index
,MF_BYCOMMAND
| MF_STRING
,
151 index
- 1 , buffer
);
156 /**********************************************************************
159 * returns "activateable" child or zero
161 static HWND16
MDI_GetWindow(WND
*clientWnd
, HWND16 hWnd
, WORD wTo
)
163 MDICLIENTINFO
*clientInfo
= (MDICLIENTINFO
*)clientWnd
->wExtra
;
164 WND
*wndPtr
, *pWnd
, *pWndLast
;
166 if( !hWnd
) hWnd
= clientInfo
->hwndActiveChild
;
168 if( !(wndPtr
= WIN_FindWndPtr(hWnd
)) ) return 0;
175 if (!pWnd
) pWnd
= wndPtr
->parent
->child
;
176 if (pWnd
== wndPtr
) /* not found */
178 if (!wTo
|| !pWndLast
) return 0;
182 if ( !pWnd
->owner
&& (pWnd
->dwStyle
&
183 (WS_VISIBLE
| WS_DISABLED
)) == WS_VISIBLE
)
189 return pWndLast
? pWndLast
->hwndSelf
: 0;
192 /**********************************************************************
193 * MDI_CalcDefaultChildPos
195 * It seems that default height is 2/3 of client rect
197 static void MDI_CalcDefaultChildPos( WND
* w
, WORD n
, LPPOINT16 lpPos
,
200 RECT16 rect
= w
->rectClient
;
201 INT32 spacing
= GetSystemMetrics32(SM_CYCAPTION
) +
202 GetSystemMetrics32(SM_CYFRAME
) - 1;
205 if( rect
.bottom
- rect
.top
- delta
>= spacing
)
206 rect
.bottom
-= delta
;
208 nstagger
= (rect
.bottom
- rect
.top
)/(3*spacing
);
209 lpPos
[1].x
= (rect
.right
- rect
.left
- nstagger
*spacing
);
210 lpPos
[1].y
= (rect
.bottom
- rect
.top
- nstagger
*spacing
);
211 lpPos
[0].x
= lpPos
[0].y
= spacing
*(n
%(nstagger
+1));
214 /**********************************************************************
217 static HMENU16
MDISetMenu(HWND16 hwnd
, BOOL32 fRefresh
, HMENU16 hmenuFrame
,
220 WND
*w
= WIN_FindWndPtr(hwnd
);
223 dprintf_mdi(stddeb
, "WM_MDISETMENU: %04x %04x %04x %04x\n",
224 hwnd
, fRefresh
, hmenuFrame
, hmenuWindow
);
226 ci
= (MDICLIENTINFO
*) w
->wExtra
;
230 HWND16 hwndFrame
= GetParent16(hwnd
);
231 HMENU32 oldFrameMenu
= GetMenu32(hwndFrame
);
233 if( ci
->hwndChildMaximized
&& hmenuFrame
&& hmenuFrame
!=oldFrameMenu
)
234 MDI_RestoreFrameMenu(w
->parent
, ci
->hwndChildMaximized
);
236 if( hmenuWindow
&& hmenuWindow
!=ci
->hWindowMenu
)
238 /* delete menu items from ci->hWindowMenu
239 * and add them to hmenuWindow */
241 INT32 i
= GetMenuItemCount32(ci
->hWindowMenu
) - 1;
242 INT32 pos
= GetMenuItemCount32(hmenuWindow
) + 1;
244 AppendMenu32A( hmenuWindow
, MF_SEPARATOR
, 0, NULL
);
246 if( ci
->nActiveChildren
)
248 INT32 j
= i
- ci
->nActiveChildren
+ 1;
252 for( ; i
>= j
; i
-- )
254 id
= GetMenuItemID32(ci
->hWindowMenu
,i
);
255 state
= GetMenuState32(ci
->hWindowMenu
,i
,MF_BYPOSITION
);
257 GetMenuString32A(ci
->hWindowMenu
, i
, buffer
, 100, MF_BYPOSITION
);
259 DeleteMenu32(ci
->hWindowMenu
, i
, MF_BYPOSITION
);
260 InsertMenu32A(hmenuWindow
, pos
, MF_BYPOSITION
| MF_STRING
,
262 CheckMenuItem32(hmenuWindow
,pos
, MF_BYPOSITION
| (state
& MF_CHECKED
));
266 /* remove separator */
267 DeleteMenu32(ci
->hWindowMenu
, i
, MF_BYPOSITION
);
269 ci
->hWindowMenu
= hmenuWindow
;
272 if( hmenuFrame
&& hmenuFrame
!=oldFrameMenu
)
274 SetMenu32(hwndFrame
, hmenuFrame
);
275 if( ci
->hwndChildMaximized
)
276 MDI_AugmentFrameMenu(ci
, w
->parent
, ci
->hwndChildMaximized
);
284 /**********************************************************************
287 static WORD
MDIIconArrange(HWND16 parent
)
289 return ArrangeIconicWindows16(parent
); /* Any reason why the */
290 /* existing icon arrange */
291 /* can't be used here? */
296 /* ------------------ MDI child window functions ---------------------- */
299 /**********************************************************************
302 static HWND16
MDICreateChild( WND
*w
, MDICLIENTINFO
*ci
, HWND16 parent
,
303 LPMDICREATESTRUCT16 cs
, LPARAM lParam
)
306 DWORD style
= cs
->style
| (WS_CHILD
| WS_CLIPSIBLINGS
);
307 HWND16 hwnd
, hwndMax
= 0;
308 WORD wIDmenu
= ci
->idFirstChild
+ ci
->nActiveChildren
;
309 char lpstrDef
[]="junk!";
311 dprintf_mdi(stdnimp
,"MDICreateChild: origin %i,%i - dim %i,%i, style %08x\n",
312 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
, (unsigned)cs
->style
);
313 /* calculate placement */
314 MDI_CalcDefaultChildPos(w
, ci
->nTotalCreated
++, pos
, 0);
316 if( cs
->cx
== CW_USEDEFAULT16
|| !cs
->cx
)
318 if( cs
->cy
== CW_USEDEFAULT16
|| !cs
->cy
)
321 if( cs
->x
== CW_USEDEFAULT16
)
327 /* restore current maximized child */
328 if( style
& WS_VISIBLE
&& ci
->hwndChildMaximized
)
330 if( style
& WS_MAXIMIZE
)
331 SendMessage16(w
->hwndSelf
, WM_SETREDRAW
, FALSE
, 0L );
332 hwndMax
= ci
->hwndChildMaximized
;
333 ShowWindow16( hwndMax
, SW_SHOWNOACTIVATE
);
334 if( style
& WS_MAXIMIZE
)
335 SendMessage16(w
->hwndSelf
, WM_SETREDRAW
, TRUE
, 0L );
338 /* this menu is needed to set a check mark in MDI_ChildActivate */
339 AppendMenu32A(ci
->hWindowMenu
,MF_STRING
,wIDmenu
, lpstrDef
);
341 ci
->nActiveChildren
++;
343 /* fix window style */
344 if( !(w
->dwStyle
& MDIS_ALLCHILDSTYLES
) )
346 style
&= (WS_CHILD
| WS_CLIPSIBLINGS
| WS_MINIMIZE
| WS_MAXIMIZE
|
347 WS_CLIPCHILDREN
| WS_DISABLED
| WS_VSCROLL
| WS_HSCROLL
);
348 style
|= (WS_VISIBLE
| WS_OVERLAPPEDWINDOW
);
351 hwnd
= CreateWindow16( (LPCSTR
)PTR_SEG_TO_LIN(cs
->szClass
),
352 (LPCSTR
)PTR_SEG_TO_LIN(cs
->szTitle
), style
,
353 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
, parent
,
354 (HMENU16
)wIDmenu
, w
->hInstance
,
357 /* MDI windows are WS_CHILD so they won't be activated by CreateWindow */
361 WND
* wnd
= WIN_FindWndPtr( hwnd
);
363 MDI_MenuModifyItem(w
,hwnd
);
364 if( wnd
->dwStyle
& WS_MINIMIZE
&& ci
->hwndActiveChild
)
365 ShowWindow16( hwnd
, SW_SHOWMINNOACTIVE
);
368 SetWindowPos32( hwnd
, 0, 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
);
370 /* Set maximized state here in case hwnd didn't receive WM_SIZE
371 * during CreateWindow - bad!
374 if( wnd
->dwStyle
& WS_MAXIMIZE
&& !ci
->hwndChildMaximized
)
376 ci
->hwndChildMaximized
= wnd
->hwndSelf
;
377 MDI_AugmentFrameMenu( ci
, w
->parent
, hwnd
);
378 MDI_UpdateFrameText( w
->parent
, ci
->self
, MDI_REPAINTFRAME
, NULL
);
381 dprintf_mdi(stddeb
, "MDICreateChild: created child - %04x\n",hwnd
);
385 ci
->nActiveChildren
--;
386 DeleteMenu32(ci
->hWindowMenu
,wIDmenu
,MF_BYCOMMAND
);
387 if( IsWindow32(hwndMax
) )
388 ShowWindow32(hwndMax
, SW_SHOWMAXIMIZED
);
394 /**********************************************************************
395 * MDI_ChildGetMinMaxInfo
397 static void MDI_ChildGetMinMaxInfo( WND
* clientWnd
, HWND16 hwnd
,
398 MINMAXINFO16
* lpMinMax
)
400 WND
* childWnd
= WIN_FindWndPtr(hwnd
);
401 RECT16 rect
= clientWnd
->rectClient
;
403 MapWindowPoints16(clientWnd
->parent
->hwndSelf
,
404 ((MDICLIENTINFO
*)clientWnd
->wExtra
)->self
, (LPPOINT16
)&rect
, 2);
405 AdjustWindowRectEx16( &rect
, childWnd
->dwStyle
, 0, childWnd
->dwExStyle
);
407 lpMinMax
->ptMaxSize
.x
= rect
.right
-= rect
.left
;
408 lpMinMax
->ptMaxSize
.y
= rect
.bottom
-= rect
.top
;
410 lpMinMax
->ptMaxPosition
.x
= rect
.left
;
411 lpMinMax
->ptMaxPosition
.y
= rect
.top
;
413 dprintf_mdi(stddeb
,"\tChildMinMaxInfo: max rect (%i,%i - %i, %i)\n",
414 rect
.left
,rect
.top
,rect
.right
,rect
.bottom
);
418 /**********************************************************************
419 * MDI_SwitchActiveChild
421 * Notes: SetWindowPos sends WM_CHILDACTIVATE to the child window that is
424 * wTo is basically lParam of WM_MDINEXT message or explicit
427 static void MDI_SwitchActiveChild( HWND16 clientHwnd
, HWND16 childHwnd
,
430 WND
*w
= WIN_FindWndPtr(clientHwnd
);
435 hwndTo
= MDI_GetWindow(w
,childHwnd
,(WORD
)wTo
);
437 ci
= (MDICLIENTINFO
*) w
->wExtra
;
439 dprintf_mdi(stddeb
, "MDI_SwitchActiveChild: from %04x, to %04x\n",childHwnd
,hwndTo
);
441 if ( !hwndTo
) return;
443 hwndPrev
= ci
->hwndActiveChild
;
445 if ( hwndTo
!= hwndPrev
)
447 BOOL32 bOptimize
= 0;
449 if( ci
->hwndChildMaximized
)
452 w
->dwStyle
&= ~WS_VISIBLE
;
455 SetWindowPos32( hwndTo
, HWND_TOP
, 0, 0, 0, 0,
456 SWP_NOMOVE
| SWP_NOSIZE
);
457 if( !wTo
&& hwndPrev
)
459 SetWindowPos32( hwndPrev
, HWND_BOTTOM
, 0, 0, 0, 0,
460 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
464 ShowWindow16( clientHwnd
, SW_SHOW
);
469 /**********************************************************************
472 static HWND16
MDIDestroyChild( WND
*w_parent
, MDICLIENTINFO
*ci
, HWND16 parent
,
473 HWND16 child
, BOOL32 flagDestroy
)
475 WND
*childPtr
= WIN_FindWndPtr(child
);
479 if( child
== ci
->hwndActiveChild
)
481 MDI_SwitchActiveChild(parent
,child
,0);
483 if( child
== ci
->hwndActiveChild
)
485 ShowWindow16( child
, SW_HIDE
);
486 if( child
== ci
->hwndChildMaximized
)
488 MDI_RestoreFrameMenu(w_parent
->parent
, child
);
489 ci
->hwndChildMaximized
= 0;
490 MDI_UpdateFrameText(w_parent
->parent
,parent
,TRUE
,NULL
);
493 MDI_ChildActivate(w_parent
,0);
495 MDI_MenuDeleteItem(w_parent
, child
);
498 ci
->nActiveChildren
--;
500 dprintf_mdi(stddeb
,"MDIDestroyChild: child destroyed - %04x\n",child
);
504 MDI_PostUpdate(GetParent16(child
), ci
, SB_BOTH
+1);
505 DestroyWindow32(child
);
513 /**********************************************************************
516 * Note: hWndChild is NULL when last child is being destroyed
518 static LONG
MDI_ChildActivate( WND
*clientPtr
, HWND16 hWndChild
)
520 MDICLIENTINFO
*clientInfo
= (MDICLIENTINFO
*)clientPtr
->wExtra
;
521 HWND16 prevActiveWnd
= clientInfo
->hwndActiveChild
;
522 WND
*wndPtr
= WIN_FindWndPtr( hWndChild
);
523 WND
*wndPrev
= WIN_FindWndPtr( prevActiveWnd
);
524 BOOL32 isActiveFrameWnd
= 0;
526 if( hWndChild
== prevActiveWnd
) return 0L;
529 if( wndPtr
->dwStyle
& WS_DISABLED
) return 0L;
531 dprintf_mdi(stddeb
,"MDI_ChildActivate: %04x\n", hWndChild
);
533 if( GetActiveWindow32() == clientPtr
->parent
->hwndSelf
)
534 isActiveFrameWnd
= TRUE
;
536 /* deactivate prev. active child */
539 wndPrev
->dwStyle
|= WS_SYSMENU
;
540 SendMessage16( prevActiveWnd
, WM_NCACTIVATE
, FALSE
, 0L );
543 SendMessage32A( prevActiveWnd
, WM_MDIACTIVATE
, (WPARAM32
)prevActiveWnd
,
547 SendMessage16( prevActiveWnd
, WM_MDIACTIVATE
, FALSE
,
548 MAKELONG(hWndChild
,prevActiveWnd
));
550 /* uncheck menu item */
551 if( clientInfo
->hWindowMenu
)
552 CheckMenuItem32( clientInfo
->hWindowMenu
,
553 wndPrev
->wIDmenu
, 0);
557 if( clientInfo
->hwndChildMaximized
)
558 if( clientInfo
->hwndChildMaximized
!= hWndChild
)
561 clientInfo
->hwndActiveChild
= hWndChild
;
562 ShowWindow16( hWndChild
, SW_SHOWMAXIMIZED
);
565 ShowWindow16( clientInfo
->hwndActiveChild
,
568 clientInfo
->hwndActiveChild
= hWndChild
;
570 /* check if we have any children left */
573 if( isActiveFrameWnd
)
574 SetFocus32( clientInfo
->self
);
578 /* check menu item */
579 if( clientInfo
->hWindowMenu
)
580 CheckMenuItem32( clientInfo
->hWindowMenu
,
581 wndPtr
->wIDmenu
, MF_CHECKED
);
583 /* bring active child to the top */
584 SetWindowPos32( hWndChild
, 0,0,0,0,0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
586 if( isActiveFrameWnd
)
588 SendMessage16( hWndChild
, WM_NCACTIVATE
, TRUE
, 0L);
589 if( GetFocus32() == clientInfo
->self
)
590 SendMessage16( clientInfo
->self
, WM_SETFOCUS
,
591 (WPARAM16
)clientInfo
->self
, 0L );
593 SetFocus32( clientInfo
->self
);
597 SendMessage32A( hWndChild
, WM_MDIACTIVATE
, (WPARAM32
)hWndChild
,
598 (LPARAM
)prevActiveWnd
);
600 SendMessage16( hWndChild
, WM_MDIACTIVATE
, TRUE
,
601 MAKELONG(hWndChild
,prevActiveWnd
));
607 /* -------------------- MDI client window functions ------------------- */
609 /**********************************************************************
610 * CreateMDIMenuBitmap
612 static HBITMAP16
CreateMDIMenuBitmap(void)
614 HDC32 hDCSrc
= CreateCompatibleDC32(0);
615 HDC32 hDCDest
= CreateCompatibleDC32(hDCSrc
);
616 HBITMAP16 hbClose
= LoadBitmap16(0, MAKEINTRESOURCE(OBM_CLOSE
) );
617 HBITMAP16 hbCopy
,hb_src
,hb_dest
;
619 hb_src
= SelectObject32(hDCSrc
,hbClose
);
620 hbCopy
= CreateCompatibleBitmap32(hDCSrc
,SYSMETRICS_CXSIZE
,SYSMETRICS_CYSIZE
);
621 hb_dest
= SelectObject32(hDCDest
,hbCopy
);
623 BitBlt32(hDCDest
, 0, 0, SYSMETRICS_CXSIZE
, SYSMETRICS_CYSIZE
,
624 hDCSrc
, SYSMETRICS_CXSIZE
, 0, SRCCOPY
);
626 SelectObject32(hDCSrc
,hb_src
);
627 SelectObject32(hDCDest
,hb_dest
);
629 DeleteObject32(hbClose
);
637 /**********************************************************************
640 static LONG
MDICascade(WND
* clientWnd
, MDICLIENTINFO
*ci
)
645 if (ci
->hwndChildMaximized
)
646 ShowWindow16( ci
->hwndChildMaximized
, SW_NORMAL
);
648 if (ci
->nActiveChildren
== 0) return 0;
650 if ((ppWnd
= WIN_BuildWinArray(clientWnd
, BWA_SKIPHIDDEN
| BWA_SKIPOWNED
|
651 BWA_SKIPICONIC
, &total
)))
653 WND
** heapPtr
= ppWnd
;
656 INT16 delta
= 0, n
= 0;
658 if( total
< ci
->nActiveChildren
)
659 delta
= SYSMETRICS_CYICONSPACING
+ SYSMETRICS_CYICON
;
661 /* walk the list and move windows */
664 dprintf_mdi(stddeb
, "MDICascade: move %04x to (%d,%d) size [%d,%d]\n",
665 (*ppWnd
)->hwndSelf
, pos
[0].x
, pos
[0].y
, pos
[1].x
, pos
[1].y
);
667 MDI_CalcDefaultChildPos(clientWnd
, n
++, pos
, delta
);
668 SetWindowPos32((*ppWnd
)->hwndSelf
, 0, pos
[0].x
, pos
[0].y
, pos
[1].x
, pos
[1].y
,
669 SWP_DRAWFRAME
| SWP_NOACTIVATE
| SWP_NOZORDER
);
673 HeapFree( SystemHeap
, 0, heapPtr
);
676 if( total
< ci
->nActiveChildren
) ArrangeIconicWindows32( clientWnd
->hwndSelf
);
680 /**********************************************************************
683 static LONG
MDITile(WND
* wndClient
, MDICLIENTINFO
*ci
,WORD wParam
)
688 if (ci
->hwndChildMaximized
)
689 ShowWindow16(ci
->hwndChildMaximized
, SW_NORMAL
);
691 if (ci
->nActiveChildren
== 0) return 0;
693 ppWnd
= WIN_BuildWinArray(wndClient
, BWA_SKIPHIDDEN
| BWA_SKIPOWNED
| BWA_SKIPICONIC
|
694 ((wParam
& MDITILE_SKIPDISABLED
)? BWA_SKIPDISABLED
: 0), &total
);
696 dprintf_mdi(stddeb
,"MDITile: %u windows to tile\n", total
);
700 WND
** heapPtr
= ppWnd
;
705 int x
, y
, xsize
, ysize
;
706 int rows
, columns
, r
, c
, i
;
708 rect
= wndClient
->rectClient
;
709 rows
= (int) sqrt((double)total
);
710 columns
= total
/ rows
;
712 if( wParam
& MDITILE_HORIZONTAL
) /* version >= 3.1 */
715 rows
= columns
; /* exchange r and c */
719 if( total
!= ci
->nActiveChildren
)
721 y
= rect
.bottom
- 2 * SYSMETRICS_CYICONSPACING
- SYSMETRICS_CYICON
;
722 rect
.bottom
= ( y
- SYSMETRICS_CYICON
< rect
.top
)? rect
.bottom
: y
;
725 ysize
= rect
.bottom
/ rows
;
726 xsize
= rect
.right
/ columns
;
728 for (x
= i
= 0, c
= 1; c
<= columns
&& *ppWnd
; c
++)
733 ysize
= rect
.bottom
/ rows
;
737 for (r
= 1; r
<= rows
&& *ppWnd
; r
++, i
++)
739 SetWindowPos32((*ppWnd
)->hwndSelf
, 0, x
, y
, xsize
, ysize
,
740 SWP_DRAWFRAME
| SWP_NOACTIVATE
| SWP_NOZORDER
);
747 HeapFree( SystemHeap
, 0, heapPtr
);
750 if( total
< ci
->nActiveChildren
) ArrangeIconicWindows32( wndClient
->hwndSelf
);
754 /* ----------------------- Frame window ---------------------------- */
757 /**********************************************************************
758 * MDI_AugmentFrameMenu
760 static BOOL32
MDI_AugmentFrameMenu( MDICLIENTINFO
* ci
, WND
*frame
,
763 WND
* child
= WIN_FindWndPtr(hChild
);
764 HMENU16 hSysPopup
= 0;
766 dprintf_mdi(stddeb
,"MDI_AugmentFrameMenu: frame %p,child %04x\n",frame
,hChild
);
768 if( !frame
->wIDmenu
|| !child
->hSysMenu
) return 0;
770 /* create a copy of sysmenu popup and insert it into frame menu bar */
772 if (!(hSysPopup
= LoadMenuIndirect32A(SYSRES_GetResPtr(SYSRES_MENU_SYSMENU
))))
775 dprintf_mdi(stddeb
,"\t\tgot popup %04x\n in sysmenu %04x",hSysPopup
,child
->hSysMenu
);
777 if( !InsertMenu32A(frame
->wIDmenu
,0,MF_BYPOSITION
| MF_BITMAP
| MF_POPUP
,
778 hSysPopup
, (LPSTR
)(DWORD
)hBmpClose
))
779 { DestroyMenu32(hSysPopup
); return 0; }
781 if( !AppendMenu32A(frame
->wIDmenu
,MF_HELP
| MF_BITMAP
,
782 SC_RESTORE
, (LPSTR
)(DWORD
)hBmpRestore
))
784 RemoveMenu32(frame
->wIDmenu
,0,MF_BYPOSITION
);
788 EnableMenuItem32(hSysPopup
, SC_SIZE
, MF_BYCOMMAND
| MF_GRAYED
);
789 EnableMenuItem32(hSysPopup
, SC_MOVE
, MF_BYCOMMAND
| MF_GRAYED
);
790 EnableMenuItem32(hSysPopup
, SC_MAXIMIZE
, MF_BYCOMMAND
| MF_GRAYED
);
793 DrawMenuBar32(frame
->hwndSelf
);
798 /**********************************************************************
799 * MDI_RestoreFrameMenu
801 static BOOL32
MDI_RestoreFrameMenu( WND
*frameWnd
, HWND16 hChild
)
803 INT32 nItems
= GetMenuItemCount32(frameWnd
->wIDmenu
) - 1;
805 dprintf_mdi(stddeb
,"MDI_RestoreFrameMenu: for child %04x\n",hChild
);
807 if( GetMenuItemID32(frameWnd
->wIDmenu
,nItems
) != SC_RESTORE
)
811 RemoveMenu32(frameWnd
->wIDmenu
,0,MF_BYPOSITION
);
812 DeleteMenu32(frameWnd
->wIDmenu
,nItems
-1,MF_BYPOSITION
);
814 DrawMenuBar32(frameWnd
->hwndSelf
);
819 /**********************************************************************
820 * MDI_UpdateFrameText
822 * used when child window is maximized/restored
824 * Note: lpTitle can be NULL
826 static void MDI_UpdateFrameText( WND
*frameWnd
, HWND16 hClient
,
827 BOOL32 repaint
, LPCSTR lpTitle
)
829 char lpBuffer
[MDI_MAXTITLELENGTH
+1];
830 WND
* clientWnd
= WIN_FindWndPtr(hClient
);
832 MDICLIENTINFO
*ci
= (MDICLIENTINFO
*) clientWnd
->wExtra
;
834 dprintf_mdi(stddeb
, "MDI: repaint %i, frameText %s\n", repaint
, (lpTitle
)?lpTitle
:"NULL");
836 /* store new "default" title if lpTitle is not NULL */
839 if (ci
->frameTitle
) HeapFree( SystemHeap
, 0, ci
->frameTitle
);
840 ci
->frameTitle
= HEAP_strdupA( SystemHeap
, 0, lpTitle
);
845 WND
* childWnd
= WIN_FindWndPtr( ci
->hwndChildMaximized
);
847 if( childWnd
&& childWnd
->text
)
849 /* combine frame title and child title if possible */
851 LPCSTR lpBracket
= " - [";
852 int i_frame_text_length
= strlen(ci
->frameTitle
);
853 int i_child_text_length
= strlen(childWnd
->text
);
855 lstrcpyn32A( lpBuffer
, ci
->frameTitle
, MDI_MAXTITLELENGTH
);
857 if( i_frame_text_length
+ 6 < MDI_MAXTITLELENGTH
)
859 strcat( lpBuffer
, lpBracket
);
861 if( i_frame_text_length
+ i_child_text_length
+ 6 < MDI_MAXTITLELENGTH
)
863 strcat( lpBuffer
, childWnd
->text
);
864 strcat( lpBuffer
, "]" );
868 lstrcpyn32A( lpBuffer
+ i_frame_text_length
+ 4,
870 MDI_MAXTITLELENGTH
- i_frame_text_length
- 5 );
871 strcat( lpBuffer
, "]" );
877 strncpy(lpBuffer
, ci
->frameTitle
, MDI_MAXTITLELENGTH
);
878 lpBuffer
[MDI_MAXTITLELENGTH
]='\0';
884 DEFWND_SetText( frameWnd
, lpBuffer
);
885 if( repaint
== MDI_REPAINTFRAME
)
886 SetWindowPos32(frameWnd
->hwndSelf
, 0,0,0,0,0, SWP_FRAMECHANGED
|
887 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
891 /* ----------------------------- Interface ---------------------------- */
894 /**********************************************************************
897 * This function is the handler for all MDI requests.
899 LRESULT
MDIClientWndProc(HWND16 hwnd
, UINT16 message
, WPARAM16 wParam
, LPARAM lParam
)
904 WND
*w
= WIN_FindWndPtr(hwnd
);
905 WND
*frameWnd
= w
->parent
;
908 ci
= (MDICLIENTINFO
*) w
->wExtra
;
914 cs
= (LPCREATESTRUCT16
) PTR_SEG_TO_LIN(lParam
);
916 /* Translation layer doesn't know what's in the cs->lpCreateParams
917 * so we have to keep track of what environment we're in. */
919 if( w
->flags
& WIN_ISWIN32
)
921 #define ccs ((LPCLIENTCREATESTRUCT32)cs->lpCreateParams)
922 ci
->hWindowMenu
= ccs
->hWindowMenu
;
923 ci
->idFirstChild
= ccs
->idFirstChild
;
928 LPCLIENTCREATESTRUCT16 ccs
= (LPCLIENTCREATESTRUCT16
)
929 PTR_SEG_TO_LIN(cs
->lpCreateParams
);
930 ci
->hWindowMenu
= ccs
->hWindowMenu
;
931 ci
->idFirstChild
= ccs
->idFirstChild
;
934 ci
->hwndChildMaximized
= 0;
935 ci
->nActiveChildren
= 0;
936 ci
->nTotalCreated
= 0;
937 ci
->frameTitle
= NULL
;
940 w
->dwStyle
|= WS_CLIPCHILDREN
;
944 hBmpClose
= CreateMDIMenuBitmap();
945 hBmpRestore
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORE
) );
947 MDI_UpdateFrameText(frameWnd
, hwnd
, MDI_NOFRAMEREPAINT
,frameWnd
->text
);
949 AppendMenu32A( ci
->hWindowMenu
, MF_SEPARATOR
, 0, NULL
);
951 GetClientRect16(frameWnd
->hwndSelf
, &rect
);
952 NC_HandleNCCalcSize( w
, &rect
);
953 w
->rectClient
= rect
;
955 dprintf_mdi(stddeb
,"MDI: Client created - hwnd = %04x, idFirst = %u\n",hwnd
,ci
->idFirstChild
);
960 if( ci
->hwndChildMaximized
) MDI_RestoreFrameMenu(w
, frameWnd
->hwndSelf
);
961 if((nItems
= GetMenuItemCount32(ci
->hWindowMenu
)) > 0) {
962 ci
->idFirstChild
= nItems
- 1;
963 ci
->nActiveChildren
++; /* to delete a separator */
964 while( ci
->nActiveChildren
-- )
965 DeleteMenu32(ci
->hWindowMenu
,MF_BYPOSITION
,ci
->idFirstChild
--);
970 if( ci
->hwndActiveChild
!= (HWND16
)wParam
)
971 SetWindowPos32((HWND32
)wParam
, 0,0,0,0,0, SWP_NOSIZE
| SWP_NOMOVE
);
975 return MDICascade(w
, ci
);
980 MDICREATESTRUCT16
* cs
= (MDICREATESTRUCT16
*) PTR_SEG_TO_LIN(lParam
);
981 return (LONG
)MDICreateChild(w
, ci
, hwnd
, cs
, lParam
);
986 return (LONG
)MDIDestroyChild(w
, ci
, hwnd
, (HWND32
)wParam
, TRUE
);
988 case WM_MDIGETACTIVE
:
989 return ((LONG
) ci
->hwndActiveChild
|
990 ((LONG
) (ci
->hwndChildMaximized
>0) << 16));
992 case WM_MDIICONARRANGE
:
993 ci
->mdiFlags
|= MDIF_NEEDUPDATE
;
994 MDIIconArrange(hwnd
);
995 ci
->sbRecalc
= SB_BOTH
+1;
996 SendMessage16(hwnd
,WM_MDICALCCHILDSCROLL
,0,0L);
1000 ShowWindow16((HWND16
)wParam
, SW_MAXIMIZE
);
1004 MDI_SwitchActiveChild(hwnd
, (HWND16
)wParam
, (lParam
)?1:0);
1008 ShowWindow16( (HWND16
)wParam
, SW_NORMAL
);
1013 return (LRESULT
)MDISetMenu(hwnd
, FALSE
, (HMENU16
)wParam
, (HMENU16
)lParam
);
1015 return (LRESULT
)MDISetMenu(hwnd
, wParam
, LOWORD(lParam
), HIWORD(lParam
));
1019 ci
->mdiFlags
|= MDIF_NEEDUPDATE
;
1020 ShowScrollBar32(hwnd
,SB_BOTH
,FALSE
);
1021 MDITile(w
, ci
,wParam
);
1022 ci
->mdiFlags
&= ~MDIF_NEEDUPDATE
;
1027 ci
->mdiFlags
|= MDIF_NEEDUPDATE
;
1028 ScrollChildren32(hwnd
,message
,wParam
,lParam
);
1029 ci
->mdiFlags
&= ~MDIF_NEEDUPDATE
;
1033 if( ci
->hwndActiveChild
)
1035 w
= WIN_FindWndPtr( ci
->hwndActiveChild
);
1036 if( !(w
->dwStyle
& WS_MINIMIZE
) )
1037 SetFocus32( ci
->hwndActiveChild
);
1042 if( ci
->hwndActiveChild
)
1043 SendMessage16(ci
->hwndActiveChild
, message
, wParam
, lParam
);
1046 case WM_PARENTNOTIFY
:
1047 if( wParam
== WM_LBUTTONDOWN
)
1049 POINT16 pt
= MAKEPOINT16(lParam
);
1050 HWND16 child
= ChildWindowFromPoint16(hwnd
, pt
);
1052 dprintf_mdi(stddeb
,"MDIClient: notification from %04x (%i,%i)\n",child
,pt
.x
,pt
.y
);
1054 if( child
&& child
!= hwnd
&&
1055 child
!= ci
->hwndActiveChild
)
1056 SetWindowPos32(child
, 0,0,0,0,0, SWP_NOSIZE
| SWP_NOMOVE
);
1061 if( ci
->hwndChildMaximized
)
1063 WND
* child
= WIN_FindWndPtr(ci
->hwndChildMaximized
);
1064 RECT16 rect
= { 0, 0, LOWORD(lParam
), HIWORD(lParam
) };
1066 AdjustWindowRectEx16(&rect
, child
->dwStyle
, 0, child
->dwExStyle
);
1067 MoveWindow16(ci
->hwndChildMaximized
, rect
.left
, rect
.top
,
1068 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
, 1);
1071 MDI_PostUpdate(hwnd
, ci
, SB_BOTH
+1);
1075 case WM_MDICALCCHILDSCROLL
:
1076 if( (ci
->mdiFlags
& MDIF_NEEDUPDATE
) && ci
->sbRecalc
)
1078 CalcChildScroll(hwnd
, ci
->sbRecalc
-1);
1080 ci
->mdiFlags
&= ~MDIF_NEEDUPDATE
;
1085 return DefWindowProc16(hwnd
, message
, wParam
, lParam
);
1089 /***********************************************************************
1090 * DefFrameProc16 (USER.445)
1092 LRESULT
DefFrameProc16( HWND16 hwnd
, HWND16 hwndMDIClient
, UINT16 message
,
1093 WPARAM16 wParam
, LPARAM lParam
)
1104 wndPtr
= WIN_FindWndPtr(hwndMDIClient
);
1105 ci
= (MDICLIENTINFO
*)wndPtr
->wExtra
;
1107 /* check for possible syscommands for maximized MDI child */
1110 wParam
< ci
->idFirstChild
||
1111 wParam
>= ci
->idFirstChild
+ ci
->nActiveChildren
1113 if( (wParam
- 0xF000) & 0xF00F ) break;
1124 if( ci
->hwndChildMaximized
)
1125 return SendMessage16( ci
->hwndChildMaximized
, WM_SYSCOMMAND
,
1131 childHwnd
= MDI_GetChildByID( WIN_FindWndPtr(hwndMDIClient
),
1134 SendMessage16(hwndMDIClient
, WM_MDIACTIVATE
,
1135 (WPARAM16
)childHwnd
, 0L);
1140 SendMessage16(hwndMDIClient
, message
, wParam
, lParam
);
1144 MDI_UpdateFrameText(WIN_FindWndPtr(hwnd
), hwndMDIClient
,
1146 (LPCSTR
)PTR_SEG_TO_LIN(lParam
));
1150 SetFocus32(hwndMDIClient
);
1154 MoveWindow16(hwndMDIClient
, 0, 0,
1155 LOWORD(lParam
), HIWORD(lParam
), TRUE
);
1160 wndPtr
= WIN_FindWndPtr(hwndMDIClient
);
1161 ci
= (MDICLIENTINFO
*)wndPtr
->wExtra
;
1163 if( !(wndPtr
->parent
->dwStyle
& WS_MINIMIZE
)
1164 && ci
->hwndActiveChild
&& !ci
->hwndChildMaximized
)
1166 /* control menu is between the frame system menu and
1167 * the first entry of menu bar */
1169 if( (wParam
== VK_LEFT
&&
1170 wndPtr
->parent
->wIDmenu
== LOWORD(lParam
)) ||
1171 (wParam
== VK_RIGHT
&&
1172 GetSubMenu16(wndPtr
->parent
->hSysMenu
, 0) == LOWORD(lParam
)) )
1174 wndPtr
= WIN_FindWndPtr(ci
->hwndActiveChild
);
1175 return MAKELONG( GetSubMenu16(wndPtr
->hSysMenu
, 0),
1176 ci
->hwndActiveChild
);
1183 return DefWindowProc16(hwnd
, message
, wParam
, lParam
);
1187 /***********************************************************************
1188 * DefFrameProc32A (USER32.121)
1190 LRESULT
DefFrameProc32A( HWND32 hwnd
, HWND32 hwndMDIClient
, UINT32 message
,
1191 WPARAM32 wParam
, LPARAM lParam
)
1198 return DefFrameProc16( hwnd
, hwndMDIClient
, message
,
1200 MAKELPARAM( (HWND16
)lParam
, HIWORD(wParam
) ) );
1203 SendMessage32A(hwndMDIClient
, message
, wParam
, lParam
);
1208 LPSTR segstr
= SEGPTR_STRDUP((LPSTR
)lParam
);
1210 ret
= DefFrameProc16(hwnd
, hwndMDIClient
, message
,
1211 wParam
, (LPARAM
)SEGPTR_GET(segstr
) );
1212 SEGPTR_FREE(segstr
);
1218 return DefFrameProc16( hwnd
, hwndMDIClient
, message
,
1223 return DefWindowProc32A(hwnd
, message
, wParam
, lParam
);
1227 /***********************************************************************
1228 * DefFrameProc32W (USER32.122)
1230 LRESULT
DefFrameProc32W( HWND32 hwnd
, HWND32 hwndMDIClient
, UINT32 message
,
1231 WPARAM32 wParam
, LPARAM lParam
)
1238 return DefFrameProc16( hwnd
, hwndMDIClient
, message
,
1240 MAKELPARAM( (HWND16
)lParam
, HIWORD(wParam
) ) );
1243 SendMessage32W(hwndMDIClient
, message
, wParam
, lParam
);
1247 LPSTR txt
= HEAP_strdupWtoA(GetProcessHeap(),0,(LPWSTR
)lParam
);
1248 LRESULT ret
= DefFrameProc32A( hwnd
, hwndMDIClient
, message
,
1249 wParam
, (DWORD
)txt
);
1250 HeapFree(GetProcessHeap(),0,txt
);
1255 return DefFrameProc32A( hwnd
, hwndMDIClient
, message
,
1260 return DefWindowProc32W( hwnd
, message
, wParam
, lParam
);
1264 /***********************************************************************
1265 * DefMDIChildProc16 (USER.447)
1267 LRESULT
DefMDIChildProc16( HWND16 hwnd
, UINT16 message
,
1268 WPARAM16 wParam
, LPARAM lParam
)
1273 clientWnd
= WIN_FindWndPtr(GetParent16(hwnd
));
1274 ci
= (MDICLIENTINFO
*) clientWnd
->wExtra
;
1279 DefWindowProc16(hwnd
, message
, wParam
, lParam
);
1280 MDI_MenuModifyItem(clientWnd
,hwnd
);
1281 if( ci
->hwndChildMaximized
== hwnd
)
1282 MDI_UpdateFrameText( clientWnd
->parent
, ci
->self
,
1283 MDI_REPAINTFRAME
, NULL
);
1287 SendMessage16(ci
->self
,WM_MDIDESTROY
,(WPARAM16
)hwnd
,0L);
1291 if( ci
->hwndActiveChild
!= hwnd
)
1292 MDI_ChildActivate(clientWnd
, hwnd
);
1295 case WM_CHILDACTIVATE
:
1296 MDI_ChildActivate(clientWnd
, hwnd
);
1300 dprintf_mdi(stddeb
,"DefMDIChildProc: WM_NCPAINT for %04x, active %04x\n",
1301 hwnd
, ci
->hwndActiveChild
);
1308 if( ci
->hwndChildMaximized
== hwnd
) return 0;
1312 WIN_FindWndPtr(hwnd
)->dwStyle
|= WS_SYSMENU
;
1315 if( ci
->hwndChildMaximized
== hwnd
)
1316 return SendMessage16( clientWnd
->parent
->hwndSelf
,
1317 message
, wParam
, lParam
);
1318 WIN_FindWndPtr(hwnd
)->dwStyle
&= ~WS_SYSMENU
;
1321 SendMessage16( ci
->self
, WM_MDINEXT
, 0, 0);
1324 SendMessage16( ci
->self
, WM_MDINEXT
, 0, 1);
1329 case WM_GETMINMAXINFO
:
1330 MDI_ChildGetMinMaxInfo(clientWnd
, hwnd
, (MINMAXINFO16
*) PTR_SEG_TO_LIN(lParam
));
1334 if( ci
->hwndChildMaximized
) ci
->mdiFlags
&= ~MDIF_NEEDUPDATE
;
1336 MDI_PostUpdate(clientWnd
->hwndSelf
, ci
, SB_BOTH
+1);
1342 if( ci
->hwndActiveChild
== hwnd
&& wParam
!= SIZE_MAXIMIZED
)
1344 ci
->hwndChildMaximized
= 0;
1346 MDI_RestoreFrameMenu( clientWnd
->parent
, hwnd
);
1347 MDI_UpdateFrameText( clientWnd
->parent
, ci
->self
,
1348 MDI_REPAINTFRAME
, NULL
);
1351 if( wParam
== SIZE_MAXIMIZED
)
1353 HWND16 hMaxChild
= ci
->hwndChildMaximized
;
1355 if( hMaxChild
== hwnd
) break;
1359 SendMessage16( hMaxChild
, WM_SETREDRAW
, FALSE
, 0L );
1361 MDI_RestoreFrameMenu( clientWnd
->parent
, hMaxChild
);
1362 ShowWindow16( hMaxChild
, SW_SHOWNOACTIVATE
);
1364 SendMessage16( hMaxChild
, WM_SETREDRAW
, TRUE
, 0L );
1367 dprintf_mdi(stddeb
,"\tMDI: maximizing child %04x\n", hwnd
);
1369 ci
->hwndChildMaximized
= hwnd
; /* !!! */
1371 MDI_AugmentFrameMenu( ci
, clientWnd
->parent
, hwnd
);
1372 MDI_UpdateFrameText( clientWnd
->parent
, ci
->self
,
1373 MDI_REPAINTFRAME
, NULL
);
1376 if( wParam
== SIZE_MINIMIZED
)
1378 HWND16 switchTo
= MDI_GetWindow(clientWnd
, hwnd
, 0);
1381 SendMessage16( switchTo
, WM_CHILDACTIVATE
, 0, 0L);
1384 MDI_PostUpdate(clientWnd
->hwndSelf
, ci
, SB_BOTH
+1);
1389 /* MDI children don't have menu bars */
1390 PostMessage16( clientWnd
->parent
->hwndSelf
, WM_SYSCOMMAND
,
1391 (WPARAM16
)SC_KEYMENU
, (LPARAM
)wParam
);
1396 if( wParam
== VK_LEFT
) /* switch to frame system menu */
1397 return MAKELONG( GetSubMenu16(clientWnd
->parent
->hSysMenu
, 0),
1398 clientWnd
->parent
->hwndSelf
);
1399 if( wParam
== VK_RIGHT
) /* to frame menu bar */
1400 return MAKELONG( clientWnd
->parent
->wIDmenu
,
1401 clientWnd
->parent
->hwndSelf
);
1406 return DefWindowProc16(hwnd
, message
, wParam
, lParam
);
1410 /***********************************************************************
1411 * DefMDIChildProc32A (USER32.123)
1413 LRESULT
DefMDIChildProc32A( HWND32 hwnd
, UINT32 message
,
1414 WPARAM32 wParam
, LPARAM lParam
)
1419 clientWnd
= WIN_FindWndPtr(GetParent16(hwnd
));
1420 ci
= (MDICLIENTINFO
*) clientWnd
->wExtra
;
1425 DefWindowProc32A(hwnd
, message
, wParam
, lParam
);
1426 MDI_MenuModifyItem(clientWnd
,hwnd
);
1427 if( ci
->hwndChildMaximized
== hwnd
)
1428 MDI_UpdateFrameText( clientWnd
->parent
, ci
->self
,
1429 MDI_REPAINTFRAME
, NULL
);
1432 case WM_GETMINMAXINFO
:
1435 STRUCT32_MINMAXINFO32to16( (MINMAXINFO32
*)lParam
, &mmi
);
1436 MDI_ChildGetMinMaxInfo( clientWnd
, hwnd
, &mmi
);
1437 STRUCT32_MINMAXINFO16to32( &mmi
, (MINMAXINFO32
*)lParam
);
1443 /* MDI children don't have menu bars */
1444 PostMessage16( clientWnd
->parent
->hwndSelf
, WM_SYSCOMMAND
,
1445 (WPARAM16
)SC_KEYMENU
, (LPARAM
)LOWORD(wParam
) );
1450 case WM_CHILDACTIVATE
:
1456 return DefMDIChildProc16( hwnd
, message
, (WPARAM16
)wParam
, lParam
);
1458 return DefWindowProc32A(hwnd
, message
, wParam
, lParam
);
1462 /***********************************************************************
1463 * DefMDIChildProc32W (USER32.124)
1465 LRESULT
DefMDIChildProc32W( HWND32 hwnd
, UINT32 message
,
1466 WPARAM32 wParam
, LPARAM lParam
)
1471 clientWnd
= WIN_FindWndPtr(GetParent16(hwnd
));
1472 ci
= (MDICLIENTINFO
*) clientWnd
->wExtra
;
1477 DefWindowProc32W(hwnd
, message
, wParam
, lParam
);
1478 MDI_MenuModifyItem(clientWnd
,hwnd
);
1479 if( ci
->hwndChildMaximized
== hwnd
)
1480 MDI_UpdateFrameText( clientWnd
->parent
, ci
->self
,
1481 MDI_REPAINTFRAME
, NULL
);
1484 case WM_GETMINMAXINFO
:
1488 case WM_CHILDACTIVATE
:
1494 return DefMDIChildProc32A( hwnd
, message
, (WPARAM16
)wParam
, lParam
);
1496 return DefWindowProc32W(hwnd
, message
, wParam
, lParam
);
1500 /**********************************************************************
1501 * CreateMDIWindowA (USER32.78)
1504 /**********************************************************************
1505 * CreateMDIWindowW (USER32.79)
1508 /**********************************************************************
1509 * TranslateMDISysAccel32 (USER32.554)
1511 BOOL32
TranslateMDISysAccel32( HWND32 hwndClient
, LPMSG32 msg
)
1515 STRUCT32_MSG32to16(msg
,&msg16
);
1516 /* MDICLIENTINFO is still the same for win32 and win16 ... */
1517 return TranslateMDISysAccel16(hwndClient
,&msg16
);
1521 /**********************************************************************
1522 * TranslateMDISysAccel16 (USER.451)
1524 BOOL16
TranslateMDISysAccel16( HWND16 hwndClient
, LPMSG16 msg
)
1526 WND
* clientWnd
= WIN_FindWndPtr( hwndClient
);
1528 if( clientWnd
&& (msg
->message
== WM_KEYDOWN
|| msg
->message
== WM_SYSKEYDOWN
))
1530 MDICLIENTINFO
*ci
= NULL
;
1533 ci
= (MDICLIENTINFO
*) clientWnd
->wExtra
;
1534 wnd
= WIN_FindWndPtr(ci
->hwndActiveChild
);
1535 if( wnd
&& !(wnd
->dwStyle
& WS_DISABLED
) )
1537 WPARAM16 wParam
= 0;
1539 /* translate if the Ctrl key is down and Alt not. */
1541 if( (GetKeyState32(VK_CONTROL
) & 0x8000) &&
1542 !(GetKeyState32(VK_MENU
) & 0x8000))
1544 switch( msg
->wParam
)
1548 wParam
= ( GetKeyState32(VK_SHIFT
) & 0x8000 )
1549 ? SC_NEXTWINDOW
: SC_PREVWINDOW
;
1558 dprintf_mdi(stddeb
,"TranslateMDISysAccel: wParam = %04x\n", wParam
);
1559 SendMessage16( ci
->hwndActiveChild
, WM_SYSCOMMAND
,
1560 wParam
, (LPARAM
)msg
->wParam
);
1565 return 0; /* failure */
1569 /***********************************************************************
1570 * CalcChildScroll (USER.462)
1572 void CalcChildScroll( HWND16 hwnd
, WORD scroll
)
1574 RECT16 childRect
, clientRect
;
1575 INT32 vmin
, vmax
, hmin
, hmax
, vpos
, hpos
;
1576 BOOL32 noscroll
= FALSE
;
1579 if (!(Wnd
= pWnd
= WIN_FindWndPtr( hwnd
))) return;
1580 GetClientRect16( hwnd
, &clientRect
);
1581 SetRectEmpty16( &childRect
);
1583 for ( pWnd
= pWnd
->child
; pWnd
; pWnd
= pWnd
->next
)
1585 UnionRect16( &childRect
, &pWnd
->rectWindow
, &childRect
);
1586 if( pWnd
->dwStyle
& WS_MAXIMIZE
)
1589 UnionRect16( &childRect
, &clientRect
, &childRect
);
1591 /* jump through the hoops to prevent excessive flashing
1594 hmin
= childRect
.left
; hmax
= childRect
.right
- clientRect
.right
;
1595 hpos
= clientRect
.left
- childRect
.left
;
1596 vmin
= childRect
.top
; vmax
= childRect
.bottom
- clientRect
.bottom
;
1597 vpos
= clientRect
.top
- childRect
.top
;
1600 ShowScrollBar32(hwnd
, SB_BOTH
, FALSE
);
1605 vpos
= hpos
; vmin
= hmin
; vmax
= hmax
;
1607 SetScrollPos32(hwnd
, scroll
, vpos
, FALSE
);
1608 SetScrollRange32(hwnd
, scroll
, vmin
, vmax
, TRUE
);
1611 SCROLL_SetNCSbState( Wnd
, vmin
, vmax
, vpos
,
1613 SetWindowPos32(hwnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
1614 | SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
1619 /***********************************************************************
1620 * ScrollChildren16 (USER.463)
1622 void ScrollChildren16(HWND16 hWnd
, UINT16 uMsg
, WPARAM16 wParam
, LPARAM lParam
)
1624 return ScrollChildren32( hWnd
, uMsg
, wParam
, lParam
);
1628 /***********************************************************************
1629 * ScrollChildren32 (USER32.447)
1631 void ScrollChildren32(HWND32 hWnd
, UINT32 uMsg
, WPARAM32 wParam
, LPARAM lParam
)
1633 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
1635 INT32 curPos
, length
, minPos
, maxPos
, shift
;
1637 if( !wndPtr
) return;
1639 if( uMsg
== WM_HSCROLL
)
1641 GetScrollRange32(hWnd
,SB_HORZ
,&minPos
,&maxPos
);
1642 curPos
= GetScrollPos32(hWnd
,SB_HORZ
);
1643 length
= (wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
)/2;
1644 shift
= SYSMETRICS_CYHSCROLL
;
1646 else if( uMsg
== WM_VSCROLL
)
1648 GetScrollRange32(hWnd
,SB_VERT
,&minPos
,&maxPos
);
1649 curPos
= GetScrollPos32(hWnd
,SB_VERT
);
1650 length
= (wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
)/2;
1651 shift
= SYSMETRICS_CXVSCROLL
;
1658 newPos
= curPos
- shift
;
1661 newPos
= curPos
+ shift
;
1664 newPos
= curPos
- length
;
1667 newPos
= curPos
+ length
;
1670 case SB_THUMBPOSITION
:
1671 newPos
= LOWORD(lParam
);
1684 CalcChildScroll(hWnd
,(uMsg
== WM_VSCROLL
)?SB_VERT
:SB_HORZ
);
1688 if( newPos
> maxPos
)
1690 else if( newPos
< minPos
)
1693 SetScrollPos32(hWnd
, (uMsg
== WM_VSCROLL
)?SB_VERT
:SB_HORZ
, newPos
, TRUE
);
1695 if( uMsg
== WM_VSCROLL
)
1696 ScrollWindow32(hWnd
,0 ,curPos
- newPos
, NULL
, NULL
);
1698 ScrollWindow32(hWnd
,curPos
- newPos
, 0, NULL
, NULL
);