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"
28 #include "stackframe.h"
30 #include "sysmetrics.h"
35 static HBITMAP hBmpClose
= 0;
36 static HBITMAP hBmpRestore
= 0;
38 DWORD
SCROLL_SetNCSbState(WND
*,int,int,int,int,int,int);
40 /* ----------------- declarations ----------------- */
41 void MDI_UpdateFrameText(WND
*, HWND
, BOOL
, LPCSTR
);
42 BOOL
MDI_AugmentFrameMenu(MDICLIENTINFO
*, WND
*, HWND
);
43 BOOL
MDI_RestoreFrameMenu(WND
*, HWND
);
45 void ScrollChildren(HWND
, UINT
, WPARAM
, LPARAM
);
46 void CalcChildScroll(HWND
, WORD
);
48 static LONG
MDI_ChildActivate(WND
* ,HWND
);
50 /* -------- Miscellaneous service functions ----------
55 static HWND
MDI_GetChildByID(WND
* wndPtr
,int id
)
57 for (wndPtr
= wndPtr
->child
; wndPtr
; wndPtr
= wndPtr
->next
)
58 if (wndPtr
->wIDmenu
== id
) return wndPtr
->hwndSelf
;
62 static void MDI_PostUpdate(HWND hwnd
, MDICLIENTINFO
* ci
, WORD recalc
)
64 if( !ci
->sbNeedUpdate
)
66 ci
->sbNeedUpdate
= TRUE
;
67 PostMessage( hwnd
, WM_MDICALCCHILDSCROLL
, 0, 0);
69 ci
->sbRecalc
= recalc
;
72 /**********************************************************************
75 #ifdef SUPERFLUOUS_FUNCTIONS
76 static BOOL
MDI_MenuAppendItem(WND
*clientWnd
, HWND hWndChild
)
79 MDICLIENTINFO
*clientInfo
= (MDICLIENTINFO
*)clientWnd
->wExtra
;
80 WND
*wndPtr
= WIN_FindWndPtr(hWndChild
);
81 int n
= sprintf(buffer
, "%d ",
82 clientInfo
->nActiveChildren
);
84 if( !clientInfo
->hWindowMenu
) return 0;
86 if (wndPtr
->text
) strncpy(buffer
+ n
, wndPtr
->text
, sizeof(buffer
) - n
- 1);
87 return AppendMenu32A( clientInfo
->hWindowMenu
, MF_STRING
,
88 wndPtr
->wIDmenu
, buffer
);
92 /**********************************************************************
95 static BOOL
MDI_MenuModifyItem(WND
* clientWnd
, HWND hWndChild
)
98 MDICLIENTINFO
*clientInfo
= (MDICLIENTINFO
*)clientWnd
->wExtra
;
99 WND
*wndPtr
= WIN_FindWndPtr(hWndChild
);
100 UINT n
= sprintf(buffer
, "%d ",
101 wndPtr
->wIDmenu
- clientInfo
->idFirstChild
+ 1);
104 if( !clientInfo
->hWindowMenu
) return 0;
106 if (wndPtr
->text
) lstrcpyn32A(buffer
+ n
, wndPtr
->text
, sizeof(buffer
) - n
);
108 n
= GetMenuState(clientInfo
->hWindowMenu
,wndPtr
->wIDmenu
,MF_BYCOMMAND
);
109 bRet
= ModifyMenu32A(clientInfo
->hWindowMenu
, wndPtr
->wIDmenu
,
110 MF_BYCOMMAND
| MF_STRING
, wndPtr
->wIDmenu
, buffer
);
111 CheckMenuItem(clientInfo
->hWindowMenu
,wndPtr
->wIDmenu
, n
& MF_CHECKED
);
115 /**********************************************************************
118 static BOOL
MDI_MenuDeleteItem(WND
* clientWnd
, HWND hWndChild
)
121 MDICLIENTINFO
*clientInfo
= (MDICLIENTINFO
*)clientWnd
->wExtra
;
122 WND
*wndPtr
= WIN_FindWndPtr(hWndChild
);
125 if( !clientInfo
->nActiveChildren
||
126 !clientInfo
->hWindowMenu
) return 0;
128 id
= wndPtr
->wIDmenu
;
129 DeleteMenu(clientInfo
->hWindowMenu
,id
,MF_BYCOMMAND
);
131 /* walk the rest of MDI children to prevent gaps in the id
132 * sequence and in the menu child list
135 for( index
= id
+1; index
<= clientInfo
->nActiveChildren
+
136 clientInfo
->idFirstChild
; index
++ )
138 wndPtr
= WIN_FindWndPtr(MDI_GetChildByID(clientWnd
,index
));
141 dprintf_mdi(stddeb
,"MDIMenuDeleteItem: no window for id=%i\n",index
);
148 n
= sprintf(buffer
, "%d ",index
- clientInfo
->idFirstChild
);
150 lstrcpyn32A(buffer
+ n
, wndPtr
->text
, sizeof(buffer
) - n
);
153 ModifyMenu32A(clientInfo
->hWindowMenu
,index
,MF_BYCOMMAND
| MF_STRING
,
154 index
- 1 , buffer
);
159 /**********************************************************************
162 * returns "activateable" child or zero
164 HWND
MDI_GetWindow(WND
*clientWnd
, HWND hWnd
, WORD wTo
)
166 MDICLIENTINFO
*clientInfo
= (MDICLIENTINFO
*)clientWnd
->wExtra
;
167 WND
*wndPtr
, *pWnd
, *pWndLast
;
169 if( !hWnd
) hWnd
= clientInfo
->hwndActiveChild
;
171 if( !(wndPtr
= WIN_FindWndPtr(hWnd
)) ) return 0;
178 if (!pWnd
) pWnd
= wndPtr
->parent
->child
;
179 if (pWnd
== wndPtr
) /* not found */
181 if (!wTo
|| !pWndLast
) return 0;
185 /* we are not interested in owned popups */
187 (pWnd
->dwStyle
& WS_VISIBLE
) &&
188 !(pWnd
->dwStyle
& WS_DISABLED
)) /* found one */
194 return pWndLast
? pWndLast
->hwndSelf
: 0;
197 /**********************************************************************
198 * MDI_CalcDefaultChildPos
200 * It seems that default height is 2/3 of client rect
202 void MDI_CalcDefaultChildPos(WND
* w
, WORD n
, LPPOINT16 lpPos
, INT delta
)
204 RECT16 rect
= w
->rectClient
;
205 INT spacing
= GetSystemMetrics(SM_CYCAPTION
) + GetSystemMetrics(SM_CYFRAME
) - 1;
208 if( rect
.bottom
- rect
.top
- delta
>= spacing
)
209 rect
.bottom
-= delta
;
211 nstagger
= (rect
.bottom
- rect
.top
)/(3*spacing
);
212 lpPos
[1].x
= (rect
.right
- rect
.left
- nstagger
*spacing
);
213 lpPos
[1].y
= (rect
.bottom
- rect
.top
- nstagger
*spacing
);
214 lpPos
[0].x
= lpPos
[0].y
= spacing
*(n
%(nstagger
+1));
217 /**********************************************************************
220 HMENU
MDISetMenu(HWND hwnd
, BOOL fRefresh
, HMENU hmenuFrame
, HMENU hmenuWindow
)
222 WND
*w
= WIN_FindWndPtr(hwnd
);
225 dprintf_mdi(stddeb
, "WM_MDISETMENU: %04x %04x %04x %04x\n",
226 hwnd
, fRefresh
, hmenuFrame
, hmenuWindow
);
228 ci
= (MDICLIENTINFO
*) w
->wExtra
;
232 HWND hwndFrame
= GetParent(hwnd
);
233 HMENU oldFrameMenu
= GetMenu(hwndFrame
);
235 if( ci
->hwndChildMaximized
&& hmenuFrame
&& hmenuFrame
!=oldFrameMenu
)
236 MDI_RestoreFrameMenu(w
->parent
, ci
->hwndChildMaximized
);
238 if( hmenuWindow
&& hmenuWindow
!=ci
->hWindowMenu
)
240 /* delete menu items from ci->hWindowMenu
241 * and add them to hmenuWindow */
243 INT i
= GetMenuItemCount(ci
->hWindowMenu
) - 1;
244 INT pos
= GetMenuItemCount(hmenuWindow
) + 1;
246 AppendMenu32A( hmenuWindow
, MF_SEPARATOR
, 0, NULL
);
248 if( ci
->nActiveChildren
)
250 INT j
= i
- ci
->nActiveChildren
+ 1;
254 for( ; i
>= j
; i
-- )
256 id
= GetMenuItemID(ci
->hWindowMenu
,i
);
257 state
= GetMenuState(ci
->hWindowMenu
,i
,MF_BYPOSITION
);
259 GetMenuString(ci
->hWindowMenu
, i
, buffer
, 100, MF_BYPOSITION
);
261 DeleteMenu(ci
->hWindowMenu
, i
, MF_BYPOSITION
);
262 InsertMenu32A(hmenuWindow
, pos
, MF_BYPOSITION
| MF_STRING
,
264 CheckMenuItem(hmenuWindow
,pos
, MF_BYPOSITION
| (state
& MF_CHECKED
));
268 /* remove separator */
269 DeleteMenu(ci
->hWindowMenu
, i
, MF_BYPOSITION
);
271 ci
->hWindowMenu
= hmenuWindow
;
274 if( hmenuFrame
&& hmenuFrame
!=oldFrameMenu
)
276 SetMenu(hwndFrame
, hmenuFrame
);
277 if( ci
->hwndChildMaximized
)
278 MDI_AugmentFrameMenu(ci
, w
->parent
, ci
->hwndChildMaximized
);
286 /**********************************************************************
289 WORD
MDIIconArrange(HWND parent
)
291 return ArrangeIconicWindows(parent
); /* Any reason why the */
292 /* existing icon arrange */
293 /* can't be used here? */
298 /* ------------------ MDI child window functions ---------------------- */
301 /**********************************************************************
304 HWND
MDICreateChild(WND
*w
, MDICLIENTINFO
*ci
, HWND parent
, LPARAM lParam
)
307 MDICREATESTRUCT16
*cs
= (MDICREATESTRUCT16
*)PTR_SEG_TO_LIN(lParam
);
308 DWORD style
= cs
->style
| (WS_CHILD
| WS_CLIPSIBLINGS
);
309 HWND hwnd
, hwndMax
= 0;
310 WORD wIDmenu
= ci
->idFirstChild
+ ci
->nActiveChildren
;
311 char lpstrDef
[]="junk!";
314 * Create child window
318 dprintf_mdi(stdnimp
,"MDICreateChild: origin %i,%i - dim %i,%i, style %08x\n",
319 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
, (unsigned)cs
->style
);
320 /* calculate placement */
321 MDI_CalcDefaultChildPos(w
, ci
->nTotalCreated
++, pos
, 0);
323 if( cs
->cx
== CW_USEDEFAULT16
|| !cs
->cx
)
325 if( cs
->cy
== CW_USEDEFAULT16
|| !cs
->cy
)
328 if( cs
->x
== CW_USEDEFAULT16
)
334 /* restore current maximized child */
335 if( style
& WS_VISIBLE
&& ci
->hwndChildMaximized
)
337 if( style
& WS_MAXIMIZE
)
338 SendMessage16(w
->hwndSelf
, WM_SETREDRAW
, FALSE
, 0L );
339 hwndMax
= ci
->hwndChildMaximized
;
340 ShowWindow( hwndMax
, SW_SHOWNOACTIVATE
);
341 if( style
& WS_MAXIMIZE
)
342 SendMessage16(w
->hwndSelf
, WM_SETREDRAW
, TRUE
, 0L );
345 /* this menu is needed to set a check mark in MDI_ChildActivate */
346 AppendMenu32A(ci
->hWindowMenu
,MF_STRING
,wIDmenu
, lpstrDef
);
348 ci
->nActiveChildren
++;
350 /* fix window style */
351 if( !(w
->dwStyle
& MDIS_ALLCHILDSTYLES
) )
353 style
&= (WS_CHILD
| WS_CLIPSIBLINGS
| WS_MINIMIZE
| WS_MAXIMIZE
|
354 WS_CLIPCHILDREN
| WS_DISABLED
| WS_VSCROLL
| WS_HSCROLL
);
355 style
|= (WS_VISIBLE
| WS_OVERLAPPEDWINDOW
);
358 hwnd
= CreateWindow16( (LPCSTR
)PTR_SEG_TO_LIN(cs
->szClass
),
359 (LPCSTR
)PTR_SEG_TO_LIN(cs
->szTitle
), style
,
360 cs
->x
, cs
->y
, cs
->cx
, cs
->cy
, parent
,
361 (HMENU
)(DWORD
)(WORD
)wIDmenu
, w
->hInstance
,
364 /* MDI windows are WS_CHILD so they won't be activated by CreateWindow */
368 WND
* wnd
= WIN_FindWndPtr( hwnd
);
370 MDI_MenuModifyItem(w
,hwnd
);
371 if( wnd
->dwStyle
& WS_MINIMIZE
&& ci
->hwndActiveChild
)
372 ShowWindow( hwnd
, SW_SHOWMINNOACTIVE
);
375 SetWindowPos( hwnd
, 0, 0, 0, 0, 0, SWP_SHOWWINDOW
| SWP_NOSIZE
| SWP_NOMOVE
);
376 if( wnd
->dwStyle
& WS_MAXIMIZE
)
378 MDI_AugmentFrameMenu( ci
, w
->parent
, hwnd
);
379 MDI_UpdateFrameText( w
->parent
, ci
->self
, MDI_REPAINTFRAME
, NULL
);
382 dprintf_mdi(stddeb
, "MDICreateChild: created child - %04x\n",hwnd
);
386 ci
->nActiveChildren
--;
387 DeleteMenu(ci
->hWindowMenu
,wIDmenu
,MF_BYCOMMAND
);
388 if( IsWindow(hwndMax
) )
389 ShowWindow(hwndMax
, SW_SHOWMAXIMIZED
);
395 /**********************************************************************
396 * MDI_ChildGetMinMaxInfo
398 void MDI_ChildGetMinMaxInfo(WND
* clientWnd
, HWND hwnd
, 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
;
414 /**********************************************************************
415 * MDI_SwitchActiveChild
417 * Notes: SetWindowPos sends WM_CHILDACTIVATE to the child window that is
420 * wTo is basically lParam of WM_MDINEXT message or explicit
423 void MDI_SwitchActiveChild(HWND clientHwnd
, HWND childHwnd
, BOOL wTo
)
425 WND
*w
= WIN_FindWndPtr(clientHwnd
);
430 hwndTo
= MDI_GetWindow(w
,childHwnd
,(WORD
)wTo
);
432 ci
= (MDICLIENTINFO
*) w
->wExtra
;
434 dprintf_mdi(stddeb
, "MDI_SwitchActiveChild: from %04x, to %04x\n",childHwnd
,hwndTo
);
436 if ( !hwndTo
) return;
438 hwndPrev
= ci
->hwndActiveChild
;
440 if ( hwndTo
!= hwndPrev
)
444 if( ci
->hwndChildMaximized
)
447 w
->dwStyle
&= ~WS_VISIBLE
;
450 SetWindowPos( hwndTo
, HWND_TOP
, 0, 0, 0, 0,
451 SWP_NOMOVE
| SWP_NOSIZE
);
452 if( !wTo
&& hwndPrev
)
454 SetWindowPos( hwndPrev
, HWND_BOTTOM
, 0, 0, 0, 0,
455 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
459 ShowWindow( clientHwnd
, SW_SHOW
);
464 /**********************************************************************
467 HWND
MDIDestroyChild(WND
*w_parent
, MDICLIENTINFO
*ci
, HWND parent
,
468 HWND child
, BOOL flagDestroy
)
470 WND
*childPtr
= WIN_FindWndPtr(child
);
474 if( child
== ci
->hwndActiveChild
)
476 MDI_SwitchActiveChild(parent
,child
,0);
478 if( child
== ci
->hwndActiveChild
)
480 ShowWindow( child
, SW_HIDE
);
481 if( child
== ci
->hwndChildMaximized
)
483 MDI_RestoreFrameMenu(w_parent
->parent
, child
);
484 ci
->hwndChildMaximized
= 0;
485 MDI_UpdateFrameText(w_parent
->parent
,parent
,TRUE
,NULL
);
488 MDI_ChildActivate(w_parent
,0);
490 MDI_MenuDeleteItem(w_parent
, child
);
493 ci
->nActiveChildren
--;
495 dprintf_mdi(stddeb
,"MDIDestroyChild: child destroyed - %04x\n",child
);
499 MDI_PostUpdate(GetParent(child
), ci
, SB_BOTH
+1);
500 DestroyWindow(child
);
508 /**********************************************************************
511 * Note: hWndChild is NULL when last child is being destroyed
513 LONG
MDI_ChildActivate(WND
*clientPtr
, HWND hWndChild
)
515 MDICLIENTINFO
*clientInfo
= (MDICLIENTINFO
*)clientPtr
->wExtra
;
516 HWND prevActiveWnd
= clientInfo
->hwndActiveChild
;
517 WND
*wndPtr
= WIN_FindWndPtr( hWndChild
);
518 WND
*wndPrev
= WIN_FindWndPtr( prevActiveWnd
);
519 BOOL isActiveFrameWnd
= 0;
521 if( hWndChild
== prevActiveWnd
) return 0L;
524 if( wndPtr
->dwStyle
& WS_DISABLED
) return 0L;
526 dprintf_mdi(stddeb
,"MDI_ChildActivate: %04x\n", hWndChild
);
528 if( GetActiveWindow() == clientPtr
->parent
->hwndSelf
)
529 isActiveFrameWnd
= TRUE
;
531 /* deactivate prev. active child */
534 SendMessage16( prevActiveWnd
, WM_NCACTIVATE
, FALSE
, 0L );
537 SendMessage32A( prevActiveWnd
, WM_MDIACTIVATE
, (WPARAM
)prevActiveWnd
,
541 SendMessage16( prevActiveWnd
, WM_MDIACTIVATE
, FALSE
,
542 MAKELONG(hWndChild
,prevActiveWnd
));
544 /* uncheck menu item */
545 if( clientInfo
->hWindowMenu
)
546 CheckMenuItem( clientInfo
->hWindowMenu
,
547 wndPrev
->wIDmenu
, 0);
551 if( clientInfo
->hwndChildMaximized
)
552 if( clientInfo
->hwndChildMaximized
!= hWndChild
)
555 clientInfo
->hwndActiveChild
= hWndChild
;
556 ShowWindow( hWndChild
, SW_SHOWMAXIMIZED
);
559 ShowWindow( clientInfo
->hwndActiveChild
,
562 clientInfo
->hwndActiveChild
= hWndChild
;
564 /* check if we have any children left */
567 if( isActiveFrameWnd
)
568 SetFocus( clientInfo
->self
);
572 /* check menu item */
573 if( clientInfo
->hWindowMenu
)
574 CheckMenuItem( clientInfo
->hWindowMenu
,
575 wndPtr
->wIDmenu
, MF_CHECKED
);
577 /* bring active child to the top */
578 SetWindowPos( hWndChild
, 0,0,0,0,0, SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
);
580 if( isActiveFrameWnd
)
582 SendMessage16( hWndChild
, WM_NCACTIVATE
, TRUE
, 0L);
583 if( GetFocus() == clientInfo
->self
)
584 SendMessage16( clientInfo
->self
, WM_SETFOCUS
,
585 (WPARAM
)clientInfo
->self
, 0L );
587 SetFocus( clientInfo
->self
);
591 SendMessage32A( hWndChild
, WM_MDIACTIVATE
, (WPARAM
)hWndChild
,
592 (LPARAM
)prevActiveWnd
);
594 SendMessage16( hWndChild
, WM_MDIACTIVATE
, TRUE
,
595 MAKELONG(hWndChild
,prevActiveWnd
));
601 /**********************************************************************
604 * iTotal returns number of children available for tiling or cascading
606 MDIWCL
* MDI_BuildWCL(WND
* clientWnd
, INT16
* iTotal
)
608 MDIWCL
*listTop
,*listNext
;
611 if (!(listTop
= (MDIWCL
*)malloc( sizeof(MDIWCL
) ))) return NULL
;
613 listTop
->hChild
= clientWnd
->child
? clientWnd
->child
->hwndSelf
: 0;
614 listTop
->prev
= NULL
;
617 /* build linked list from top child to bottom */
619 childWnd
= WIN_FindWndPtr( listTop
->hChild
);
620 while( childWnd
&& childWnd
->next
)
622 listNext
= (MDIWCL
*)xmalloc(sizeof(MDIWCL
));
624 if( (childWnd
->dwStyle
& WS_DISABLED
) ||
625 (childWnd
->dwStyle
& WS_MINIMIZE
) ||
626 !(childWnd
->dwStyle
& WS_VISIBLE
) )
632 listNext
->hChild
= childWnd
->next
->hwndSelf
;
633 listNext
->prev
= listTop
;
637 childWnd
= childWnd
->next
;
640 if( (childWnd
->dwStyle
& WS_DISABLED
) ||
641 (childWnd
->dwStyle
& WS_MINIMIZE
) ||
642 !(childWnd
->dwStyle
& WS_VISIBLE
) )
652 /* -------------------- MDI client window functions ------------------- */
654 /**********************************************************************
655 * CreateMDIMenuBitmap
657 HBITMAP
CreateMDIMenuBitmap(void)
659 HDC hDCSrc
= CreateCompatibleDC(0);
660 HDC hDCDest
= CreateCompatibleDC(hDCSrc
);
661 HBITMAP16 hbClose
= LoadBitmap16(0, MAKEINTRESOURCE(OBM_CLOSE
) );
662 HBITMAP16 hbCopy
,hb_src
,hb_dest
;
664 hb_src
= SelectObject(hDCSrc
,hbClose
);
665 hbCopy
= CreateCompatibleBitmap(hDCSrc
,SYSMETRICS_CXSIZE
, SYSMETRICS_CYSIZE
);
666 hb_dest
= SelectObject(hDCDest
,hbCopy
);
668 BitBlt(hDCDest
, 0, 0, SYSMETRICS_CXSIZE
, SYSMETRICS_CYSIZE
,
669 hDCSrc
, SYSMETRICS_CXSIZE
, 0, SRCCOPY
);
671 SelectObject(hDCSrc
,hb_src
);
672 SelectObject(hDCDest
,hb_dest
);
674 DeleteObject(hbClose
);
682 /**********************************************************************
685 LONG
MDICascade(WND
* clientWnd
, MDICLIENTINFO
*ci
)
687 MDIWCL
*listTop
,*listPrev
;
688 INT16 delta
= 0,iToPosition
= 0, n
= 0;
691 if (ci
->hwndChildMaximized
)
692 ShowWindow( ci
->hwndChildMaximized
, SW_NORMAL
);
694 if (ci
->nActiveChildren
== 0) return 0;
696 if (!(listTop
= MDI_BuildWCL(clientWnd
,&iToPosition
))) return 0;
698 if( iToPosition
< ci
->nActiveChildren
)
699 delta
= 2 * SYSMETRICS_CYICONSPACING
+ SYSMETRICS_CYICON
;
701 /* walk list and move windows */
704 dprintf_mdi(stddeb
, "MDICascade: move %04x to (%d,%d) size [%d,%d]\n",
705 listTop
->hChild
, pos
[0].x
, pos
[0].y
, pos
[1].x
, pos
[1].y
);
707 if( listTop
->hChild
)
709 MDI_CalcDefaultChildPos(clientWnd
, n
++, pos
, delta
);
710 SetWindowPos(listTop
->hChild
, 0, pos
[0].x
, pos
[0].y
, pos
[1].x
, pos
[1].y
,
711 SWP_DRAWFRAME
| SWP_NOACTIVATE
| SWP_NOZORDER
);
714 listPrev
= listTop
->prev
;
719 if( iToPosition
< ci
->nActiveChildren
)
720 ArrangeIconicWindows( clientWnd
->hwndSelf
);
725 /**********************************************************************
729 LONG
MDITile(WND
* wndClient
, MDICLIENTINFO
*ci
,WORD wParam
)
731 MDIWCL
*listTop
,*listPrev
;
738 INT16 iToPosition
= 0;
740 if (ci
->hwndChildMaximized
)
741 ShowWindow(ci
->hwndChildMaximized
, SW_NORMAL
);
743 if (ci
->nActiveChildren
== 0) return 0;
745 listTop
= MDI_BuildWCL(wndClient
, &iToPosition
);
747 dprintf_mdi(stddeb
,"MDITile: %i windows to tile\n",iToPosition
);
749 if( !listTop
) return 0;
754 rect
= wndClient
->rectClient
;
755 rows
= (int) sqrt((double) iToPosition
);
756 columns
= iToPosition
/ rows
;
758 if (wParam
== MDITILE_HORIZONTAL
) /* version >= 3.1 */
761 rows
=columns
; /* exchange r and c */
766 if( iToPosition
!= ci
->nActiveChildren
)
768 y
= rect
.bottom
- 2 * SYSMETRICS_CYICONSPACING
- SYSMETRICS_CYICON
;
769 rect
.bottom
= ( y
- SYSMETRICS_CYICON
< rect
.top
)? rect
.bottom
: y
;
772 ysize
= rect
.bottom
/ rows
;
773 xsize
= rect
.right
/ columns
;
778 for (c
= 1; c
<= columns
; c
++)
782 rows
= iToPosition
- i
;
783 ysize
= rect
.bottom
/ rows
;
787 for (r
= 1; r
<= rows
; r
++, i
++)
789 /* shouldn't happen but... */
793 /* skip iconized childs from tiling */
794 while (!listTop
->hChild
)
796 listPrev
= listTop
->prev
;
800 SetWindowPos(listTop
->hChild
, 0, x
, y
, xsize
, ysize
,
801 SWP_DRAWFRAME
| SWP_NOACTIVATE
| SWP_NOZORDER
);
803 listPrev
= listTop
->prev
;
811 /* free the rest if any */
814 listPrev
= listTop
->prev
;
819 if (iToPosition
< ci
->nActiveChildren
)
820 ArrangeIconicWindows( wndClient
->hwndSelf
);
825 /* ----------------------- Frame window ---------------------------- */
828 /**********************************************************************
829 * MDI_AugmentFrameMenu
831 BOOL
MDI_AugmentFrameMenu(MDICLIENTINFO
* ci
, WND
*frame
, HWND hChild
)
833 WND
* child
= WIN_FindWndPtr(hChild
);
837 dprintf_mdi(stddeb
,"MDI_AugmentFrameMenu: frame %p,child %04x\n",frame
,hChild
);
839 if( !frame
->wIDmenu
|| !child
->hSysMenu
) return 0;
841 /* create a copy of sysmenu popup and insert it into frame menu bar */
843 if (!(handle
= SYSRES_LoadResource( SYSRES_MENU_SYSMENU
))) return 0;
844 hSysPopup
= LoadMenuIndirect16( GlobalLock16( handle
) );
845 SYSRES_FreeResource( handle
);
847 dprintf_mdi(stddeb
,"\t\tgot popup %04x\n in sysmenu %04x",hSysPopup
,child
->hSysMenu
);
849 if( !InsertMenu32A(frame
->wIDmenu
,0,MF_BYPOSITION
| MF_BITMAP
| MF_POPUP
,
850 hSysPopup
, (LPSTR
)(DWORD
)hBmpClose
))
851 { DestroyMenu(hSysPopup
); return 0; }
853 if( !AppendMenu32A(frame
->wIDmenu
,MF_HELP
| MF_BITMAP
,
854 SC_RESTORE
, (LPSTR
)(DWORD
)hBmpRestore
))
856 RemoveMenu(frame
->wIDmenu
,0,MF_BYPOSITION
);
860 EnableMenuItem(hSysPopup
, SC_SIZE
, MF_BYCOMMAND
| MF_GRAYED
);
861 EnableMenuItem(hSysPopup
, SC_MOVE
, MF_BYCOMMAND
| MF_GRAYED
);
862 EnableMenuItem(hSysPopup
, SC_MAXIMIZE
, MF_BYCOMMAND
| MF_GRAYED
);
864 child
->dwStyle
&= ~WS_SYSMENU
;
867 DrawMenuBar(frame
->hwndSelf
);
872 /**********************************************************************
873 * MDI_RestoreFrameMenu
875 BOOL
MDI_RestoreFrameMenu( WND
*frameWnd
, HWND hChild
)
877 WND
* child
= WIN_FindWndPtr(hChild
);
878 INT nItems
= GetMenuItemCount(frameWnd
->wIDmenu
) - 1;
880 dprintf_mdi(stddeb
,"MDI_RestoreFrameMenu: for child %04x\n",hChild
);
882 if( GetMenuItemID(frameWnd
->wIDmenu
,nItems
) != SC_RESTORE
)
885 child
->dwStyle
|= WS_SYSMENU
;
887 RemoveMenu(frameWnd
->wIDmenu
,0,MF_BYPOSITION
);
888 DeleteMenu(frameWnd
->wIDmenu
,nItems
-1,MF_BYPOSITION
);
890 DrawMenuBar(frameWnd
->hwndSelf
);
895 /**********************************************************************
896 * MDI_UpdateFrameText
898 * used when child window is maximized/restored
900 * Note: lpTitle can be NULL
902 void MDI_UpdateFrameText(WND
*frameWnd
, HWND hClient
, BOOL repaint
, LPCSTR lpTitle
)
904 char lpBuffer
[MDI_MAXTITLELENGTH
+1];
905 WND
* clientWnd
= WIN_FindWndPtr(hClient
);
907 MDICLIENTINFO
*ci
= (MDICLIENTINFO
*) clientWnd
->wExtra
;
909 dprintf_mdi(stddeb
, "MDI: repaint %i, frameText %s\n", repaint
, (lpTitle
)?lpTitle
:"NULL");
911 /* store new "default" title if lpTitle is not NULL */
914 if (ci
->frameTitle
) HeapFree( SystemHeap
, 0, ci
->frameTitle
);
915 ci
->frameTitle
= HEAP_strdupA( SystemHeap
, 0, lpTitle
);
920 WND
* childWnd
= WIN_FindWndPtr( ci
->hwndChildMaximized
);
922 if( childWnd
&& childWnd
->text
)
924 /* combine frame title and child title if possible */
926 LPCSTR lpBracket
= " - [";
927 int i_frame_text_length
= strlen(ci
->frameTitle
);
928 int i_child_text_length
= strlen(childWnd
->text
);
930 lstrcpyn32A( lpBuffer
, ci
->frameTitle
, MDI_MAXTITLELENGTH
);
932 if( i_frame_text_length
+ 6 < MDI_MAXTITLELENGTH
)
934 strcat( lpBuffer
, lpBracket
);
936 if( i_frame_text_length
+ i_child_text_length
+ 6 < MDI_MAXTITLELENGTH
)
938 strcat( lpBuffer
, childWnd
->text
);
939 strcat( lpBuffer
, "]" );
943 lstrcpyn32A( lpBuffer
+ i_frame_text_length
+ 4,
945 MDI_MAXTITLELENGTH
- i_frame_text_length
- 5 );
946 strcat( lpBuffer
, "]" );
952 strncpy(lpBuffer
, ci
->frameTitle
, MDI_MAXTITLELENGTH
);
953 lpBuffer
[MDI_MAXTITLELENGTH
]='\0';
959 DEFWND_SetText( frameWnd
, lpBuffer
);
960 if( repaint
== MDI_REPAINTFRAME
)
961 SetWindowPos(frameWnd
->hwndSelf
, 0,0,0,0,0, SWP_FRAMECHANGED
|
962 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOACTIVATE
| SWP_NOZORDER
);
966 /* ----------------------------- Interface ---------------------------- */
969 /**********************************************************************
972 * This function is the handler for all MDI requests.
974 LRESULT
MDIClientWndProc(HWND hwnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
977 LPCLIENTCREATESTRUCT16 ccs
;
980 WND
*w
= WIN_FindWndPtr(hwnd
);
981 WND
*frameWnd
= w
->parent
;
983 ci
= (MDICLIENTINFO
*) w
->wExtra
;
988 cs
= (LPCREATESTRUCT16
) PTR_SEG_TO_LIN(lParam
);
989 ccs
= (LPCLIENTCREATESTRUCT16
) PTR_SEG_TO_LIN(cs
->lpCreateParams
);
991 ci
->hWindowMenu
= ccs
->hWindowMenu
;
992 ci
->idFirstChild
= ccs
->idFirstChild
;
993 ci
->hwndChildMaximized
= 0;
994 ci
->nActiveChildren
= 0;
995 ci
->nTotalCreated
= 0;
996 ci
->frameTitle
= NULL
;
997 ci
->sbNeedUpdate
= 0;
999 w
->dwStyle
|= WS_CLIPCHILDREN
;
1003 hBmpClose
= CreateMDIMenuBitmap();
1004 hBmpRestore
= LoadBitmap16( 0, MAKEINTRESOURCE(OBM_RESTORE
) );
1006 MDI_UpdateFrameText(frameWnd
, hwnd
, MDI_NOFRAMEREPAINT
,frameWnd
->text
);
1008 AppendMenu32A( ccs
->hWindowMenu
, MF_SEPARATOR
, 0, NULL
);
1010 GetClientRect16(frameWnd
->hwndSelf
, &rect
);
1011 NC_HandleNCCalcSize( w
, &rect
);
1012 w
->rectClient
= rect
;
1014 dprintf_mdi(stddeb
,"MDI: Client created - hwnd = %04x, idFirst = %u\n",hwnd
,ci
->idFirstChild
);
1019 if( ci
->hwndChildMaximized
) MDI_RestoreFrameMenu(w
, frameWnd
->hwndSelf
);
1020 ci
->idFirstChild
= GetMenuItemCount(ci
->hWindowMenu
) - 1;
1021 ci
->nActiveChildren
++; /* to delete a separator */
1023 while( ci
->nActiveChildren
-- )
1024 DeleteMenu(ci
->hWindowMenu
,MF_BYPOSITION
,ci
->idFirstChild
--);
1028 case WM_MDIACTIVATE
:
1029 if( ci
->hwndActiveChild
!= (HWND
)wParam
)
1030 SetWindowPos((HWND
)wParam
, 0,0,0,0,0, SWP_NOSIZE
| SWP_NOMOVE
);
1034 return MDICascade(w
, ci
);
1037 return (LONG
)MDICreateChild(w
, ci
, hwnd
, lParam
);
1040 return (LONG
)MDIDestroyChild(w
, ci
, hwnd
, (HWND
)wParam
, TRUE
);
1042 case WM_MDIGETACTIVE
:
1043 return ((LONG
) ci
->hwndActiveChild
|
1044 ((LONG
) (ci
->hwndChildMaximized
>0) << 16));
1046 case WM_MDIICONARRANGE
:
1047 ci
->sbNeedUpdate
= TRUE
;
1048 MDIIconArrange(hwnd
);
1049 ci
->sbRecalc
= SB_BOTH
+1;
1050 SendMessage16(hwnd
,WM_MDICALCCHILDSCROLL
,0,0L);
1053 case WM_MDIMAXIMIZE
:
1054 ShowWindow((HWND
)wParam
, SW_MAXIMIZE
);
1058 MDI_SwitchActiveChild(hwnd
, (HWND
)wParam
, (lParam
)?1:0);
1062 ShowWindow( (HWND
)wParam
, SW_NORMAL
);
1067 return (LRESULT
)MDISetMenu(hwnd
, FALSE
, (HMENU
)wParam
, (HMENU
)lParam
);
1069 return (LRESULT
)MDISetMenu(hwnd
, wParam
, LOWORD(lParam
), HIWORD(lParam
));
1073 ci
->sbNeedUpdate
= TRUE
;
1074 ShowScrollBar(hwnd
,SB_BOTH
,FALSE
);
1075 MDITile(w
, ci
,wParam
);
1076 ci
->sbNeedUpdate
= FALSE
;
1081 ci
->sbNeedUpdate
= TRUE
;
1082 ScrollChildren(hwnd
,message
,wParam
,lParam
);
1083 ci
->sbNeedUpdate
= FALSE
;
1087 if( ci
->hwndActiveChild
)
1089 w
= WIN_FindWndPtr( ci
->hwndActiveChild
);
1090 if( !(w
->dwStyle
& WS_MINIMIZE
) )
1091 SetFocus( ci
->hwndActiveChild
);
1096 if( ci
->hwndActiveChild
)
1097 SendMessage16(ci
->hwndActiveChild
, message
, wParam
, lParam
);
1100 case WM_PARENTNOTIFY
:
1101 if( wParam
== WM_LBUTTONDOWN
)
1103 POINT16 pt
= MAKEPOINT16(lParam
);
1104 HWND child
= ChildWindowFromPoint16(hwnd
, pt
);
1106 dprintf_mdi(stddeb
,"MDIClient: notification from %04x (%i,%i)\n",child
,pt
.x
,pt
.y
);
1108 if( child
&& child
!= hwnd
)
1110 WND
* wnd
= WIN_FindWndPtr( child
);
1112 /* if we got owned popup */
1113 if( wnd
->owner
) child
= wnd
->owner
->hwndSelf
;
1115 if( child
!= ci
->hwndActiveChild
)
1116 SetWindowPos(child
, 0,0,0,0,0, SWP_NOSIZE
| SWP_NOMOVE
);
1122 if( ci
->hwndChildMaximized
)
1124 WND
* child
= WIN_FindWndPtr(ci
->hwndChildMaximized
);
1125 RECT16 rect
= { 0, 0, LOWORD(lParam
), HIWORD(lParam
) };
1127 AdjustWindowRectEx16(&rect
, child
->dwStyle
, 0, child
->dwExStyle
);
1128 MoveWindow(ci
->hwndChildMaximized
, rect
.left
, rect
.top
,
1129 rect
.right
- rect
.left
, rect
.bottom
- rect
.top
, 1);
1132 MDI_PostUpdate(hwnd
, ci
, SB_BOTH
+1);
1136 case WM_MDICALCCHILDSCROLL
:
1137 if( ci
->sbNeedUpdate
)
1140 CalcChildScroll(hwnd
, ci
->sbRecalc
-1);
1141 ci
->sbRecalc
= ci
->sbNeedUpdate
= 0;
1146 return DefWindowProc16(hwnd
, message
, wParam
, lParam
);
1150 /***********************************************************************
1151 * DefFrameProc16 (USER.445)
1153 LRESULT
DefFrameProc16( HWND16 hwnd
, HWND16 hwndMDIClient
, UINT16 message
,
1154 WPARAM16 wParam
, LPARAM lParam
)
1165 wndPtr
= WIN_FindWndPtr(hwndMDIClient
);
1166 ci
= (MDICLIENTINFO
*)wndPtr
->wExtra
;
1168 /* check for possible syscommands for maximized MDI child */
1170 if( wParam
< ci
->idFirstChild
||
1171 wParam
>= ci
->idFirstChild
+ ci
->nActiveChildren
)
1173 if( (wParam
- 0xF000) & 0xF00F ) break;
1184 if( ci
->hwndChildMaximized
)
1185 return SendMessage16( ci
->hwndChildMaximized
, WM_SYSCOMMAND
,
1191 childHwnd
= MDI_GetChildByID( WIN_FindWndPtr(hwndMDIClient
),
1194 SendMessage16(hwndMDIClient
, WM_MDIACTIVATE
, (WPARAM
)childHwnd
, 0L);
1199 SendMessage16(hwndMDIClient
, message
, wParam
, lParam
);
1203 MDI_UpdateFrameText(WIN_FindWndPtr(hwnd
), hwndMDIClient
,
1205 (LPCSTR
)PTR_SEG_TO_LIN(lParam
));
1209 SetFocus(hwndMDIClient
);
1213 MoveWindow(hwndMDIClient
, 0, 0,
1214 LOWORD(lParam
), HIWORD(lParam
), TRUE
);
1219 return DefWindowProc16(hwnd
, message
, wParam
, lParam
);
1223 /***********************************************************************
1224 * DefFrameProc32A (USER32.121)
1226 LRESULT
DefFrameProc32A( HWND32 hwnd
, HWND32 hwndMDIClient
, UINT32 message
,
1227 WPARAM32 wParam
, LPARAM lParam
)
1234 return DefFrameProc16( hwnd
, hwndMDIClient
, message
,
1236 MAKELPARAM( (HWND16
)lParam
, HIWORD(wParam
) ) );
1239 SendMessage32A(hwndMDIClient
, message
, wParam
, lParam
);
1243 return DefFrameProc16( hwnd
, hwndMDIClient
, message
,
1244 wParam
, (LPARAM
)PTR_SEG_TO_LIN(lParam
) );
1248 return DefFrameProc16( hwnd
, hwndMDIClient
, message
,
1253 return DefWindowProc32A(hwnd
, message
, wParam
, lParam
);
1257 /***********************************************************************
1258 * DefFrameProc32W (USER32.122)
1260 LRESULT
DefFrameProc32W( HWND32 hwnd
, HWND32 hwndMDIClient
, UINT32 message
,
1261 WPARAM32 wParam
, LPARAM lParam
)
1268 return DefFrameProc16( hwnd
, hwndMDIClient
, message
,
1270 MAKELPARAM( (HWND16
)lParam
, HIWORD(wParam
) ) );
1273 SendMessage32W(hwndMDIClient
, message
, wParam
, lParam
);
1277 /* FIXME: Unicode */
1278 return DefFrameProc32A( hwnd
, hwndMDIClient
, message
,
1283 return DefFrameProc32A( hwnd
, hwndMDIClient
, message
,
1288 return DefWindowProc32W( hwnd
, message
, wParam
, lParam
);
1292 /***********************************************************************
1293 * DefMDIChildProc16 (USER.447)
1295 LRESULT
DefMDIChildProc16( HWND16 hwnd
, UINT16 message
,
1296 WPARAM16 wParam
, LPARAM lParam
)
1301 clientWnd
= WIN_FindWndPtr(GetParent(hwnd
));
1302 ci
= (MDICLIENTINFO
*) clientWnd
->wExtra
;
1307 DefWindowProc16(hwnd
, message
, wParam
, lParam
);
1308 MDI_MenuModifyItem(clientWnd
,hwnd
);
1309 if( ci
->hwndChildMaximized
== hwnd
)
1310 MDI_UpdateFrameText( clientWnd
->parent
, ci
->self
,
1311 MDI_REPAINTFRAME
, NULL
);
1315 SendMessage16(ci
->self
,WM_MDIDESTROY
,(WPARAM
)hwnd
,0L);
1319 if( ci
->hwndActiveChild
!= hwnd
)
1320 MDI_ChildActivate(clientWnd
, hwnd
);
1323 case WM_CHILDACTIVATE
:
1324 MDI_ChildActivate(clientWnd
, hwnd
);
1328 dprintf_mdi(stddeb
,"DefMDIChildProc: WM_NCPAINT for %04x, active %04x\n",
1329 hwnd
, ci
->hwndActiveChild
);
1336 if( ci
->hwndChildMaximized
== hwnd
) return 0;
1339 if( ci
->hwndChildMaximized
== hwnd
)
1340 return SendMessage16( clientWnd
->parent
->hwndSelf
,
1341 message
, wParam
, lParam
);
1344 SendMessage16( ci
->self
, WM_MDINEXT
, 0, 0);
1347 SendMessage16( ci
->self
, WM_MDINEXT
, 0, 1);
1352 case WM_GETMINMAXINFO
:
1353 MDI_ChildGetMinMaxInfo(clientWnd
, hwnd
, (MINMAXINFO16
*) PTR_SEG_TO_LIN(lParam
));
1357 if( ci
->hwndChildMaximized
)
1358 ci
->sbNeedUpdate
= 0;
1360 MDI_PostUpdate(clientWnd
->hwndSelf
, ci
, SB_BOTH
+1);
1366 if( ci
->hwndActiveChild
== hwnd
&& wParam
!= SIZE_MAXIMIZED
)
1368 ci
->hwndChildMaximized
= 0;
1370 MDI_RestoreFrameMenu( clientWnd
->parent
, hwnd
);
1371 MDI_UpdateFrameText( clientWnd
->parent
, ci
->self
,
1372 MDI_REPAINTFRAME
, NULL
);
1375 if( wParam
== SIZE_MAXIMIZED
)
1377 HWND hMaxChild
= ci
->hwndChildMaximized
;
1379 if( hMaxChild
== hwnd
) break;
1383 SendMessage16( hMaxChild
, WM_SETREDRAW
, FALSE
, 0L );
1385 MDI_RestoreFrameMenu( clientWnd
->parent
, hMaxChild
);
1386 ShowWindow( hMaxChild
, SW_SHOWNOACTIVATE
);
1388 SendMessage16( hMaxChild
, WM_SETREDRAW
, TRUE
, 0L );
1391 dprintf_mdi(stddeb
,"\tMDI: maximizing child %04x\n", hwnd
);
1393 ci
->hwndChildMaximized
= hwnd
; /* !!! */
1395 MDI_AugmentFrameMenu( ci
, clientWnd
->parent
, hwnd
);
1396 MDI_UpdateFrameText( clientWnd
->parent
, ci
->self
,
1397 MDI_REPAINTFRAME
, NULL
);
1400 if( wParam
== SIZE_MINIMIZED
)
1402 HWND switchTo
= MDI_GetWindow(clientWnd
, hwnd
, 0);
1405 SendMessage16( switchTo
, WM_CHILDACTIVATE
, 0, 0L);
1408 MDI_PostUpdate(clientWnd
->hwndSelf
, ci
, SB_BOTH
+1);
1413 /* MDI children don't have menus */
1414 PostMessage( clientWnd
->parent
->hwndSelf
, WM_SYSCOMMAND
,
1415 (WPARAM
)SC_KEYMENU
, (LPARAM
)wParam
);
1419 /* set current menu to child system menu */
1424 return DefWindowProc16(hwnd
, message
, wParam
, lParam
);
1428 /***********************************************************************
1429 * DefMDIChildProc32A (USER32.123)
1431 LRESULT
DefMDIChildProc32A( HWND32 hwnd
, UINT32 message
,
1432 WPARAM32 wParam
, LPARAM lParam
)
1437 clientWnd
= WIN_FindWndPtr(GetParent(hwnd
));
1438 ci
= (MDICLIENTINFO
*) clientWnd
->wExtra
;
1443 DefWindowProc32A(hwnd
, message
, wParam
, lParam
);
1444 MDI_MenuModifyItem(clientWnd
,hwnd
);
1445 if( ci
->hwndChildMaximized
== hwnd
)
1446 MDI_UpdateFrameText( clientWnd
->parent
, ci
->self
,
1447 MDI_REPAINTFRAME
, NULL
);
1450 case WM_GETMINMAXINFO
:
1453 STRUCT32_MINMAXINFO32to16( (MINMAXINFO32
*)lParam
, &mmi
);
1454 MDI_ChildGetMinMaxInfo( clientWnd
, hwnd
, &mmi
);
1455 STRUCT32_MINMAXINFO16to32( &mmi
, (MINMAXINFO32
*)lParam
);
1461 /* MDI children don't have menus */
1462 PostMessage( clientWnd
->parent
->hwndSelf
, WM_SYSCOMMAND
,
1463 (WPARAM
)SC_KEYMENU
, (LPARAM
)LOWORD(wParam
) );
1468 case WM_CHILDACTIVATE
:
1474 return DefMDIChildProc16( hwnd
, message
, (WPARAM16
)wParam
, lParam
);
1476 return DefWindowProc32A(hwnd
, message
, wParam
, lParam
);
1480 /***********************************************************************
1481 * DefMDIChildProc32W (USER32.124)
1483 LRESULT
DefMDIChildProc32W( HWND32 hwnd
, UINT32 message
,
1484 WPARAM32 wParam
, LPARAM lParam
)
1489 clientWnd
= WIN_FindWndPtr(GetParent(hwnd
));
1490 ci
= (MDICLIENTINFO
*) clientWnd
->wExtra
;
1495 DefWindowProc32W(hwnd
, message
, wParam
, lParam
);
1496 MDI_MenuModifyItem(clientWnd
,hwnd
);
1497 if( ci
->hwndChildMaximized
== hwnd
)
1498 MDI_UpdateFrameText( clientWnd
->parent
, ci
->self
,
1499 MDI_REPAINTFRAME
, NULL
);
1502 case WM_GETMINMAXINFO
:
1506 case WM_CHILDACTIVATE
:
1512 return DefMDIChildProc32A( hwnd
, message
, (WPARAM16
)wParam
, lParam
);
1514 return DefWindowProc32W(hwnd
, message
, wParam
, lParam
);
1518 /**********************************************************************
1519 * TranslateMDISysAccel (USER.451)
1522 BOOL
TranslateMDISysAccel(HWND hwndClient
, LPMSG16 msg
)
1524 WND
* clientWnd
= WIN_FindWndPtr( hwndClient
);
1526 MDICLIENTINFO
*ci
= NULL
;
1529 if( (msg
->message
!= WM_KEYDOWN
&& msg
->message
!= WM_SYSKEYDOWN
) || !clientWnd
)
1532 ci
= (MDICLIENTINFO
*) clientWnd
->wExtra
;
1533 wnd
= WIN_FindWndPtr(ci
->hwndActiveChild
);
1535 if( !wnd
) return 0;
1537 if( wnd
->dwStyle
& WS_DISABLED
) return 0;
1539 if ((GetKeyState(VK_CONTROL
) & 0x8000) && !(GetKeyState(VK_MENU
) & 0x8000))
1540 switch( msg
->wParam
)
1544 wParam
= ( GetKeyState(VK_SHIFT
) & 0x8000 )? SC_NEXTWINDOW
: SC_PREVWINDOW
;
1555 dprintf_mdi(stddeb
,"TranslateMDISysAccel: wParam = %04x\n", wParam
);
1557 SendMessage16(ci
->hwndActiveChild
,WM_SYSCOMMAND
, wParam
, (LPARAM
)msg
->wParam
);
1562 /***********************************************************************
1563 * CalcChildScroll (USER.462)
1565 void CalcChildScroll( HWND hwnd
, WORD scroll
)
1567 RECT16 childRect
, clientRect
;
1568 INT vmin
, vmax
, hmin
, hmax
, vpos
, hpos
;
1569 BOOL noscroll
= FALSE
;
1572 if (!(Wnd
= pWnd
= WIN_FindWndPtr( hwnd
))) return;
1573 GetClientRect16( hwnd
, &clientRect
);
1574 SetRectEmpty16( &childRect
);
1576 for ( pWnd
= pWnd
->child
; pWnd
; pWnd
= pWnd
->next
)
1578 UnionRect16( &childRect
, &pWnd
->rectWindow
, &childRect
);
1579 if( pWnd
->dwStyle
& WS_MAXIMIZE
)
1582 UnionRect16( &childRect
, &clientRect
, &childRect
);
1584 /* jump through the hoops to prevent excessive flashing
1587 hmin
= childRect
.left
; hmax
= childRect
.right
- clientRect
.right
;
1588 hpos
= clientRect
.left
- childRect
.left
;
1589 vmin
= childRect
.top
; vmax
= childRect
.bottom
- clientRect
.bottom
;
1590 vpos
= clientRect
.top
- childRect
.top
;
1593 ShowScrollBar(hwnd
, SB_BOTH
, FALSE
);
1598 vpos
= hpos
; vmin
= hmin
; vmax
= hmax
;
1600 SetScrollPos(hwnd
, scroll
, vpos
, FALSE
);
1601 SetScrollRange(hwnd
, scroll
, vmin
, vmax
, TRUE
);
1604 SCROLL_SetNCSbState( Wnd
, vmin
, vmax
, vpos
,
1606 SetWindowPos(hwnd
, 0, 0, 0, 0, 0, SWP_NOSIZE
| SWP_NOMOVE
1607 | SWP_NOACTIVATE
| SWP_NOZORDER
| SWP_FRAMECHANGED
);
1611 /***********************************************************************
1612 * ScrollChildren (USER.463)
1614 void ScrollChildren(HWND hWnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1616 WND
*wndPtr
= WIN_FindWndPtr(hWnd
);
1624 if( !wndPtr
) return;
1626 if( uMsg
== WM_HSCROLL
)
1628 GetScrollRange(hWnd
,SB_HORZ
,&minPos
,&maxPos
);
1629 curPos
= GetScrollPos(hWnd
,SB_HORZ
);
1630 length
= (wndPtr
->rectClient
.right
- wndPtr
->rectClient
.left
)/2;
1631 shift
= SYSMETRICS_CYHSCROLL
;
1633 else if( uMsg
== WM_VSCROLL
)
1635 GetScrollRange(hWnd
,SB_VERT
,&minPos
,&maxPos
);
1636 curPos
= GetScrollPos(hWnd
,SB_VERT
);
1637 length
= (wndPtr
->rectClient
.bottom
- wndPtr
->rectClient
.top
)/2;
1638 shift
= SYSMETRICS_CXVSCROLL
;
1645 newPos
= curPos
- shift
;
1648 newPos
= curPos
+ shift
;
1651 newPos
= curPos
- length
;
1654 newPos
= curPos
+ length
;
1657 case SB_THUMBPOSITION
:
1658 newPos
= LOWORD(lParam
);
1671 CalcChildScroll(hWnd
,(uMsg
== WM_VSCROLL
)?SB_VERT
:SB_HORZ
);
1675 if( newPos
> maxPos
)
1677 else if( newPos
< minPos
)
1680 SetScrollPos(hWnd
, (uMsg
== WM_VSCROLL
)?SB_VERT
:SB_HORZ
, newPos
, TRUE
);
1682 if( uMsg
== WM_VSCROLL
)
1683 ScrollWindow(hWnd
,0 ,curPos
- newPos
, NULL
, NULL
);
1685 ScrollWindow(hWnd
,curPos
- newPos
, 0, NULL
, NULL
);