blob: 3d9aec2394e89adcd521a03a1daff6ea07fc430c [file] [log] [blame]
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001/* MDI.C
2 *
3 * Copyright 1994, Bob Amstadt
Alexandre Julliard7e56f681996-01-31 19:02:28 +00004 * 1995,1996 Alex Korobka
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00005 *
Matthew Clinec448c5c2000-02-13 15:05:07 +00006 * This file contains routines to support MDI (Multiple Document
7 * Interface) features .
Alexandre Julliardd4719651995-12-12 18:49:11 +00008 *
David Lassondef58d80d2000-06-15 01:03:32 +00009 * Notes: Fairly complete implementation.
Alexandre Julliard2ace16a1996-04-28 15:09:19 +000010 * Also, Excel and WinWord do _not_ use MDI so if you're trying
11 * to fix them look elsewhere.
David Lassondef58d80d2000-06-15 01:03:32 +000012 *
13 * Notes on how the "More Windows..." is implemented:
14 *
15 * When we have more than 9 opened windows, a "More Windows..."
16 * option appears in the "Windows" menu. Each child window has
17 * a WND* associated with it, accesible via the children list of
18 * the parent window. This WND* has a wIDmenu member, which reflects
19 * the position of the child in the window list. For example, with
20 * 9 child windows, we could have the following pattern:
21 *
22 *
23 *
24 * Name of the child window pWndChild->wIDmenu
25 * Doc1 5000
26 * Doc2 5001
27 * Doc3 5002
28 * Doc4 5003
29 * Doc5 5004
30 * Doc6 5005
31 * Doc7 5006
32 * Doc8 5007
33 * Doc9 5008
34 *
35 *
36 * The "Windows" menu, as the "More windows..." dialog, are constructed
37 * in this order. If we add a child, we would have the following list:
38 *
39 *
40 * Name of the child window pWndChild->wIDmenu
41 * Doc1 5000
42 * Doc2 5001
43 * Doc3 5002
44 * Doc4 5003
45 * Doc5 5004
46 * Doc6 5005
47 * Doc7 5006
48 * Doc8 5007
49 * Doc9 5008
50 * Doc10 5009
51 *
52 * But only 5000 to 5008 would be displayed in the "Windows" menu. We want
53 * the last created child to be in the menu, so we swap the last child with
54 * the 9th... Doc9 will be accessible via the "More Windows..." option.
55 *
56 * Doc1 5000
57 * Doc2 5001
58 * Doc3 5002
59 * Doc4 5003
60 * Doc5 5004
61 * Doc6 5005
62 * Doc7 5006
63 * Doc8 5007
64 * Doc9 5009
65 * Doc10 5008
66 *
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000067 */
Alexandre Julliardd4719651995-12-12 18:49:11 +000068
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000069#include <stdlib.h>
Jeremy Whited3e22d92000-02-10 19:03:02 +000070#include <stdio.h>
Alexandre Julliardd4719651995-12-12 18:49:11 +000071#include <string.h>
Alexandre Julliard490a27e1994-06-08 13:57:50 +000072#include <math.h>
Jeremy Whited3e22d92000-02-10 19:03:02 +000073#include "windef.h"
74#include "wingdi.h"
Marcus Meissner61afa331999-02-22 10:16:00 +000075#include "winuser.h"
Alexandre Julliardc7e7df82000-08-14 14:41:19 +000076#include "wine/unicode.h"
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000077#include "win.h"
Alexandre Julliard2d93d001996-05-21 15:01:41 +000078#include "heap.h"
Alexandre Julliard18506551995-01-24 16:21:01 +000079#include "nonclient.h"
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000080#include "mdi.h"
81#include "user.h"
Alexandre Julliard234bc241994-12-10 13:02:28 +000082#include "menu.h"
Patrik Stridvall1ed4ecf1999-06-26 14:58:24 +000083#include "scroll.h"
Alexandre Julliard2d93d001996-05-21 15:01:41 +000084#include "struct32.h"
Francois Boisvert197a8e11999-02-13 09:10:17 +000085#include "tweak.h"
Alexandre Julliard359f497e1999-07-04 16:02:24 +000086#include "debugtools.h"
David Lassondef58d80d2000-06-15 01:03:32 +000087#include "dlgs.h"
Alexandre Julliard8d24ae61994-04-05 21:42:43 +000088
Jeremy Whited3e22d92000-02-10 19:03:02 +000089DEFAULT_DEBUG_CHANNEL(mdi);
Patrik Stridvallb4b9fae1999-04-19 14:56:29 +000090
Alexandre Julliard7ff1c411997-05-25 13:58:18 +000091#define MDIF_NEEDUPDATE 0x0001
92
Alexandre Julliardbf9130a1996-10-13 17:45:47 +000093static HBITMAP16 hBmpClose = 0;
94static HBITMAP16 hBmpRestore = 0;
Alexandre Julliard2d93d001996-05-21 15:01:41 +000095
Alexandre Julliardcdcdede1996-04-21 14:57:41 +000096/* ----------------- declarations ----------------- */
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +000097static void MDI_UpdateFrameText(WND *, HWND, BOOL, LPCWSTR);
Alexandre Julliarda3960291999-02-26 11:11:13 +000098static BOOL MDI_AugmentFrameMenu(MDICLIENTINFO*, WND *, HWND);
99static BOOL MDI_RestoreFrameMenu(WND *, HWND);
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000100
Alexandre Julliarda3960291999-02-26 11:11:13 +0000101static LONG MDI_ChildActivate( WND*, HWND );
Alexandre Julliardd4719651995-12-12 18:49:11 +0000102
David Lassondef58d80d2000-06-15 01:03:32 +0000103static HWND MDI_MoreWindowsDialog(WND*);
104static void MDI_SwapMenuItems(WND *, UINT, UINT);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000105/* -------- Miscellaneous service functions ----------
106 *
107 * MDI_GetChildByID
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000108 */
Alexandre Julliardd4719651995-12-12 18:49:11 +0000109
Alexandre Julliarda3960291999-02-26 11:11:13 +0000110static HWND MDI_GetChildByID(WND* wndPtr, INT id)
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000111{
Alexandre Julliard59730ae1996-03-24 16:20:51 +0000112 for (wndPtr = wndPtr->child; wndPtr; wndPtr = wndPtr->next)
113 if (wndPtr->wIDmenu == id) return wndPtr->hwndSelf;
114 return 0;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000115}
116
Alexandre Julliarda3960291999-02-26 11:11:13 +0000117static void MDI_PostUpdate(HWND hwnd, MDICLIENTINFO* ci, WORD recalc)
Alexandre Julliardcdcdede1996-04-21 14:57:41 +0000118{
Alexandre Julliard77b99181997-09-14 17:17:23 +0000119 if( !(ci->mdiFlags & MDIF_NEEDUPDATE) )
120 {
121 ci->mdiFlags |= MDIF_NEEDUPDATE;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000122 PostMessageA( hwnd, WM_MDICALCCHILDSCROLL, 0, 0);
Alexandre Julliard77b99181997-09-14 17:17:23 +0000123 }
124 ci->sbRecalc = recalc;
Alexandre Julliardcdcdede1996-04-21 14:57:41 +0000125}
126
Alexandre Julliarde2991ea1995-07-29 13:09:43 +0000127/**********************************************************************
Alexandre Julliardd4719651995-12-12 18:49:11 +0000128 * MDI_MenuModifyItem
129 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000130static BOOL MDI_MenuModifyItem(WND* clientWnd, HWND hWndChild )
Alexandre Julliardd4719651995-12-12 18:49:11 +0000131{
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +0000132 WCHAR buffer[128];
133 static const WCHAR format[] = {'%','d',' ',0};
Alexandre Julliard77b99181997-09-14 17:17:23 +0000134 MDICLIENTINFO *clientInfo = (MDICLIENTINFO*)clientWnd->wExtra;
135 WND *wndPtr = WIN_FindWndPtr(hWndChild);
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +0000136 UINT n = wsprintfW(buffer, format,
137 wndPtr->wIDmenu - clientInfo->idFirstChild + 1);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000138 BOOL bRet = 0;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000139
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000140 if( !clientInfo->hWindowMenu )
141 {
142 bRet = FALSE;
143 goto END;
144 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000145
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +0000146 if (wndPtr->text) lstrcpynW(buffer + n, wndPtr->text, sizeof(buffer)/sizeof(WCHAR) - n );
Alexandre Julliardd4719651995-12-12 18:49:11 +0000147
Alexandre Julliarda3960291999-02-26 11:11:13 +0000148 n = GetMenuState(clientInfo->hWindowMenu,wndPtr->wIDmenu ,MF_BYCOMMAND);
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +0000149 bRet = ModifyMenuW(clientInfo->hWindowMenu , wndPtr->wIDmenu,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000150 MF_BYCOMMAND | MF_STRING, wndPtr->wIDmenu, buffer );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000151 CheckMenuItem(clientInfo->hWindowMenu ,wndPtr->wIDmenu , n & MF_CHECKED);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000152END:
153 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard77b99181997-09-14 17:17:23 +0000154 return bRet;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000155}
156
157/**********************************************************************
158 * MDI_MenuDeleteItem
159 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000160static BOOL MDI_MenuDeleteItem(WND* clientWnd, HWND hWndChild )
Alexandre Julliardd4719651995-12-12 18:49:11 +0000161{
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +0000162 WCHAR buffer[128];
163 static const WCHAR format[] = {'&','%','d',' ',0};
Alexandre Julliard77b99181997-09-14 17:17:23 +0000164 MDICLIENTINFO *clientInfo = (MDICLIENTINFO*)clientWnd->wExtra;
165 WND *wndPtr = WIN_FindWndPtr(hWndChild);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000166 UINT index = 0,id,n;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000167 BOOL retvalue;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000168
Alexandre Julliard77b99181997-09-14 17:17:23 +0000169 if( !clientInfo->nActiveChildren ||
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000170 !clientInfo->hWindowMenu )
171 {
172 retvalue = FALSE;
173 goto END;
174 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000175
Alexandre Julliard77b99181997-09-14 17:17:23 +0000176 id = wndPtr->wIDmenu;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000177 DeleteMenu(clientInfo->hWindowMenu,id,MF_BYCOMMAND);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000178
179 /* walk the rest of MDI children to prevent gaps in the id
Alexandre Julliard1e37a181996-08-18 16:21:52 +0000180 * sequence and in the menu child list */
Alexandre Julliardd4719651995-12-12 18:49:11 +0000181
Alexandre Julliard77b99181997-09-14 17:17:23 +0000182 for( index = id+1; index <= clientInfo->nActiveChildren +
183 clientInfo->idFirstChild; index++ )
Alexandre Julliardd4719651995-12-12 18:49:11 +0000184 {
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +0000185 WND *tmpWnd = WIN_FindWndPtr(MDI_GetChildByID(clientWnd,index));
186 if( !tmpWnd )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000187 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000188 TRACE("no window for id=%i\n",index);
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +0000189 WIN_ReleaseWndPtr(tmpWnd);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000190 continue;
Alexandre Julliard77b99181997-09-14 17:17:23 +0000191 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000192
193 /* set correct id */
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +0000194 tmpWnd->wIDmenu--;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000195
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +0000196 n = wsprintfW(buffer, format ,index - clientInfo->idFirstChild);
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +0000197 if (tmpWnd->text)
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +0000198 lstrcpynW(buffer + n, tmpWnd->text, sizeof(buffer)/sizeof(WCHAR) - n );
Alexandre Julliardd4719651995-12-12 18:49:11 +0000199
David Lassondef58d80d2000-06-15 01:03:32 +0000200 /* change menu if the current child is to be shown in the
201 * "Windows" menu
202 */
203 if (index <= clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT)
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +0000204 ModifyMenuW(clientInfo->hWindowMenu ,index ,MF_BYCOMMAND | MF_STRING,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000205 index - 1 , buffer );
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +0000206 WIN_ReleaseWndPtr(tmpWnd);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000207 }
David Lassondef58d80d2000-06-15 01:03:32 +0000208
209 /* We must restore the "More Windows..." option if there is enough child
210 */
211 if (clientInfo->nActiveChildren - 1 > MDI_MOREWINDOWSLIMIT)
212 {
213 char szTmp[50];
214 LoadStringA(GetModuleHandleA("USER32"), MDI_IDS_MOREWINDOWS, szTmp, 50);
215
216 AppendMenuA(clientInfo->hWindowMenu ,MF_STRING ,clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT, szTmp );
217 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000218 retvalue = TRUE;
219END:
220 WIN_ReleaseWndPtr(wndPtr);
221 return retvalue;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000222}
223
224/**********************************************************************
225 * MDI_GetWindow
226 *
Alexandre Julliard77b99181997-09-14 17:17:23 +0000227 * returns "activateable" child different from the current or zero
Alexandre Julliardd4719651995-12-12 18:49:11 +0000228 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000229static HWND MDI_GetWindow(WND *clientWnd, HWND hWnd, BOOL bNext,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000230 DWORD dwStyleMask )
Alexandre Julliardd4719651995-12-12 18:49:11 +0000231{
Alexandre Julliard59730ae1996-03-24 16:20:51 +0000232 MDICLIENTINFO *clientInfo = (MDICLIENTINFO*)clientWnd->wExtra;
Alexandre Julliard77b99181997-09-14 17:17:23 +0000233 WND *wndPtr, *pWnd, *pWndLast = NULL;
Alexandre Julliard59730ae1996-03-24 16:20:51 +0000234
Alexandre Julliard77b99181997-09-14 17:17:23 +0000235 dwStyleMask |= WS_DISABLED | WS_VISIBLE;
Alexandre Julliard59730ae1996-03-24 16:20:51 +0000236 if( !hWnd ) hWnd = clientInfo->hwndActiveChild;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000237
Alexandre Julliard59730ae1996-03-24 16:20:51 +0000238 if( !(wndPtr = WIN_FindWndPtr(hWnd)) ) return 0;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000239
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000240 for ( pWnd = WIN_LockWndPtr(wndPtr->next); ; WIN_UpdateWndPtr(&pWnd,pWnd->next))
Alexandre Julliardd4719651995-12-12 18:49:11 +0000241 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000242 if (!pWnd ) WIN_UpdateWndPtr(&pWnd,wndPtr->parent->child);
Alexandre Julliardc981d0b1996-03-31 16:40:13 +0000243
Alexandre Julliard77b99181997-09-14 17:17:23 +0000244 if ( pWnd == wndPtr ) break; /* went full circle */
245
246 if (!pWnd->owner && (pWnd->dwStyle & dwStyleMask) == WS_VISIBLE )
Alexandre Julliard59730ae1996-03-24 16:20:51 +0000247 {
Alexandre Julliard77b99181997-09-14 17:17:23 +0000248 pWndLast = pWnd;
249 if ( bNext ) break;
Alexandre Julliard59730ae1996-03-24 16:20:51 +0000250 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000251 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000252 WIN_ReleaseWndPtr(wndPtr);
253 WIN_ReleaseWndPtr(pWnd);
Alexandre Julliard59730ae1996-03-24 16:20:51 +0000254 return pWndLast ? pWndLast->hwndSelf : 0;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000255}
256
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000257/**********************************************************************
258 * MDI_CalcDefaultChildPos
259 *
Alexandre Julliard77b99181997-09-14 17:17:23 +0000260 * It seems that the default height is about 2/3 of the client rect
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000261 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000262static void MDI_CalcDefaultChildPos( WND* w, WORD n, LPPOINT lpPos,
263 INT delta)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000264{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000265 INT nstagger;
266 RECT rect = w->rectClient;
267 INT spacing = GetSystemMetrics(SM_CYCAPTION) +
268 GetSystemMetrics(SM_CYFRAME) - 1;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000269
Alexandre Julliard77b99181997-09-14 17:17:23 +0000270 if( rect.bottom - rect.top - delta >= spacing )
271 rect.bottom -= delta;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000272
Alexandre Julliard77b99181997-09-14 17:17:23 +0000273 nstagger = (rect.bottom - rect.top)/(3 * spacing);
274 lpPos[1].x = (rect.right - rect.left - nstagger * spacing);
275 lpPos[1].y = (rect.bottom - rect.top - nstagger * spacing);
276 lpPos[0].x = lpPos[0].y = spacing * (n%(nstagger+1));
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000277}
Alexandre Julliardd4719651995-12-12 18:49:11 +0000278
279/**********************************************************************
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000280 * MDISetMenu
Alexandre Julliarde2991ea1995-07-29 13:09:43 +0000281 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000282static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame,
283 HMENU hmenuWindow)
Alexandre Julliarde2991ea1995-07-29 13:09:43 +0000284{
Richard Cohen55b92471999-09-19 14:05:05 +0000285 WND *w;
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000286 MDICLIENTINFO *ci;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000287 HWND hwndFrame = GetParent(hwnd);
288 HMENU oldFrameMenu = GetMenu(hwndFrame);
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000289
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000290 TRACE("%04x %04x %04x\n",
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000291 hwnd, hmenuFrame, hmenuWindow);
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000292
Richard Cohen55b92471999-09-19 14:05:05 +0000293 if (hmenuFrame && !IsMenu(hmenuFrame))
294 {
295 WARN("hmenuFrame is not a menu handle\n");
296 return 0L;
297 }
298
299 if (hmenuWindow && !IsMenu(hmenuWindow))
300 {
301 WARN("hmenuWindow is not a menu handle\n");
302 return 0L;
303 }
304
305 w = WIN_FindWndPtr(hwnd);
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000306 ci = (MDICLIENTINFO *) w->wExtra;
307
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000308 if( ci->hwndChildMaximized && hmenuFrame && hmenuFrame!=oldFrameMenu )
309 MDI_RestoreFrameMenu(w->parent, ci->hwndChildMaximized );
310
Guy L. Albertellic0504ca2000-05-10 21:39:00 +0000311 if( hmenuWindow && ci->hWindowMenu && hmenuWindow!=ci->hWindowMenu )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000312 {
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000313 /* delete menu items from ci->hWindowMenu
314 * and add them to hmenuWindow */
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000315
Alexandre Julliarda3960291999-02-26 11:11:13 +0000316 INT i = GetMenuItemCount(ci->hWindowMenu) - 1;
317 INT pos = GetMenuItemCount(hmenuWindow) + 1;
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000318
Alexandre Julliarda3960291999-02-26 11:11:13 +0000319 AppendMenuA( hmenuWindow, MF_SEPARATOR, 0, NULL);
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000320
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000321 if( ci->nActiveChildren )
322 {
David Lassondef58d80d2000-06-15 01:03:32 +0000323 INT j;
Huw D M Davies738c06d2000-03-24 19:49:13 +0000324 LPWSTR buffer = NULL;
325 MENUITEMINFOW mii;
David Lassondef58d80d2000-06-15 01:03:32 +0000326 INT nbWindowsMenuItems; /* num of documents shown + "More Windows..." if present */
327
328 if (ci->nActiveChildren <= MDI_MOREWINDOWSLIMIT)
329 nbWindowsMenuItems = ci->nActiveChildren;
330 else
331 nbWindowsMenuItems = MDI_MOREWINDOWSLIMIT + 1;
332
333 j = i - nbWindowsMenuItems + 1;
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000334
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000335 for( ; i >= j ; i-- )
336 {
Huw D M Davies738c06d2000-03-24 19:49:13 +0000337 memset(&mii, 0, sizeof(mii));
338 mii.cbSize = sizeof(mii);
339 mii.fMask = MIIM_CHECKMARKS | MIIM_DATA | MIIM_ID | MIIM_STATE
340 | MIIM_SUBMENU | MIIM_TYPE | MIIM_BITMAP;
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000341
Huw D M Davies738c06d2000-03-24 19:49:13 +0000342 GetMenuItemInfoW(ci->hWindowMenu, i, TRUE, &mii);
343 if(mii.cch) { /* Menu is MFT_STRING */
344 mii.cch++; /* add room for '\0' */
345 buffer = HeapAlloc(GetProcessHeap(), 0,
346 mii.cch * sizeof(WCHAR));
347 mii.dwTypeData = buffer;
348 GetMenuItemInfoW(ci->hWindowMenu, i, TRUE, &mii);
349 }
350 DeleteMenu(ci->hWindowMenu, i, MF_BYPOSITION);
351 InsertMenuItemW(hmenuWindow, pos, TRUE, &mii);
352 if(buffer) {
353 HeapFree(GetProcessHeap(), 0, buffer);
354 buffer = NULL;
355 }
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000356 }
357 }
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000358
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000359 /* remove separator */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000360 DeleteMenu(ci->hWindowMenu, i, MF_BYPOSITION);
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000361
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000362 ci->hWindowMenu = hmenuWindow;
363 }
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000364
Gerard Patela2e1b412000-05-07 18:25:33 +0000365 if (hmenuFrame)
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000366 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000367 SetMenu(hwndFrame, hmenuFrame);
Gerard Patela2e1b412000-05-07 18:25:33 +0000368 if( hmenuFrame!=oldFrameMenu )
369 {
370 if( ci->hwndChildMaximized )
371 MDI_AugmentFrameMenu(ci, w->parent, ci->hwndChildMaximized );
372 WIN_ReleaseWndPtr(w);
373 return oldFrameMenu;
374 }
Alexandre Julliard77b99181997-09-14 17:17:23 +0000375 }
Alexandre Julliard60cf6122000-09-01 01:24:19 +0000376 else
377 {
378 INT nItems = GetMenuItemCount(w->parent->wIDmenu) - 1;
379 UINT iId = GetMenuItemID(w->parent->wIDmenu,nItems) ;
380
381 if( !(iId == SC_RESTORE || iId == SC_CLOSE) )
382 {
383 /* SetMenu() may already have been called, meaning that this window
384 * already has its menu. But they may have done a SetMenu() on
385 * an MDI window, and called MDISetMenu() after the fact, meaning
386 * that the "if" to this "else" wouldn't catch the need to
387 * augment the frame menu.
388 */
389 if( ci->hwndChildMaximized )
390 MDI_AugmentFrameMenu(ci, w->parent, ci->hwndChildMaximized );
391 }
392 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000393 WIN_ReleaseWndPtr(w);
Alexandre Julliarde2991ea1995-07-29 13:09:43 +0000394 return 0;
395}
Alexandre Julliard2787be81995-05-22 18:23:01 +0000396
Alexandre Julliard85ed45e1998-08-22 19:03:56 +0000397/**********************************************************************
398 * MDIRefreshMenu
399 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000400static LRESULT MDIRefreshMenu( HWND hwnd, HMENU hmenuFrame,
401 HMENU hmenuWindow)
Alexandre Julliard85ed45e1998-08-22 19:03:56 +0000402{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000403 HWND hwndFrame = GetParent(hwnd);
404 HMENU oldFrameMenu = GetMenu(hwndFrame);
Alexandre Julliard85ed45e1998-08-22 19:03:56 +0000405
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000406 TRACE("%04x %04x %04x\n",
Alexandre Julliard85ed45e1998-08-22 19:03:56 +0000407 hwnd, hmenuFrame, hmenuWindow);
408
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000409 FIXME("partially function stub\n");
Alexandre Julliard85ed45e1998-08-22 19:03:56 +0000410
411 return oldFrameMenu;
412}
413
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000414
415/* ------------------ MDI child window functions ---------------------- */
416
417
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000418/**********************************************************************
Alexandre Julliard58199531994-04-21 01:20:00 +0000419 * MDICreateChild
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000420 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000421static HWND MDICreateChild( WND *w, MDICLIENTINFO *ci, HWND parent,
422 LPMDICREATESTRUCTA cs )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000423{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000424 POINT pos[2];
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000425 DWORD style = cs->style | (WS_CHILD | WS_CLIPSIBLINGS);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000426 HWND hwnd, hwndMax = 0;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000427 WORD wIDmenu = ci->idFirstChild + ci->nActiveChildren;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000428 char lpstrDef[]="junk!";
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000429
Dmitry Timoshkov73968f02000-09-09 19:38:52 +0000430 TRACE("origin %i,%i - dim %i,%i, style %08lx\n",
431 cs->x, cs->y, cs->cx, cs->cy, cs->style);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000432 /* calculate placement */
433 MDI_CalcDefaultChildPos(w, ci->nTotalCreated++, pos, 0);
Alexandre Julliard2787be81995-05-22 18:23:01 +0000434
Alexandre Julliarda3960291999-02-26 11:11:13 +0000435 if (cs->cx == CW_USEDEFAULT || !cs->cx) cs->cx = pos[1].x;
436 if (cs->cy == CW_USEDEFAULT || !cs->cy) cs->cy = pos[1].y;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000437
Alexandre Julliarda3960291999-02-26 11:11:13 +0000438 if( cs->x == CW_USEDEFAULT )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000439 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000440 cs->x = pos[0].x;
441 cs->y = pos[0].y;
Alexandre Julliard77b99181997-09-14 17:17:23 +0000442 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000443
444 /* restore current maximized child */
Dmitry Timoshkov73968f02000-09-09 19:38:52 +0000445 if( (style & WS_VISIBLE) && ci->hwndChildMaximized )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000446 {
Dmitry Timoshkov73968f02000-09-09 19:38:52 +0000447 TRACE("Restoring current maximized child %04x\n", ci->hwndChildMaximized);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000448 if( style & WS_MAXIMIZE )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000449 SendMessageA(w->hwndSelf, WM_SETREDRAW, FALSE, 0L );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000450 hwndMax = ci->hwndChildMaximized;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000451 ShowWindow( hwndMax, SW_SHOWNOACTIVATE );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000452 if( style & WS_MAXIMIZE )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000453 SendMessageA(w->hwndSelf, WM_SETREDRAW, TRUE, 0L );
Alexandre Julliard77b99181997-09-14 17:17:23 +0000454 }
Alexandre Julliard2787be81995-05-22 18:23:01 +0000455
David Lassondef58d80d2000-06-15 01:03:32 +0000456 if (ci->nActiveChildren <= MDI_MOREWINDOWSLIMIT)
Alexandre Julliardd4719651995-12-12 18:49:11 +0000457 /* this menu is needed to set a check mark in MDI_ChildActivate */
Matthew Clinec448c5c2000-02-13 15:05:07 +0000458 if (ci->hWindowMenu != 0)
459 AppendMenuA(ci->hWindowMenu ,MF_STRING ,wIDmenu, lpstrDef );
Alexandre Julliardd4719651995-12-12 18:49:11 +0000460
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000461 ci->nActiveChildren++;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000462
463 /* fix window style */
464 if( !(w->dwStyle & MDIS_ALLCHILDSTYLES) )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000465 {
Dmitry Timoshkov73968f02000-09-09 19:38:52 +0000466 TRACE("MDIS_ALLCHILDSTYLES is missing, fixing window style\n");
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000467 style &= (WS_CHILD | WS_CLIPSIBLINGS | WS_MINIMIZE | WS_MAXIMIZE |
468 WS_CLIPCHILDREN | WS_DISABLED | WS_VSCROLL | WS_HSCROLL );
469 style |= (WS_VISIBLE | WS_OVERLAPPEDWINDOW);
Alexandre Julliard77b99181997-09-14 17:17:23 +0000470 }
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000471
Alexandre Julliard491502b1997-11-01 19:08:16 +0000472 if( w->flags & WIN_ISWIN32 )
473 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000474 hwnd = CreateWindowA( cs->szClass, cs->szTitle, style,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000475 cs->x, cs->y, cs->cx, cs->cy, parent,
Dmitry Timoshkov73968f02000-09-09 19:38:52 +0000476 (HMENU)wIDmenu, cs->hOwner, cs );
Alexandre Julliard491502b1997-11-01 19:08:16 +0000477 }
478 else
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000479 {
480 MDICREATESTRUCT16 *cs16;
481 LPSTR title, cls;
482
483 cs16 = SEGPTR_NEW(MDICREATESTRUCT16);
484 STRUCT32_MDICREATESTRUCT32Ato16( cs, cs16 );
485 title = SEGPTR_STRDUP( cs->szTitle );
486 cls = SEGPTR_STRDUP( cs->szClass );
487 cs16->szTitle = SEGPTR_GET(title);
488 cs16->szClass = SEGPTR_GET(cls);
489
490 hwnd = CreateWindow16( cs->szClass, cs->szTitle, style,
491 cs16->x, cs16->y, cs16->cx, cs16->cy, parent,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000492 (HMENU)wIDmenu, cs16->hOwner,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000493 (LPVOID)SEGPTR_GET(cs16) );
494 SEGPTR_FREE( title );
495 SEGPTR_FREE( cls );
496 SEGPTR_FREE( cs16 );
497 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000498
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000499 /* MDI windows are WS_CHILD so they won't be activated by CreateWindow */
500
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000501 if (hwnd)
502 {
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000503 WND* wnd = WIN_FindWndPtr( hwnd );
504
Francis Beaudet1cc0a9a1999-09-03 15:00:45 +0000505 /* All MDI child windows have the WS_EX_MDICHILD style */
506 wnd->dwExStyle |= WS_EX_MDICHILD;
507
David Lassondef58d80d2000-06-15 01:03:32 +0000508 /* If we have more than 9 windows, we must insert the new one at the
509 * 9th position in order to see it in the "Windows" menu
510 */
511 if (ci->nActiveChildren > MDI_MOREWINDOWSLIMIT)
512 MDI_SwapMenuItems(wnd->parent, wnd->wIDmenu, ci->idFirstChild + MDI_MOREWINDOWSLIMIT - 1);
513
Alexandre Julliardd4719651995-12-12 18:49:11 +0000514 MDI_MenuModifyItem(w ,hwnd);
David Lassondef58d80d2000-06-15 01:03:32 +0000515
516 /* Have we hit the "More Windows..." limit? If so, we must
517 * add a "More Windows..." option
518 */
519 if (ci->nActiveChildren == MDI_MOREWINDOWSLIMIT + 1)
520 {
521 char szTmp[50];
522 LoadStringA(GetModuleHandleA("USER32"), MDI_IDS_MOREWINDOWS, szTmp, 50);
523
524 ModifyMenuA(ci->hWindowMenu,
525 ci->idFirstChild + MDI_MOREWINDOWSLIMIT,
526 MF_BYCOMMAND | MF_STRING,
527 ci->idFirstChild + MDI_MOREWINDOWSLIMIT,
528 szTmp);
529 }
530
Dmitry Timoshkov73968f02000-09-09 19:38:52 +0000531 if( (wnd->dwStyle & WS_MINIMIZE) && ci->hwndActiveChild )
532 {
533 TRACE("Minimizing created MDI child %04x\n", hwnd);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000534 ShowWindow( hwnd, SW_SHOWMINNOACTIVE );
Dmitry Timoshkov73968f02000-09-09 19:38:52 +0000535 }
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000536 else
Alexandre Julliard77b99181997-09-14 17:17:23 +0000537 {
Rein Klazes4f7abc01998-10-31 12:18:17 +0000538 /* WS_VISIBLE is clear if a) the MDI client has
539 * MDIS_ALLCHILDSTYLES style and 2) the flag is cleared in the
540 * MDICreateStruct. If so the created window is not shown nor
541 * activated.
542 */
Dmitry Timoshkov73968f02000-09-09 19:38:52 +0000543 if(wnd->dwStyle & WS_VISIBLE)
544 ShowWindow(hwnd, SW_SHOW);
Alexandre Julliard77b99181997-09-14 17:17:23 +0000545 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000546 WIN_ReleaseWndPtr(wnd);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000547 TRACE("created child - %04x\n",hwnd);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000548 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000549 else
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000550 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000551 ci->nActiveChildren--;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000552 DeleteMenu(ci->hWindowMenu,wIDmenu,MF_BYCOMMAND);
553 if( IsWindow(hwndMax) )
554 ShowWindow(hwndMax, SW_SHOWMAXIMIZED);
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000555 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000556
557 return hwnd;
558}
559
560/**********************************************************************
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000561 * MDI_ChildGetMinMaxInfo
Alexandre Julliard77b99181997-09-14 17:17:23 +0000562 *
563 * Note: The rule here is that client rect of the maximized MDI child
564 * is equal to the client rect of the MDI client window.
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000565 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000566static void MDI_ChildGetMinMaxInfo( WND* clientWnd, HWND hwnd,
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000567 MINMAXINFO16* lpMinMax )
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000568{
Alexandre Julliard77b99181997-09-14 17:17:23 +0000569 WND* childWnd = WIN_FindWndPtr(hwnd);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000570 RECT rect = clientWnd->rectClient;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000571
Alexandre Julliarda3960291999-02-26 11:11:13 +0000572 MapWindowPoints( clientWnd->parent->hwndSelf,
573 ((MDICLIENTINFO*)clientWnd->wExtra)->self, (LPPOINT)&rect, 2);
574 AdjustWindowRectEx( &rect, childWnd->dwStyle, 0, childWnd->dwExStyle );
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000575
Alexandre Julliard77b99181997-09-14 17:17:23 +0000576 lpMinMax->ptMaxSize.x = rect.right -= rect.left;
577 lpMinMax->ptMaxSize.y = rect.bottom -= rect.top;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000578
Alexandre Julliard77b99181997-09-14 17:17:23 +0000579 lpMinMax->ptMaxPosition.x = rect.left;
580 lpMinMax->ptMaxPosition.y = rect.top;
Alexandre Julliardac9c9b01996-07-28 18:50:11 +0000581
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000582 WIN_ReleaseWndPtr(childWnd);
583
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000584 TRACE("max rect (%i,%i - %i, %i)\n",
Alexandre Julliardac9c9b01996-07-28 18:50:11 +0000585 rect.left,rect.top,rect.right,rect.bottom);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000586
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000587}
588
589/**********************************************************************
Alexandre Julliardd4719651995-12-12 18:49:11 +0000590 * MDI_SwitchActiveChild
591 *
Alexandre Julliard77b99181997-09-14 17:17:23 +0000592 * Note: SetWindowPos sends WM_CHILDACTIVATE to the child window that is
593 * being activated
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000594 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000595static void MDI_SwitchActiveChild( HWND clientHwnd, HWND childHwnd,
596 BOOL bNextWindow )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000597{
Alexandre Julliardd4719651995-12-12 18:49:11 +0000598 WND *w = WIN_FindWndPtr(clientHwnd);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000599 HWND hwndTo = 0;
600 HWND hwndPrev = 0;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000601 MDICLIENTINFO *ci;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000602
Alexandre Julliard77b99181997-09-14 17:17:23 +0000603 hwndTo = MDI_GetWindow(w, childHwnd, bNextWindow, 0);
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000604
Alexandre Julliardd4719651995-12-12 18:49:11 +0000605 ci = (MDICLIENTINFO *) w->wExtra;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000606
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000607 TRACE("from %04x, to %04x\n",childHwnd,hwndTo);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000608
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000609 if ( !hwndTo ) goto END; /* no window to switch to */
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000610
Alexandre Julliardd4719651995-12-12 18:49:11 +0000611 hwndPrev = ci->hwndActiveChild;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000612
Alexandre Julliardd4719651995-12-12 18:49:11 +0000613 if ( hwndTo != hwndPrev )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000614 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000615 BOOL bOptimize = 0;
Alexandre Julliard77b99181997-09-14 17:17:23 +0000616
617 if( ci->hwndChildMaximized )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000618 {
Alexandre Julliard77b99181997-09-14 17:17:23 +0000619 bOptimize = 1;
620 w->dwStyle &= ~WS_VISIBLE;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000621 }
Alexandre Julliard77b99181997-09-14 17:17:23 +0000622
Alexandre Julliarda3960291999-02-26 11:11:13 +0000623 SetWindowPos( hwndTo, HWND_TOP, 0, 0, 0, 0,
Alexandre Julliard77b99181997-09-14 17:17:23 +0000624 SWP_NOMOVE | SWP_NOSIZE );
625
626 if( bNextWindow && hwndPrev )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000627 SetWindowPos( hwndPrev, HWND_BOTTOM, 0, 0, 0, 0,
Alexandre Julliard77b99181997-09-14 17:17:23 +0000628 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE );
629 if( bOptimize )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000630 ShowWindow( clientHwnd, SW_SHOW );
Alexandre Julliard77b99181997-09-14 17:17:23 +0000631 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000632END:
633 WIN_ReleaseWndPtr(w);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000634}
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000635
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000636
Alexandre Julliardd4719651995-12-12 18:49:11 +0000637/**********************************************************************
638 * MDIDestroyChild
639 */
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000640static LRESULT MDIDestroyChild( WND *w_parent, MDICLIENTINFO *ci,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000641 HWND parent, HWND child,
642 BOOL flagDestroy )
Alexandre Julliardd4719651995-12-12 18:49:11 +0000643{
644 WND *childPtr = WIN_FindWndPtr(child);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000645
Alexandre Julliardd4719651995-12-12 18:49:11 +0000646 if( childPtr )
647 {
648 if( child == ci->hwndActiveChild )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000649 {
650 MDI_SwitchActiveChild(parent, child, TRUE);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000651
652 if( child == ci->hwndActiveChild )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000653 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000654 ShowWindow( child, SW_HIDE);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000655 if( child == ci->hwndChildMaximized )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000656 {
Alexandre Julliard59730ae1996-03-24 16:20:51 +0000657 MDI_RestoreFrameMenu(w_parent->parent, child);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000658 ci->hwndChildMaximized = 0;
Alexandre Julliard59730ae1996-03-24 16:20:51 +0000659 MDI_UpdateFrameText(w_parent->parent,parent,TRUE,NULL);
Alexandre Julliard77b99181997-09-14 17:17:23 +0000660 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000661
Alexandre Julliard77b99181997-09-14 17:17:23 +0000662 MDI_ChildActivate(w_parent, 0);
663 }
Alexandre Julliarda1ce9162000-09-06 19:40:07 +0000664 }
665
666 MDI_MenuDeleteItem(w_parent, child);
Noomen Hamzaedd3d4a1999-07-20 15:03:28 +0000667
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000668 WIN_ReleaseWndPtr(childPtr);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000669
Alexandre Julliardd4719651995-12-12 18:49:11 +0000670 ci->nActiveChildren--;
671
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000672 TRACE("child destroyed - %04x\n",child);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000673
674 if (flagDestroy)
Alexandre Julliard77b99181997-09-14 17:17:23 +0000675 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000676 MDI_PostUpdate(GetParent(child), ci, SB_BOTH+1);
677 DestroyWindow(child);
Alexandre Julliard77b99181997-09-14 17:17:23 +0000678 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000679 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000680
681 return 0;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000682}
683
Alexandre Julliardd4719651995-12-12 18:49:11 +0000684
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000685/**********************************************************************
Alexandre Julliardd4719651995-12-12 18:49:11 +0000686 * MDI_ChildActivate
687 *
688 * Note: hWndChild is NULL when last child is being destroyed
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000689 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000690static LONG MDI_ChildActivate( WND *clientPtr, HWND hWndChild )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000691{
Alexandre Julliardd4719651995-12-12 18:49:11 +0000692 MDICLIENTINFO *clientInfo = (MDICLIENTINFO*)clientPtr->wExtra;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000693 HWND prevActiveWnd = clientInfo->hwndActiveChild;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000694 WND *wndPtr = WIN_FindWndPtr( hWndChild );
695 WND *wndPrev = WIN_FindWndPtr( prevActiveWnd );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000696 BOOL isActiveFrameWnd = 0;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000697 LONG retvalue;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000698
Alexandre Julliardd4719651995-12-12 18:49:11 +0000699 if( wndPtr )
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000700 {
701 if( wndPtr->dwStyle & WS_DISABLED )
702 {
703 retvalue = 0L;
704 goto END;
705 }
706 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000707
Francis Beaudet458719d1999-10-31 17:35:06 +0000708 /* Don't activate if it is already active. Might happen
709 since ShowWindow DOES activate MDI children */
710 if (clientInfo->hwndActiveChild == hWndChild)
711 {
712 retvalue = 0L;
713 goto END;
714 }
715
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000716 TRACE("%04x\n", hWndChild);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000717
Alexandre Julliarda3960291999-02-26 11:11:13 +0000718 if( GetActiveWindow() == clientPtr->parent->hwndSelf )
Alexandre Julliardd4719651995-12-12 18:49:11 +0000719 isActiveFrameWnd = TRUE;
720
721 /* deactivate prev. active child */
722 if( wndPrev )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000723 {
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000724 wndPrev->dwStyle |= WS_SYSMENU;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000725 SendMessageA( prevActiveWnd, WM_NCACTIVATE, FALSE, 0L );
726 SendMessageA( prevActiveWnd, WM_MDIACTIVATE, (WPARAM)prevActiveWnd,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000727 (LPARAM)hWndChild);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000728 /* uncheck menu item */
729 if( clientInfo->hWindowMenu )
David Lassondef58d80d2000-06-15 01:03:32 +0000730 {
731 WORD wPrevID = wndPrev->wIDmenu - clientInfo->idFirstChild;
732
733 if (wPrevID < MDI_MOREWINDOWSLIMIT)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000734 CheckMenuItem( clientInfo->hWindowMenu,
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000735 wndPrev->wIDmenu, 0);
David Lassondef58d80d2000-06-15 01:03:32 +0000736 else
737 CheckMenuItem( clientInfo->hWindowMenu,
738 clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT - 1, 0);
739 }
Alexandre Julliard77b99181997-09-14 17:17:23 +0000740 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000741
Alexandre Julliardd4719651995-12-12 18:49:11 +0000742 /* set appearance */
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000743 if( clientInfo->hwndChildMaximized )
Jesper Skov5c3e4571998-11-01 19:27:22 +0000744 {
Marcus Meissner03479f81999-01-28 10:06:38 +0000745 if( clientInfo->hwndChildMaximized != hWndChild ) {
746 if( hWndChild ) {
Alexandre Julliardd4719651995-12-12 18:49:11 +0000747 clientInfo->hwndActiveChild = hWndChild;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000748 ShowWindow( hWndChild, SW_SHOWMAXIMIZED);
Marcus Meissner03479f81999-01-28 10:06:38 +0000749 } else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000750 ShowWindow( clientInfo->hwndActiveChild, SW_SHOWNORMAL );
Marcus Meissner03479f81999-01-28 10:06:38 +0000751 }
Jesper Skov5c3e4571998-11-01 19:27:22 +0000752 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000753
Alexandre Julliardd4719651995-12-12 18:49:11 +0000754 clientInfo->hwndActiveChild = hWndChild;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000755
Alexandre Julliardd4719651995-12-12 18:49:11 +0000756 /* check if we have any children left */
757 if( !hWndChild )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000758 {
759 if( isActiveFrameWnd )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000760 SetFocus( clientInfo->self );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000761 retvalue = 0;
762 goto END;
Alexandre Julliard77b99181997-09-14 17:17:23 +0000763 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000764
Alexandre Julliardd4719651995-12-12 18:49:11 +0000765 /* check menu item */
766 if( clientInfo->hWindowMenu )
David Lassondef58d80d2000-06-15 01:03:32 +0000767 {
768 /* The window to be activated must be displayed in the "Windows" menu */
769 if (wndPtr->wIDmenu >= clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT)
770 {
771 MDI_SwapMenuItems(wndPtr->parent, wndPtr->wIDmenu, clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT - 1);
772 MDI_MenuModifyItem(wndPtr->parent ,wndPtr->hwndSelf);
773 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000774
David Lassondef58d80d2000-06-15 01:03:32 +0000775 CheckMenuItem(clientInfo->hWindowMenu, wndPtr->wIDmenu, MF_CHECKED);
776 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000777 /* bring active child to the top */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000778 SetWindowPos( hWndChild, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000779
780 if( isActiveFrameWnd )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000781 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000782 SendMessageA( hWndChild, WM_NCACTIVATE, TRUE, 0L);
783 if( GetFocus() == clientInfo->self )
784 SendMessageA( clientInfo->self, WM_SETFOCUS,
785 (WPARAM)clientInfo->self, 0L );
Alexandre Julliardd4719651995-12-12 18:49:11 +0000786 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000787 SetFocus( clientInfo->self );
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000788 }
Alexandre Julliarda3960291999-02-26 11:11:13 +0000789 SendMessageA( hWndChild, WM_MDIACTIVATE, (WPARAM)prevActiveWnd,
Alexandre Julliard491502b1997-11-01 19:08:16 +0000790 (LPARAM)hWndChild );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000791 retvalue = 1;
792END:
793 WIN_ReleaseWndPtr(wndPtr);
794 WIN_ReleaseWndPtr(wndPrev);
Veksler Michael3130fce1999-03-22 12:37:09 +0000795 return retvalue;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000796}
797
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000798/* -------------------- MDI client window functions ------------------- */
799
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000800/**********************************************************************
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000801 * CreateMDIMenuBitmap
802 */
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000803static HBITMAP16 CreateMDIMenuBitmap(void)
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000804{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000805 HDC hDCSrc = CreateCompatibleDC(0);
806 HDC hDCDest = CreateCompatibleDC(hDCSrc);
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000807 HBITMAP16 hbClose = LoadBitmap16(0, MAKEINTRESOURCE16(OBM_CLOSE) );
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000808 HBITMAP16 hbCopy;
809 HANDLE16 hobjSrc, hobjDest;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000810
Alexandre Julliarda3960291999-02-26 11:11:13 +0000811 hobjSrc = SelectObject(hDCSrc, hbClose);
Marcus Meissnerddca3151999-05-22 11:33:23 +0000812 hbCopy = CreateCompatibleBitmap(hDCSrc,GetSystemMetrics(SM_CXSIZE),GetSystemMetrics(SM_CYSIZE));
Alexandre Julliarda3960291999-02-26 11:11:13 +0000813 hobjDest = SelectObject(hDCDest, hbCopy);
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000814
Marcus Meissnerddca3151999-05-22 11:33:23 +0000815 BitBlt(hDCDest, 0, 0, GetSystemMetrics(SM_CXSIZE), GetSystemMetrics(SM_CYSIZE),
816 hDCSrc, GetSystemMetrics(SM_CXSIZE), 0, SRCCOPY);
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000817
Alexandre Julliarda3960291999-02-26 11:11:13 +0000818 SelectObject(hDCSrc, hobjSrc);
819 DeleteObject(hbClose);
820 DeleteDC(hDCSrc);
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000821
Alexandre Julliarda3960291999-02-26 11:11:13 +0000822 hobjSrc = SelectObject( hDCDest, GetStockObject(BLACK_PEN) );
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000823
Marcus Meissnerddca3151999-05-22 11:33:23 +0000824 MoveToEx( hDCDest, GetSystemMetrics(SM_CXSIZE) - 1, 0, NULL );
825 LineTo( hDCDest, GetSystemMetrics(SM_CXSIZE) - 1, GetSystemMetrics(SM_CYSIZE) - 1);
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000826
Alexandre Julliarda3960291999-02-26 11:11:13 +0000827 SelectObject(hDCDest, hobjSrc );
828 SelectObject(hDCDest, hobjDest);
829 DeleteDC(hDCDest);
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000830
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000831 return hbCopy;
832}
833
834/**********************************************************************
835 * MDICascade
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000836 */
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000837static LONG MDICascade(WND* clientWnd, MDICLIENTINFO *ci)
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000838{
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000839 WND** ppWnd;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000840 UINT total;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000841
842 if (ci->hwndChildMaximized)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000843 SendMessageA( clientWnd->hwndSelf, WM_MDIRESTORE,
844 (WPARAM)ci->hwndChildMaximized, 0);
Alexandre Julliard58199531994-04-21 01:20:00 +0000845
Alexandre Julliardd4719651995-12-12 18:49:11 +0000846 if (ci->nActiveChildren == 0) return 0;
Alexandre Julliard7cbe6571995-01-09 18:21:16 +0000847
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000848 if ((ppWnd = WIN_BuildWinArray(clientWnd, BWA_SKIPHIDDEN | BWA_SKIPOWNED |
849 BWA_SKIPICONIC, &total)))
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000850 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000851 WND** heapPtr = ppWnd;
852 if( total )
853 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000854 INT delta = 0, n = 0;
855 POINT pos[2];
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000856 if( total < ci->nActiveChildren )
Marcus Meissnerddca3151999-05-22 11:33:23 +0000857 delta = GetSystemMetrics(SM_CYICONSPACING) +
858 GetSystemMetrics(SM_CYICON);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000859
Alexandre Julliard829fe321998-07-26 14:27:39 +0000860 /* walk the list (backwards) and move windows */
861 while (*ppWnd) ppWnd++;
862 while (ppWnd != heapPtr)
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000863 {
Alexandre Julliard829fe321998-07-26 14:27:39 +0000864 ppWnd--;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000865 TRACE("move %04x to (%ld,%ld) size [%ld,%ld]\n",
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000866 (*ppWnd)->hwndSelf, pos[0].x, pos[0].y, pos[1].x, pos[1].y);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000867
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000868 MDI_CalcDefaultChildPos(clientWnd, n++, pos, delta);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000869 SetWindowPos( (*ppWnd)->hwndSelf, 0, pos[0].x, pos[0].y,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000870 pos[1].x, pos[1].y,
871 SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER);
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000872 }
873 }
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +0000874 WIN_ReleaseWinArray(heapPtr);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000875 }
876
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000877 if( total < ci->nActiveChildren )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000878 ArrangeIconicWindows( clientWnd->hwndSelf );
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000879 return 0;
880}
881
882/**********************************************************************
Alexandre Julliard58199531994-04-21 01:20:00 +0000883 * MDITile
884 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000885static void MDITile( WND* wndClient, MDICLIENTINFO *ci, WPARAM wParam )
Alexandre Julliard58199531994-04-21 01:20:00 +0000886{
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000887 WND** ppWnd;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000888 UINT total = 0;
Alexandre Julliard58199531994-04-21 01:20:00 +0000889
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000890 if (ci->hwndChildMaximized)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000891 SendMessageA( wndClient->hwndSelf, WM_MDIRESTORE,
892 (WPARAM)ci->hwndChildMaximized, 0);
Alexandre Julliard58199531994-04-21 01:20:00 +0000893
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000894 if (ci->nActiveChildren == 0) return;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000895
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000896 ppWnd = WIN_BuildWinArray(wndClient, BWA_SKIPHIDDEN | BWA_SKIPOWNED | BWA_SKIPICONIC |
897 ((wParam & MDITILE_SKIPDISABLED)? BWA_SKIPDISABLED : 0), &total );
Alexandre Julliardd4719651995-12-12 18:49:11 +0000898
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000899 TRACE("%u windows to tile\n", total);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000900
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000901 if( ppWnd )
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000902 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000903 WND** heapPtr = ppWnd;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000904
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000905 if( total )
906 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000907 RECT rect;
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000908 int x, y, xsize, ysize;
909 int rows, columns, r, c, i;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000910
Noomen Hamzafe0a5e81999-06-12 08:08:35 +0000911 GetClientRect(wndClient->hwndSelf,&rect);
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000912 rows = (int) sqrt((double)total);
913 columns = total / rows;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000914
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000915 if( wParam & MDITILE_HORIZONTAL ) /* version >= 3.1 */
916 {
917 i = rows;
918 rows = columns; /* exchange r and c */
919 columns = i;
920 }
921
922 if( total != ci->nActiveChildren)
923 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000924 y = rect.bottom - 2 * GetSystemMetrics(SM_CYICONSPACING) - GetSystemMetrics(SM_CYICON);
925 rect.bottom = ( y - GetSystemMetrics(SM_CYICON) < rect.top )? rect.bottom: y;
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000926 }
927
928 ysize = rect.bottom / rows;
929 xsize = rect.right / columns;
Alexandre Julliard58199531994-04-21 01:20:00 +0000930
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000931 for (x = i = 0, c = 1; c <= columns && *ppWnd; c++)
932 {
933 if (c == columns)
934 {
935 rows = total - i;
936 ysize = rect.bottom / rows;
937 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000938
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000939 y = 0;
940 for (r = 1; r <= rows && *ppWnd; r++, i++)
941 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000942 SetWindowPos((*ppWnd)->hwndSelf, 0, x, y, xsize, ysize,
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000943 SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER);
944 y += ysize;
945 ppWnd++;
946 }
947 x += xsize;
948 }
949 }
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +0000950 WIN_ReleaseWinArray(heapPtr);
Alexandre Julliard58199531994-04-21 01:20:00 +0000951 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000952
Alexandre Julliarda3960291999-02-26 11:11:13 +0000953 if( total < ci->nActiveChildren ) ArrangeIconicWindows( wndClient->hwndSelf );
Alexandre Julliard58199531994-04-21 01:20:00 +0000954}
955
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000956/* ----------------------- Frame window ---------------------------- */
957
958
959/**********************************************************************
960 * MDI_AugmentFrameMenu
961 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000962static BOOL MDI_AugmentFrameMenu( MDICLIENTINFO* ci, WND *frame,
963 HWND hChild )
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000964{
Alexandre Julliard77b99181997-09-14 17:17:23 +0000965 WND* child = WIN_FindWndPtr(hChild);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000966 HMENU hSysPopup = 0;
Abey George967ec701999-06-26 11:44:18 +0000967 HBITMAP hSysMenuBitmap = 0;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000968
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000969 TRACE("frame %p,child %04x\n",frame,hChild);
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000970
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000971 if( !frame->wIDmenu || !child->hSysMenu )
972 {
973 WIN_ReleaseWndPtr(child);
974 return 0;
975 }
976 WIN_ReleaseWndPtr(child);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000977
Alexandre Julliard77b99181997-09-14 17:17:23 +0000978 /* create a copy of sysmenu popup and insert it into frame menu bar */
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000979
Bertho Stultiensd1895a71999-04-25 18:31:35 +0000980 if (!(hSysPopup = LoadMenuA(GetModuleHandleA("USER32"), "SYSMENU")))
Alexandre Julliard77b99181997-09-14 17:17:23 +0000981 return 0;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000982
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000983 TRACE("\tgot popup %04x in sysmenu %04x\n",
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000984 hSysPopup, child->hSysMenu);
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000985
Alexandre Julliarda3960291999-02-26 11:11:13 +0000986 AppendMenuA(frame->wIDmenu,MF_HELP | MF_BITMAP,
Juergen Schmied78513941999-04-18 14:40:32 +0000987 SC_MINIMIZE, (LPSTR)(DWORD)HBMMENU_MBAR_MINIMIZE ) ;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000988 AppendMenuA(frame->wIDmenu,MF_HELP | MF_BITMAP,
Juergen Schmied78513941999-04-18 14:40:32 +0000989 SC_RESTORE, (LPSTR)(DWORD)HBMMENU_MBAR_RESTORE );
Francois Boisvert197a8e11999-02-13 09:10:17 +0000990
Abey George967ec701999-06-26 11:44:18 +0000991 /* In Win 95 look, the system menu is replaced by the child icon */
992
993 if(TWEAK_WineLook > WIN31_LOOK)
994 {
995 HICON hIcon = GetClassLongA(hChild, GCL_HICONSM);
996 if (!hIcon)
997 hIcon = GetClassLongA(hChild, GCL_HICON);
998 if (hIcon)
999 {
1000 HDC hMemDC;
1001 HBITMAP hBitmap, hOldBitmap;
1002 HBRUSH hBrush;
1003 HDC hdc = GetDC(hChild);
1004
1005 if (hdc)
1006 {
1007 int cx, cy;
1008 cx = GetSystemMetrics(SM_CXSMICON);
1009 cy = GetSystemMetrics(SM_CYSMICON);
1010 hMemDC = CreateCompatibleDC(hdc);
1011 hBitmap = CreateCompatibleBitmap(hdc, cx, cy);
1012 hOldBitmap = SelectObject(hMemDC, hBitmap);
1013 SetMapMode(hMemDC, MM_TEXT);
1014 hBrush = CreateSolidBrush(GetSysColor(COLOR_MENU));
1015 DrawIconEx(hMemDC, 0, 0, hIcon, cx, cy, 0, hBrush, DI_NORMAL);
1016 SelectObject (hMemDC, hOldBitmap);
1017 DeleteObject(hBrush);
1018 DeleteDC(hMemDC);
1019 ReleaseDC(hChild, hdc);
1020 hSysMenuBitmap = hBitmap;
1021 }
1022 }
1023 }
1024 else
1025 hSysMenuBitmap = hBmpClose;
1026
Alexandre Julliarda3960291999-02-26 11:11:13 +00001027 if( !InsertMenuA(frame->wIDmenu,0,MF_BYPOSITION | MF_BITMAP | MF_POPUP,
Abey George967ec701999-06-26 11:44:18 +00001028 hSysPopup, (LPSTR)(DWORD)hSysMenuBitmap))
Alexandre Julliard77b99181997-09-14 17:17:23 +00001029 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001030 TRACE("not inserted\n");
Alexandre Julliarda3960291999-02-26 11:11:13 +00001031 DestroyMenu(hSysPopup);
Alexandre Julliard77b99181997-09-14 17:17:23 +00001032 return 0;
1033 }
Huw D M Daviesbc1d1df1999-02-14 09:20:01 +00001034
Patrik Stridvall0f8bc5b1999-04-22 16:27:50 +00001035 /* The close button is only present in Win 95 look */
Huw D M Daviesbc1d1df1999-02-14 09:20:01 +00001036 if(TWEAK_WineLook > WIN31_LOOK)
1037 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001038 AppendMenuA(frame->wIDmenu,MF_HELP | MF_BITMAP,
Juergen Schmied78513941999-04-18 14:40:32 +00001039 SC_CLOSE, (LPSTR)(DWORD)HBMMENU_MBAR_CLOSE );
Huw D M Daviesbc1d1df1999-02-14 09:20:01 +00001040 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001041
Alexandre Julliarda3960291999-02-26 11:11:13 +00001042 EnableMenuItem(hSysPopup, SC_SIZE, MF_BYCOMMAND | MF_GRAYED);
1043 EnableMenuItem(hSysPopup, SC_MOVE, MF_BYCOMMAND | MF_GRAYED);
1044 EnableMenuItem(hSysPopup, SC_MAXIMIZE, MF_BYCOMMAND | MF_GRAYED);
Juergen Schmied90905021999-05-17 15:05:08 +00001045 SetMenuDefaultItem(hSysPopup, SC_CLOSE, FALSE);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001046
Alexandre Julliard77b99181997-09-14 17:17:23 +00001047 /* redraw menu */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001048 DrawMenuBar(frame->hwndSelf);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001049
Alexandre Julliard77b99181997-09-14 17:17:23 +00001050 return 1;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001051}
1052
1053/**********************************************************************
1054 * MDI_RestoreFrameMenu
1055 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001056static BOOL MDI_RestoreFrameMenu( WND *frameWnd, HWND hChild )
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001057{
Francis Beaudet4691d0c1999-07-30 18:02:04 +00001058 MENUITEMINFOA menuInfo;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001059 INT nItems = GetMenuItemCount(frameWnd->wIDmenu) - 1;
1060 UINT iId = GetMenuItemID(frameWnd->wIDmenu,nItems) ;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001061
Gerard Patele8a3d072000-01-23 03:19:44 +00001062 TRACE("frameWnd %p,(%04x),child %04x,nIt=%d,iId=%d\n",
1063 frameWnd,frameWnd->hwndSelf,hChild,nItems,iId);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001064
Francois Boisvert197a8e11999-02-13 09:10:17 +00001065 if(!(iId == SC_RESTORE || iId == SC_CLOSE) )
Alexandre Julliard77b99181997-09-14 17:17:23 +00001066 return 0;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001067
Francis Beaudet4691d0c1999-07-30 18:02:04 +00001068 /*
1069 * Remove the system menu, If that menu is the icon of the window
1070 * as it is in win95, we have to delete the bitmap.
1071 */
1072 menuInfo.cbSize = sizeof(MENUITEMINFOA);
1073 menuInfo.fMask = MIIM_DATA | MIIM_TYPE;
1074
1075 GetMenuItemInfoA(frameWnd->wIDmenu,
1076 0,
1077 TRUE,
1078 &menuInfo);
1079
Alexandre Julliarda3960291999-02-26 11:11:13 +00001080 RemoveMenu(frameWnd->wIDmenu,0,MF_BYPOSITION);
Huw D M Daviesbc1d1df1999-02-14 09:20:01 +00001081
Francis Beaudet4691d0c1999-07-30 18:02:04 +00001082 if ( (menuInfo.fType & MFT_BITMAP) &&
1083 (LOWORD(menuInfo.dwTypeData)!=0) &&
1084 (LOWORD(menuInfo.dwTypeData)!=hBmpClose) )
1085 {
1086 DeleteObject((HBITMAP)LOWORD(menuInfo.dwTypeData));
1087 }
1088
Francois Boisvert197a8e11999-02-13 09:10:17 +00001089 if(TWEAK_WineLook > WIN31_LOOK)
1090 {
Patrik Stridvall0f8bc5b1999-04-22 16:27:50 +00001091 /* close */
1092 DeleteMenu(frameWnd->wIDmenu,GetMenuItemCount(frameWnd->wIDmenu) - 1,MF_BYPOSITION);
Francois Boisvert197a8e11999-02-13 09:10:17 +00001093 }
Patrik Stridvall0f8bc5b1999-04-22 16:27:50 +00001094 /* restore */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001095 DeleteMenu(frameWnd->wIDmenu,GetMenuItemCount(frameWnd->wIDmenu) - 1,MF_BYPOSITION);
Patrik Stridvall0f8bc5b1999-04-22 16:27:50 +00001096 /* minimize */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001097 DeleteMenu(frameWnd->wIDmenu,GetMenuItemCount(frameWnd->wIDmenu) - 1,MF_BYPOSITION);
Francois Boisvert47e2b851999-02-09 14:11:19 +00001098
Alexandre Julliarda3960291999-02-26 11:11:13 +00001099 DrawMenuBar(frameWnd->hwndSelf);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001100
Alexandre Julliard77b99181997-09-14 17:17:23 +00001101 return 1;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001102}
1103
Francois Boisvert197a8e11999-02-13 09:10:17 +00001104
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001105/**********************************************************************
1106 * MDI_UpdateFrameText
1107 *
1108 * used when child window is maximized/restored
1109 *
1110 * Note: lpTitle can be NULL
1111 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001112static void MDI_UpdateFrameText( WND *frameWnd, HWND hClient,
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001113 BOOL repaint, LPCWSTR lpTitle )
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001114{
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001115 WCHAR lpBuffer[MDI_MAXTITLELENGTH+1];
Alexandre Julliard77b99181997-09-14 17:17:23 +00001116 WND* clientWnd = WIN_FindWndPtr(hClient);
1117 MDICLIENTINFO *ci = (MDICLIENTINFO *) clientWnd->wExtra;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001118
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001119 TRACE("repaint %i, frameText %s\n", repaint, (lpTitle)?debugstr_w(lpTitle):"NULL");
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001120
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001121 if (!clientWnd)
1122 return;
1123
1124 if (!ci)
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +00001125 {
1126 WIN_ReleaseWndPtr(clientWnd);
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001127 return;
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +00001128 }
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001129
Alexandre Julliard77b99181997-09-14 17:17:23 +00001130 /* store new "default" title if lpTitle is not NULL */
1131 if (lpTitle)
1132 {
1133 if (ci->frameTitle) HeapFree( SystemHeap, 0, ci->frameTitle );
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001134 ci->frameTitle = HEAP_strdupW( SystemHeap, 0, lpTitle );
Alexandre Julliard77b99181997-09-14 17:17:23 +00001135 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001136
Alexandre Julliard77b99181997-09-14 17:17:23 +00001137 if (ci->frameTitle)
1138 {
1139 WND* childWnd = WIN_FindWndPtr( ci->hwndChildMaximized );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001140
Alexandre Julliard77b99181997-09-14 17:17:23 +00001141 if( childWnd && childWnd->text )
1142 {
1143 /* combine frame title and child title if possible */
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001144
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001145 static const WCHAR lpBracket[] = {' ','-',' ','[',0};
1146 static const WCHAR lpBracket2[] = {']',0};
Alexandre Julliardc7e7df82000-08-14 14:41:19 +00001147 int i_frame_text_length = strlenW(ci->frameTitle);
1148 int i_child_text_length = strlenW(childWnd->text);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001149
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001150 lstrcpynW( lpBuffer, ci->frameTitle, MDI_MAXTITLELENGTH);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001151
Alexandre Julliard77b99181997-09-14 17:17:23 +00001152 if( i_frame_text_length + 6 < MDI_MAXTITLELENGTH )
1153 {
Alexandre Julliardc7e7df82000-08-14 14:41:19 +00001154 strcatW( lpBuffer, lpBracket );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001155
Alexandre Julliard77b99181997-09-14 17:17:23 +00001156 if( i_frame_text_length + i_child_text_length + 6 < MDI_MAXTITLELENGTH )
1157 {
Alexandre Julliardc7e7df82000-08-14 14:41:19 +00001158 strcatW( lpBuffer, childWnd->text );
1159 strcatW( lpBuffer, lpBracket2 );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001160 }
Alexandre Julliard77b99181997-09-14 17:17:23 +00001161 else
1162 {
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001163 lstrcpynW( lpBuffer + i_frame_text_length + 4,
Alexandre Julliard77b99181997-09-14 17:17:23 +00001164 childWnd->text, MDI_MAXTITLELENGTH - i_frame_text_length - 5 );
Alexandre Julliardc7e7df82000-08-14 14:41:19 +00001165 strcatW( lpBuffer, lpBracket2 );
Alexandre Julliard77b99181997-09-14 17:17:23 +00001166 }
1167 }
1168 }
1169 else
1170 {
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001171 lstrcpynW(lpBuffer, ci->frameTitle, MDI_MAXTITLELENGTH+1 );
Alexandre Julliard77b99181997-09-14 17:17:23 +00001172 }
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +00001173 WIN_ReleaseWndPtr(childWnd);
1174
Alexandre Julliard77b99181997-09-14 17:17:23 +00001175 }
1176 else
1177 lpBuffer[0] = '\0';
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001178
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001179 DEFWND_SetTextW( frameWnd, lpBuffer );
Alexandre Julliard77b99181997-09-14 17:17:23 +00001180 if( repaint == MDI_REPAINTFRAME)
Alexandre Julliarda3960291999-02-26 11:11:13 +00001181 SetWindowPos( frameWnd->hwndSelf, 0,0,0,0,0, SWP_FRAMECHANGED |
Alexandre Julliard77b99181997-09-14 17:17:23 +00001182 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER );
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +00001183
1184 WIN_ReleaseWndPtr(clientWnd);
1185
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001186}
1187
1188
1189/* ----------------------------- Interface ---------------------------- */
1190
1191
Alexandre Julliard58199531994-04-21 01:20:00 +00001192/**********************************************************************
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001193 * MDIClientWndProc
1194 *
Alexandre Julliard77b99181997-09-14 17:17:23 +00001195 * This function handles all MDI requests.
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001196 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001197LRESULT WINAPI MDIClientWndProc( HWND hwnd, UINT message, WPARAM wParam,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001198 LPARAM lParam )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001199{
Eric Pouechfa9724f1999-07-23 19:21:56 +00001200 LPCREATESTRUCTA cs;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001201 MDICLIENTINFO *ci;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001202 RECT rect;
Eric Pouechfa9724f1999-07-23 19:21:56 +00001203 WND *w, *frameWnd;
1204 INT nItems;
1205 LRESULT retvalue;
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001206
Eric Pouechfa9724f1999-07-23 19:21:56 +00001207 if ( ( w = WIN_FindWndPtr(hwnd) ) == NULL )
1208 return 0;
1209
1210 if ( ( frameWnd = WIN_LockWndPtr(w->parent) ) == NULL ) {
1211 WIN_ReleaseWndPtr(w);
1212 return 0;
1213 }
1214
1215 ci = (MDICLIENTINFO *) w->wExtra;
1216
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001217 switch (message)
1218 {
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001219 case WM_CREATE:
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001220
Alexandre Julliarda3960291999-02-26 11:11:13 +00001221 cs = (LPCREATESTRUCTA)lParam;
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001222
1223 /* Translation layer doesn't know what's in the cs->lpCreateParams
1224 * so we have to keep track of what environment we're in. */
1225
1226 if( w->flags & WIN_ISWIN32 )
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001227 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001228#define ccs ((LPCLIENTCREATESTRUCT)cs->lpCreateParams)
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001229 ci->hWindowMenu = ccs->hWindowMenu;
1230 ci->idFirstChild = ccs->idFirstChild;
1231#undef ccs
1232 }
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001233 else
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001234 {
1235 LPCLIENTCREATESTRUCT16 ccs = (LPCLIENTCREATESTRUCT16)
1236 PTR_SEG_TO_LIN(cs->lpCreateParams);
1237 ci->hWindowMenu = ccs->hWindowMenu;
1238 ci->idFirstChild = ccs->idFirstChild;
1239 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001240
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001241 ci->hwndChildMaximized = 0;
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +00001242 ci->nActiveChildren = 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001243 ci->nTotalCreated = 0;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001244 ci->frameTitle = NULL;
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001245 ci->mdiFlags = 0;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001246 ci->self = hwnd;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001247 w->dwStyle |= WS_CLIPCHILDREN;
1248
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001249 if (!hBmpClose)
1250 {
1251 hBmpClose = CreateMDIMenuBitmap();
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001252 hBmpRestore = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORE) );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001253 }
1254 MDI_UpdateFrameText(frameWnd, hwnd, MDI_NOFRAMEREPAINT,frameWnd->text);
Alexandre Julliardd4719651995-12-12 18:49:11 +00001255
Matthew Clinec448c5c2000-02-13 15:05:07 +00001256 if (ci->hWindowMenu != 0)
1257 AppendMenuA( ci->hWindowMenu, MF_SEPARATOR, 0, NULL );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001258
Alexandre Julliarda3960291999-02-26 11:11:13 +00001259 GetClientRect(frameWnd->hwndSelf, &rect);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001260 NC_HandleNCCalcSize( w, &rect );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001261 w->rectClient = rect;
1262
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001263 TRACE("Client created - hwnd = %04x, idFirst = %u\n",
Alexandre Julliard77b99181997-09-14 17:17:23 +00001264 hwnd, ci->idFirstChild );
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +00001265
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001266 retvalue = 0;
1267 goto END;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001268
1269 case WM_DESTROY:
Gerard Patele8a3d072000-01-23 03:19:44 +00001270 if( ci->hwndChildMaximized )
1271 MDI_RestoreFrameMenu(w->parent, ci->hwndChildMaximized);
Matthew Clinec448c5c2000-02-13 15:05:07 +00001272 if((ci->hWindowMenu != 0) &&
1273 (nItems = GetMenuItemCount(ci->hWindowMenu)) > 0)
Alexandre Julliard77b99181997-09-14 17:17:23 +00001274 {
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001275 ci->idFirstChild = nItems - 1;
1276 ci->nActiveChildren++; /* to delete a separator */
1277 while( ci->nActiveChildren-- )
Alexandre Julliarda3960291999-02-26 11:11:13 +00001278 DeleteMenu(ci->hWindowMenu,MF_BYPOSITION,ci->idFirstChild--);
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001279 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001280 retvalue = 0;
1281 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001282
1283 case WM_MDIACTIVATE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001284 if( ci->hwndActiveChild != (HWND)wParam )
1285 SetWindowPos((HWND)wParam, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001286 retvalue = 0;
1287 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001288
1289 case WM_MDICASCADE:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001290 retvalue = MDICascade(w, ci);
1291 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001292
1293 case WM_MDICREATE:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001294 if (lParam) retvalue = MDICreateChild( w, ci, hwnd,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001295 (MDICREATESTRUCTA*)lParam );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001296 else retvalue = 0;
1297 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001298
1299 case WM_MDIDESTROY:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001300 retvalue = MDIDestroyChild( w, ci, hwnd, (HWND)wParam, TRUE );
1301 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001302
1303 case WM_MDIGETACTIVE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001304 if (lParam) *(BOOL *)lParam = (ci->hwndChildMaximized > 0);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001305 retvalue = ci->hwndActiveChild;
1306 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001307
1308 case WM_MDIICONARRANGE:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001309 ci->mdiFlags |= MDIF_NEEDUPDATE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001310 ArrangeIconicWindows(hwnd);
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00001311 ci->sbRecalc = SB_BOTH+1;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001312 SendMessageA(hwnd, WM_MDICALCCHILDSCROLL, 0, 0L);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001313 retvalue = 0;
1314 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001315
1316 case WM_MDIMAXIMIZE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001317 ShowWindow( (HWND)wParam, SW_MAXIMIZE );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001318 retvalue = 0;
1319 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001320
Alexandre Julliard77b99181997-09-14 17:17:23 +00001321 case WM_MDINEXT: /* lParam != 0 means previous window */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001322 MDI_SwitchActiveChild(hwnd, (HWND)wParam, (lParam)? FALSE : TRUE );
Alexandre Julliard58199531994-04-21 01:20:00 +00001323 break;
1324
1325 case WM_MDIRESTORE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001326 SendMessageA( (HWND)wParam, WM_SYSCOMMAND, SC_RESTORE, 0);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001327 retvalue = 0;
1328 goto END;
Alexandre Julliard58199531994-04-21 01:20:00 +00001329
1330 case WM_MDISETMENU:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001331 retvalue = MDISetMenu( hwnd, (HMENU)wParam, (HMENU)lParam );
1332 goto END;
Alexandre Julliard85ed45e1998-08-22 19:03:56 +00001333 case WM_MDIREFRESHMENU:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001334 retvalue = MDIRefreshMenu( hwnd, (HMENU)wParam, (HMENU)lParam );
1335 goto END;
Alexandre Julliard85ed45e1998-08-22 19:03:56 +00001336
Alexandre Julliard58199531994-04-21 01:20:00 +00001337 case WM_MDITILE:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001338 ci->mdiFlags |= MDIF_NEEDUPDATE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001339 ShowScrollBar(hwnd,SB_BOTH,FALSE);
Alexandre Julliard77b99181997-09-14 17:17:23 +00001340 MDITile(w, ci, wParam);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001341 ci->mdiFlags &= ~MDIF_NEEDUPDATE;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001342 retvalue = 0;
1343 goto END;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001344
1345 case WM_VSCROLL:
1346 case WM_HSCROLL:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001347 ci->mdiFlags |= MDIF_NEEDUPDATE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001348 ScrollChildren(hwnd, message, wParam, lParam);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001349 ci->mdiFlags &= ~MDIF_NEEDUPDATE;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001350 retvalue = 0;
1351 goto END;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001352
1353 case WM_SETFOCUS:
1354 if( ci->hwndActiveChild )
Alexandre Julliard77b99181997-09-14 17:17:23 +00001355 {
Eric Pouech8dde5a41999-04-25 10:58:04 +00001356 WND* pw = WIN_FindWndPtr( ci->hwndActiveChild );
1357 if( !(pw->dwStyle & WS_MINIMIZE) )
Alexandre Julliarda3960291999-02-26 11:11:13 +00001358 SetFocus( ci->hwndActiveChild );
Eric Pouech8dde5a41999-04-25 10:58:04 +00001359 WIN_ReleaseWndPtr(pw);
Alexandre Julliard77b99181997-09-14 17:17:23 +00001360 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001361 retvalue = 0;
1362 goto END;
Alexandre Julliard58199531994-04-21 01:20:00 +00001363
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001364 case WM_NCACTIVATE:
Alexandre Julliardd4719651995-12-12 18:49:11 +00001365 if( ci->hwndActiveChild )
Alexandre Julliarda3960291999-02-26 11:11:13 +00001366 SendMessageA(ci->hwndActiveChild, message, wParam, lParam);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001367 break;
1368
1369 case WM_PARENTNOTIFY:
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001370 if (LOWORD(wParam) == WM_LBUTTONDOWN)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001371 {
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001372 HWND child;
1373 POINT pt;
1374 pt.x = SLOWORD(lParam);
1375 pt.y = SHIWORD(lParam);
1376 child = ChildWindowFromPoint(hwnd, pt);
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001377
Alexandre Julliard83f52d12000-09-26 22:20:14 +00001378 TRACE("notification from %04x (%li,%li)\n",child,pt.x,pt.y);
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001379
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001380 if( child && child != hwnd && child != ci->hwndActiveChild )
Alexandre Julliarda3960291999-02-26 11:11:13 +00001381 SetWindowPos(child, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001382 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001383 retvalue = 0;
1384 goto END;
Alexandre Julliard58199531994-04-21 01:20:00 +00001385
1386 case WM_SIZE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001387 if( IsWindow(ci->hwndChildMaximized) )
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001388 {
1389 WND* child = WIN_FindWndPtr(ci->hwndChildMaximized);
Patrik Stridvall0f8bc5b1999-04-22 16:27:50 +00001390 RECT rect;
1391
1392 rect.left = 0;
1393 rect.top = 0;
1394 rect.right = LOWORD(lParam);
1395 rect.bottom = HIWORD(lParam);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001396
Alexandre Julliarda3960291999-02-26 11:11:13 +00001397 AdjustWindowRectEx(&rect, child->dwStyle, 0, child->dwExStyle);
1398 MoveWindow(ci->hwndChildMaximized, rect.left, rect.top,
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001399 rect.right - rect.left, rect.bottom - rect.top, 1);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001400 WIN_ReleaseWndPtr(child);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001401 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001402 else
Alexandre Julliard77b99181997-09-14 17:17:23 +00001403 MDI_PostUpdate(hwnd, ci, SB_BOTH+1);
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00001404
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001405 break;
1406
Alexandre Julliardd4719651995-12-12 18:49:11 +00001407 case WM_MDICALCCHILDSCROLL:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001408 if( (ci->mdiFlags & MDIF_NEEDUPDATE) && ci->sbRecalc )
1409 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001410 CalcChildScroll16(hwnd, ci->sbRecalc-1);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001411 ci->sbRecalc = 0;
1412 ci->mdiFlags &= ~MDIF_NEEDUPDATE;
1413 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001414 retvalue = 0;
1415 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001416 }
1417
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001418 retvalue = DefWindowProcA( hwnd, message, wParam, lParam );
1419END:
1420 WIN_ReleaseWndPtr(w);
1421 WIN_ReleaseWndPtr(frameWnd);
1422 return retvalue;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001423}
1424
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001425
1426/***********************************************************************
1427 * DefFrameProc16 (USER.445)
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001428 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001429LRESULT WINAPI DefFrameProc16( HWND16 hwnd, HWND16 hwndMDIClient,
1430 UINT16 message, WPARAM16 wParam, LPARAM lParam )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001431{
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001432 HWND16 childHwnd;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001433 MDICLIENTINFO* ci;
1434 WND* wndPtr;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001435
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001436 if (hwndMDIClient)
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001437 {
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001438 switch (message)
1439 {
1440 case WM_COMMAND:
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001441 wndPtr = WIN_FindWndPtr(hwndMDIClient);
Guy Albertelli4a6af351999-03-13 17:03:41 +00001442
1443 if (!wndPtr) {
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001444 ERR("null wndPtr for mdi window hwndMDIClient=%04x\n",
Guy Albertelli4a6af351999-03-13 17:03:41 +00001445 hwndMDIClient);
1446 return 0;
1447 }
1448
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001449 ci = (MDICLIENTINFO*)wndPtr->wExtra;
1450
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001451 /* check for possible syscommands for maximized MDI child */
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001452 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001453
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001454 if( ci && (
1455 wParam < ci->idFirstChild ||
1456 wParam >= ci->idFirstChild + ci->nActiveChildren
1457 )){
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001458 if( (wParam - 0xF000) & 0xF00F ) break;
1459 switch( wParam )
1460 {
1461 case SC_SIZE:
1462 case SC_MOVE:
1463 case SC_MINIMIZE:
1464 case SC_MAXIMIZE:
1465 case SC_NEXTWINDOW:
1466 case SC_PREVWINDOW:
1467 case SC_CLOSE:
1468 case SC_RESTORE:
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001469 if( ci->hwndChildMaximized )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001470 return SendMessage16( ci->hwndChildMaximized, WM_SYSCOMMAND,
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001471 wParam, lParam);
1472 }
1473 }
1474 else
1475 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001476 wndPtr = WIN_FindWndPtr(hwndMDIClient);
David Lassondef58d80d2000-06-15 01:03:32 +00001477 ci = (MDICLIENTINFO*)wndPtr->wExtra;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001478
David Lassondef58d80d2000-06-15 01:03:32 +00001479 if (wParam - ci->idFirstChild == MDI_MOREWINDOWSLIMIT)
1480 /* User chose "More Windows..." */
1481 childHwnd = MDI_MoreWindowsDialog(wndPtr);
1482 else
1483 /* User chose one of the windows listed in the "Windows" menu */
1484 childHwnd = MDI_GetChildByID(wndPtr,wParam );
1485
1486 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001487 if( childHwnd )
Alexandre Julliard530ee841996-10-23 16:59:13 +00001488 SendMessage16(hwndMDIClient, WM_MDIACTIVATE,
1489 (WPARAM16)childHwnd , 0L);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001490 }
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001491 break;
Alexandre Julliard58199531994-04-21 01:20:00 +00001492
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001493 case WM_NCACTIVATE:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001494 SendMessage16(hwndMDIClient, message, wParam, lParam);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001495 break;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001496
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001497 case WM_SETTEXT:
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001498 {
1499 LPWSTR text = HEAP_strdupAtoW( GetProcessHeap(), 0,
1500 (LPCSTR)PTR_SEG_TO_LIN(lParam) );
1501 wndPtr = WIN_FindWndPtr(hwnd);
1502 MDI_UpdateFrameText(wndPtr, hwndMDIClient,
1503 MDI_REPAINTFRAME, text );
1504 WIN_ReleaseWndPtr(wndPtr);
1505 HeapFree( GetProcessHeap(), 0, text );
1506 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001507 return 0;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001508
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001509 case WM_SETFOCUS:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001510 SetFocus(hwndMDIClient);
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001511 break;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001512
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001513 case WM_SIZE:
Alexandre Julliard01d63461997-01-20 19:43:45 +00001514 MoveWindow16(hwndMDIClient, 0, 0,
1515 LOWORD(lParam), HIWORD(lParam), TRUE);
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001516 break;
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001517
1518 case WM_NEXTMENU:
1519
1520 wndPtr = WIN_FindWndPtr(hwndMDIClient);
1521 ci = (MDICLIENTINFO*)wndPtr->wExtra;
1522
1523 if( !(wndPtr->parent->dwStyle & WS_MINIMIZE)
1524 && ci->hwndActiveChild && !ci->hwndChildMaximized )
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001525 {
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001526 /* control menu is between the frame system menu and
1527 * the first entry of menu bar */
1528
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001529 if( (wParam == VK_LEFT &&
1530 wndPtr->parent->wIDmenu == LOWORD(lParam)) ||
1531 (wParam == VK_RIGHT &&
1532 GetSubMenu16(wndPtr->parent->hSysMenu, 0) == LOWORD(lParam)) )
1533 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001534 LRESULT retvalue;
1535 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001536 wndPtr = WIN_FindWndPtr(ci->hwndActiveChild);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001537 retvalue = MAKELONG( GetSubMenu16(wndPtr->hSysMenu, 0),
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001538 ci->hwndActiveChild);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001539 WIN_ReleaseWndPtr(wndPtr);
1540 return retvalue;
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001541 }
1542 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001543 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001544 break;
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001545 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001546 }
1547
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001548 return DefWindowProc16(hwnd, message, wParam, lParam);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001549}
1550
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001551
1552/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001553 * DefFrameProcA (USER32.122)
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001554 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001555LRESULT WINAPI DefFrameProcA( HWND hwnd, HWND hwndMDIClient,
1556 UINT message, WPARAM wParam, LPARAM lParam)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001557{
1558 if (hwndMDIClient)
1559 {
1560 switch (message)
1561 {
1562 case WM_COMMAND:
1563 return DefFrameProc16( hwnd, hwndMDIClient, message,
1564 (WPARAM16)wParam,
1565 MAKELPARAM( (HWND16)lParam, HIWORD(wParam) ) );
1566
1567 case WM_NCACTIVATE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001568 SendMessageA(hwndMDIClient, message, wParam, lParam);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001569 break;
1570
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001571 case WM_SETTEXT: {
1572 LRESULT ret;
1573 LPSTR segstr = SEGPTR_STRDUP((LPSTR)lParam);
1574
1575 ret = DefFrameProc16(hwnd, hwndMDIClient, message,
1576 wParam, (LPARAM)SEGPTR_GET(segstr) );
1577 SEGPTR_FREE(segstr);
1578 return ret;
1579 }
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001580
NF Stevens95524831998-10-26 10:44:17 +00001581 case WM_NEXTMENU:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001582 case WM_SETFOCUS:
1583 case WM_SIZE:
1584 return DefFrameProc16( hwnd, hwndMDIClient, message,
1585 wParam, lParam );
1586 }
1587 }
1588
Alexandre Julliarda3960291999-02-26 11:11:13 +00001589 return DefWindowProcA(hwnd, message, wParam, lParam);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001590}
1591
1592
1593/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001594 * DefFrameProcW (USER32.123)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001595 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001596LRESULT WINAPI DefFrameProcW( HWND hwnd, HWND hwndMDIClient,
1597 UINT message, WPARAM wParam, LPARAM lParam)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001598{
1599 if (hwndMDIClient)
1600 {
1601 switch (message)
1602 {
1603 case WM_COMMAND:
1604 return DefFrameProc16( hwnd, hwndMDIClient, message,
1605 (WPARAM16)wParam,
1606 MAKELPARAM( (HWND16)lParam, HIWORD(wParam) ) );
1607
1608 case WM_NCACTIVATE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001609 SendMessageW(hwndMDIClient, message, wParam, lParam);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001610 break;
1611
Alexandre Julliard77b99181997-09-14 17:17:23 +00001612 case WM_SETTEXT:
1613 {
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001614 LPSTR txt = HEAP_strdupWtoA(GetProcessHeap(),0,(LPWSTR)lParam);
Alexandre Julliarda3960291999-02-26 11:11:13 +00001615 LRESULT ret = DefFrameProcA( hwnd, hwndMDIClient, message,
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001616 wParam, (DWORD)txt );
1617 HeapFree(GetProcessHeap(),0,txt);
1618 return ret;
1619 }
NF Stevens95524831998-10-26 10:44:17 +00001620 case WM_NEXTMENU:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001621 case WM_SETFOCUS:
1622 case WM_SIZE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001623 return DefFrameProcA( hwnd, hwndMDIClient, message,
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001624 wParam, lParam );
1625 }
1626 }
1627
Alexandre Julliarda3960291999-02-26 11:11:13 +00001628 return DefWindowProcW( hwnd, message, wParam, lParam );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001629}
1630
1631
1632/***********************************************************************
1633 * DefMDIChildProc16 (USER.447)
1634 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001635LRESULT WINAPI DefMDIChildProc16( HWND16 hwnd, UINT16 message,
1636 WPARAM16 wParam, LPARAM lParam )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001637{
1638 MDICLIENTINFO *ci;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001639 WND *clientWnd,*tmpWnd = 0;
1640 LRESULT retvalue;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001641
Marcus Meissnere6c63901999-12-12 19:39:37 +00001642 tmpWnd = WIN_FindWndPtr(hwnd);
1643 if (!tmpWnd) return 0;
1644 clientWnd = WIN_FindWndPtr(tmpWnd->parent->hwndSelf);
Alexandre Julliardd4719651995-12-12 18:49:11 +00001645 ci = (MDICLIENTINFO *) clientWnd->wExtra;
Marcus Meissnere6c63901999-12-12 19:39:37 +00001646 WIN_ReleaseWndPtr(tmpWnd);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001647
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001648 switch (message)
1649 {
Alexandre Julliardd4719651995-12-12 18:49:11 +00001650 case WM_SETTEXT:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001651 DefWindowProc16(hwnd, message, wParam, lParam);
Alexandre Julliardd4719651995-12-12 18:49:11 +00001652 MDI_MenuModifyItem(clientWnd,hwnd);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001653 if( ci->hwndChildMaximized == hwnd )
Alexandre Julliard59730ae1996-03-24 16:20:51 +00001654 MDI_UpdateFrameText( clientWnd->parent, ci->self,
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001655 MDI_REPAINTFRAME, NULL );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001656 retvalue = 0;
1657 goto END;
Alexandre Julliard58199531994-04-21 01:20:00 +00001658
Alexandre Julliardd4719651995-12-12 18:49:11 +00001659 case WM_CLOSE:
Alexandre Julliard530ee841996-10-23 16:59:13 +00001660 SendMessage16(ci->self,WM_MDIDESTROY,(WPARAM16)hwnd,0L);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001661 retvalue = 0;
1662 goto END;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001663
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001664 case WM_SETFOCUS:
Alexandre Julliardd4719651995-12-12 18:49:11 +00001665 if( ci->hwndActiveChild != hwnd )
1666 MDI_ChildActivate(clientWnd, hwnd);
1667 break;
1668
1669 case WM_CHILDACTIVATE:
1670 MDI_ChildActivate(clientWnd, hwnd);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001671 retvalue = 0;
1672 goto END;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001673
1674 case WM_NCPAINT:
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001675 TRACE("WM_NCPAINT for %04x, active %04x\n",
Alexandre Julliardd4719651995-12-12 18:49:11 +00001676 hwnd, ci->hwndActiveChild );
1677 break;
1678
Alexandre Julliard58199531994-04-21 01:20:00 +00001679 case WM_SYSCOMMAND:
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001680 switch( wParam )
Alexandre Julliard77b99181997-09-14 17:17:23 +00001681 {
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001682 case SC_MOVE:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001683 if( ci->hwndChildMaximized == hwnd)
1684 {
1685 retvalue = 0;
1686 goto END;
1687 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001688 break;
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001689 case SC_RESTORE:
1690 case SC_MINIMIZE:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001691 tmpWnd = WIN_FindWndPtr(hwnd);
1692 tmpWnd->dwStyle |= WS_SYSMENU;
1693 WIN_ReleaseWndPtr(tmpWnd);
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001694 break;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001695 case SC_MAXIMIZE:
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001696 if( ci->hwndChildMaximized == hwnd)
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001697 {
1698 retvalue = SendMessage16( clientWnd->parent->hwndSelf,
Alexandre Julliard59730ae1996-03-24 16:20:51 +00001699 message, wParam, lParam);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001700 goto END;
1701 }
1702 tmpWnd = WIN_FindWndPtr(hwnd);
1703 tmpWnd->dwStyle &= ~WS_SYSMENU;
1704 WIN_ReleaseWndPtr(tmpWnd);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001705 break;
1706 case SC_NEXTWINDOW:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001707 SendMessage16( ci->self, WM_MDINEXT, 0, 0);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001708 retvalue = 0;
1709 goto END;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001710 case SC_PREVWINDOW:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001711 SendMessage16( ci->self, WM_MDINEXT, 0, 1);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001712 retvalue = 0;
1713 goto END;
Alexandre Julliard77b99181997-09-14 17:17:23 +00001714 }
Alexandre Julliard58199531994-04-21 01:20:00 +00001715 break;
1716
Alexandre Julliardd4719651995-12-12 18:49:11 +00001717 case WM_GETMINMAXINFO:
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001718 MDI_ChildGetMinMaxInfo(clientWnd, hwnd, (MINMAXINFO16*) PTR_SEG_TO_LIN(lParam));
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001719 retvalue = 0;
1720 goto END;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001721
1722 case WM_SETVISIBLE:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001723 if( ci->hwndChildMaximized) ci->mdiFlags &= ~MDIF_NEEDUPDATE;
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00001724 else
1725 MDI_PostUpdate(clientWnd->hwndSelf, ci, SB_BOTH+1);
Alexandre Julliardd4719651995-12-12 18:49:11 +00001726 break;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001727
1728 case WM_SIZE:
1729 /* do not change */
1730
1731 if( ci->hwndActiveChild == hwnd && wParam != SIZE_MAXIMIZED )
Alexandre Julliard77b99181997-09-14 17:17:23 +00001732 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001733 ci->hwndChildMaximized = 0;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001734
Alexandre Julliard59730ae1996-03-24 16:20:51 +00001735 MDI_RestoreFrameMenu( clientWnd->parent, hwnd);
1736 MDI_UpdateFrameText( clientWnd->parent, ci->self,
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001737 MDI_REPAINTFRAME, NULL );
Alexandre Julliard77b99181997-09-14 17:17:23 +00001738 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001739
1740 if( wParam == SIZE_MAXIMIZED )
Alexandre Julliard77b99181997-09-14 17:17:23 +00001741 {
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001742 HWND16 hMaxChild = ci->hwndChildMaximized;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001743
1744 if( hMaxChild == hwnd ) break;
1745
1746 if( hMaxChild)
Alexandre Julliard77b99181997-09-14 17:17:23 +00001747 {
1748 SendMessage16( hMaxChild, WM_SETREDRAW, FALSE, 0L );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001749
Alexandre Julliard77b99181997-09-14 17:17:23 +00001750 MDI_RestoreFrameMenu( clientWnd->parent, hMaxChild);
1751 ShowWindow16( hMaxChild, SW_SHOWNOACTIVATE);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001752
Alexandre Julliard77b99181997-09-14 17:17:23 +00001753 SendMessage16( hMaxChild, WM_SETREDRAW, TRUE, 0L );
1754 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001755
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001756 TRACE("maximizing child %04x\n", hwnd );
Alexandre Julliard18f92e71996-07-17 20:02:21 +00001757
Alexandre Julliardbd616cb2000-09-01 01:23:03 +00001758 /*
1759 * Keep track of the maximized window.
1760 */
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001761 ci->hwndChildMaximized = hwnd; /* !!! */
Alexandre Julliardbd616cb2000-09-01 01:23:03 +00001762
1763 /*
1764 * The maximized window should also be the active window
1765 */
1766 MDI_ChildActivate(clientWnd, hwnd);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001767
Alexandre Julliard59730ae1996-03-24 16:20:51 +00001768 MDI_AugmentFrameMenu( ci, clientWnd->parent, hwnd);
1769 MDI_UpdateFrameText( clientWnd->parent, ci->self,
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001770 MDI_REPAINTFRAME, NULL );
Alexandre Julliard77b99181997-09-14 17:17:23 +00001771 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001772
1773 if( wParam == SIZE_MINIMIZED )
Alexandre Julliard77b99181997-09-14 17:17:23 +00001774 {
1775 HWND16 switchTo = MDI_GetWindow(clientWnd, hwnd, TRUE, WS_MINIMIZE);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001776
1777 if( switchTo )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001778 SendMessage16( switchTo, WM_CHILDACTIVATE, 0, 0L);
Alexandre Julliard77b99181997-09-14 17:17:23 +00001779 }
1780
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00001781 MDI_PostUpdate(clientWnd->hwndSelf, ci, SB_BOTH+1);
Alexandre Julliardd4719651995-12-12 18:49:11 +00001782 break;
1783
1784 case WM_MENUCHAR:
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001785
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001786 /* MDI children don't have menu bars */
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001787 retvalue = 0x00010000L;
1788 goto END;
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001789
Alexandre Julliardd4719651995-12-12 18:49:11 +00001790 case WM_NEXTMENU:
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001791
1792 if( wParam == VK_LEFT ) /* switch to frame system menu */
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001793 {
1794 retvalue = MAKELONG( GetSubMenu16(clientWnd->parent->hSysMenu, 0),
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001795 clientWnd->parent->hwndSelf );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001796 goto END;
1797 }
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001798 if( wParam == VK_RIGHT ) /* to frame menu bar */
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001799 {
1800 retvalue = MAKELONG( clientWnd->parent->wIDmenu,
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001801 clientWnd->parent->hwndSelf );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001802 goto END;
1803 }
Alexandre Julliardd4719651995-12-12 18:49:11 +00001804
1805 break;
NF Stevens95524831998-10-26 10:44:17 +00001806
1807 case WM_SYSCHAR:
1808 if (wParam == '-')
1809 {
1810 SendMessage16(hwnd,WM_SYSCOMMAND,
1811 (WPARAM16)SC_KEYMENU, (LPARAM)(DWORD)VK_SPACE);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001812 retvalue = 0;
1813 goto END;
NF Stevens95524831998-10-26 10:44:17 +00001814 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001815 }
1816
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001817 retvalue = DefWindowProc16(hwnd, message, wParam, lParam);
1818END:
1819 WIN_ReleaseWndPtr(clientWnd);
Veksler Michael3130fce1999-03-22 12:37:09 +00001820 return retvalue;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001821}
1822
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001823
1824/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001825 * DefMDIChildProcA (USER32.124)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001826 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001827LRESULT WINAPI DefMDIChildProcA( HWND hwnd, UINT message,
1828 WPARAM wParam, LPARAM lParam )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001829{
1830 MDICLIENTINFO *ci;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001831 WND *clientWnd,*tmpWnd;
1832 LRESULT retvalue;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001833
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001834 tmpWnd = WIN_FindWndPtr(hwnd);
Marcus Meissnere6c63901999-12-12 19:39:37 +00001835 if (!tmpWnd) return 0;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001836 clientWnd = WIN_FindWndPtr(tmpWnd->parent->hwndSelf);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001837 ci = (MDICLIENTINFO *) clientWnd->wExtra;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001838 WIN_ReleaseWndPtr(tmpWnd);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001839
1840 switch (message)
1841 {
1842 case WM_SETTEXT:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001843 DefWindowProcA(hwnd, message, wParam, lParam);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001844 MDI_MenuModifyItem(clientWnd,hwnd);
1845 if( ci->hwndChildMaximized == hwnd )
1846 MDI_UpdateFrameText( clientWnd->parent, ci->self,
1847 MDI_REPAINTFRAME, NULL );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001848 retvalue = 0;
1849 goto END;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001850
1851 case WM_GETMINMAXINFO:
1852 {
1853 MINMAXINFO16 mmi;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001854 STRUCT32_MINMAXINFO32to16( (MINMAXINFO *)lParam, &mmi );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001855 MDI_ChildGetMinMaxInfo( clientWnd, hwnd, &mmi );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001856 STRUCT32_MINMAXINFO16to32( &mmi, (MINMAXINFO *)lParam );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001857 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001858 retvalue = 0;
1859 goto END;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001860
1861 case WM_MENUCHAR:
1862
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001863 /* MDI children don't have menu bars */
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001864 retvalue = 0x00010000L;
1865 goto END;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001866
1867 case WM_CLOSE:
1868 case WM_SETFOCUS:
1869 case WM_CHILDACTIVATE:
1870 case WM_NCPAINT:
1871 case WM_SYSCOMMAND:
1872 case WM_SETVISIBLE:
1873 case WM_SIZE:
1874 case WM_NEXTMENU:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001875 retvalue = DefMDIChildProc16( hwnd, message, (WPARAM16)wParam, lParam );
1876 goto END;
NF Stevens95524831998-10-26 10:44:17 +00001877
1878 case WM_SYSCHAR:
1879 if (wParam == '-')
1880 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001881 SendMessageA(hwnd,WM_SYSCOMMAND,
1882 (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)VK_SPACE);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001883 retvalue = 0;
1884 goto END;
NF Stevens95524831998-10-26 10:44:17 +00001885 }
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001886 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001887 retvalue = DefWindowProcA(hwnd, message, wParam, lParam);
1888END:
1889 WIN_ReleaseWndPtr(clientWnd);
1890 return retvalue;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001891}
1892
1893
1894/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001895 * DefMDIChildProcW (USER32.125)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001896 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001897LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message,
1898 WPARAM wParam, LPARAM lParam )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001899{
1900 MDICLIENTINFO *ci;
Marcus Meissnere6c63901999-12-12 19:39:37 +00001901 WND *clientWnd,*tmpWnd;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001902 LRESULT retvalue;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001903
Marcus Meissnere6c63901999-12-12 19:39:37 +00001904 tmpWnd = WIN_FindWndPtr(hwnd);
1905 if (!tmpWnd) return 0;
1906 clientWnd = WIN_FindWndPtr(tmpWnd->parent->hwndSelf);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001907 ci = (MDICLIENTINFO *) clientWnd->wExtra;
Marcus Meissnere6c63901999-12-12 19:39:37 +00001908 WIN_ReleaseWndPtr(tmpWnd);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001909
1910 switch (message)
1911 {
1912 case WM_SETTEXT:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001913 DefWindowProcW(hwnd, message, wParam, lParam);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001914 MDI_MenuModifyItem(clientWnd,hwnd);
1915 if( ci->hwndChildMaximized == hwnd )
1916 MDI_UpdateFrameText( clientWnd->parent, ci->self,
1917 MDI_REPAINTFRAME, NULL );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001918 retvalue = 0;
1919 goto END;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001920
1921 case WM_GETMINMAXINFO:
1922 case WM_MENUCHAR:
1923 case WM_CLOSE:
1924 case WM_SETFOCUS:
1925 case WM_CHILDACTIVATE:
1926 case WM_NCPAINT:
1927 case WM_SYSCOMMAND:
1928 case WM_SETVISIBLE:
1929 case WM_SIZE:
1930 case WM_NEXTMENU:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001931 retvalue = DefMDIChildProcA( hwnd, message, (WPARAM16)wParam, lParam );
1932 goto END;
NF Stevens95524831998-10-26 10:44:17 +00001933
1934 case WM_SYSCHAR:
1935 if (wParam == '-')
1936 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001937 SendMessageW(hwnd,WM_SYSCOMMAND,
1938 (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)VK_SPACE);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001939 retvalue = 0;
1940 goto END;
NF Stevens95524831998-10-26 10:44:17 +00001941 }
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001942 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001943 retvalue = DefWindowProcW(hwnd, message, wParam, lParam);
1944END:
1945 WIN_ReleaseWndPtr(clientWnd);
1946 return retvalue;
1947
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001948}
1949
1950
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001951/**********************************************************************
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001952 * CreateMDIWindowA [USER32.79] Creates a MDI child in new thread
1953 * FIXME: its in the same thread now
1954 *
1955 * RETURNS
1956 * Success: Handle to created window
1957 * Failure: NULL
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001958 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001959HWND WINAPI CreateMDIWindowA(
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001960 LPCSTR lpClassName, /* [in] Pointer to registered child class name */
1961 LPCSTR lpWindowName, /* [in] Pointer to window name */
1962 DWORD dwStyle, /* [in] Window style */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001963 INT X, /* [in] Horizontal position of window */
1964 INT Y, /* [in] Vertical position of window */
1965 INT nWidth, /* [in] Width of window */
1966 INT nHeight, /* [in] Height of window */
1967 HWND hWndParent, /* [in] Handle to parent window */
1968 HINSTANCE hInstance, /* [in] Handle to application instance */
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001969 LPARAM lParam) /* [in] Application-defined value */
1970{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001971 WARN("is only single threaded!\n");
Alexandre Julliarda3960291999-02-26 11:11:13 +00001972 return MDI_CreateMDIWindowA(lpClassName, lpWindowName, dwStyle, X, Y,
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001973 nWidth, nHeight, hWndParent, hInstance, lParam);
1974}
1975
1976/**********************************************************************
1977 * MDI_CreateMDIWindowA
1978 * single threaded version of CreateMDIWindowA
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001979 * called by CreateWindowExA
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001980 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001981HWND MDI_CreateMDIWindowA(
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00001982 LPCSTR lpClassName,
1983 LPCSTR lpWindowName,
1984 DWORD dwStyle,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001985 INT X,
1986 INT Y,
1987 INT nWidth,
1988 INT nHeight,
1989 HWND hWndParent,
1990 HINSTANCE hInstance,
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00001991 LPARAM lParam)
1992{
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001993 MDICLIENTINFO* pCi;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001994 MDICREATESTRUCTA cs;
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001995 WND *pWnd=WIN_FindWndPtr(hWndParent);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001996 HWND retvalue;
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001997
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001998 TRACE("(%s,%s,%ld,%d,%d,%d,%d,%x,%d,%ld)\n",
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001999 debugstr_a(lpClassName),debugstr_a(lpWindowName),dwStyle,X,Y,
2000 nWidth,nHeight,hWndParent,hInstance,lParam);
2001
2002 if(!pWnd){
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002003 ERR(" bad hwnd for MDI-client: %d\n",hWndParent);
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002004 return 0;
2005 }
2006 cs.szClass=lpClassName;
2007 cs.szTitle=lpWindowName;
2008 cs.hOwner=hInstance;
2009 cs.x=X;
2010 cs.y=Y;
2011 cs.cx=nWidth;
2012 cs.cy=nHeight;
2013 cs.style=dwStyle;
2014 cs.lParam=lParam;
2015
2016 pCi=(MDICLIENTINFO *)pWnd->wExtra;
2017
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002018 retvalue = MDICreateChild(pWnd,pCi,hWndParent,&cs);
2019 WIN_ReleaseWndPtr(pWnd);
2020 return retvalue;
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00002021}
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002022
Patrik Stridvall54fe8382000-04-06 20:21:16 +00002023/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00002024 * CreateMDIWindowW [USER32.80] Creates a MDI child in new thread
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00002025 *
2026 * RETURNS
2027 * Success: Handle to created window
2028 * Failure: NULL
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002029 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002030HWND WINAPI CreateMDIWindowW(
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002031 LPCWSTR lpClassName, /* [in] Pointer to registered child class name */
2032 LPCWSTR lpWindowName, /* [in] Pointer to window name */
2033 DWORD dwStyle, /* [in] Window style */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002034 INT X, /* [in] Horizontal position of window */
2035 INT Y, /* [in] Vertical position of window */
2036 INT nWidth, /* [in] Width of window */
2037 INT nHeight, /* [in] Height of window */
2038 HWND hWndParent, /* [in] Handle to parent window */
2039 HINSTANCE hInstance, /* [in] Handle to application instance */
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002040 LPARAM lParam) /* [in] Application-defined value */
2041{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002042 FIXME("(%s,%s,%ld,%d,%d,%d,%d,%x,%d,%ld): stub\n",
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002043 debugstr_w(lpClassName),debugstr_w(lpWindowName),dwStyle,X,Y,
2044 nWidth,nHeight,hWndParent,hInstance,lParam);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002045 return (HWND)NULL;
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002046}
2047
2048
2049/******************************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00002050 * CreateMDIWindowW [USER32.80] Creates a MDI child window
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002051 * single threaded version of CreateMDIWindow
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00002052 * called by CreateWindowExW().
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002053 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002054HWND MDI_CreateMDIWindowW(
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00002055 LPCWSTR lpClassName, /* [in] Pointer to registered child class name */
2056 LPCWSTR lpWindowName, /* [in] Pointer to window name */
2057 DWORD dwStyle, /* [in] Window style */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002058 INT X, /* [in] Horizontal position of window */
2059 INT Y, /* [in] Vertical position of window */
2060 INT nWidth, /* [in] Width of window */
2061 INT nHeight, /* [in] Height of window */
2062 HWND hWndParent, /* [in] Handle to parent window */
2063 HINSTANCE hInstance, /* [in] Handle to application instance */
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00002064 LPARAM lParam) /* [in] Application-defined value */
2065{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002066 FIXME("(%s,%s,%ld,%d,%d,%d,%d,%x,%d,%ld): stub\n",
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00002067 debugstr_w(lpClassName),debugstr_w(lpWindowName),dwStyle,X,Y,
2068 nWidth,nHeight,hWndParent,hInstance,lParam);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002069 return (HWND)NULL;
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00002070}
2071
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002072
2073/**********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00002074 * TranslateMDISysAccel (USER32.555)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002075 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002076BOOL WINAPI TranslateMDISysAccel( HWND hwndClient, LPMSG msg )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002077{
2078 MSG16 msg16;
2079
2080 STRUCT32_MSG32to16(msg,&msg16);
2081 /* MDICLIENTINFO is still the same for win32 and win16 ... */
2082 return TranslateMDISysAccel16(hwndClient,&msg16);
2083}
2084
2085
2086/**********************************************************************
2087 * TranslateMDISysAccel16 (USER.451)
2088 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002089BOOL16 WINAPI TranslateMDISysAccel16( HWND16 hwndClient, LPMSG16 msg )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00002090{
Alexandre Julliard7e56f681996-01-31 19:02:28 +00002091
Francois Boisvertd753a991999-05-01 10:19:35 +00002092 if( IsWindow(hwndClient) && (msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN))
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002093 {
2094 MDICLIENTINFO *ci = NULL;
Francois Boisvertd753a991999-05-01 10:19:35 +00002095 HWND wnd;
2096 WND *clientWnd = WIN_FindWndPtr(hwndClient);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00002097
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002098 ci = (MDICLIENTINFO*) clientWnd->wExtra;
Francois Boisvertd753a991999-05-01 10:19:35 +00002099 wnd = ci->hwndActiveChild;
2100
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002101 WIN_ReleaseWndPtr(clientWnd);
Francois Boisvertd753a991999-05-01 10:19:35 +00002102
2103 if( IsWindow(wnd) && !(GetWindowLongA(wnd,GWL_STYLE) & WS_DISABLED) )
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002104 {
2105 WPARAM16 wParam = 0;
2106
2107 /* translate if the Ctrl key is down and Alt not. */
Alexandre Julliard7e56f681996-01-31 19:02:28 +00002108
Alexandre Julliarda3960291999-02-26 11:11:13 +00002109 if( (GetKeyState(VK_CONTROL) & 0x8000) &&
2110 !(GetKeyState(VK_MENU) & 0x8000))
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002111 {
2112 switch( msg->wParam )
2113 {
2114 case VK_F6:
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00002115 case VK_TAB:
Alexandre Julliarda3960291999-02-26 11:11:13 +00002116 wParam = ( GetKeyState(VK_SHIFT) & 0x8000 )
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002117 ? SC_NEXTWINDOW : SC_PREVWINDOW;
2118 break;
2119 case VK_F4:
2120 case VK_RBUTTON:
2121 wParam = SC_CLOSE;
2122 break;
2123 default:
2124 return 0;
2125 }
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002126 TRACE("wParam = %04x\n", wParam);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002127 SendMessage16( ci->hwndActiveChild, WM_SYSCOMMAND,
2128 wParam, (LPARAM)msg->wParam);
2129 return 1;
2130 }
2131 }
2132 }
2133 return 0; /* failure */
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00002134}
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +00002135
2136
2137/***********************************************************************
2138 * CalcChildScroll (USER.462)
2139 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002140void WINAPI CalcChildScroll16( HWND16 hwnd, WORD scroll )
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +00002141{
Alex Korobkad2085841998-10-18 10:37:46 +00002142 SCROLLINFO info;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002143 RECT childRect, clientRect;
2144 INT vmin, vmax, hmin, hmax, vpos, hpos;
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002145 WND *pWnd, *Wnd;
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +00002146
Gerard Patele38b0e11999-04-10 16:28:12 +00002147 if (!(pWnd = WIN_FindWndPtr( hwnd ))) return;
2148 Wnd = WIN_FindWndPtr(hwnd);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002149 GetClientRect( hwnd, &clientRect );
2150 SetRectEmpty( &childRect );
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002151
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002152 for ( WIN_UpdateWndPtr(&pWnd,pWnd->child); pWnd; WIN_UpdateWndPtr(&pWnd,pWnd->next))
Alexandre Julliarda0d77311998-09-13 16:32:00 +00002153 {
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002154 if( pWnd->dwStyle & WS_MAXIMIZE )
Alexandre Julliarda0d77311998-09-13 16:32:00 +00002155 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002156 ShowScrollBar(hwnd, SB_BOTH, FALSE);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002157 WIN_ReleaseWndPtr(pWnd);
Gerard Patele38b0e11999-04-10 16:28:12 +00002158 WIN_ReleaseWndPtr(Wnd);
Alexandre Julliarda0d77311998-09-13 16:32:00 +00002159 return;
2160 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00002161 UnionRect( &childRect, &pWnd->rectWindow, &childRect );
Alexandre Julliarda0d77311998-09-13 16:32:00 +00002162 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002163 WIN_ReleaseWndPtr(pWnd);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002164 UnionRect( &childRect, &clientRect, &childRect );
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +00002165
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002166 hmin = childRect.left; hmax = childRect.right - clientRect.right;
2167 hpos = clientRect.left - childRect.left;
2168 vmin = childRect.top; vmax = childRect.bottom - clientRect.bottom;
2169 vpos = clientRect.top - childRect.top;
2170
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002171 switch( scroll )
Alexandre Julliarda0d77311998-09-13 16:32:00 +00002172 {
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002173 case SB_HORZ:
2174 vpos = hpos; vmin = hmin; vmax = hmax;
2175 case SB_VERT:
Alex Korobkad2085841998-10-18 10:37:46 +00002176 info.cbSize = sizeof(info);
2177 info.nMax = vmax; info.nMin = vmin; info.nPos = vpos;
2178 info.fMask = SIF_POS | SIF_RANGE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002179 SetScrollInfo(hwnd, scroll, &info, TRUE);
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002180 break;
2181 case SB_BOTH:
2182 SCROLL_SetNCSbState( Wnd, vmin, vmax, vpos,
2183 hmin, hmax, hpos);
Alexandre Julliarda0d77311998-09-13 16:32:00 +00002184 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002185 WIN_ReleaseWndPtr(Wnd);
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +00002186}
Alexandre Julliardd4719651995-12-12 18:49:11 +00002187
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002188
Alexandre Julliardd4719651995-12-12 18:49:11 +00002189/***********************************************************************
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002190 * ScrollChildren16 (USER.463)
Alexandre Julliardd4719651995-12-12 18:49:11 +00002191 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002192void WINAPI ScrollChildren16(HWND16 hWnd, UINT16 uMsg, WPARAM16 wParam, LPARAM lParam)
Alexandre Julliardd4719651995-12-12 18:49:11 +00002193{
Patrik Stridvall0f8bc5b1999-04-22 16:27:50 +00002194 ScrollChildren( hWnd, uMsg, wParam, lParam );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002195}
2196
2197
2198/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00002199 * ScrollChildren (USER32.448)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002200 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002201void WINAPI ScrollChildren(HWND hWnd, UINT uMsg, WPARAM wParam,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002202 LPARAM lParam)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002203{
2204 WND *wndPtr = WIN_FindWndPtr(hWnd);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002205 INT newPos = -1;
2206 INT curPos, length, minPos, maxPos, shift;
Alexandre Julliardd4719651995-12-12 18:49:11 +00002207
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002208 if( !wndPtr ) return;
Alexandre Julliardd4719651995-12-12 18:49:11 +00002209
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002210 if( uMsg == WM_HSCROLL )
2211 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002212 GetScrollRange(hWnd,SB_HORZ,&minPos,&maxPos);
2213 curPos = GetScrollPos(hWnd,SB_HORZ);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002214 length = (wndPtr->rectClient.right - wndPtr->rectClient.left)/2;
Marcus Meissnerddca3151999-05-22 11:33:23 +00002215 shift = GetSystemMetrics(SM_CYHSCROLL);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002216 }
2217 else if( uMsg == WM_VSCROLL )
2218 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002219 GetScrollRange(hWnd,SB_VERT,&minPos,&maxPos);
2220 curPos = GetScrollPos(hWnd,SB_VERT);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002221 length = (wndPtr->rectClient.bottom - wndPtr->rectClient.top)/2;
Marcus Meissnerddca3151999-05-22 11:33:23 +00002222 shift = GetSystemMetrics(SM_CXVSCROLL);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002223 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002224 else
2225 {
2226 WIN_ReleaseWndPtr(wndPtr);
2227 return;
2228 }
Alexandre Julliardd4719651995-12-12 18:49:11 +00002229
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002230 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002231 switch( wParam )
2232 {
Alexandre Julliardd4719651995-12-12 18:49:11 +00002233 case SB_LINEUP:
2234 newPos = curPos - shift;
2235 break;
2236 case SB_LINEDOWN:
2237 newPos = curPos + shift;
2238 break;
2239 case SB_PAGEUP:
2240 newPos = curPos - length;
2241 break;
2242 case SB_PAGEDOWN:
2243 newPos = curPos + length;
2244 break;
2245
2246 case SB_THUMBPOSITION:
2247 newPos = LOWORD(lParam);
2248 break;
2249
2250 case SB_THUMBTRACK:
2251 return;
2252
2253 case SB_TOP:
2254 newPos = minPos;
2255 break;
2256 case SB_BOTTOM:
2257 newPos = maxPos;
2258 break;
2259 case SB_ENDSCROLL:
Alexandre Julliarda3960291999-02-26 11:11:13 +00002260 CalcChildScroll16(hWnd,(uMsg == WM_VSCROLL)?SB_VERT:SB_HORZ);
Alexandre Julliardd4719651995-12-12 18:49:11 +00002261 return;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002262 }
Alexandre Julliardd4719651995-12-12 18:49:11 +00002263
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002264 if( newPos > maxPos )
2265 newPos = maxPos;
2266 else
2267 if( newPos < minPos )
2268 newPos = minPos;
Alexandre Julliardd4719651995-12-12 18:49:11 +00002269
Alexandre Julliarda3960291999-02-26 11:11:13 +00002270 SetScrollPos(hWnd, (uMsg == WM_VSCROLL)?SB_VERT:SB_HORZ , newPos, TRUE);
Alexandre Julliardd4719651995-12-12 18:49:11 +00002271
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002272 if( uMsg == WM_VSCROLL )
Alexandre Julliarda3960291999-02-26 11:11:13 +00002273 ScrollWindowEx(hWnd ,0 ,curPos - newPos, NULL, NULL, 0, NULL,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002274 SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN );
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002275 else
Alexandre Julliarda3960291999-02-26 11:11:13 +00002276 ScrollWindowEx(hWnd ,curPos - newPos, 0, NULL, NULL, 0, NULL,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002277 SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN );
Alexandre Julliardd4719651995-12-12 18:49:11 +00002278}
2279
Alexandre Julliardf90efa91998-06-14 15:24:15 +00002280
2281/******************************************************************************
2282 * CascadeWindows [USER32.21] Cascades MDI child windows
2283 *
2284 * RETURNS
2285 * Success: Number of cascaded windows.
2286 * Failure: 0
2287 */
2288WORD WINAPI
Alexandre Julliarda3960291999-02-26 11:11:13 +00002289CascadeWindows (HWND hwndParent, UINT wFlags, const LPRECT lpRect,
2290 UINT cKids, const HWND *lpKids)
Alexandre Julliardf90efa91998-06-14 15:24:15 +00002291{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002292 FIXME("(0x%08x,0x%08x,...,%u,...): stub\n",
Alexandre Julliardf90efa91998-06-14 15:24:15 +00002293 hwndParent, wFlags, cKids);
2294
2295 return 0;
2296}
2297
2298
2299/******************************************************************************
2300 * TileWindows [USER32.545] Tiles MDI child windows
2301 *
2302 * RETURNS
2303 * Success: Number of tiled windows.
2304 * Failure: 0
2305 */
2306WORD WINAPI
Alexandre Julliarda3960291999-02-26 11:11:13 +00002307TileWindows (HWND hwndParent, UINT wFlags, const LPRECT lpRect,
2308 UINT cKids, const HWND *lpKids)
Alexandre Julliardf90efa91998-06-14 15:24:15 +00002309{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002310 FIXME("(0x%08x,0x%08x,...,%u,...): stub\n",
Alexandre Julliardf90efa91998-06-14 15:24:15 +00002311 hwndParent, wFlags, cKids);
2312
2313 return 0;
2314}
2315
David Lassondef58d80d2000-06-15 01:03:32 +00002316/************************************************************************
2317 * "More Windows..." functionality
2318 */
2319
2320/* MDI_MoreWindowsDlgProc
2321 *
2322 * This function will process the messages sent to the "More Windows..."
2323 * dialog.
2324 * Return values: 0 = cancel pressed
2325 * HWND = ok pressed or double-click in the list...
2326 *
2327 */
2328
2329static BOOL WINAPI MDI_MoreWindowsDlgProc (HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
2330{
2331 switch (iMsg)
2332 {
2333 case WM_INITDIALOG:
2334 {
2335 WND *pWnd;
2336 UINT widest = 0;
2337 UINT length;
2338 UINT i;
2339 WND *pParentWnd = (WND *)lParam;
2340 MDICLIENTINFO *ci = (MDICLIENTINFO*)pParentWnd->wExtra;
2341 HWND hListBox = GetDlgItem(hDlg, MDI_IDC_LISTBOX);
2342
2343 /* Fill the list, sorted by id... */
2344 for (i = 0; i < ci->nActiveChildren; i++)
2345 {
2346
2347 /* Find the window with the current ID */
2348 for (pWnd = WIN_LockWndPtr(pParentWnd->child); pWnd; WIN_UpdateWndPtr(&pWnd, pWnd->next))
2349 if (pWnd->wIDmenu == ci->idFirstChild + i)
2350 break;
2351
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00002352 SendMessageW(hListBox, LB_ADDSTRING, 0, (LPARAM) pWnd->text);
David Lassondef58d80d2000-06-15 01:03:32 +00002353 SendMessageA(hListBox, LB_SETITEMDATA, i, (LPARAM) pWnd);
Alexandre Julliardc7e7df82000-08-14 14:41:19 +00002354 length = strlenW(pWnd->text);
David Lassondef58d80d2000-06-15 01:03:32 +00002355 WIN_ReleaseWndPtr(pWnd);
2356
2357 if (length > widest)
2358 widest = length;
2359 }
2360 /* Make sure the horizontal scrollbar scrolls ok */
2361 SendMessageA(hListBox, LB_SETHORIZONTALEXTENT, widest * 6, 0);
2362
2363 /* Set the current selection */
2364 SendMessageA(hListBox, LB_SETCURSEL, MDI_MOREWINDOWSLIMIT, 0);
2365 return TRUE;
2366 }
2367
2368 case WM_COMMAND:
2369 switch (LOWORD(wParam))
2370 {
2371 case IDOK:
2372 {
2373 /* windows are sorted by menu ID, so we must return the
2374 * window associated to the given id
2375 */
2376 HWND hListBox = GetDlgItem(hDlg, MDI_IDC_LISTBOX);
2377 UINT index = SendMessageA(hListBox, LB_GETCURSEL, 0, 0);
2378 WND* pWnd = (WND*) SendMessageA(hListBox, LB_GETITEMDATA, index, 0);
2379
2380 EndDialog(hDlg, pWnd->hwndSelf);
2381 return TRUE;
2382 }
2383 case IDCANCEL:
2384 EndDialog(hDlg, 0);
2385 return TRUE;
2386
2387 default:
2388 switch (HIWORD(wParam))
2389 {
2390 case LBN_DBLCLK:
2391 {
2392 /* windows are sorted by menu ID, so we must return the
2393 * window associated to the given id
2394 */
2395 HWND hListBox = GetDlgItem(hDlg, MDI_IDC_LISTBOX);
2396 UINT index = SendMessageA(hListBox, LB_GETCURSEL, 0, 0);
2397 WND* pWnd = (WND*) SendMessageA(hListBox, LB_GETITEMDATA, index, 0);
2398
2399 EndDialog(hDlg, pWnd->hwndSelf);
2400 return TRUE;
2401 }
2402 }
2403 break;
2404 }
2405 break;
2406 }
2407 return FALSE;
2408}
2409
2410/*
2411 *
2412 * MDI_MoreWindowsDialog
2413 *
2414 * Prompts the user with a listbox containing the opened
2415 * documents. The user can then choose a windows and click
2416 * on OK to set the current window to the one selected, or
2417 * CANCEL to cancel. The function returns a handle to the
2418 * selected window.
2419 */
2420
2421static HWND MDI_MoreWindowsDialog(WND* wndPtr)
2422{
2423 LPCVOID template;
2424 HRSRC hRes;
2425 HANDLE hDlgTmpl;
2426
2427 hRes = FindResourceA(GetModuleHandleA("USER32"), "MDI_MOREWINDOWS", RT_DIALOGA);
2428
2429 if (hRes == 0)
2430 return 0;
2431
2432 hDlgTmpl = LoadResource(GetModuleHandleA("USER32"), hRes );
2433
2434 if (hDlgTmpl == 0)
2435 return 0;
2436
2437 template = LockResource( hDlgTmpl );
2438
2439 if (template == 0)
2440 return 0;
2441
2442 return (HWND) DialogBoxIndirectParamA(GetModuleHandleA("USER32"),
2443 (LPDLGTEMPLATEA) template,
2444 wndPtr->hwndSelf,
2445 (DLGPROC) MDI_MoreWindowsDlgProc,
2446 (LPARAM) wndPtr);
2447}
2448
2449/*
2450 *
2451 * MDI_SwapMenuItems
2452 *
2453 * Will swap the menu IDs for the given 2 positions.
2454 * pos1 and pos2 are menu IDs
2455 *
2456 *
2457 */
2458
2459static void MDI_SwapMenuItems(WND *parentWnd, UINT pos1, UINT pos2)
2460{
2461 WND *pWnd;
2462
2463 for (pWnd = WIN_LockWndPtr(parentWnd->child); pWnd; WIN_UpdateWndPtr(&pWnd,pWnd->next))
2464 {
2465 if (pWnd->wIDmenu == pos1)
2466 pWnd->wIDmenu = pos2;
2467 else
2468 if (pWnd->wIDmenu == pos2)
2469 pWnd->wIDmenu = pos1;
2470 }
2471
2472 WIN_ReleaseWndPtr(pWnd);
2473}
2474