blob: 1f65c0e1a54066dbfe79296c480d500e4583d585 [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 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000376 WIN_ReleaseWndPtr(w);
Alexandre Julliarde2991ea1995-07-29 13:09:43 +0000377 return 0;
378}
Alexandre Julliard2787be81995-05-22 18:23:01 +0000379
Alexandre Julliard85ed45e1998-08-22 19:03:56 +0000380/**********************************************************************
381 * MDIRefreshMenu
382 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000383static LRESULT MDIRefreshMenu( HWND hwnd, HMENU hmenuFrame,
384 HMENU hmenuWindow)
Alexandre Julliard85ed45e1998-08-22 19:03:56 +0000385{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000386 HWND hwndFrame = GetParent(hwnd);
387 HMENU oldFrameMenu = GetMenu(hwndFrame);
Alexandre Julliard85ed45e1998-08-22 19:03:56 +0000388
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000389 TRACE("%04x %04x %04x\n",
Alexandre Julliard85ed45e1998-08-22 19:03:56 +0000390 hwnd, hmenuFrame, hmenuWindow);
391
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000392 FIXME("partially function stub\n");
Alexandre Julliard85ed45e1998-08-22 19:03:56 +0000393
394 return oldFrameMenu;
395}
396
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000397
398/* ------------------ MDI child window functions ---------------------- */
399
400
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000401/**********************************************************************
Alexandre Julliard58199531994-04-21 01:20:00 +0000402 * MDICreateChild
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000403 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000404static HWND MDICreateChild( WND *w, MDICLIENTINFO *ci, HWND parent,
405 LPMDICREATESTRUCTA cs )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000406{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000407 POINT pos[2];
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000408 DWORD style = cs->style | (WS_CHILD | WS_CLIPSIBLINGS);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000409 HWND hwnd, hwndMax = 0;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000410 WORD wIDmenu = ci->idFirstChild + ci->nActiveChildren;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000411 char lpstrDef[]="junk!";
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000412
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000413 TRACE("origin %i,%i - dim %i,%i, style %08x\n",
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000414 cs->x, cs->y, cs->cx, cs->cy, (unsigned)cs->style);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000415 /* calculate placement */
416 MDI_CalcDefaultChildPos(w, ci->nTotalCreated++, pos, 0);
Alexandre Julliard2787be81995-05-22 18:23:01 +0000417
Alexandre Julliarda3960291999-02-26 11:11:13 +0000418 if (cs->cx == CW_USEDEFAULT || !cs->cx) cs->cx = pos[1].x;
419 if (cs->cy == CW_USEDEFAULT || !cs->cy) cs->cy = pos[1].y;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000420
Alexandre Julliarda3960291999-02-26 11:11:13 +0000421 if( cs->x == CW_USEDEFAULT )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000422 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000423 cs->x = pos[0].x;
424 cs->y = pos[0].y;
Alexandre Julliard77b99181997-09-14 17:17:23 +0000425 }
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000426
427 /* restore current maximized child */
428 if( style & WS_VISIBLE && ci->hwndChildMaximized )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000429 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000430 if( style & WS_MAXIMIZE )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000431 SendMessageA(w->hwndSelf, WM_SETREDRAW, FALSE, 0L );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000432 hwndMax = ci->hwndChildMaximized;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000433 ShowWindow( hwndMax, SW_SHOWNOACTIVATE );
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000434 if( style & WS_MAXIMIZE )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000435 SendMessageA(w->hwndSelf, WM_SETREDRAW, TRUE, 0L );
Alexandre Julliard77b99181997-09-14 17:17:23 +0000436 }
Alexandre Julliard2787be81995-05-22 18:23:01 +0000437
David Lassondef58d80d2000-06-15 01:03:32 +0000438 if (ci->nActiveChildren <= MDI_MOREWINDOWSLIMIT)
Alexandre Julliardd4719651995-12-12 18:49:11 +0000439 /* this menu is needed to set a check mark in MDI_ChildActivate */
Matthew Clinec448c5c2000-02-13 15:05:07 +0000440 if (ci->hWindowMenu != 0)
441 AppendMenuA(ci->hWindowMenu ,MF_STRING ,wIDmenu, lpstrDef );
Alexandre Julliardd4719651995-12-12 18:49:11 +0000442
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000443 ci->nActiveChildren++;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000444
445 /* fix window style */
446 if( !(w->dwStyle & MDIS_ALLCHILDSTYLES) )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000447 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000448 style &= (WS_CHILD | WS_CLIPSIBLINGS | WS_MINIMIZE | WS_MAXIMIZE |
449 WS_CLIPCHILDREN | WS_DISABLED | WS_VSCROLL | WS_HSCROLL );
450 style |= (WS_VISIBLE | WS_OVERLAPPEDWINDOW);
Alexandre Julliard77b99181997-09-14 17:17:23 +0000451 }
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000452
Alexandre Julliard491502b1997-11-01 19:08:16 +0000453 if( w->flags & WIN_ISWIN32 )
454 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000455 hwnd = CreateWindowA( cs->szClass, cs->szTitle, style,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000456 cs->x, cs->y, cs->cx, cs->cy, parent,
457 (HMENU16)wIDmenu, cs->hOwner, cs );
Alexandre Julliard491502b1997-11-01 19:08:16 +0000458 }
459 else
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000460 {
461 MDICREATESTRUCT16 *cs16;
462 LPSTR title, cls;
463
464 cs16 = SEGPTR_NEW(MDICREATESTRUCT16);
465 STRUCT32_MDICREATESTRUCT32Ato16( cs, cs16 );
466 title = SEGPTR_STRDUP( cs->szTitle );
467 cls = SEGPTR_STRDUP( cs->szClass );
468 cs16->szTitle = SEGPTR_GET(title);
469 cs16->szClass = SEGPTR_GET(cls);
470
471 hwnd = CreateWindow16( cs->szClass, cs->szTitle, style,
472 cs16->x, cs16->y, cs16->cx, cs16->cy, parent,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000473 (HMENU)wIDmenu, cs16->hOwner,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000474 (LPVOID)SEGPTR_GET(cs16) );
475 SEGPTR_FREE( title );
476 SEGPTR_FREE( cls );
477 SEGPTR_FREE( cs16 );
478 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000479
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000480 /* MDI windows are WS_CHILD so they won't be activated by CreateWindow */
481
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000482 if (hwnd)
483 {
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000484 WND* wnd = WIN_FindWndPtr( hwnd );
485
Francis Beaudet1cc0a9a1999-09-03 15:00:45 +0000486 /* All MDI child windows have the WS_EX_MDICHILD style */
487 wnd->dwExStyle |= WS_EX_MDICHILD;
488
David Lassondef58d80d2000-06-15 01:03:32 +0000489 /* If we have more than 9 windows, we must insert the new one at the
490 * 9th position in order to see it in the "Windows" menu
491 */
492 if (ci->nActiveChildren > MDI_MOREWINDOWSLIMIT)
493 MDI_SwapMenuItems(wnd->parent, wnd->wIDmenu, ci->idFirstChild + MDI_MOREWINDOWSLIMIT - 1);
494
Alexandre Julliardd4719651995-12-12 18:49:11 +0000495 MDI_MenuModifyItem(w ,hwnd);
David Lassondef58d80d2000-06-15 01:03:32 +0000496
497 /* Have we hit the "More Windows..." limit? If so, we must
498 * add a "More Windows..." option
499 */
500 if (ci->nActiveChildren == MDI_MOREWINDOWSLIMIT + 1)
501 {
502 char szTmp[50];
503 LoadStringA(GetModuleHandleA("USER32"), MDI_IDS_MOREWINDOWS, szTmp, 50);
504
505 ModifyMenuA(ci->hWindowMenu,
506 ci->idFirstChild + MDI_MOREWINDOWSLIMIT,
507 MF_BYCOMMAND | MF_STRING,
508 ci->idFirstChild + MDI_MOREWINDOWSLIMIT,
509 szTmp);
510 }
511
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000512 if( wnd->dwStyle & WS_MINIMIZE && ci->hwndActiveChild )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000513 ShowWindow( hwnd, SW_SHOWMINNOACTIVE );
Alexandre Julliard18f92e71996-07-17 20:02:21 +0000514 else
Alexandre Julliard77b99181997-09-14 17:17:23 +0000515 {
Rein Klazes4f7abc01998-10-31 12:18:17 +0000516 /* WS_VISIBLE is clear if a) the MDI client has
517 * MDIS_ALLCHILDSTYLES style and 2) the flag is cleared in the
518 * MDICreateStruct. If so the created window is not shown nor
519 * activated.
520 */
521 int showflag=wnd->dwStyle & WS_VISIBLE;
522 /* clear visible flag, otherwise SetWindoPos32 ignores
523 * the SWP_SHOWWINDOW command.
524 */
525 wnd->dwStyle &= ~WS_VISIBLE;
526 if(showflag){
Alexandre Julliarda3960291999-02-26 11:11:13 +0000527 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE );
Alexandre Julliardac9c9b01996-07-28 18:50:11 +0000528
Rein Klazes4f7abc01998-10-31 12:18:17 +0000529 /* Set maximized state here in case hwnd didn't receive WM_SIZE
530 * during CreateWindow - bad!
531 */
Alexandre Julliardac9c9b01996-07-28 18:50:11 +0000532
Rein Klazes4f7abc01998-10-31 12:18:17 +0000533 if((wnd->dwStyle & WS_MAXIMIZE) && !ci->hwndChildMaximized )
534 {
535 ci->hwndChildMaximized = wnd->hwndSelf;
536 MDI_AugmentFrameMenu( ci, w->parent, hwnd );
537 MDI_UpdateFrameText( w->parent, ci->self, MDI_REPAINTFRAME, NULL );
538 }
539 }else
540 /* needed, harmless ? */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000541 SetWindowPos( hwnd, 0, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE );
Rein Klazes4f7abc01998-10-31 12:18:17 +0000542
Alexandre Julliard77b99181997-09-14 17:17:23 +0000543 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000544 WIN_ReleaseWndPtr(wnd);
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000545 TRACE("created child - %04x\n",hwnd);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000546 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000547 else
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000548 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000549 ci->nActiveChildren--;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000550 DeleteMenu(ci->hWindowMenu,wIDmenu,MF_BYCOMMAND);
551 if( IsWindow(hwndMax) )
552 ShowWindow(hwndMax, SW_SHOWMAXIMIZED);
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +0000553 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000554
555 return hwnd;
556}
557
558/**********************************************************************
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000559 * MDI_ChildGetMinMaxInfo
Alexandre Julliard77b99181997-09-14 17:17:23 +0000560 *
561 * Note: The rule here is that client rect of the maximized MDI child
562 * is equal to the client rect of the MDI client window.
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000563 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000564static void MDI_ChildGetMinMaxInfo( WND* clientWnd, HWND hwnd,
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000565 MINMAXINFO16* lpMinMax )
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000566{
Alexandre Julliard77b99181997-09-14 17:17:23 +0000567 WND* childWnd = WIN_FindWndPtr(hwnd);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000568 RECT rect = clientWnd->rectClient;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000569
Alexandre Julliarda3960291999-02-26 11:11:13 +0000570 MapWindowPoints( clientWnd->parent->hwndSelf,
571 ((MDICLIENTINFO*)clientWnd->wExtra)->self, (LPPOINT)&rect, 2);
572 AdjustWindowRectEx( &rect, childWnd->dwStyle, 0, childWnd->dwExStyle );
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000573
Alexandre Julliard77b99181997-09-14 17:17:23 +0000574 lpMinMax->ptMaxSize.x = rect.right -= rect.left;
575 lpMinMax->ptMaxSize.y = rect.bottom -= rect.top;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000576
Alexandre Julliard77b99181997-09-14 17:17:23 +0000577 lpMinMax->ptMaxPosition.x = rect.left;
578 lpMinMax->ptMaxPosition.y = rect.top;
Alexandre Julliardac9c9b01996-07-28 18:50:11 +0000579
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000580 WIN_ReleaseWndPtr(childWnd);
581
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000582 TRACE("max rect (%i,%i - %i, %i)\n",
Alexandre Julliardac9c9b01996-07-28 18:50:11 +0000583 rect.left,rect.top,rect.right,rect.bottom);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000584
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000585}
586
587/**********************************************************************
Alexandre Julliardd4719651995-12-12 18:49:11 +0000588 * MDI_SwitchActiveChild
589 *
Alexandre Julliard77b99181997-09-14 17:17:23 +0000590 * Note: SetWindowPos sends WM_CHILDACTIVATE to the child window that is
591 * being activated
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000592 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000593static void MDI_SwitchActiveChild( HWND clientHwnd, HWND childHwnd,
594 BOOL bNextWindow )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000595{
Alexandre Julliardd4719651995-12-12 18:49:11 +0000596 WND *w = WIN_FindWndPtr(clientHwnd);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000597 HWND hwndTo = 0;
598 HWND hwndPrev = 0;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000599 MDICLIENTINFO *ci;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000600
Alexandre Julliard77b99181997-09-14 17:17:23 +0000601 hwndTo = MDI_GetWindow(w, childHwnd, bNextWindow, 0);
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000602
Alexandre Julliardd4719651995-12-12 18:49:11 +0000603 ci = (MDICLIENTINFO *) w->wExtra;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000604
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000605 TRACE("from %04x, to %04x\n",childHwnd,hwndTo);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000606
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000607 if ( !hwndTo ) goto END; /* no window to switch to */
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000608
Alexandre Julliardd4719651995-12-12 18:49:11 +0000609 hwndPrev = ci->hwndActiveChild;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000610
Alexandre Julliardd4719651995-12-12 18:49:11 +0000611 if ( hwndTo != hwndPrev )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000612 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000613 BOOL bOptimize = 0;
Alexandre Julliard77b99181997-09-14 17:17:23 +0000614
615 if( ci->hwndChildMaximized )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000616 {
Alexandre Julliard77b99181997-09-14 17:17:23 +0000617 bOptimize = 1;
618 w->dwStyle &= ~WS_VISIBLE;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000619 }
Alexandre Julliard77b99181997-09-14 17:17:23 +0000620
Alexandre Julliarda3960291999-02-26 11:11:13 +0000621 SetWindowPos( hwndTo, HWND_TOP, 0, 0, 0, 0,
Alexandre Julliard77b99181997-09-14 17:17:23 +0000622 SWP_NOMOVE | SWP_NOSIZE );
623
624 if( bNextWindow && hwndPrev )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000625 SetWindowPos( hwndPrev, HWND_BOTTOM, 0, 0, 0, 0,
Alexandre Julliard77b99181997-09-14 17:17:23 +0000626 SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE );
627 if( bOptimize )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000628 ShowWindow( clientHwnd, SW_SHOW );
Alexandre Julliard77b99181997-09-14 17:17:23 +0000629 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000630END:
631 WIN_ReleaseWndPtr(w);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000632}
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000633
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000634
Alexandre Julliardd4719651995-12-12 18:49:11 +0000635/**********************************************************************
636 * MDIDestroyChild
637 */
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000638static LRESULT MDIDestroyChild( WND *w_parent, MDICLIENTINFO *ci,
Alexandre Julliarda3960291999-02-26 11:11:13 +0000639 HWND parent, HWND child,
640 BOOL flagDestroy )
Alexandre Julliardd4719651995-12-12 18:49:11 +0000641{
642 WND *childPtr = WIN_FindWndPtr(child);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000643
Alexandre Julliardd4719651995-12-12 18:49:11 +0000644 if( childPtr )
645 {
David Lassondef58d80d2000-06-15 01:03:32 +0000646 MDI_MenuDeleteItem(w_parent, child);
647
Alexandre Julliardd4719651995-12-12 18:49:11 +0000648 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 Julliard8d24ae61994-04-05 21:42:43 +0000664 }
Noomen Hamzaedd3d4a1999-07-20 15:03:28 +0000665
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000666 WIN_ReleaseWndPtr(childPtr);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000667
Alexandre Julliardd4719651995-12-12 18:49:11 +0000668 ci->nActiveChildren--;
669
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000670 TRACE("child destroyed - %04x\n",child);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000671
672 if (flagDestroy)
Alexandre Julliard77b99181997-09-14 17:17:23 +0000673 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000674 MDI_PostUpdate(GetParent(child), ci, SB_BOTH+1);
675 DestroyWindow(child);
Alexandre Julliard77b99181997-09-14 17:17:23 +0000676 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000677 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000678
679 return 0;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000680}
681
Alexandre Julliardd4719651995-12-12 18:49:11 +0000682
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000683/**********************************************************************
Alexandre Julliardd4719651995-12-12 18:49:11 +0000684 * MDI_ChildActivate
685 *
686 * Note: hWndChild is NULL when last child is being destroyed
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000687 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000688static LONG MDI_ChildActivate( WND *clientPtr, HWND hWndChild )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000689{
Alexandre Julliardd4719651995-12-12 18:49:11 +0000690 MDICLIENTINFO *clientInfo = (MDICLIENTINFO*)clientPtr->wExtra;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000691 HWND prevActiveWnd = clientInfo->hwndActiveChild;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000692 WND *wndPtr = WIN_FindWndPtr( hWndChild );
693 WND *wndPrev = WIN_FindWndPtr( prevActiveWnd );
Alexandre Julliarda3960291999-02-26 11:11:13 +0000694 BOOL isActiveFrameWnd = 0;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000695 LONG retvalue;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000696
Alexandre Julliardd4719651995-12-12 18:49:11 +0000697 if( wndPtr )
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000698 {
699 if( wndPtr->dwStyle & WS_DISABLED )
700 {
701 retvalue = 0L;
702 goto END;
703 }
704 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000705
Francis Beaudet458719d1999-10-31 17:35:06 +0000706 /* Don't activate if it is already active. Might happen
707 since ShowWindow DOES activate MDI children */
708 if (clientInfo->hwndActiveChild == hWndChild)
709 {
710 retvalue = 0L;
711 goto END;
712 }
713
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000714 TRACE("%04x\n", hWndChild);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000715
Alexandre Julliarda3960291999-02-26 11:11:13 +0000716 if( GetActiveWindow() == clientPtr->parent->hwndSelf )
Alexandre Julliardd4719651995-12-12 18:49:11 +0000717 isActiveFrameWnd = TRUE;
718
719 /* deactivate prev. active child */
720 if( wndPrev )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000721 {
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +0000722 wndPrev->dwStyle |= WS_SYSMENU;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000723 SendMessageA( prevActiveWnd, WM_NCACTIVATE, FALSE, 0L );
724 SendMessageA( prevActiveWnd, WM_MDIACTIVATE, (WPARAM)prevActiveWnd,
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000725 (LPARAM)hWndChild);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000726 /* uncheck menu item */
727 if( clientInfo->hWindowMenu )
David Lassondef58d80d2000-06-15 01:03:32 +0000728 {
729 WORD wPrevID = wndPrev->wIDmenu - clientInfo->idFirstChild;
730
731 if (wPrevID < MDI_MOREWINDOWSLIMIT)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000732 CheckMenuItem( clientInfo->hWindowMenu,
Alexandre Julliardc6c09441997-01-12 18:32:19 +0000733 wndPrev->wIDmenu, 0);
David Lassondef58d80d2000-06-15 01:03:32 +0000734 else
735 CheckMenuItem( clientInfo->hWindowMenu,
736 clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT - 1, 0);
737 }
Alexandre Julliard77b99181997-09-14 17:17:23 +0000738 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000739
Alexandre Julliardd4719651995-12-12 18:49:11 +0000740 /* set appearance */
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000741 if( clientInfo->hwndChildMaximized )
Jesper Skov5c3e4571998-11-01 19:27:22 +0000742 {
Marcus Meissner03479f81999-01-28 10:06:38 +0000743 if( clientInfo->hwndChildMaximized != hWndChild ) {
744 if( hWndChild ) {
Alexandre Julliardd4719651995-12-12 18:49:11 +0000745 clientInfo->hwndActiveChild = hWndChild;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000746 ShowWindow( hWndChild, SW_SHOWMAXIMIZED);
Marcus Meissner03479f81999-01-28 10:06:38 +0000747 } else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000748 ShowWindow( clientInfo->hwndActiveChild, SW_SHOWNORMAL );
Marcus Meissner03479f81999-01-28 10:06:38 +0000749 }
Jesper Skov5c3e4571998-11-01 19:27:22 +0000750 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000751
Alexandre Julliardd4719651995-12-12 18:49:11 +0000752 clientInfo->hwndActiveChild = hWndChild;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000753
Alexandre Julliardd4719651995-12-12 18:49:11 +0000754 /* check if we have any children left */
755 if( !hWndChild )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000756 {
757 if( isActiveFrameWnd )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000758 SetFocus( clientInfo->self );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000759 retvalue = 0;
760 goto END;
Alexandre Julliard77b99181997-09-14 17:17:23 +0000761 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000762
Alexandre Julliardd4719651995-12-12 18:49:11 +0000763 /* check menu item */
764 if( clientInfo->hWindowMenu )
David Lassondef58d80d2000-06-15 01:03:32 +0000765 {
766 /* The window to be activated must be displayed in the "Windows" menu */
767 if (wndPtr->wIDmenu >= clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT)
768 {
769 MDI_SwapMenuItems(wndPtr->parent, wndPtr->wIDmenu, clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT - 1);
770 MDI_MenuModifyItem(wndPtr->parent ,wndPtr->hwndSelf);
771 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000772
David Lassondef58d80d2000-06-15 01:03:32 +0000773 CheckMenuItem(clientInfo->hWindowMenu, wndPtr->wIDmenu, MF_CHECKED);
774 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000775 /* bring active child to the top */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000776 SetWindowPos( hWndChild, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000777
778 if( isActiveFrameWnd )
Alexandre Julliard77b99181997-09-14 17:17:23 +0000779 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000780 SendMessageA( hWndChild, WM_NCACTIVATE, TRUE, 0L);
781 if( GetFocus() == clientInfo->self )
782 SendMessageA( clientInfo->self, WM_SETFOCUS,
783 (WPARAM)clientInfo->self, 0L );
Alexandre Julliardd4719651995-12-12 18:49:11 +0000784 else
Alexandre Julliarda3960291999-02-26 11:11:13 +0000785 SetFocus( clientInfo->self );
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000786 }
Alexandre Julliarda3960291999-02-26 11:11:13 +0000787 SendMessageA( hWndChild, WM_MDIACTIVATE, (WPARAM)prevActiveWnd,
Alexandre Julliard491502b1997-11-01 19:08:16 +0000788 (LPARAM)hWndChild );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000789 retvalue = 1;
790END:
791 WIN_ReleaseWndPtr(wndPtr);
792 WIN_ReleaseWndPtr(wndPrev);
Veksler Michael3130fce1999-03-22 12:37:09 +0000793 return retvalue;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000794}
795
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000796/* -------------------- MDI client window functions ------------------- */
797
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000798/**********************************************************************
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000799 * CreateMDIMenuBitmap
800 */
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000801static HBITMAP16 CreateMDIMenuBitmap(void)
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000802{
Alexandre Julliarda3960291999-02-26 11:11:13 +0000803 HDC hDCSrc = CreateCompatibleDC(0);
804 HDC hDCDest = CreateCompatibleDC(hDCSrc);
Alexandre Julliardc7c217b1998-04-13 12:21:30 +0000805 HBITMAP16 hbClose = LoadBitmap16(0, MAKEINTRESOURCE16(OBM_CLOSE) );
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000806 HBITMAP16 hbCopy;
807 HANDLE16 hobjSrc, hobjDest;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000808
Alexandre Julliarda3960291999-02-26 11:11:13 +0000809 hobjSrc = SelectObject(hDCSrc, hbClose);
Marcus Meissnerddca3151999-05-22 11:33:23 +0000810 hbCopy = CreateCompatibleBitmap(hDCSrc,GetSystemMetrics(SM_CXSIZE),GetSystemMetrics(SM_CYSIZE));
Alexandre Julliarda3960291999-02-26 11:11:13 +0000811 hobjDest = SelectObject(hDCDest, hbCopy);
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000812
Marcus Meissnerddca3151999-05-22 11:33:23 +0000813 BitBlt(hDCDest, 0, 0, GetSystemMetrics(SM_CXSIZE), GetSystemMetrics(SM_CYSIZE),
814 hDCSrc, GetSystemMetrics(SM_CXSIZE), 0, SRCCOPY);
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000815
Alexandre Julliarda3960291999-02-26 11:11:13 +0000816 SelectObject(hDCSrc, hobjSrc);
817 DeleteObject(hbClose);
818 DeleteDC(hDCSrc);
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000819
Alexandre Julliarda3960291999-02-26 11:11:13 +0000820 hobjSrc = SelectObject( hDCDest, GetStockObject(BLACK_PEN) );
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000821
Marcus Meissnerddca3151999-05-22 11:33:23 +0000822 MoveToEx( hDCDest, GetSystemMetrics(SM_CXSIZE) - 1, 0, NULL );
823 LineTo( hDCDest, GetSystemMetrics(SM_CXSIZE) - 1, GetSystemMetrics(SM_CYSIZE) - 1);
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000824
Alexandre Julliarda3960291999-02-26 11:11:13 +0000825 SelectObject(hDCDest, hobjSrc );
826 SelectObject(hDCDest, hobjDest);
827 DeleteDC(hDCDest);
Alexandre Julliard670cdc41997-08-24 16:00:30 +0000828
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000829 return hbCopy;
830}
831
832/**********************************************************************
833 * MDICascade
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000834 */
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +0000835static LONG MDICascade(WND* clientWnd, MDICLIENTINFO *ci)
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000836{
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000837 WND** ppWnd;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000838 UINT total;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000839
840 if (ci->hwndChildMaximized)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000841 SendMessageA( clientWnd->hwndSelf, WM_MDIRESTORE,
842 (WPARAM)ci->hwndChildMaximized, 0);
Alexandre Julliard58199531994-04-21 01:20:00 +0000843
Alexandre Julliardd4719651995-12-12 18:49:11 +0000844 if (ci->nActiveChildren == 0) return 0;
Alexandre Julliard7cbe6571995-01-09 18:21:16 +0000845
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000846 if ((ppWnd = WIN_BuildWinArray(clientWnd, BWA_SKIPHIDDEN | BWA_SKIPOWNED |
847 BWA_SKIPICONIC, &total)))
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000848 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000849 WND** heapPtr = ppWnd;
850 if( total )
851 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000852 INT delta = 0, n = 0;
853 POINT pos[2];
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000854 if( total < ci->nActiveChildren )
Marcus Meissnerddca3151999-05-22 11:33:23 +0000855 delta = GetSystemMetrics(SM_CYICONSPACING) +
856 GetSystemMetrics(SM_CYICON);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000857
Alexandre Julliard829fe321998-07-26 14:27:39 +0000858 /* walk the list (backwards) and move windows */
859 while (*ppWnd) ppWnd++;
860 while (ppWnd != heapPtr)
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000861 {
Alexandre Julliard829fe321998-07-26 14:27:39 +0000862 ppWnd--;
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000863 TRACE("move %04x to (%ld,%ld) size [%ld,%ld]\n",
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000864 (*ppWnd)->hwndSelf, pos[0].x, pos[0].y, pos[1].x, pos[1].y);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000865
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000866 MDI_CalcDefaultChildPos(clientWnd, n++, pos, delta);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000867 SetWindowPos( (*ppWnd)->hwndSelf, 0, pos[0].x, pos[0].y,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000868 pos[1].x, pos[1].y,
869 SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER);
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000870 }
871 }
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +0000872 WIN_ReleaseWinArray(heapPtr);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000873 }
874
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000875 if( total < ci->nActiveChildren )
Alexandre Julliarda3960291999-02-26 11:11:13 +0000876 ArrangeIconicWindows( clientWnd->hwndSelf );
Alexandre Julliard8d24ae61994-04-05 21:42:43 +0000877 return 0;
878}
879
880/**********************************************************************
Alexandre Julliard58199531994-04-21 01:20:00 +0000881 * MDITile
882 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000883static void MDITile( WND* wndClient, MDICLIENTINFO *ci, WPARAM wParam )
Alexandre Julliard58199531994-04-21 01:20:00 +0000884{
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000885 WND** ppWnd;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000886 UINT total = 0;
Alexandre Julliard58199531994-04-21 01:20:00 +0000887
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000888 if (ci->hwndChildMaximized)
Alexandre Julliarda3960291999-02-26 11:11:13 +0000889 SendMessageA( wndClient->hwndSelf, WM_MDIRESTORE,
890 (WPARAM)ci->hwndChildMaximized, 0);
Alexandre Julliard58199531994-04-21 01:20:00 +0000891
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +0000892 if (ci->nActiveChildren == 0) return;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000893
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000894 ppWnd = WIN_BuildWinArray(wndClient, BWA_SKIPHIDDEN | BWA_SKIPOWNED | BWA_SKIPICONIC |
895 ((wParam & MDITILE_SKIPDISABLED)? BWA_SKIPDISABLED : 0), &total );
Alexandre Julliardd4719651995-12-12 18:49:11 +0000896
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000897 TRACE("%u windows to tile\n", total);
Alexandre Julliardd4719651995-12-12 18:49:11 +0000898
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000899 if( ppWnd )
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000900 {
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000901 WND** heapPtr = ppWnd;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000902
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000903 if( total )
904 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000905 RECT rect;
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000906 int x, y, xsize, ysize;
907 int rows, columns, r, c, i;
Alexandre Julliardd4719651995-12-12 18:49:11 +0000908
Noomen Hamzafe0a5e81999-06-12 08:08:35 +0000909 GetClientRect(wndClient->hwndSelf,&rect);
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000910 rows = (int) sqrt((double)total);
911 columns = total / rows;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000912
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000913 if( wParam & MDITILE_HORIZONTAL ) /* version >= 3.1 */
914 {
915 i = rows;
916 rows = columns; /* exchange r and c */
917 columns = i;
918 }
919
920 if( total != ci->nActiveChildren)
921 {
Marcus Meissnerddca3151999-05-22 11:33:23 +0000922 y = rect.bottom - 2 * GetSystemMetrics(SM_CYICONSPACING) - GetSystemMetrics(SM_CYICON);
923 rect.bottom = ( y - GetSystemMetrics(SM_CYICON) < rect.top )? rect.bottom: y;
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000924 }
925
926 ysize = rect.bottom / rows;
927 xsize = rect.right / columns;
Alexandre Julliard58199531994-04-21 01:20:00 +0000928
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000929 for (x = i = 0, c = 1; c <= columns && *ppWnd; c++)
930 {
931 if (c == columns)
932 {
933 rows = total - i;
934 ysize = rect.bottom / rows;
935 }
Alexandre Julliardd4719651995-12-12 18:49:11 +0000936
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000937 y = 0;
938 for (r = 1; r <= rows && *ppWnd; r++, i++)
939 {
Alexandre Julliarda3960291999-02-26 11:11:13 +0000940 SetWindowPos((*ppWnd)->hwndSelf, 0, x, y, xsize, ysize,
Alexandre Julliard23946ad1997-06-16 17:43:53 +0000941 SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER);
942 y += ysize;
943 ppWnd++;
944 }
945 x += xsize;
946 }
947 }
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +0000948 WIN_ReleaseWinArray(heapPtr);
Alexandre Julliard58199531994-04-21 01:20:00 +0000949 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000950
Alexandre Julliarda3960291999-02-26 11:11:13 +0000951 if( total < ci->nActiveChildren ) ArrangeIconicWindows( wndClient->hwndSelf );
Alexandre Julliard58199531994-04-21 01:20:00 +0000952}
953
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000954/* ----------------------- Frame window ---------------------------- */
955
956
957/**********************************************************************
958 * MDI_AugmentFrameMenu
959 */
Alexandre Julliarda3960291999-02-26 11:11:13 +0000960static BOOL MDI_AugmentFrameMenu( MDICLIENTINFO* ci, WND *frame,
961 HWND hChild )
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000962{
Alexandre Julliard77b99181997-09-14 17:17:23 +0000963 WND* child = WIN_FindWndPtr(hChild);
Alexandre Julliarda3960291999-02-26 11:11:13 +0000964 HMENU hSysPopup = 0;
Abey George967ec701999-06-26 11:44:18 +0000965 HBITMAP hSysMenuBitmap = 0;
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000966
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000967 TRACE("frame %p,child %04x\n",frame,hChild);
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000968
Francois Boisvert6b1b41c1999-03-14 17:25:32 +0000969 if( !frame->wIDmenu || !child->hSysMenu )
970 {
971 WIN_ReleaseWndPtr(child);
972 return 0;
973 }
974 WIN_ReleaseWndPtr(child);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +0000975
Alexandre Julliard77b99181997-09-14 17:17:23 +0000976 /* create a copy of sysmenu popup and insert it into frame menu bar */
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000977
Bertho Stultiensd1895a71999-04-25 18:31:35 +0000978 if (!(hSysPopup = LoadMenuA(GetModuleHandleA("USER32"), "SYSMENU")))
Alexandre Julliard77b99181997-09-14 17:17:23 +0000979 return 0;
Alexandre Julliard2d93d001996-05-21 15:01:41 +0000980
Alexandre Julliard359f497e1999-07-04 16:02:24 +0000981 TRACE("\tgot popup %04x in sysmenu %04x\n",
Alexandre Julliarda11d7b11998-03-01 20:05:02 +0000982 hSysPopup, child->hSysMenu);
Alexandre Julliard7e56f681996-01-31 19:02:28 +0000983
Alexandre Julliarda3960291999-02-26 11:11:13 +0000984 AppendMenuA(frame->wIDmenu,MF_HELP | MF_BITMAP,
Juergen Schmied78513941999-04-18 14:40:32 +0000985 SC_MINIMIZE, (LPSTR)(DWORD)HBMMENU_MBAR_MINIMIZE ) ;
Alexandre Julliarda3960291999-02-26 11:11:13 +0000986 AppendMenuA(frame->wIDmenu,MF_HELP | MF_BITMAP,
Juergen Schmied78513941999-04-18 14:40:32 +0000987 SC_RESTORE, (LPSTR)(DWORD)HBMMENU_MBAR_RESTORE );
Francois Boisvert197a8e11999-02-13 09:10:17 +0000988
Abey George967ec701999-06-26 11:44:18 +0000989 /* In Win 95 look, the system menu is replaced by the child icon */
990
991 if(TWEAK_WineLook > WIN31_LOOK)
992 {
993 HICON hIcon = GetClassLongA(hChild, GCL_HICONSM);
994 if (!hIcon)
995 hIcon = GetClassLongA(hChild, GCL_HICON);
996 if (hIcon)
997 {
998 HDC hMemDC;
999 HBITMAP hBitmap, hOldBitmap;
1000 HBRUSH hBrush;
1001 HDC hdc = GetDC(hChild);
1002
1003 if (hdc)
1004 {
1005 int cx, cy;
1006 cx = GetSystemMetrics(SM_CXSMICON);
1007 cy = GetSystemMetrics(SM_CYSMICON);
1008 hMemDC = CreateCompatibleDC(hdc);
1009 hBitmap = CreateCompatibleBitmap(hdc, cx, cy);
1010 hOldBitmap = SelectObject(hMemDC, hBitmap);
1011 SetMapMode(hMemDC, MM_TEXT);
1012 hBrush = CreateSolidBrush(GetSysColor(COLOR_MENU));
1013 DrawIconEx(hMemDC, 0, 0, hIcon, cx, cy, 0, hBrush, DI_NORMAL);
1014 SelectObject (hMemDC, hOldBitmap);
1015 DeleteObject(hBrush);
1016 DeleteDC(hMemDC);
1017 ReleaseDC(hChild, hdc);
1018 hSysMenuBitmap = hBitmap;
1019 }
1020 }
1021 }
1022 else
1023 hSysMenuBitmap = hBmpClose;
1024
Alexandre Julliarda3960291999-02-26 11:11:13 +00001025 if( !InsertMenuA(frame->wIDmenu,0,MF_BYPOSITION | MF_BITMAP | MF_POPUP,
Abey George967ec701999-06-26 11:44:18 +00001026 hSysPopup, (LPSTR)(DWORD)hSysMenuBitmap))
Alexandre Julliard77b99181997-09-14 17:17:23 +00001027 {
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001028 TRACE("not inserted\n");
Alexandre Julliarda3960291999-02-26 11:11:13 +00001029 DestroyMenu(hSysPopup);
Alexandre Julliard77b99181997-09-14 17:17:23 +00001030 return 0;
1031 }
Huw D M Daviesbc1d1df1999-02-14 09:20:01 +00001032
Patrik Stridvall0f8bc5b1999-04-22 16:27:50 +00001033 /* The close button is only present in Win 95 look */
Huw D M Daviesbc1d1df1999-02-14 09:20:01 +00001034 if(TWEAK_WineLook > WIN31_LOOK)
1035 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001036 AppendMenuA(frame->wIDmenu,MF_HELP | MF_BITMAP,
Juergen Schmied78513941999-04-18 14:40:32 +00001037 SC_CLOSE, (LPSTR)(DWORD)HBMMENU_MBAR_CLOSE );
Huw D M Daviesbc1d1df1999-02-14 09:20:01 +00001038 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001039
Alexandre Julliarda3960291999-02-26 11:11:13 +00001040 EnableMenuItem(hSysPopup, SC_SIZE, MF_BYCOMMAND | MF_GRAYED);
1041 EnableMenuItem(hSysPopup, SC_MOVE, MF_BYCOMMAND | MF_GRAYED);
1042 EnableMenuItem(hSysPopup, SC_MAXIMIZE, MF_BYCOMMAND | MF_GRAYED);
Juergen Schmied90905021999-05-17 15:05:08 +00001043 SetMenuDefaultItem(hSysPopup, SC_CLOSE, FALSE);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001044
Alexandre Julliard77b99181997-09-14 17:17:23 +00001045 /* redraw menu */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001046 DrawMenuBar(frame->hwndSelf);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001047
Alexandre Julliard77b99181997-09-14 17:17:23 +00001048 return 1;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001049}
1050
1051/**********************************************************************
1052 * MDI_RestoreFrameMenu
1053 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001054static BOOL MDI_RestoreFrameMenu( WND *frameWnd, HWND hChild )
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001055{
Francis Beaudet4691d0c1999-07-30 18:02:04 +00001056 MENUITEMINFOA menuInfo;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001057 INT nItems = GetMenuItemCount(frameWnd->wIDmenu) - 1;
1058 UINT iId = GetMenuItemID(frameWnd->wIDmenu,nItems) ;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001059
Gerard Patele8a3d072000-01-23 03:19:44 +00001060 TRACE("frameWnd %p,(%04x),child %04x,nIt=%d,iId=%d\n",
1061 frameWnd,frameWnd->hwndSelf,hChild,nItems,iId);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001062
Francois Boisvert197a8e11999-02-13 09:10:17 +00001063 if(!(iId == SC_RESTORE || iId == SC_CLOSE) )
Alexandre Julliard77b99181997-09-14 17:17:23 +00001064 return 0;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001065
Francis Beaudet4691d0c1999-07-30 18:02:04 +00001066 /*
1067 * Remove the system menu, If that menu is the icon of the window
1068 * as it is in win95, we have to delete the bitmap.
1069 */
1070 menuInfo.cbSize = sizeof(MENUITEMINFOA);
1071 menuInfo.fMask = MIIM_DATA | MIIM_TYPE;
1072
1073 GetMenuItemInfoA(frameWnd->wIDmenu,
1074 0,
1075 TRUE,
1076 &menuInfo);
1077
Alexandre Julliarda3960291999-02-26 11:11:13 +00001078 RemoveMenu(frameWnd->wIDmenu,0,MF_BYPOSITION);
Huw D M Daviesbc1d1df1999-02-14 09:20:01 +00001079
Francis Beaudet4691d0c1999-07-30 18:02:04 +00001080 if ( (menuInfo.fType & MFT_BITMAP) &&
1081 (LOWORD(menuInfo.dwTypeData)!=0) &&
1082 (LOWORD(menuInfo.dwTypeData)!=hBmpClose) )
1083 {
1084 DeleteObject((HBITMAP)LOWORD(menuInfo.dwTypeData));
1085 }
1086
Francois Boisvert197a8e11999-02-13 09:10:17 +00001087 if(TWEAK_WineLook > WIN31_LOOK)
1088 {
Patrik Stridvall0f8bc5b1999-04-22 16:27:50 +00001089 /* close */
1090 DeleteMenu(frameWnd->wIDmenu,GetMenuItemCount(frameWnd->wIDmenu) - 1,MF_BYPOSITION);
Francois Boisvert197a8e11999-02-13 09:10:17 +00001091 }
Patrik Stridvall0f8bc5b1999-04-22 16:27:50 +00001092 /* restore */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001093 DeleteMenu(frameWnd->wIDmenu,GetMenuItemCount(frameWnd->wIDmenu) - 1,MF_BYPOSITION);
Patrik Stridvall0f8bc5b1999-04-22 16:27:50 +00001094 /* minimize */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001095 DeleteMenu(frameWnd->wIDmenu,GetMenuItemCount(frameWnd->wIDmenu) - 1,MF_BYPOSITION);
Francois Boisvert47e2b851999-02-09 14:11:19 +00001096
Alexandre Julliarda3960291999-02-26 11:11:13 +00001097 DrawMenuBar(frameWnd->hwndSelf);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001098
Alexandre Julliard77b99181997-09-14 17:17:23 +00001099 return 1;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001100}
1101
Francois Boisvert197a8e11999-02-13 09:10:17 +00001102
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001103/**********************************************************************
1104 * MDI_UpdateFrameText
1105 *
1106 * used when child window is maximized/restored
1107 *
1108 * Note: lpTitle can be NULL
1109 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001110static void MDI_UpdateFrameText( WND *frameWnd, HWND hClient,
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001111 BOOL repaint, LPCWSTR lpTitle )
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001112{
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001113 WCHAR lpBuffer[MDI_MAXTITLELENGTH+1];
Alexandre Julliard77b99181997-09-14 17:17:23 +00001114 WND* clientWnd = WIN_FindWndPtr(hClient);
1115 MDICLIENTINFO *ci = (MDICLIENTINFO *) clientWnd->wExtra;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001116
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001117 TRACE("repaint %i, frameText %s\n", repaint, (lpTitle)?debugstr_w(lpTitle):"NULL");
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001118
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001119 if (!clientWnd)
1120 return;
1121
1122 if (!ci)
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +00001123 {
1124 WIN_ReleaseWndPtr(clientWnd);
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001125 return;
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +00001126 }
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001127
Alexandre Julliard77b99181997-09-14 17:17:23 +00001128 /* store new "default" title if lpTitle is not NULL */
1129 if (lpTitle)
1130 {
1131 if (ci->frameTitle) HeapFree( SystemHeap, 0, ci->frameTitle );
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001132 ci->frameTitle = HEAP_strdupW( SystemHeap, 0, lpTitle );
Alexandre Julliard77b99181997-09-14 17:17:23 +00001133 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001134
Alexandre Julliard77b99181997-09-14 17:17:23 +00001135 if (ci->frameTitle)
1136 {
1137 WND* childWnd = WIN_FindWndPtr( ci->hwndChildMaximized );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001138
Alexandre Julliard77b99181997-09-14 17:17:23 +00001139 if( childWnd && childWnd->text )
1140 {
1141 /* combine frame title and child title if possible */
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001142
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001143 static const WCHAR lpBracket[] = {' ','-',' ','[',0};
1144 static const WCHAR lpBracket2[] = {']',0};
Alexandre Julliardc7e7df82000-08-14 14:41:19 +00001145 int i_frame_text_length = strlenW(ci->frameTitle);
1146 int i_child_text_length = strlenW(childWnd->text);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001147
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001148 lstrcpynW( lpBuffer, ci->frameTitle, MDI_MAXTITLELENGTH);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001149
Alexandre Julliard77b99181997-09-14 17:17:23 +00001150 if( i_frame_text_length + 6 < MDI_MAXTITLELENGTH )
1151 {
Alexandre Julliardc7e7df82000-08-14 14:41:19 +00001152 strcatW( lpBuffer, lpBracket );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001153
Alexandre Julliard77b99181997-09-14 17:17:23 +00001154 if( i_frame_text_length + i_child_text_length + 6 < MDI_MAXTITLELENGTH )
1155 {
Alexandre Julliardc7e7df82000-08-14 14:41:19 +00001156 strcatW( lpBuffer, childWnd->text );
1157 strcatW( lpBuffer, lpBracket2 );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001158 }
Alexandre Julliard77b99181997-09-14 17:17:23 +00001159 else
1160 {
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001161 lstrcpynW( lpBuffer + i_frame_text_length + 4,
Alexandre Julliard77b99181997-09-14 17:17:23 +00001162 childWnd->text, MDI_MAXTITLELENGTH - i_frame_text_length - 5 );
Alexandre Julliardc7e7df82000-08-14 14:41:19 +00001163 strcatW( lpBuffer, lpBracket2 );
Alexandre Julliard77b99181997-09-14 17:17:23 +00001164 }
1165 }
1166 }
1167 else
1168 {
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001169 lstrcpynW(lpBuffer, ci->frameTitle, MDI_MAXTITLELENGTH+1 );
Alexandre Julliard77b99181997-09-14 17:17:23 +00001170 }
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +00001171 WIN_ReleaseWndPtr(childWnd);
1172
Alexandre Julliard77b99181997-09-14 17:17:23 +00001173 }
1174 else
1175 lpBuffer[0] = '\0';
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001176
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001177 DEFWND_SetTextW( frameWnd, lpBuffer );
Alexandre Julliard77b99181997-09-14 17:17:23 +00001178 if( repaint == MDI_REPAINTFRAME)
Alexandre Julliarda3960291999-02-26 11:11:13 +00001179 SetWindowPos( frameWnd->hwndSelf, 0,0,0,0,0, SWP_FRAMECHANGED |
Alexandre Julliard77b99181997-09-14 17:17:23 +00001180 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER );
Francois Boisvert3a3cd9f1999-03-28 12:42:52 +00001181
1182 WIN_ReleaseWndPtr(clientWnd);
1183
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001184}
1185
1186
1187/* ----------------------------- Interface ---------------------------- */
1188
1189
Alexandre Julliard58199531994-04-21 01:20:00 +00001190/**********************************************************************
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001191 * MDIClientWndProc
1192 *
Alexandre Julliard77b99181997-09-14 17:17:23 +00001193 * This function handles all MDI requests.
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001194 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001195LRESULT WINAPI MDIClientWndProc( HWND hwnd, UINT message, WPARAM wParam,
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001196 LPARAM lParam )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001197{
Eric Pouechfa9724f1999-07-23 19:21:56 +00001198 LPCREATESTRUCTA cs;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001199 MDICLIENTINFO *ci;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001200 RECT rect;
Eric Pouechfa9724f1999-07-23 19:21:56 +00001201 WND *w, *frameWnd;
1202 INT nItems;
1203 LRESULT retvalue;
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001204
Eric Pouechfa9724f1999-07-23 19:21:56 +00001205 if ( ( w = WIN_FindWndPtr(hwnd) ) == NULL )
1206 return 0;
1207
1208 if ( ( frameWnd = WIN_LockWndPtr(w->parent) ) == NULL ) {
1209 WIN_ReleaseWndPtr(w);
1210 return 0;
1211 }
1212
1213 ci = (MDICLIENTINFO *) w->wExtra;
1214
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001215 switch (message)
1216 {
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001217 case WM_CREATE:
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001218
Alexandre Julliarda3960291999-02-26 11:11:13 +00001219 cs = (LPCREATESTRUCTA)lParam;
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001220
1221 /* Translation layer doesn't know what's in the cs->lpCreateParams
1222 * so we have to keep track of what environment we're in. */
1223
1224 if( w->flags & WIN_ISWIN32 )
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001225 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001226#define ccs ((LPCLIENTCREATESTRUCT)cs->lpCreateParams)
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001227 ci->hWindowMenu = ccs->hWindowMenu;
1228 ci->idFirstChild = ccs->idFirstChild;
1229#undef ccs
1230 }
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001231 else
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001232 {
1233 LPCLIENTCREATESTRUCT16 ccs = (LPCLIENTCREATESTRUCT16)
1234 PTR_SEG_TO_LIN(cs->lpCreateParams);
1235 ci->hWindowMenu = ccs->hWindowMenu;
1236 ci->idFirstChild = ccs->idFirstChild;
1237 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001238
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001239 ci->hwndChildMaximized = 0;
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +00001240 ci->nActiveChildren = 0;
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001241 ci->nTotalCreated = 0;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001242 ci->frameTitle = NULL;
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001243 ci->mdiFlags = 0;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001244 ci->self = hwnd;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001245 w->dwStyle |= WS_CLIPCHILDREN;
1246
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001247 if (!hBmpClose)
1248 {
1249 hBmpClose = CreateMDIMenuBitmap();
Alexandre Julliardc7c217b1998-04-13 12:21:30 +00001250 hBmpRestore = LoadBitmap16( 0, MAKEINTRESOURCE16(OBM_RESTORE) );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001251 }
1252 MDI_UpdateFrameText(frameWnd, hwnd, MDI_NOFRAMEREPAINT,frameWnd->text);
Alexandre Julliardd4719651995-12-12 18:49:11 +00001253
Matthew Clinec448c5c2000-02-13 15:05:07 +00001254 if (ci->hWindowMenu != 0)
1255 AppendMenuA( ci->hWindowMenu, MF_SEPARATOR, 0, NULL );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001256
Alexandre Julliarda3960291999-02-26 11:11:13 +00001257 GetClientRect(frameWnd->hwndSelf, &rect);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001258 NC_HandleNCCalcSize( w, &rect );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001259 w->rectClient = rect;
1260
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001261 TRACE("Client created - hwnd = %04x, idFirst = %u\n",
Alexandre Julliard77b99181997-09-14 17:17:23 +00001262 hwnd, ci->idFirstChild );
Alexandre Julliardd2e1c1a1996-03-09 16:12:43 +00001263
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001264 retvalue = 0;
1265 goto END;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001266
1267 case WM_DESTROY:
Gerard Patele8a3d072000-01-23 03:19:44 +00001268 if( ci->hwndChildMaximized )
1269 MDI_RestoreFrameMenu(w->parent, ci->hwndChildMaximized);
Matthew Clinec448c5c2000-02-13 15:05:07 +00001270 if((ci->hWindowMenu != 0) &&
1271 (nItems = GetMenuItemCount(ci->hWindowMenu)) > 0)
Alexandre Julliard77b99181997-09-14 17:17:23 +00001272 {
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001273 ci->idFirstChild = nItems - 1;
1274 ci->nActiveChildren++; /* to delete a separator */
1275 while( ci->nActiveChildren-- )
Alexandre Julliarda3960291999-02-26 11:11:13 +00001276 DeleteMenu(ci->hWindowMenu,MF_BYPOSITION,ci->idFirstChild--);
Alexandre Julliard75d86e11996-11-17 18:59:11 +00001277 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001278 retvalue = 0;
1279 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001280
1281 case WM_MDIACTIVATE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001282 if( ci->hwndActiveChild != (HWND)wParam )
1283 SetWindowPos((HWND)wParam, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001284 retvalue = 0;
1285 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001286
1287 case WM_MDICASCADE:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001288 retvalue = MDICascade(w, ci);
1289 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001290
1291 case WM_MDICREATE:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001292 if (lParam) retvalue = MDICreateChild( w, ci, hwnd,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001293 (MDICREATESTRUCTA*)lParam );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001294 else retvalue = 0;
1295 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001296
1297 case WM_MDIDESTROY:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001298 retvalue = MDIDestroyChild( w, ci, hwnd, (HWND)wParam, TRUE );
1299 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001300
1301 case WM_MDIGETACTIVE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001302 if (lParam) *(BOOL *)lParam = (ci->hwndChildMaximized > 0);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001303 retvalue = ci->hwndActiveChild;
1304 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001305
1306 case WM_MDIICONARRANGE:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001307 ci->mdiFlags |= MDIF_NEEDUPDATE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001308 ArrangeIconicWindows(hwnd);
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00001309 ci->sbRecalc = SB_BOTH+1;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001310 SendMessageA(hwnd, WM_MDICALCCHILDSCROLL, 0, 0L);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001311 retvalue = 0;
1312 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001313
1314 case WM_MDIMAXIMIZE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001315 ShowWindow( (HWND)wParam, SW_MAXIMIZE );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001316 retvalue = 0;
1317 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001318
Alexandre Julliard77b99181997-09-14 17:17:23 +00001319 case WM_MDINEXT: /* lParam != 0 means previous window */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001320 MDI_SwitchActiveChild(hwnd, (HWND)wParam, (lParam)? FALSE : TRUE );
Alexandre Julliard58199531994-04-21 01:20:00 +00001321 break;
1322
1323 case WM_MDIRESTORE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001324 SendMessageA( (HWND)wParam, WM_SYSCOMMAND, SC_RESTORE, 0);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001325 retvalue = 0;
1326 goto END;
Alexandre Julliard58199531994-04-21 01:20:00 +00001327
1328 case WM_MDISETMENU:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001329 retvalue = MDISetMenu( hwnd, (HMENU)wParam, (HMENU)lParam );
1330 goto END;
Alexandre Julliard85ed45e1998-08-22 19:03:56 +00001331 case WM_MDIREFRESHMENU:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001332 retvalue = MDIRefreshMenu( hwnd, (HMENU)wParam, (HMENU)lParam );
1333 goto END;
Alexandre Julliard85ed45e1998-08-22 19:03:56 +00001334
Alexandre Julliard58199531994-04-21 01:20:00 +00001335 case WM_MDITILE:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001336 ci->mdiFlags |= MDIF_NEEDUPDATE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001337 ShowScrollBar(hwnd,SB_BOTH,FALSE);
Alexandre Julliard77b99181997-09-14 17:17:23 +00001338 MDITile(w, ci, wParam);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001339 ci->mdiFlags &= ~MDIF_NEEDUPDATE;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001340 retvalue = 0;
1341 goto END;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001342
1343 case WM_VSCROLL:
1344 case WM_HSCROLL:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001345 ci->mdiFlags |= MDIF_NEEDUPDATE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001346 ScrollChildren(hwnd, message, wParam, lParam);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001347 ci->mdiFlags &= ~MDIF_NEEDUPDATE;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001348 retvalue = 0;
1349 goto END;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001350
1351 case WM_SETFOCUS:
1352 if( ci->hwndActiveChild )
Alexandre Julliard77b99181997-09-14 17:17:23 +00001353 {
Eric Pouech8dde5a41999-04-25 10:58:04 +00001354 WND* pw = WIN_FindWndPtr( ci->hwndActiveChild );
1355 if( !(pw->dwStyle & WS_MINIMIZE) )
Alexandre Julliarda3960291999-02-26 11:11:13 +00001356 SetFocus( ci->hwndActiveChild );
Eric Pouech8dde5a41999-04-25 10:58:04 +00001357 WIN_ReleaseWndPtr(pw);
Alexandre Julliard77b99181997-09-14 17:17:23 +00001358 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001359 retvalue = 0;
1360 goto END;
Alexandre Julliard58199531994-04-21 01:20:00 +00001361
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001362 case WM_NCACTIVATE:
Alexandre Julliardd4719651995-12-12 18:49:11 +00001363 if( ci->hwndActiveChild )
Alexandre Julliarda3960291999-02-26 11:11:13 +00001364 SendMessageA(ci->hwndActiveChild, message, wParam, lParam);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001365 break;
1366
1367 case WM_PARENTNOTIFY:
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001368 if (LOWORD(wParam) == WM_LBUTTONDOWN)
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001369 {
1370 POINT16 pt = MAKEPOINT16(lParam);
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001371 HWND16 child = ChildWindowFromPoint16(hwnd, pt);
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001372
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001373 TRACE("notification from %04x (%i,%i)\n",child,pt.x,pt.y);
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001374
Alexandre Julliarda0b2b1d1997-11-16 17:38:29 +00001375 if( child && child != hwnd && child != ci->hwndActiveChild )
Alexandre Julliarda3960291999-02-26 11:11:13 +00001376 SetWindowPos(child, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001377 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001378 retvalue = 0;
1379 goto END;
Alexandre Julliard58199531994-04-21 01:20:00 +00001380
1381 case WM_SIZE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001382 if( IsWindow(ci->hwndChildMaximized) )
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001383 {
1384 WND* child = WIN_FindWndPtr(ci->hwndChildMaximized);
Patrik Stridvall0f8bc5b1999-04-22 16:27:50 +00001385 RECT rect;
1386
1387 rect.left = 0;
1388 rect.top = 0;
1389 rect.right = LOWORD(lParam);
1390 rect.bottom = HIWORD(lParam);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001391
Alexandre Julliarda3960291999-02-26 11:11:13 +00001392 AdjustWindowRectEx(&rect, child->dwStyle, 0, child->dwExStyle);
1393 MoveWindow(ci->hwndChildMaximized, rect.left, rect.top,
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001394 rect.right - rect.left, rect.bottom - rect.top, 1);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001395 WIN_ReleaseWndPtr(child);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001396 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001397 else
Alexandre Julliard77b99181997-09-14 17:17:23 +00001398 MDI_PostUpdate(hwnd, ci, SB_BOTH+1);
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00001399
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001400 break;
1401
Alexandre Julliardd4719651995-12-12 18:49:11 +00001402 case WM_MDICALCCHILDSCROLL:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001403 if( (ci->mdiFlags & MDIF_NEEDUPDATE) && ci->sbRecalc )
1404 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001405 CalcChildScroll16(hwnd, ci->sbRecalc-1);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001406 ci->sbRecalc = 0;
1407 ci->mdiFlags &= ~MDIF_NEEDUPDATE;
1408 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001409 retvalue = 0;
1410 goto END;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001411 }
1412
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001413 retvalue = DefWindowProcA( hwnd, message, wParam, lParam );
1414END:
1415 WIN_ReleaseWndPtr(w);
1416 WIN_ReleaseWndPtr(frameWnd);
1417 return retvalue;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001418}
1419
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001420
1421/***********************************************************************
1422 * DefFrameProc16 (USER.445)
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001423 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001424LRESULT WINAPI DefFrameProc16( HWND16 hwnd, HWND16 hwndMDIClient,
1425 UINT16 message, WPARAM16 wParam, LPARAM lParam )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001426{
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001427 HWND16 childHwnd;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001428 MDICLIENTINFO* ci;
1429 WND* wndPtr;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001430
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001431 if (hwndMDIClient)
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001432 {
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001433 switch (message)
1434 {
1435 case WM_COMMAND:
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001436 wndPtr = WIN_FindWndPtr(hwndMDIClient);
Guy Albertelli4a6af351999-03-13 17:03:41 +00001437
1438 if (!wndPtr) {
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001439 ERR("null wndPtr for mdi window hwndMDIClient=%04x\n",
Guy Albertelli4a6af351999-03-13 17:03:41 +00001440 hwndMDIClient);
1441 return 0;
1442 }
1443
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001444 ci = (MDICLIENTINFO*)wndPtr->wExtra;
1445
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001446 /* check for possible syscommands for maximized MDI child */
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001447 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001448
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001449 if( ci && (
1450 wParam < ci->idFirstChild ||
1451 wParam >= ci->idFirstChild + ci->nActiveChildren
1452 )){
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001453 if( (wParam - 0xF000) & 0xF00F ) break;
1454 switch( wParam )
1455 {
1456 case SC_SIZE:
1457 case SC_MOVE:
1458 case SC_MINIMIZE:
1459 case SC_MAXIMIZE:
1460 case SC_NEXTWINDOW:
1461 case SC_PREVWINDOW:
1462 case SC_CLOSE:
1463 case SC_RESTORE:
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001464 if( ci->hwndChildMaximized )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001465 return SendMessage16( ci->hwndChildMaximized, WM_SYSCOMMAND,
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001466 wParam, lParam);
1467 }
1468 }
1469 else
1470 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001471 wndPtr = WIN_FindWndPtr(hwndMDIClient);
David Lassondef58d80d2000-06-15 01:03:32 +00001472 ci = (MDICLIENTINFO*)wndPtr->wExtra;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001473
David Lassondef58d80d2000-06-15 01:03:32 +00001474 if (wParam - ci->idFirstChild == MDI_MOREWINDOWSLIMIT)
1475 /* User chose "More Windows..." */
1476 childHwnd = MDI_MoreWindowsDialog(wndPtr);
1477 else
1478 /* User chose one of the windows listed in the "Windows" menu */
1479 childHwnd = MDI_GetChildByID(wndPtr,wParam );
1480
1481 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001482 if( childHwnd )
Alexandre Julliard530ee841996-10-23 16:59:13 +00001483 SendMessage16(hwndMDIClient, WM_MDIACTIVATE,
1484 (WPARAM16)childHwnd , 0L);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001485 }
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001486 break;
Alexandre Julliard58199531994-04-21 01:20:00 +00001487
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001488 case WM_NCACTIVATE:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001489 SendMessage16(hwndMDIClient, message, wParam, lParam);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001490 break;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001491
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001492 case WM_SETTEXT:
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00001493 {
1494 LPWSTR text = HEAP_strdupAtoW( GetProcessHeap(), 0,
1495 (LPCSTR)PTR_SEG_TO_LIN(lParam) );
1496 wndPtr = WIN_FindWndPtr(hwnd);
1497 MDI_UpdateFrameText(wndPtr, hwndMDIClient,
1498 MDI_REPAINTFRAME, text );
1499 WIN_ReleaseWndPtr(wndPtr);
1500 HeapFree( GetProcessHeap(), 0, text );
1501 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001502 return 0;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001503
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001504 case WM_SETFOCUS:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001505 SetFocus(hwndMDIClient);
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001506 break;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001507
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001508 case WM_SIZE:
Alexandre Julliard01d63461997-01-20 19:43:45 +00001509 MoveWindow16(hwndMDIClient, 0, 0,
1510 LOWORD(lParam), HIWORD(lParam), TRUE);
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001511 break;
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001512
1513 case WM_NEXTMENU:
1514
1515 wndPtr = WIN_FindWndPtr(hwndMDIClient);
1516 ci = (MDICLIENTINFO*)wndPtr->wExtra;
1517
1518 if( !(wndPtr->parent->dwStyle & WS_MINIMIZE)
1519 && ci->hwndActiveChild && !ci->hwndChildMaximized )
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001520 {
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001521 /* control menu is between the frame system menu and
1522 * the first entry of menu bar */
1523
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001524 if( (wParam == VK_LEFT &&
1525 wndPtr->parent->wIDmenu == LOWORD(lParam)) ||
1526 (wParam == VK_RIGHT &&
1527 GetSubMenu16(wndPtr->parent->hSysMenu, 0) == LOWORD(lParam)) )
1528 {
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001529 LRESULT retvalue;
1530 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001531 wndPtr = WIN_FindWndPtr(ci->hwndActiveChild);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001532 retvalue = MAKELONG( GetSubMenu16(wndPtr->hSysMenu, 0),
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001533 ci->hwndActiveChild);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001534 WIN_ReleaseWndPtr(wndPtr);
1535 return retvalue;
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001536 }
1537 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001538 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001539 break;
Alexandre Julliard7cc9c0c1994-06-15 15:45:11 +00001540 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001541 }
1542
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001543 return DefWindowProc16(hwnd, message, wParam, lParam);
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001544}
1545
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001546
1547/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001548 * DefFrameProcA (USER32.122)
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001549 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001550LRESULT WINAPI DefFrameProcA( HWND hwnd, HWND hwndMDIClient,
1551 UINT message, WPARAM wParam, LPARAM lParam)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001552{
1553 if (hwndMDIClient)
1554 {
1555 switch (message)
1556 {
1557 case WM_COMMAND:
1558 return DefFrameProc16( hwnd, hwndMDIClient, message,
1559 (WPARAM16)wParam,
1560 MAKELPARAM( (HWND16)lParam, HIWORD(wParam) ) );
1561
1562 case WM_NCACTIVATE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001563 SendMessageA(hwndMDIClient, message, wParam, lParam);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001564 break;
1565
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001566 case WM_SETTEXT: {
1567 LRESULT ret;
1568 LPSTR segstr = SEGPTR_STRDUP((LPSTR)lParam);
1569
1570 ret = DefFrameProc16(hwnd, hwndMDIClient, message,
1571 wParam, (LPARAM)SEGPTR_GET(segstr) );
1572 SEGPTR_FREE(segstr);
1573 return ret;
1574 }
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001575
NF Stevens95524831998-10-26 10:44:17 +00001576 case WM_NEXTMENU:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001577 case WM_SETFOCUS:
1578 case WM_SIZE:
1579 return DefFrameProc16( hwnd, hwndMDIClient, message,
1580 wParam, lParam );
1581 }
1582 }
1583
Alexandre Julliarda3960291999-02-26 11:11:13 +00001584 return DefWindowProcA(hwnd, message, wParam, lParam);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001585}
1586
1587
1588/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001589 * DefFrameProcW (USER32.123)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001590 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001591LRESULT WINAPI DefFrameProcW( HWND hwnd, HWND hwndMDIClient,
1592 UINT message, WPARAM wParam, LPARAM lParam)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001593{
1594 if (hwndMDIClient)
1595 {
1596 switch (message)
1597 {
1598 case WM_COMMAND:
1599 return DefFrameProc16( hwnd, hwndMDIClient, message,
1600 (WPARAM16)wParam,
1601 MAKELPARAM( (HWND16)lParam, HIWORD(wParam) ) );
1602
1603 case WM_NCACTIVATE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001604 SendMessageW(hwndMDIClient, message, wParam, lParam);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001605 break;
1606
Alexandre Julliard77b99181997-09-14 17:17:23 +00001607 case WM_SETTEXT:
1608 {
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001609 LPSTR txt = HEAP_strdupWtoA(GetProcessHeap(),0,(LPWSTR)lParam);
Alexandre Julliarda3960291999-02-26 11:11:13 +00001610 LRESULT ret = DefFrameProcA( hwnd, hwndMDIClient, message,
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001611 wParam, (DWORD)txt );
1612 HeapFree(GetProcessHeap(),0,txt);
1613 return ret;
1614 }
NF Stevens95524831998-10-26 10:44:17 +00001615 case WM_NEXTMENU:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001616 case WM_SETFOCUS:
1617 case WM_SIZE:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001618 return DefFrameProcA( hwnd, hwndMDIClient, message,
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001619 wParam, lParam );
1620 }
1621 }
1622
Alexandre Julliarda3960291999-02-26 11:11:13 +00001623 return DefWindowProcW( hwnd, message, wParam, lParam );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001624}
1625
1626
1627/***********************************************************************
1628 * DefMDIChildProc16 (USER.447)
1629 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00001630LRESULT WINAPI DefMDIChildProc16( HWND16 hwnd, UINT16 message,
1631 WPARAM16 wParam, LPARAM lParam )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001632{
1633 MDICLIENTINFO *ci;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001634 WND *clientWnd,*tmpWnd = 0;
1635 LRESULT retvalue;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001636
Marcus Meissnere6c63901999-12-12 19:39:37 +00001637 tmpWnd = WIN_FindWndPtr(hwnd);
1638 if (!tmpWnd) return 0;
1639 clientWnd = WIN_FindWndPtr(tmpWnd->parent->hwndSelf);
Alexandre Julliardd4719651995-12-12 18:49:11 +00001640 ci = (MDICLIENTINFO *) clientWnd->wExtra;
Marcus Meissnere6c63901999-12-12 19:39:37 +00001641 WIN_ReleaseWndPtr(tmpWnd);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001642
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001643 switch (message)
1644 {
Alexandre Julliardd4719651995-12-12 18:49:11 +00001645 case WM_SETTEXT:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001646 DefWindowProc16(hwnd, message, wParam, lParam);
Alexandre Julliardd4719651995-12-12 18:49:11 +00001647 MDI_MenuModifyItem(clientWnd,hwnd);
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001648 if( ci->hwndChildMaximized == hwnd )
Alexandre Julliard59730ae1996-03-24 16:20:51 +00001649 MDI_UpdateFrameText( clientWnd->parent, ci->self,
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001650 MDI_REPAINTFRAME, NULL );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001651 retvalue = 0;
1652 goto END;
Alexandre Julliard58199531994-04-21 01:20:00 +00001653
Alexandre Julliardd4719651995-12-12 18:49:11 +00001654 case WM_CLOSE:
Alexandre Julliard530ee841996-10-23 16:59:13 +00001655 SendMessage16(ci->self,WM_MDIDESTROY,(WPARAM16)hwnd,0L);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001656 retvalue = 0;
1657 goto END;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001658
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001659 case WM_SETFOCUS:
Alexandre Julliardd4719651995-12-12 18:49:11 +00001660 if( ci->hwndActiveChild != hwnd )
1661 MDI_ChildActivate(clientWnd, hwnd);
1662 break;
1663
1664 case WM_CHILDACTIVATE:
1665 MDI_ChildActivate(clientWnd, hwnd);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001666 retvalue = 0;
1667 goto END;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001668
1669 case WM_NCPAINT:
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001670 TRACE("WM_NCPAINT for %04x, active %04x\n",
Alexandre Julliardd4719651995-12-12 18:49:11 +00001671 hwnd, ci->hwndActiveChild );
1672 break;
1673
Alexandre Julliard58199531994-04-21 01:20:00 +00001674 case WM_SYSCOMMAND:
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001675 switch( wParam )
Alexandre Julliard77b99181997-09-14 17:17:23 +00001676 {
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001677 case SC_MOVE:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001678 if( ci->hwndChildMaximized == hwnd)
1679 {
1680 retvalue = 0;
1681 goto END;
1682 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001683 break;
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001684 case SC_RESTORE:
1685 case SC_MINIMIZE:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001686 tmpWnd = WIN_FindWndPtr(hwnd);
1687 tmpWnd->dwStyle |= WS_SYSMENU;
1688 WIN_ReleaseWndPtr(tmpWnd);
Alexandre Julliard2c69f6d1996-09-28 18:11:01 +00001689 break;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001690 case SC_MAXIMIZE:
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001691 if( ci->hwndChildMaximized == hwnd)
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001692 {
1693 retvalue = SendMessage16( clientWnd->parent->hwndSelf,
Alexandre Julliard59730ae1996-03-24 16:20:51 +00001694 message, wParam, lParam);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001695 goto END;
1696 }
1697 tmpWnd = WIN_FindWndPtr(hwnd);
1698 tmpWnd->dwStyle &= ~WS_SYSMENU;
1699 WIN_ReleaseWndPtr(tmpWnd);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001700 break;
1701 case SC_NEXTWINDOW:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001702 SendMessage16( ci->self, WM_MDINEXT, 0, 0);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001703 retvalue = 0;
1704 goto END;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001705 case SC_PREVWINDOW:
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001706 SendMessage16( ci->self, WM_MDINEXT, 0, 1);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001707 retvalue = 0;
1708 goto END;
Alexandre Julliard77b99181997-09-14 17:17:23 +00001709 }
Alexandre Julliard58199531994-04-21 01:20:00 +00001710 break;
1711
Alexandre Julliardd4719651995-12-12 18:49:11 +00001712 case WM_GETMINMAXINFO:
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001713 MDI_ChildGetMinMaxInfo(clientWnd, hwnd, (MINMAXINFO16*) PTR_SEG_TO_LIN(lParam));
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001714 retvalue = 0;
1715 goto END;
Alexandre Julliardd4719651995-12-12 18:49:11 +00001716
1717 case WM_SETVISIBLE:
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00001718 if( ci->hwndChildMaximized) ci->mdiFlags &= ~MDIF_NEEDUPDATE;
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00001719 else
1720 MDI_PostUpdate(clientWnd->hwndSelf, ci, SB_BOTH+1);
Alexandre Julliardd4719651995-12-12 18:49:11 +00001721 break;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001722
1723 case WM_SIZE:
1724 /* do not change */
1725
1726 if( ci->hwndActiveChild == hwnd && wParam != SIZE_MAXIMIZED )
Alexandre Julliard77b99181997-09-14 17:17:23 +00001727 {
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001728 ci->hwndChildMaximized = 0;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001729
Alexandre Julliard59730ae1996-03-24 16:20:51 +00001730 MDI_RestoreFrameMenu( clientWnd->parent, hwnd);
1731 MDI_UpdateFrameText( clientWnd->parent, ci->self,
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001732 MDI_REPAINTFRAME, NULL );
Alexandre Julliard77b99181997-09-14 17:17:23 +00001733 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001734
1735 if( wParam == SIZE_MAXIMIZED )
Alexandre Julliard77b99181997-09-14 17:17:23 +00001736 {
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00001737 HWND16 hMaxChild = ci->hwndChildMaximized;
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001738
1739 if( hMaxChild == hwnd ) break;
1740
1741 if( hMaxChild)
Alexandre Julliard77b99181997-09-14 17:17:23 +00001742 {
1743 SendMessage16( hMaxChild, WM_SETREDRAW, FALSE, 0L );
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001744
Alexandre Julliard77b99181997-09-14 17:17:23 +00001745 MDI_RestoreFrameMenu( clientWnd->parent, hMaxChild);
1746 ShowWindow16( hMaxChild, SW_SHOWNOACTIVATE);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001747
Alexandre Julliard77b99181997-09-14 17:17:23 +00001748 SendMessage16( hMaxChild, WM_SETREDRAW, TRUE, 0L );
1749 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001750
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001751 TRACE("maximizing child %04x\n", hwnd );
Alexandre Julliard18f92e71996-07-17 20:02:21 +00001752
Alexandre Julliardbd616cb2000-09-01 01:23:03 +00001753 /*
1754 * Keep track of the maximized window.
1755 */
Alexandre Julliarde2bfa4c1996-05-16 18:21:06 +00001756 ci->hwndChildMaximized = hwnd; /* !!! */
Alexandre Julliardbd616cb2000-09-01 01:23:03 +00001757
1758 /*
1759 * The maximized window should also be the active window
1760 */
1761 MDI_ChildActivate(clientWnd, hwnd);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001762
Alexandre Julliard59730ae1996-03-24 16:20:51 +00001763 MDI_AugmentFrameMenu( ci, clientWnd->parent, hwnd);
1764 MDI_UpdateFrameText( clientWnd->parent, ci->self,
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001765 MDI_REPAINTFRAME, NULL );
Alexandre Julliard77b99181997-09-14 17:17:23 +00001766 }
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001767
1768 if( wParam == SIZE_MINIMIZED )
Alexandre Julliard77b99181997-09-14 17:17:23 +00001769 {
1770 HWND16 switchTo = MDI_GetWindow(clientWnd, hwnd, TRUE, WS_MINIMIZE);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00001771
1772 if( switchTo )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001773 SendMessage16( switchTo, WM_CHILDACTIVATE, 0, 0L);
Alexandre Julliard77b99181997-09-14 17:17:23 +00001774 }
1775
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00001776 MDI_PostUpdate(clientWnd->hwndSelf, ci, SB_BOTH+1);
Alexandre Julliardd4719651995-12-12 18:49:11 +00001777 break;
1778
1779 case WM_MENUCHAR:
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001780
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001781 /* MDI children don't have menu bars */
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001782 retvalue = 0x00010000L;
1783 goto END;
Alexandre Julliardc981d0b1996-03-31 16:40:13 +00001784
Alexandre Julliardd4719651995-12-12 18:49:11 +00001785 case WM_NEXTMENU:
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001786
1787 if( wParam == VK_LEFT ) /* switch to frame system menu */
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001788 {
1789 retvalue = MAKELONG( GetSubMenu16(clientWnd->parent->hSysMenu, 0),
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001790 clientWnd->parent->hwndSelf );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001791 goto END;
1792 }
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001793 if( wParam == VK_RIGHT ) /* to frame menu bar */
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001794 {
1795 retvalue = MAKELONG( clientWnd->parent->wIDmenu,
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001796 clientWnd->parent->hwndSelf );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001797 goto END;
1798 }
Alexandre Julliardd4719651995-12-12 18:49:11 +00001799
1800 break;
NF Stevens95524831998-10-26 10:44:17 +00001801
1802 case WM_SYSCHAR:
1803 if (wParam == '-')
1804 {
1805 SendMessage16(hwnd,WM_SYSCOMMAND,
1806 (WPARAM16)SC_KEYMENU, (LPARAM)(DWORD)VK_SPACE);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001807 retvalue = 0;
1808 goto END;
NF Stevens95524831998-10-26 10:44:17 +00001809 }
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001810 }
1811
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001812 retvalue = DefWindowProc16(hwnd, message, wParam, lParam);
1813END:
1814 WIN_ReleaseWndPtr(clientWnd);
Veksler Michael3130fce1999-03-22 12:37:09 +00001815 return retvalue;
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001816}
1817
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001818
1819/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001820 * DefMDIChildProcA (USER32.124)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001821 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001822LRESULT WINAPI DefMDIChildProcA( HWND hwnd, UINT message,
1823 WPARAM wParam, LPARAM lParam )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001824{
1825 MDICLIENTINFO *ci;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001826 WND *clientWnd,*tmpWnd;
1827 LRESULT retvalue;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001828
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001829 tmpWnd = WIN_FindWndPtr(hwnd);
Marcus Meissnere6c63901999-12-12 19:39:37 +00001830 if (!tmpWnd) return 0;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001831 clientWnd = WIN_FindWndPtr(tmpWnd->parent->hwndSelf);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001832 ci = (MDICLIENTINFO *) clientWnd->wExtra;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001833 WIN_ReleaseWndPtr(tmpWnd);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001834
1835 switch (message)
1836 {
1837 case WM_SETTEXT:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001838 DefWindowProcA(hwnd, message, wParam, lParam);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001839 MDI_MenuModifyItem(clientWnd,hwnd);
1840 if( ci->hwndChildMaximized == hwnd )
1841 MDI_UpdateFrameText( clientWnd->parent, ci->self,
1842 MDI_REPAINTFRAME, NULL );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001843 retvalue = 0;
1844 goto END;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001845
1846 case WM_GETMINMAXINFO:
1847 {
1848 MINMAXINFO16 mmi;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001849 STRUCT32_MINMAXINFO32to16( (MINMAXINFO *)lParam, &mmi );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001850 MDI_ChildGetMinMaxInfo( clientWnd, hwnd, &mmi );
Alexandre Julliarda3960291999-02-26 11:11:13 +00001851 STRUCT32_MINMAXINFO16to32( &mmi, (MINMAXINFO *)lParam );
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001852 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001853 retvalue = 0;
1854 goto END;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001855
1856 case WM_MENUCHAR:
1857
Alexandre Julliard1e37a181996-08-18 16:21:52 +00001858 /* MDI children don't have menu bars */
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001859 retvalue = 0x00010000L;
1860 goto END;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001861
1862 case WM_CLOSE:
1863 case WM_SETFOCUS:
1864 case WM_CHILDACTIVATE:
1865 case WM_NCPAINT:
1866 case WM_SYSCOMMAND:
1867 case WM_SETVISIBLE:
1868 case WM_SIZE:
1869 case WM_NEXTMENU:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001870 retvalue = DefMDIChildProc16( hwnd, message, (WPARAM16)wParam, lParam );
1871 goto END;
NF Stevens95524831998-10-26 10:44:17 +00001872
1873 case WM_SYSCHAR:
1874 if (wParam == '-')
1875 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001876 SendMessageA(hwnd,WM_SYSCOMMAND,
1877 (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)VK_SPACE);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001878 retvalue = 0;
1879 goto END;
NF Stevens95524831998-10-26 10:44:17 +00001880 }
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001881 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001882 retvalue = DefWindowProcA(hwnd, message, wParam, lParam);
1883END:
1884 WIN_ReleaseWndPtr(clientWnd);
1885 return retvalue;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001886}
1887
1888
1889/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001890 * DefMDIChildProcW (USER32.125)
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001891 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001892LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message,
1893 WPARAM wParam, LPARAM lParam )
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001894{
1895 MDICLIENTINFO *ci;
Marcus Meissnere6c63901999-12-12 19:39:37 +00001896 WND *clientWnd,*tmpWnd;
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001897 LRESULT retvalue;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001898
Marcus Meissnere6c63901999-12-12 19:39:37 +00001899 tmpWnd = WIN_FindWndPtr(hwnd);
1900 if (!tmpWnd) return 0;
1901 clientWnd = WIN_FindWndPtr(tmpWnd->parent->hwndSelf);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001902 ci = (MDICLIENTINFO *) clientWnd->wExtra;
Marcus Meissnere6c63901999-12-12 19:39:37 +00001903 WIN_ReleaseWndPtr(tmpWnd);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001904
1905 switch (message)
1906 {
1907 case WM_SETTEXT:
Alexandre Julliarda3960291999-02-26 11:11:13 +00001908 DefWindowProcW(hwnd, message, wParam, lParam);
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001909 MDI_MenuModifyItem(clientWnd,hwnd);
1910 if( ci->hwndChildMaximized == hwnd )
1911 MDI_UpdateFrameText( clientWnd->parent, ci->self,
1912 MDI_REPAINTFRAME, NULL );
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001913 retvalue = 0;
1914 goto END;
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001915
1916 case WM_GETMINMAXINFO:
1917 case WM_MENUCHAR:
1918 case WM_CLOSE:
1919 case WM_SETFOCUS:
1920 case WM_CHILDACTIVATE:
1921 case WM_NCPAINT:
1922 case WM_SYSCOMMAND:
1923 case WM_SETVISIBLE:
1924 case WM_SIZE:
1925 case WM_NEXTMENU:
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001926 retvalue = DefMDIChildProcA( hwnd, message, (WPARAM16)wParam, lParam );
1927 goto END;
NF Stevens95524831998-10-26 10:44:17 +00001928
1929 case WM_SYSCHAR:
1930 if (wParam == '-')
1931 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00001932 SendMessageW(hwnd,WM_SYSCOMMAND,
1933 (WPARAM)SC_KEYMENU, (LPARAM)(DWORD)VK_SPACE);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001934 retvalue = 0;
1935 goto END;
NF Stevens95524831998-10-26 10:44:17 +00001936 }
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001937 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001938 retvalue = DefWindowProcW(hwnd, message, wParam, lParam);
1939END:
1940 WIN_ReleaseWndPtr(clientWnd);
1941 return retvalue;
1942
Alexandre Julliard2d93d001996-05-21 15:01:41 +00001943}
1944
1945
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001946/**********************************************************************
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001947 * CreateMDIWindowA [USER32.79] Creates a MDI child in new thread
1948 * FIXME: its in the same thread now
1949 *
1950 * RETURNS
1951 * Success: Handle to created window
1952 * Failure: NULL
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00001953 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001954HWND WINAPI CreateMDIWindowA(
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001955 LPCSTR lpClassName, /* [in] Pointer to registered child class name */
1956 LPCSTR lpWindowName, /* [in] Pointer to window name */
1957 DWORD dwStyle, /* [in] Window style */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001958 INT X, /* [in] Horizontal position of window */
1959 INT Y, /* [in] Vertical position of window */
1960 INT nWidth, /* [in] Width of window */
1961 INT nHeight, /* [in] Height of window */
1962 HWND hWndParent, /* [in] Handle to parent window */
1963 HINSTANCE hInstance, /* [in] Handle to application instance */
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001964 LPARAM lParam) /* [in] Application-defined value */
1965{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001966 WARN("is only single threaded!\n");
Alexandre Julliarda3960291999-02-26 11:11:13 +00001967 return MDI_CreateMDIWindowA(lpClassName, lpWindowName, dwStyle, X, Y,
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001968 nWidth, nHeight, hWndParent, hInstance, lParam);
1969}
1970
1971/**********************************************************************
1972 * MDI_CreateMDIWindowA
1973 * single threaded version of CreateMDIWindowA
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00001974 * called by CreateWindowExA
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001975 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00001976HWND MDI_CreateMDIWindowA(
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00001977 LPCSTR lpClassName,
1978 LPCSTR lpWindowName,
1979 DWORD dwStyle,
Alexandre Julliarda3960291999-02-26 11:11:13 +00001980 INT X,
1981 INT Y,
1982 INT nWidth,
1983 INT nHeight,
1984 HWND hWndParent,
1985 HINSTANCE hInstance,
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00001986 LPARAM lParam)
1987{
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001988 MDICLIENTINFO* pCi;
Alexandre Julliarda3960291999-02-26 11:11:13 +00001989 MDICREATESTRUCTA cs;
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001990 WND *pWnd=WIN_FindWndPtr(hWndParent);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00001991 HWND retvalue;
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001992
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001993 TRACE("(%s,%s,%ld,%d,%d,%d,%d,%x,%d,%ld)\n",
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001994 debugstr_a(lpClassName),debugstr_a(lpWindowName),dwStyle,X,Y,
1995 nWidth,nHeight,hWndParent,hInstance,lParam);
1996
1997 if(!pWnd){
Alexandre Julliard359f497e1999-07-04 16:02:24 +00001998 ERR(" bad hwnd for MDI-client: %d\n",hWndParent);
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00001999 return 0;
2000 }
2001 cs.szClass=lpClassName;
2002 cs.szTitle=lpWindowName;
2003 cs.hOwner=hInstance;
2004 cs.x=X;
2005 cs.y=Y;
2006 cs.cx=nWidth;
2007 cs.cy=nHeight;
2008 cs.style=dwStyle;
2009 cs.lParam=lParam;
2010
2011 pCi=(MDICLIENTINFO *)pWnd->wExtra;
2012
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002013 retvalue = MDICreateChild(pWnd,pCi,hWndParent,&cs);
2014 WIN_ReleaseWndPtr(pWnd);
2015 return retvalue;
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00002016}
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002017
Patrik Stridvall54fe8382000-04-06 20:21:16 +00002018/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00002019 * CreateMDIWindowW [USER32.80] Creates a MDI child in new thread
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00002020 *
2021 * RETURNS
2022 * Success: Handle to created window
2023 * Failure: NULL
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002024 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002025HWND WINAPI CreateMDIWindowW(
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002026 LPCWSTR lpClassName, /* [in] Pointer to registered child class name */
2027 LPCWSTR lpWindowName, /* [in] Pointer to window name */
2028 DWORD dwStyle, /* [in] Window style */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002029 INT X, /* [in] Horizontal position of window */
2030 INT Y, /* [in] Vertical position of window */
2031 INT nWidth, /* [in] Width of window */
2032 INT nHeight, /* [in] Height of window */
2033 HWND hWndParent, /* [in] Handle to parent window */
2034 HINSTANCE hInstance, /* [in] Handle to application instance */
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002035 LPARAM lParam) /* [in] Application-defined value */
2036{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002037 FIXME("(%s,%s,%ld,%d,%d,%d,%d,%x,%d,%ld): stub\n",
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002038 debugstr_w(lpClassName),debugstr_w(lpWindowName),dwStyle,X,Y,
2039 nWidth,nHeight,hWndParent,hInstance,lParam);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002040 return (HWND)NULL;
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002041}
2042
2043
2044/******************************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00002045 * CreateMDIWindowW [USER32.80] Creates a MDI child window
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002046 * single threaded version of CreateMDIWindow
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00002047 * called by CreateWindowExW().
Rein Klazes5c6fc1b1998-11-01 14:50:06 +00002048 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002049HWND MDI_CreateMDIWindowW(
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00002050 LPCWSTR lpClassName, /* [in] Pointer to registered child class name */
2051 LPCWSTR lpWindowName, /* [in] Pointer to window name */
2052 DWORD dwStyle, /* [in] Window style */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002053 INT X, /* [in] Horizontal position of window */
2054 INT Y, /* [in] Vertical position of window */
2055 INT nWidth, /* [in] Width of window */
2056 INT nHeight, /* [in] Height of window */
2057 HWND hWndParent, /* [in] Handle to parent window */
2058 HINSTANCE hInstance, /* [in] Handle to application instance */
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00002059 LPARAM lParam) /* [in] Application-defined value */
2060{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002061 FIXME("(%s,%s,%ld,%d,%d,%d,%d,%x,%d,%ld): stub\n",
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00002062 debugstr_w(lpClassName),debugstr_w(lpWindowName),dwStyle,X,Y,
2063 nWidth,nHeight,hWndParent,hInstance,lParam);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002064 return (HWND)NULL;
Alexandre Julliard46ea8b31998-05-03 19:01:20 +00002065}
2066
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002067
2068/**********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00002069 * TranslateMDISysAccel (USER32.555)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002070 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002071BOOL WINAPI TranslateMDISysAccel( HWND hwndClient, LPMSG msg )
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002072{
2073 MSG16 msg16;
2074
2075 STRUCT32_MSG32to16(msg,&msg16);
2076 /* MDICLIENTINFO is still the same for win32 and win16 ... */
2077 return TranslateMDISysAccel16(hwndClient,&msg16);
2078}
2079
2080
2081/**********************************************************************
2082 * TranslateMDISysAccel16 (USER.451)
2083 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002084BOOL16 WINAPI TranslateMDISysAccel16( HWND16 hwndClient, LPMSG16 msg )
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00002085{
Alexandre Julliard7e56f681996-01-31 19:02:28 +00002086
Francois Boisvertd753a991999-05-01 10:19:35 +00002087 if( IsWindow(hwndClient) && (msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN))
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002088 {
2089 MDICLIENTINFO *ci = NULL;
Francois Boisvertd753a991999-05-01 10:19:35 +00002090 HWND wnd;
2091 WND *clientWnd = WIN_FindWndPtr(hwndClient);
Alexandre Julliard7e56f681996-01-31 19:02:28 +00002092
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002093 ci = (MDICLIENTINFO*) clientWnd->wExtra;
Francois Boisvertd753a991999-05-01 10:19:35 +00002094 wnd = ci->hwndActiveChild;
2095
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002096 WIN_ReleaseWndPtr(clientWnd);
Francois Boisvertd753a991999-05-01 10:19:35 +00002097
2098 if( IsWindow(wnd) && !(GetWindowLongA(wnd,GWL_STYLE) & WS_DISABLED) )
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002099 {
2100 WPARAM16 wParam = 0;
2101
2102 /* translate if the Ctrl key is down and Alt not. */
Alexandre Julliard7e56f681996-01-31 19:02:28 +00002103
Alexandre Julliarda3960291999-02-26 11:11:13 +00002104 if( (GetKeyState(VK_CONTROL) & 0x8000) &&
2105 !(GetKeyState(VK_MENU) & 0x8000))
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002106 {
2107 switch( msg->wParam )
2108 {
2109 case VK_F6:
Alexandre Julliard44ed71f1997-12-21 19:17:50 +00002110 case VK_TAB:
Alexandre Julliarda3960291999-02-26 11:11:13 +00002111 wParam = ( GetKeyState(VK_SHIFT) & 0x8000 )
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002112 ? SC_NEXTWINDOW : SC_PREVWINDOW;
2113 break;
2114 case VK_F4:
2115 case VK_RBUTTON:
2116 wParam = SC_CLOSE;
2117 break;
2118 default:
2119 return 0;
2120 }
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002121 TRACE("wParam = %04x\n", wParam);
Alexandre Julliard7ff1c411997-05-25 13:58:18 +00002122 SendMessage16( ci->hwndActiveChild, WM_SYSCOMMAND,
2123 wParam, (LPARAM)msg->wParam);
2124 return 1;
2125 }
2126 }
2127 }
2128 return 0; /* failure */
Alexandre Julliard8d24ae61994-04-05 21:42:43 +00002129}
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +00002130
2131
2132/***********************************************************************
2133 * CalcChildScroll (USER.462)
2134 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002135void WINAPI CalcChildScroll16( HWND16 hwnd, WORD scroll )
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +00002136{
Alex Korobkad2085841998-10-18 10:37:46 +00002137 SCROLLINFO info;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002138 RECT childRect, clientRect;
2139 INT vmin, vmax, hmin, hmax, vpos, hpos;
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002140 WND *pWnd, *Wnd;
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +00002141
Gerard Patele38b0e11999-04-10 16:28:12 +00002142 if (!(pWnd = WIN_FindWndPtr( hwnd ))) return;
2143 Wnd = WIN_FindWndPtr(hwnd);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002144 GetClientRect( hwnd, &clientRect );
2145 SetRectEmpty( &childRect );
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002146
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002147 for ( WIN_UpdateWndPtr(&pWnd,pWnd->child); pWnd; WIN_UpdateWndPtr(&pWnd,pWnd->next))
Alexandre Julliarda0d77311998-09-13 16:32:00 +00002148 {
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002149 if( pWnd->dwStyle & WS_MAXIMIZE )
Alexandre Julliarda0d77311998-09-13 16:32:00 +00002150 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002151 ShowScrollBar(hwnd, SB_BOTH, FALSE);
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002152 WIN_ReleaseWndPtr(pWnd);
Gerard Patele38b0e11999-04-10 16:28:12 +00002153 WIN_ReleaseWndPtr(Wnd);
Alexandre Julliarda0d77311998-09-13 16:32:00 +00002154 return;
2155 }
Alexandre Julliarda3960291999-02-26 11:11:13 +00002156 UnionRect( &childRect, &pWnd->rectWindow, &childRect );
Alexandre Julliarda0d77311998-09-13 16:32:00 +00002157 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002158 WIN_ReleaseWndPtr(pWnd);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002159 UnionRect( &childRect, &clientRect, &childRect );
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +00002160
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002161 hmin = childRect.left; hmax = childRect.right - clientRect.right;
2162 hpos = clientRect.left - childRect.left;
2163 vmin = childRect.top; vmax = childRect.bottom - clientRect.bottom;
2164 vpos = clientRect.top - childRect.top;
2165
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002166 switch( scroll )
Alexandre Julliarda0d77311998-09-13 16:32:00 +00002167 {
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002168 case SB_HORZ:
2169 vpos = hpos; vmin = hmin; vmax = hmax;
2170 case SB_VERT:
Alex Korobkad2085841998-10-18 10:37:46 +00002171 info.cbSize = sizeof(info);
2172 info.nMax = vmax; info.nMin = vmin; info.nPos = vpos;
2173 info.fMask = SIF_POS | SIF_RANGE;
Alexandre Julliarda3960291999-02-26 11:11:13 +00002174 SetScrollInfo(hwnd, scroll, &info, TRUE);
Alexandre Julliardcdcdede1996-04-21 14:57:41 +00002175 break;
2176 case SB_BOTH:
2177 SCROLL_SetNCSbState( Wnd, vmin, vmax, vpos,
2178 hmin, hmax, hpos);
Alexandre Julliarda0d77311998-09-13 16:32:00 +00002179 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002180 WIN_ReleaseWndPtr(Wnd);
Alexandre Julliardbd34d4f1995-06-20 19:08:12 +00002181}
Alexandre Julliardd4719651995-12-12 18:49:11 +00002182
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002183
Alexandre Julliardd4719651995-12-12 18:49:11 +00002184/***********************************************************************
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002185 * ScrollChildren16 (USER.463)
Alexandre Julliardd4719651995-12-12 18:49:11 +00002186 */
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002187void WINAPI ScrollChildren16(HWND16 hWnd, UINT16 uMsg, WPARAM16 wParam, LPARAM lParam)
Alexandre Julliardd4719651995-12-12 18:49:11 +00002188{
Patrik Stridvall0f8bc5b1999-04-22 16:27:50 +00002189 ScrollChildren( hWnd, uMsg, wParam, lParam );
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002190}
2191
2192
2193/***********************************************************************
Patrik Stridvall2d6457c2000-03-28 20:22:59 +00002194 * ScrollChildren (USER32.448)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002195 */
Alexandre Julliarda3960291999-02-26 11:11:13 +00002196void WINAPI ScrollChildren(HWND hWnd, UINT uMsg, WPARAM wParam,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002197 LPARAM lParam)
Alexandre Julliardf0cbfa01997-02-15 14:29:56 +00002198{
2199 WND *wndPtr = WIN_FindWndPtr(hWnd);
Alexandre Julliarda3960291999-02-26 11:11:13 +00002200 INT newPos = -1;
2201 INT curPos, length, minPos, maxPos, shift;
Alexandre Julliardd4719651995-12-12 18:49:11 +00002202
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002203 if( !wndPtr ) return;
Alexandre Julliardd4719651995-12-12 18:49:11 +00002204
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002205 if( uMsg == WM_HSCROLL )
2206 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002207 GetScrollRange(hWnd,SB_HORZ,&minPos,&maxPos);
2208 curPos = GetScrollPos(hWnd,SB_HORZ);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002209 length = (wndPtr->rectClient.right - wndPtr->rectClient.left)/2;
Marcus Meissnerddca3151999-05-22 11:33:23 +00002210 shift = GetSystemMetrics(SM_CYHSCROLL);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002211 }
2212 else if( uMsg == WM_VSCROLL )
2213 {
Alexandre Julliarda3960291999-02-26 11:11:13 +00002214 GetScrollRange(hWnd,SB_VERT,&minPos,&maxPos);
2215 curPos = GetScrollPos(hWnd,SB_VERT);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002216 length = (wndPtr->rectClient.bottom - wndPtr->rectClient.top)/2;
Marcus Meissnerddca3151999-05-22 11:33:23 +00002217 shift = GetSystemMetrics(SM_CXVSCROLL);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002218 }
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002219 else
2220 {
2221 WIN_ReleaseWndPtr(wndPtr);
2222 return;
2223 }
Alexandre Julliardd4719651995-12-12 18:49:11 +00002224
Francois Boisvert6b1b41c1999-03-14 17:25:32 +00002225 WIN_ReleaseWndPtr(wndPtr);
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002226 switch( wParam )
2227 {
Alexandre Julliardd4719651995-12-12 18:49:11 +00002228 case SB_LINEUP:
2229 newPos = curPos - shift;
2230 break;
2231 case SB_LINEDOWN:
2232 newPos = curPos + shift;
2233 break;
2234 case SB_PAGEUP:
2235 newPos = curPos - length;
2236 break;
2237 case SB_PAGEDOWN:
2238 newPos = curPos + length;
2239 break;
2240
2241 case SB_THUMBPOSITION:
2242 newPos = LOWORD(lParam);
2243 break;
2244
2245 case SB_THUMBTRACK:
2246 return;
2247
2248 case SB_TOP:
2249 newPos = minPos;
2250 break;
2251 case SB_BOTTOM:
2252 newPos = maxPos;
2253 break;
2254 case SB_ENDSCROLL:
Alexandre Julliarda3960291999-02-26 11:11:13 +00002255 CalcChildScroll16(hWnd,(uMsg == WM_VSCROLL)?SB_VERT:SB_HORZ);
Alexandre Julliardd4719651995-12-12 18:49:11 +00002256 return;
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002257 }
Alexandre Julliardd4719651995-12-12 18:49:11 +00002258
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002259 if( newPos > maxPos )
2260 newPos = maxPos;
2261 else
2262 if( newPos < minPos )
2263 newPos = minPos;
Alexandre Julliardd4719651995-12-12 18:49:11 +00002264
Alexandre Julliarda3960291999-02-26 11:11:13 +00002265 SetScrollPos(hWnd, (uMsg == WM_VSCROLL)?SB_VERT:SB_HORZ , newPos, TRUE);
Alexandre Julliardd4719651995-12-12 18:49:11 +00002266
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002267 if( uMsg == WM_VSCROLL )
Alexandre Julliarda3960291999-02-26 11:11:13 +00002268 ScrollWindowEx(hWnd ,0 ,curPos - newPos, NULL, NULL, 0, NULL,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002269 SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN );
Alexandre Julliard60ce85c1998-02-01 18:33:27 +00002270 else
Alexandre Julliarda3960291999-02-26 11:11:13 +00002271 ScrollWindowEx(hWnd ,curPos - newPos, 0, NULL, NULL, 0, NULL,
Alexandre Julliard670cdc41997-08-24 16:00:30 +00002272 SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN );
Alexandre Julliardd4719651995-12-12 18:49:11 +00002273}
2274
Alexandre Julliardf90efa91998-06-14 15:24:15 +00002275
2276/******************************************************************************
2277 * CascadeWindows [USER32.21] Cascades MDI child windows
2278 *
2279 * RETURNS
2280 * Success: Number of cascaded windows.
2281 * Failure: 0
2282 */
2283WORD WINAPI
Alexandre Julliarda3960291999-02-26 11:11:13 +00002284CascadeWindows (HWND hwndParent, UINT wFlags, const LPRECT lpRect,
2285 UINT cKids, const HWND *lpKids)
Alexandre Julliardf90efa91998-06-14 15:24:15 +00002286{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002287 FIXME("(0x%08x,0x%08x,...,%u,...): stub\n",
Alexandre Julliardf90efa91998-06-14 15:24:15 +00002288 hwndParent, wFlags, cKids);
2289
2290 return 0;
2291}
2292
2293
2294/******************************************************************************
2295 * TileWindows [USER32.545] Tiles MDI child windows
2296 *
2297 * RETURNS
2298 * Success: Number of tiled windows.
2299 * Failure: 0
2300 */
2301WORD WINAPI
Alexandre Julliarda3960291999-02-26 11:11:13 +00002302TileWindows (HWND hwndParent, UINT wFlags, const LPRECT lpRect,
2303 UINT cKids, const HWND *lpKids)
Alexandre Julliardf90efa91998-06-14 15:24:15 +00002304{
Alexandre Julliard359f497e1999-07-04 16:02:24 +00002305 FIXME("(0x%08x,0x%08x,...,%u,...): stub\n",
Alexandre Julliardf90efa91998-06-14 15:24:15 +00002306 hwndParent, wFlags, cKids);
2307
2308 return 0;
2309}
2310
David Lassondef58d80d2000-06-15 01:03:32 +00002311/************************************************************************
2312 * "More Windows..." functionality
2313 */
2314
2315/* MDI_MoreWindowsDlgProc
2316 *
2317 * This function will process the messages sent to the "More Windows..."
2318 * dialog.
2319 * Return values: 0 = cancel pressed
2320 * HWND = ok pressed or double-click in the list...
2321 *
2322 */
2323
2324static BOOL WINAPI MDI_MoreWindowsDlgProc (HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam)
2325{
2326 switch (iMsg)
2327 {
2328 case WM_INITDIALOG:
2329 {
2330 WND *pWnd;
2331 UINT widest = 0;
2332 UINT length;
2333 UINT i;
2334 WND *pParentWnd = (WND *)lParam;
2335 MDICLIENTINFO *ci = (MDICLIENTINFO*)pParentWnd->wExtra;
2336 HWND hListBox = GetDlgItem(hDlg, MDI_IDC_LISTBOX);
2337
2338 /* Fill the list, sorted by id... */
2339 for (i = 0; i < ci->nActiveChildren; i++)
2340 {
2341
2342 /* Find the window with the current ID */
2343 for (pWnd = WIN_LockWndPtr(pParentWnd->child); pWnd; WIN_UpdateWndPtr(&pWnd, pWnd->next))
2344 if (pWnd->wIDmenu == ci->idFirstChild + i)
2345 break;
2346
Dmitry Timoshkov04da8b82000-07-10 12:09:31 +00002347 SendMessageW(hListBox, LB_ADDSTRING, 0, (LPARAM) pWnd->text);
David Lassondef58d80d2000-06-15 01:03:32 +00002348 SendMessageA(hListBox, LB_SETITEMDATA, i, (LPARAM) pWnd);
Alexandre Julliardc7e7df82000-08-14 14:41:19 +00002349 length = strlenW(pWnd->text);
David Lassondef58d80d2000-06-15 01:03:32 +00002350 WIN_ReleaseWndPtr(pWnd);
2351
2352 if (length > widest)
2353 widest = length;
2354 }
2355 /* Make sure the horizontal scrollbar scrolls ok */
2356 SendMessageA(hListBox, LB_SETHORIZONTALEXTENT, widest * 6, 0);
2357
2358 /* Set the current selection */
2359 SendMessageA(hListBox, LB_SETCURSEL, MDI_MOREWINDOWSLIMIT, 0);
2360 return TRUE;
2361 }
2362
2363 case WM_COMMAND:
2364 switch (LOWORD(wParam))
2365 {
2366 case IDOK:
2367 {
2368 /* windows are sorted by menu ID, so we must return the
2369 * window associated to the given id
2370 */
2371 HWND hListBox = GetDlgItem(hDlg, MDI_IDC_LISTBOX);
2372 UINT index = SendMessageA(hListBox, LB_GETCURSEL, 0, 0);
2373 WND* pWnd = (WND*) SendMessageA(hListBox, LB_GETITEMDATA, index, 0);
2374
2375 EndDialog(hDlg, pWnd->hwndSelf);
2376 return TRUE;
2377 }
2378 case IDCANCEL:
2379 EndDialog(hDlg, 0);
2380 return TRUE;
2381
2382 default:
2383 switch (HIWORD(wParam))
2384 {
2385 case LBN_DBLCLK:
2386 {
2387 /* windows are sorted by menu ID, so we must return the
2388 * window associated to the given id
2389 */
2390 HWND hListBox = GetDlgItem(hDlg, MDI_IDC_LISTBOX);
2391 UINT index = SendMessageA(hListBox, LB_GETCURSEL, 0, 0);
2392 WND* pWnd = (WND*) SendMessageA(hListBox, LB_GETITEMDATA, index, 0);
2393
2394 EndDialog(hDlg, pWnd->hwndSelf);
2395 return TRUE;
2396 }
2397 }
2398 break;
2399 }
2400 break;
2401 }
2402 return FALSE;
2403}
2404
2405/*
2406 *
2407 * MDI_MoreWindowsDialog
2408 *
2409 * Prompts the user with a listbox containing the opened
2410 * documents. The user can then choose a windows and click
2411 * on OK to set the current window to the one selected, or
2412 * CANCEL to cancel. The function returns a handle to the
2413 * selected window.
2414 */
2415
2416static HWND MDI_MoreWindowsDialog(WND* wndPtr)
2417{
2418 LPCVOID template;
2419 HRSRC hRes;
2420 HANDLE hDlgTmpl;
2421
2422 hRes = FindResourceA(GetModuleHandleA("USER32"), "MDI_MOREWINDOWS", RT_DIALOGA);
2423
2424 if (hRes == 0)
2425 return 0;
2426
2427 hDlgTmpl = LoadResource(GetModuleHandleA("USER32"), hRes );
2428
2429 if (hDlgTmpl == 0)
2430 return 0;
2431
2432 template = LockResource( hDlgTmpl );
2433
2434 if (template == 0)
2435 return 0;
2436
2437 return (HWND) DialogBoxIndirectParamA(GetModuleHandleA("USER32"),
2438 (LPDLGTEMPLATEA) template,
2439 wndPtr->hwndSelf,
2440 (DLGPROC) MDI_MoreWindowsDlgProc,
2441 (LPARAM) wndPtr);
2442}
2443
2444/*
2445 *
2446 * MDI_SwapMenuItems
2447 *
2448 * Will swap the menu IDs for the given 2 positions.
2449 * pos1 and pos2 are menu IDs
2450 *
2451 *
2452 */
2453
2454static void MDI_SwapMenuItems(WND *parentWnd, UINT pos1, UINT pos2)
2455{
2456 WND *pWnd;
2457
2458 for (pWnd = WIN_LockWndPtr(parentWnd->child); pWnd; WIN_UpdateWndPtr(&pWnd,pWnd->next))
2459 {
2460 if (pWnd->wIDmenu == pos1)
2461 pWnd->wIDmenu = pos2;
2462 else
2463 if (pWnd->wIDmenu == pos2)
2464 pWnd->wIDmenu = pos1;
2465 }
2466
2467 WIN_ReleaseWndPtr(pWnd);
2468}
2469