Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1 | /* MDI.C |
| 2 | * |
| 3 | * Copyright 1994, Bob Amstadt |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 4 | * 1995,1996 Alex Korobka |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 5 | * |
Matthew Cline | c448c5c | 2000-02-13 15:05:07 +0000 | [diff] [blame] | 6 | * This file contains routines to support MDI (Multiple Document |
| 7 | * Interface) features . |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 8 | * |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 9 | * This library is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU Lesser General Public |
| 11 | * License as published by the Free Software Foundation; either |
| 12 | * version 2.1 of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This library is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 17 | * Lesser General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU Lesser General Public |
| 20 | * License along with this library; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 22 | * |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 23 | * Notes: Fairly complete implementation. |
Alexandre Julliard | 2ace16a | 1996-04-28 15:09:19 +0000 | [diff] [blame] | 24 | * Also, Excel and WinWord do _not_ use MDI so if you're trying |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 25 | * to fix them look elsewhere. |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 26 | * |
| 27 | * Notes on how the "More Windows..." is implemented: |
| 28 | * |
| 29 | * When we have more than 9 opened windows, a "More Windows..." |
| 30 | * option appears in the "Windows" menu. Each child window has |
| 31 | * a WND* associated with it, accesible via the children list of |
| 32 | * the parent window. This WND* has a wIDmenu member, which reflects |
| 33 | * the position of the child in the window list. For example, with |
| 34 | * 9 child windows, we could have the following pattern: |
| 35 | * |
| 36 | * |
| 37 | * |
| 38 | * Name of the child window pWndChild->wIDmenu |
| 39 | * Doc1 5000 |
| 40 | * Doc2 5001 |
| 41 | * Doc3 5002 |
| 42 | * Doc4 5003 |
| 43 | * Doc5 5004 |
| 44 | * Doc6 5005 |
| 45 | * Doc7 5006 |
| 46 | * Doc8 5007 |
| 47 | * Doc9 5008 |
| 48 | * |
| 49 | * |
| 50 | * The "Windows" menu, as the "More windows..." dialog, are constructed |
| 51 | * in this order. If we add a child, we would have the following list: |
| 52 | * |
| 53 | * |
| 54 | * Name of the child window pWndChild->wIDmenu |
| 55 | * Doc1 5000 |
| 56 | * Doc2 5001 |
| 57 | * Doc3 5002 |
| 58 | * Doc4 5003 |
| 59 | * Doc5 5004 |
| 60 | * Doc6 5005 |
| 61 | * Doc7 5006 |
| 62 | * Doc8 5007 |
| 63 | * Doc9 5008 |
| 64 | * Doc10 5009 |
| 65 | * |
| 66 | * But only 5000 to 5008 would be displayed in the "Windows" menu. We want |
| 67 | * the last created child to be in the menu, so we swap the last child with |
| 68 | * the 9th... Doc9 will be accessible via the "More Windows..." option. |
| 69 | * |
| 70 | * Doc1 5000 |
| 71 | * Doc2 5001 |
| 72 | * Doc3 5002 |
| 73 | * Doc4 5003 |
| 74 | * Doc5 5004 |
| 75 | * Doc6 5005 |
| 76 | * Doc7 5006 |
| 77 | * Doc8 5007 |
| 78 | * Doc9 5009 |
| 79 | * Doc10 5008 |
| 80 | * |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 81 | */ |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 82 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 83 | #include <stdlib.h> |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 84 | #include <stdio.h> |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 85 | #include <string.h> |
Alexandre Julliard | 490a27e | 1994-06-08 13:57:50 +0000 | [diff] [blame] | 86 | #include <math.h> |
François Gouget | 44a1822 | 2000-12-19 04:53:20 +0000 | [diff] [blame] | 87 | |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 88 | #include "windef.h" |
François Gouget | 44a1822 | 2000-12-19 04:53:20 +0000 | [diff] [blame] | 89 | #include "winbase.h" |
Jeremy White | d3e22d9 | 2000-02-10 19:03:02 +0000 | [diff] [blame] | 90 | #include "wingdi.h" |
Marcus Meissner | 61afa33 | 1999-02-22 10:16:00 +0000 | [diff] [blame] | 91 | #include "winuser.h" |
Alexandre Julliard | 0ca051e | 2002-10-17 16:43:42 +0000 | [diff] [blame] | 92 | #include "wownt32.h" |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 93 | #include "wine/unicode.h" |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 94 | #include "win.h" |
Alexandre Julliard | 1850655 | 1995-01-24 16:21:01 +0000 | [diff] [blame] | 95 | #include "nonclient.h" |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 96 | #include "controls.h" |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 97 | #include "user.h" |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 98 | #include "struct32.h" |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 99 | #include "wine/debug.h" |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 100 | #include "dlgs.h" |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 101 | |
Alexandre Julliard | 0799c1a | 2002-03-09 23:29:33 +0000 | [diff] [blame] | 102 | WINE_DEFAULT_DEBUG_CHANNEL(mdi); |
Patrik Stridvall | b4b9fae | 1999-04-19 14:56:29 +0000 | [diff] [blame] | 103 | |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 104 | #define MDI_MAXLISTLENGTH 0x40 |
| 105 | #define MDI_MAXTITLELENGTH 0xa1 |
| 106 | |
| 107 | #define MDI_NOFRAMEREPAINT 0 |
| 108 | #define MDI_REPAINTFRAMENOW 1 |
| 109 | #define MDI_REPAINTFRAME 2 |
| 110 | |
| 111 | #define WM_MDICALCCHILDSCROLL 0x10ac /* this is exactly what Windows uses */ |
| 112 | |
| 113 | /* "More Windows..." definitions */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 114 | #define MDI_MOREWINDOWSLIMIT 9 /* after this number of windows, a "More Windows..." |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 115 | option will appear under the Windows menu */ |
| 116 | #define MDI_IDC_LISTBOX 100 |
Dmitry Timoshkov | 9abcad5 | 2002-10-22 00:42:53 +0000 | [diff] [blame] | 117 | #define IDS_MDI_MOREWINDOWS 13 |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 118 | |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 119 | #define MDIF_NEEDUPDATE 0x0001 |
| 120 | |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 121 | typedef struct |
| 122 | { |
| 123 | UINT nActiveChildren; |
| 124 | HWND hwndChildMaximized; |
| 125 | HWND hwndActiveChild; |
| 126 | HMENU hWindowMenu; |
| 127 | UINT idFirstChild; |
| 128 | LPWSTR frameTitle; |
| 129 | UINT nTotalCreated; |
| 130 | UINT mdiFlags; |
| 131 | UINT sbRecalc; /* SB_xxx flags for scrollbar fixup */ |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 132 | } MDICLIENTINFO; |
| 133 | |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 134 | static HBITMAP hBmpClose = 0; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 135 | |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 136 | /* ----------------- declarations ----------------- */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 137 | static void MDI_UpdateFrameText( HWND, HWND, BOOL, LPCWSTR); |
| 138 | static BOOL MDI_AugmentFrameMenu( HWND, HWND ); |
| 139 | static BOOL MDI_RestoreFrameMenu( HWND, HWND ); |
| 140 | static LONG MDI_ChildActivate( HWND, HWND ); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 141 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 142 | static HWND MDI_MoreWindowsDialog(HWND); |
| 143 | static void MDI_SwapMenuItems(HWND, UINT, UINT); |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 144 | static LRESULT WINAPI MDIClientWndProcA( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ); |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 145 | static LRESULT WINAPI MDIClientWndProcW( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ); |
| 146 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 147 | /* -------- Miscellaneous service functions ---------- |
| 148 | * |
| 149 | * MDI_GetChildByID |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 150 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 151 | static HWND MDI_GetChildByID(HWND hwnd, UINT id) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 152 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 153 | HWND ret; |
| 154 | HWND *win_array; |
| 155 | int i; |
| 156 | |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 157 | if (!(win_array = WIN_ListChildren( hwnd ))) return 0; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 158 | for (i = 0; win_array[i]; i++) |
| 159 | { |
| 160 | if (GetWindowLongA( win_array[i], GWL_ID ) == id) break; |
| 161 | } |
| 162 | ret = win_array[i]; |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 163 | HeapFree( GetProcessHeap(), 0, win_array ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 164 | return ret; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 165 | } |
| 166 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 167 | static void MDI_PostUpdate(HWND hwnd, MDICLIENTINFO* ci, WORD recalc) |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 168 | { |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 169 | if( !(ci->mdiFlags & MDIF_NEEDUPDATE) ) |
| 170 | { |
| 171 | ci->mdiFlags |= MDIF_NEEDUPDATE; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 172 | PostMessageA( hwnd, WM_MDICALCCHILDSCROLL, 0, 0); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 173 | } |
| 174 | ci->sbRecalc = recalc; |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 175 | } |
| 176 | |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 177 | |
| 178 | /********************************************************************* |
| 179 | * MDIClient class descriptor |
| 180 | */ |
| 181 | const struct builtin_class_descr MDICLIENT_builtin_class = |
| 182 | { |
| 183 | "MDIClient", /* name */ |
| 184 | CS_GLOBALCLASS, /* style */ |
| 185 | MDIClientWndProcA, /* procA */ |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 186 | MDIClientWndProcW, /* procW */ |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 187 | sizeof(MDICLIENTINFO), /* extra */ |
| 188 | IDC_ARROWA, /* cursor */ |
Michael Stefaniuc | 95591a6 | 2002-10-28 20:11:40 +0000 | [diff] [blame] | 189 | (HBRUSH)(COLOR_APPWORKSPACE+1) /* brush */ |
Alexandre Julliard | 91222da | 2000-12-10 23:01:33 +0000 | [diff] [blame] | 190 | }; |
| 191 | |
| 192 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 193 | static MDICLIENTINFO *get_client_info( HWND client ) |
| 194 | { |
| 195 | MDICLIENTINFO *ret = NULL; |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 196 | WND *win = WIN_GetPtr( client ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 197 | if (win) |
| 198 | { |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 199 | if (win == WND_OTHER_PROCESS) |
| 200 | { |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 201 | ERR( "client %p belongs to other process\n", client ); |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 202 | return NULL; |
| 203 | } |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 204 | if (win->cbWndExtra < sizeof(MDICLIENTINFO)) WARN( "%p is not an MDI client\n", client ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 205 | else ret = (MDICLIENTINFO *)win->wExtra; |
Mike McCormack | cb97a3b | 2001-10-18 21:33:03 +0000 | [diff] [blame] | 206 | WIN_ReleasePtr( win ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 207 | } |
| 208 | return ret; |
| 209 | } |
| 210 | |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 211 | /********************************************************************** |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 212 | * MDI_MenuModifyItem |
| 213 | */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 214 | static void MDI_MenuModifyItem( HWND client, HWND hWndChild ) |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 215 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 216 | MDICLIENTINFO *clientInfo = get_client_info( client ); |
| 217 | WCHAR buffer[128]; |
| 218 | UINT n, id; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 219 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 220 | if (!clientInfo || !clientInfo->hWindowMenu) return; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 221 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 222 | id = GetWindowLongA( hWndChild, GWL_ID ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 223 | if (id >= clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT) return; |
| 224 | buffer[0] = '&'; |
| 225 | buffer[1] = '1' + id - clientInfo->idFirstChild; |
| 226 | buffer[2] = ' '; |
| 227 | GetWindowTextW( hWndChild, buffer + 3, sizeof(buffer)/sizeof(WCHAR) - 3 ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 228 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 229 | n = GetMenuState(clientInfo->hWindowMenu, id, MF_BYCOMMAND); |
| 230 | ModifyMenuW(clientInfo->hWindowMenu, id, MF_BYCOMMAND | MF_STRING, id, buffer ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 231 | CheckMenuItem(clientInfo->hWindowMenu, id, n & MF_CHECKED); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | /********************************************************************** |
| 235 | * MDI_MenuDeleteItem |
| 236 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 237 | static BOOL MDI_MenuDeleteItem( HWND client, HWND hWndChild ) |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 238 | { |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 239 | WCHAR buffer[128]; |
| 240 | static const WCHAR format[] = {'&','%','d',' ',0}; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 241 | MDICLIENTINFO *clientInfo = get_client_info( client ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 242 | UINT index = 0,id,n; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 243 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 244 | if( !clientInfo->nActiveChildren || !clientInfo->hWindowMenu ) |
| 245 | return FALSE; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 246 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 247 | id = GetWindowLongA( hWndChild, GWL_ID ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 248 | DeleteMenu(clientInfo->hWindowMenu,id,MF_BYCOMMAND); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 249 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 250 | /* walk the rest of MDI children to prevent gaps in the id |
Alexandre Julliard | 1e37a18 | 1996-08-18 16:21:52 +0000 | [diff] [blame] | 251 | * sequence and in the menu child list */ |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 252 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 253 | for( index = id+1; index <= clientInfo->nActiveChildren + |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 254 | clientInfo->idFirstChild; index++ ) |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 255 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 256 | HWND hwnd = MDI_GetChildByID(client,index); |
| 257 | if (!hwnd) |
| 258 | { |
| 259 | TRACE("no window for id=%i\n",index); |
| 260 | continue; |
| 261 | } |
| 262 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 263 | /* set correct id */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 264 | SetWindowLongW( hwnd, GWL_ID, GetWindowLongW( hwnd, GWL_ID ) - 1 ); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 265 | |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 266 | n = wsprintfW(buffer, format ,index - clientInfo->idFirstChild); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 267 | GetWindowTextW( hwnd, buffer + n, sizeof(buffer)/sizeof(WCHAR) - n ); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 268 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 269 | /* change menu if the current child is to be shown in the |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 270 | * "Windows" menu |
| 271 | */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 272 | if (index <= clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT) |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 273 | ModifyMenuW(clientInfo->hWindowMenu ,index ,MF_BYCOMMAND | MF_STRING, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 274 | index - 1 , buffer ); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 275 | } |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 276 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 277 | /* We must restore the "More Windows..." option if there are enough children |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 278 | */ |
| 279 | if (clientInfo->nActiveChildren - 1 > MDI_MOREWINDOWSLIMIT) |
| 280 | { |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 281 | WCHAR szTmp[50]; |
Dmitry Timoshkov | 9abcad5 | 2002-10-22 00:42:53 +0000 | [diff] [blame] | 282 | LoadStringW(GetModuleHandleA("USER32"), IDS_MDI_MOREWINDOWS, szTmp, sizeof(szTmp)/sizeof(szTmp[0])); |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 283 | AppendMenuW(clientInfo->hWindowMenu, MF_STRING, clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT, szTmp); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 284 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 285 | return TRUE; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | /********************************************************************** |
| 289 | * MDI_GetWindow |
| 290 | * |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 291 | * returns "activateable" child different from the current or zero |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 292 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 293 | static HWND MDI_GetWindow(MDICLIENTINFO *clientInfo, HWND hWnd, BOOL bNext, |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 294 | DWORD dwStyleMask ) |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 295 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 296 | int i; |
| 297 | HWND *list; |
| 298 | HWND last = 0; |
| 299 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 300 | dwStyleMask |= WS_DISABLED | WS_VISIBLE; |
Alexandre Julliard | 59730ae | 1996-03-24 16:20:51 +0000 | [diff] [blame] | 301 | if( !hWnd ) hWnd = clientInfo->hwndActiveChild; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 302 | |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 303 | if (!(list = WIN_ListChildren( GetParent(hWnd) ))) return 0; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 304 | i = 0; |
| 305 | /* start from next after hWnd */ |
| 306 | while (list[i] && list[i] != hWnd) i++; |
| 307 | if (list[i]) i++; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 308 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 309 | for ( ; list[i]; i++) |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 310 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 311 | if (GetWindow( list[i], GW_OWNER )) continue; |
| 312 | if ((GetWindowLongW( list[i], GWL_STYLE ) & dwStyleMask) != WS_VISIBLE) continue; |
| 313 | last = list[i]; |
| 314 | if (bNext) goto found; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 315 | } |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 316 | /* now restart from the beginning */ |
| 317 | for (i = 0; list[i] && list[i] != hWnd; i++) |
| 318 | { |
| 319 | if (GetWindow( list[i], GW_OWNER )) continue; |
| 320 | if ((GetWindowLongW( list[i], GWL_STYLE ) & dwStyleMask) != WS_VISIBLE) continue; |
| 321 | last = list[i]; |
| 322 | if (bNext) goto found; |
| 323 | } |
| 324 | found: |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 325 | HeapFree( GetProcessHeap(), 0, list ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 326 | return last; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 327 | } |
| 328 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 329 | /********************************************************************** |
| 330 | * MDI_CalcDefaultChildPos |
| 331 | * |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 332 | * It seems that the default height is about 2/3 of the client rect |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 333 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 334 | static void MDI_CalcDefaultChildPos( HWND hwnd, WORD n, LPPOINT lpPos, INT delta) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 335 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 336 | INT nstagger; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 337 | RECT rect; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 338 | INT spacing = GetSystemMetrics(SM_CYCAPTION) + |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 339 | GetSystemMetrics(SM_CYFRAME) - 1; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 340 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 341 | GetClientRect( hwnd, &rect ); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 342 | if( rect.bottom - rect.top - delta >= spacing ) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 343 | rect.bottom -= delta; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 344 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 345 | nstagger = (rect.bottom - rect.top)/(3 * spacing); |
| 346 | lpPos[1].x = (rect.right - rect.left - nstagger * spacing); |
| 347 | lpPos[1].y = (rect.bottom - rect.top - nstagger * spacing); |
| 348 | lpPos[0].x = lpPos[0].y = spacing * (n%(nstagger+1)); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 349 | } |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 350 | |
| 351 | /********************************************************************** |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 352 | * MDISetMenu |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 353 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 354 | static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame, |
| 355 | HMENU hmenuWindow) |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 356 | { |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 357 | MDICLIENTINFO *ci; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 358 | HWND hwndFrame = GetParent(hwnd); |
| 359 | HMENU oldFrameMenu = GetMenu(hwndFrame); |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 360 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 361 | TRACE("%p %p %p\n", hwnd, hmenuFrame, hmenuWindow); |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 362 | |
Richard Cohen | 55b9247 | 1999-09-19 14:05:05 +0000 | [diff] [blame] | 363 | if (hmenuFrame && !IsMenu(hmenuFrame)) |
| 364 | { |
| 365 | WARN("hmenuFrame is not a menu handle\n"); |
| 366 | return 0L; |
| 367 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 368 | |
Richard Cohen | 55b9247 | 1999-09-19 14:05:05 +0000 | [diff] [blame] | 369 | if (hmenuWindow && !IsMenu(hmenuWindow)) |
| 370 | { |
| 371 | WARN("hmenuWindow is not a menu handle\n"); |
| 372 | return 0L; |
| 373 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 374 | |
| 375 | if (!(ci = get_client_info( hwnd ))) return 0; |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 376 | |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 377 | if( ci->hwndChildMaximized && hmenuFrame && hmenuFrame!=oldFrameMenu ) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 378 | MDI_RestoreFrameMenu( GetParent(hwnd), ci->hwndChildMaximized ); |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 379 | |
Guy L. Albertelli | c0504ca | 2000-05-10 21:39:00 +0000 | [diff] [blame] | 380 | if( hmenuWindow && ci->hWindowMenu && hmenuWindow!=ci->hWindowMenu ) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 381 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 382 | /* delete menu items from ci->hWindowMenu |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 383 | * and add them to hmenuWindow */ |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 384 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 385 | INT i = GetMenuItemCount(ci->hWindowMenu) - 1; |
| 386 | INT pos = GetMenuItemCount(hmenuWindow) + 1; |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 387 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 388 | AppendMenuA( hmenuWindow, MF_SEPARATOR, 0, NULL); |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 389 | |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 390 | if( ci->nActiveChildren ) |
| 391 | { |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 392 | INT j; |
Huw D M Davies | 738c06d | 2000-03-24 19:49:13 +0000 | [diff] [blame] | 393 | LPWSTR buffer = NULL; |
| 394 | MENUITEMINFOW mii; |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 395 | INT nbWindowsMenuItems; /* num of documents shown + "More Windows..." if present */ |
| 396 | |
| 397 | if (ci->nActiveChildren <= MDI_MOREWINDOWSLIMIT) |
| 398 | nbWindowsMenuItems = ci->nActiveChildren; |
| 399 | else |
| 400 | nbWindowsMenuItems = MDI_MOREWINDOWSLIMIT + 1; |
| 401 | |
| 402 | j = i - nbWindowsMenuItems + 1; |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 403 | |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 404 | for( ; i >= j ; i-- ) |
| 405 | { |
Huw D M Davies | 738c06d | 2000-03-24 19:49:13 +0000 | [diff] [blame] | 406 | memset(&mii, 0, sizeof(mii)); |
| 407 | mii.cbSize = sizeof(mii); |
| 408 | mii.fMask = MIIM_CHECKMARKS | MIIM_DATA | MIIM_ID | MIIM_STATE |
| 409 | | MIIM_SUBMENU | MIIM_TYPE | MIIM_BITMAP; |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 410 | |
Huw D M Davies | 738c06d | 2000-03-24 19:49:13 +0000 | [diff] [blame] | 411 | GetMenuItemInfoW(ci->hWindowMenu, i, TRUE, &mii); |
| 412 | if(mii.cch) { /* Menu is MFT_STRING */ |
| 413 | mii.cch++; /* add room for '\0' */ |
| 414 | buffer = HeapAlloc(GetProcessHeap(), 0, |
| 415 | mii.cch * sizeof(WCHAR)); |
| 416 | mii.dwTypeData = buffer; |
| 417 | GetMenuItemInfoW(ci->hWindowMenu, i, TRUE, &mii); |
| 418 | } |
| 419 | DeleteMenu(ci->hWindowMenu, i, MF_BYPOSITION); |
| 420 | InsertMenuItemW(hmenuWindow, pos, TRUE, &mii); |
| 421 | if(buffer) { |
| 422 | HeapFree(GetProcessHeap(), 0, buffer); |
| 423 | buffer = NULL; |
| 424 | } |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 425 | } |
| 426 | } |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 427 | |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 428 | /* remove separator */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 429 | DeleteMenu(ci->hWindowMenu, i, MF_BYPOSITION); |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 430 | |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 431 | ci->hWindowMenu = hmenuWindow; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 432 | } |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 433 | |
Gerard Patel | a2e1b41 | 2000-05-07 18:25:33 +0000 | [diff] [blame] | 434 | if (hmenuFrame) |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 435 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 436 | SetMenu(hwndFrame, hmenuFrame); |
Gerard Patel | a2e1b41 | 2000-05-07 18:25:33 +0000 | [diff] [blame] | 437 | if( hmenuFrame!=oldFrameMenu ) |
| 438 | { |
| 439 | if( ci->hwndChildMaximized ) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 440 | MDI_AugmentFrameMenu( GetParent(hwnd), ci->hwndChildMaximized ); |
Michael Stefaniuc | 95591a6 | 2002-10-28 20:11:40 +0000 | [diff] [blame] | 441 | return (LRESULT)oldFrameMenu; |
Gerard Patel | a2e1b41 | 2000-05-07 18:25:33 +0000 | [diff] [blame] | 442 | } |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 443 | } |
Alexandre Julliard | 60cf612 | 2000-09-01 01:24:19 +0000 | [diff] [blame] | 444 | else |
| 445 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 446 | HMENU menu = GetMenu( GetParent(hwnd) ); |
| 447 | INT nItems = GetMenuItemCount(menu) - 1; |
| 448 | UINT iId = GetMenuItemID(menu,nItems) ; |
Alexandre Julliard | 60cf612 | 2000-09-01 01:24:19 +0000 | [diff] [blame] | 449 | |
| 450 | if( !(iId == SC_RESTORE || iId == SC_CLOSE) ) |
| 451 | { |
| 452 | /* SetMenu() may already have been called, meaning that this window |
| 453 | * already has its menu. But they may have done a SetMenu() on |
| 454 | * an MDI window, and called MDISetMenu() after the fact, meaning |
| 455 | * that the "if" to this "else" wouldn't catch the need to |
| 456 | * augment the frame menu. |
| 457 | */ |
| 458 | if( ci->hwndChildMaximized ) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 459 | MDI_AugmentFrameMenu( GetParent(hwnd), ci->hwndChildMaximized ); |
Alexandre Julliard | 60cf612 | 2000-09-01 01:24:19 +0000 | [diff] [blame] | 460 | } |
| 461 | } |
Alexandre Julliard | e2991ea | 1995-07-29 13:09:43 +0000 | [diff] [blame] | 462 | return 0; |
| 463 | } |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 464 | |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 465 | /********************************************************************** |
| 466 | * MDIRefreshMenu |
| 467 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 468 | static LRESULT MDIRefreshMenu( HWND hwnd, HMENU hmenuFrame, |
| 469 | HMENU hmenuWindow) |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 470 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 471 | HWND hwndFrame = GetParent(hwnd); |
| 472 | HMENU oldFrameMenu = GetMenu(hwndFrame); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 473 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 474 | TRACE("%p %p %p\n", hwnd, hmenuFrame, hmenuWindow); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 475 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 476 | FIXME("partially function stub\n"); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 477 | |
Michael Stefaniuc | 95591a6 | 2002-10-28 20:11:40 +0000 | [diff] [blame] | 478 | return (LRESULT)oldFrameMenu; |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 479 | } |
| 480 | |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 481 | |
| 482 | /* ------------------ MDI child window functions ---------------------- */ |
| 483 | |
| 484 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 485 | /********************************************************************** |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 486 | * MDICreateChild |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 487 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 488 | static HWND MDICreateChild( HWND parent, MDICLIENTINFO *ci, |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 489 | LPMDICREATESTRUCTA cs, BOOL unicode ) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 490 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 491 | POINT pos[2]; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 492 | DWORD style = cs->style | (WS_CHILD | WS_CLIPSIBLINGS); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 493 | HWND hwnd, hwndMax = 0; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 494 | UINT wIDmenu = ci->idFirstChild + ci->nActiveChildren; |
| 495 | WND *wndParent; |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 496 | static const WCHAR lpstrDef[] = {'j','u','n','k','!',0}; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 497 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 498 | TRACE("origin %i,%i - dim %i,%i, style %08lx\n", |
Dmitry Timoshkov | 73968f0 | 2000-09-09 19:38:52 +0000 | [diff] [blame] | 499 | cs->x, cs->y, cs->cx, cs->cy, cs->style); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 500 | /* calculate placement */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 501 | MDI_CalcDefaultChildPos(parent, ci->nTotalCreated++, pos, 0); |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 502 | |
Joshua Thielen | 26c4d6b | 2001-09-19 22:33:01 +0000 | [diff] [blame] | 503 | if (cs->cx == CW_USEDEFAULT || cs->cx == CW_USEDEFAULT16 || !cs->cx) cs->cx = pos[1].x; |
| 504 | if (cs->cy == CW_USEDEFAULT || cs->cy == CW_USEDEFAULT16 || !cs->cy) cs->cy = pos[1].y; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 505 | |
Joshua Thielen | 26c4d6b | 2001-09-19 22:33:01 +0000 | [diff] [blame] | 506 | if (cs->x == CW_USEDEFAULT || cs->x == CW_USEDEFAULT16) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 507 | { |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 508 | cs->x = pos[0].x; |
| 509 | cs->y = pos[0].y; |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 510 | } |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 511 | |
| 512 | /* restore current maximized child */ |
Dmitry Timoshkov | 73968f0 | 2000-09-09 19:38:52 +0000 | [diff] [blame] | 513 | if( (style & WS_VISIBLE) && ci->hwndChildMaximized ) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 514 | { |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 515 | TRACE("Restoring current maximized child %p\n", ci->hwndChildMaximized); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 516 | if( style & WS_MAXIMIZE ) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 517 | SendMessageW(parent, WM_SETREDRAW, FALSE, 0L); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 518 | hwndMax = ci->hwndChildMaximized; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 519 | ShowWindow( hwndMax, SW_SHOWNOACTIVATE ); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 520 | if( style & WS_MAXIMIZE ) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 521 | SendMessageW(parent, WM_SETREDRAW, TRUE, 0L); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 522 | } |
Alexandre Julliard | 2787be8 | 1995-05-22 18:23:01 +0000 | [diff] [blame] | 523 | |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 524 | if (ci->nActiveChildren <= MDI_MOREWINDOWSLIMIT) |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 525 | /* this menu is needed to set a check mark in MDI_ChildActivate */ |
Matthew Cline | c448c5c | 2000-02-13 15:05:07 +0000 | [diff] [blame] | 526 | if (ci->hWindowMenu != 0) |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 527 | AppendMenuW(ci->hWindowMenu, MF_STRING, wIDmenu, lpstrDef); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 528 | |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 529 | ci->nActiveChildren++; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 530 | |
| 531 | /* fix window style */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 532 | wndParent = WIN_FindWndPtr( parent ); |
Dmitry Timoshkov | 2b560c7 | 2001-02-12 18:09:51 +0000 | [diff] [blame] | 533 | if( !(wndParent->dwStyle & MDIS_ALLCHILDSTYLES) ) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 534 | { |
Dmitry Timoshkov | 73968f0 | 2000-09-09 19:38:52 +0000 | [diff] [blame] | 535 | TRACE("MDIS_ALLCHILDSTYLES is missing, fixing window style\n"); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 536 | style &= (WS_CHILD | WS_CLIPSIBLINGS | WS_MINIMIZE | WS_MAXIMIZE | |
| 537 | WS_CLIPCHILDREN | WS_DISABLED | WS_VSCROLL | WS_HSCROLL ); |
| 538 | style |= (WS_VISIBLE | WS_OVERLAPPEDWINDOW); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 539 | } |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 540 | |
Dmitry Timoshkov | 2b560c7 | 2001-02-12 18:09:51 +0000 | [diff] [blame] | 541 | if( wndParent->flags & WIN_ISWIN32 ) |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 542 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 543 | WIN_ReleaseWndPtr( wndParent ); |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 544 | if(unicode) |
| 545 | { |
| 546 | MDICREATESTRUCTW *csW = (MDICREATESTRUCTW *)cs; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 547 | hwnd = CreateWindowW( csW->szClass, csW->szTitle, style, |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 548 | csW->x, csW->y, csW->cx, csW->cy, parent, |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 549 | (HMENU)wIDmenu, csW->hOwner, csW ); |
| 550 | } |
| 551 | else |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 552 | hwnd = CreateWindowA( cs->szClass, cs->szTitle, style, |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 553 | cs->x, cs->y, cs->cx, cs->cy, parent, |
Dmitry Timoshkov | 73968f0 | 2000-09-09 19:38:52 +0000 | [diff] [blame] | 554 | (HMENU)wIDmenu, cs->hOwner, cs ); |
Alexandre Julliard | 491502b | 1997-11-01 19:08:16 +0000 | [diff] [blame] | 555 | } |
| 556 | else |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 557 | { |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 558 | MDICREATESTRUCT16 cs16; |
| 559 | SEGPTR title, cls, seg_cs16; |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 560 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 561 | WIN_ReleaseWndPtr( wndParent ); |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 562 | STRUCT32_MDICREATESTRUCT32Ato16( cs, &cs16 ); |
| 563 | cs16.szTitle = title = MapLS( cs->szTitle ); |
| 564 | cs16.szClass = cls = MapLS( cs->szClass ); |
| 565 | seg_cs16 = MapLS( &cs16 ); |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 566 | hwnd = WIN_Handle32( CreateWindow16( cs->szClass, cs->szTitle, style, |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 567 | cs16.x, cs16.y, cs16.cx, cs16.cy, |
Alexandre Julliard | 7ef66af | 2002-11-22 04:47:10 +0000 | [diff] [blame] | 568 | HWND_16(parent), (HMENU16)wIDmenu, |
Alexandre Julliard | d7b7682 | 2001-12-20 00:19:40 +0000 | [diff] [blame] | 569 | cs16.hOwner, (LPVOID)seg_cs16 )); |
| 570 | UnMapLS( seg_cs16 ); |
| 571 | UnMapLS( title ); |
| 572 | UnMapLS( cls ); |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 573 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 574 | |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 575 | /* MDI windows are WS_CHILD so they won't be activated by CreateWindow */ |
| 576 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 577 | if (hwnd) |
| 578 | { |
Francis Beaudet | 1cc0a9a | 1999-09-03 15:00:45 +0000 | [diff] [blame] | 579 | /* All MDI child windows have the WS_EX_MDICHILD style */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 580 | SetWindowLongW( hwnd, GWL_EXSTYLE, GetWindowLongW( hwnd, GWL_EXSTYLE ) | WS_EX_MDICHILD ); |
Francis Beaudet | 1cc0a9a | 1999-09-03 15:00:45 +0000 | [diff] [blame] | 581 | |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 582 | /* If we have more than 9 windows, we must insert the new one at the |
| 583 | * 9th position in order to see it in the "Windows" menu |
| 584 | */ |
| 585 | if (ci->nActiveChildren > MDI_MOREWINDOWSLIMIT) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 586 | MDI_SwapMenuItems( parent, GetWindowLongW( hwnd, GWL_ID ), |
| 587 | ci->idFirstChild + MDI_MOREWINDOWSLIMIT - 1); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 588 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 589 | MDI_MenuModifyItem(parent, hwnd); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 590 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 591 | /* Have we hit the "More Windows..." limit? If so, we must |
| 592 | * add a "More Windows..." option |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 593 | */ |
| 594 | if (ci->nActiveChildren == MDI_MOREWINDOWSLIMIT + 1) |
| 595 | { |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 596 | WCHAR szTmp[50]; |
Dmitry Timoshkov | 9abcad5 | 2002-10-22 00:42:53 +0000 | [diff] [blame] | 597 | LoadStringW(GetModuleHandleA("USER32"), IDS_MDI_MOREWINDOWS, szTmp, sizeof(szTmp)/sizeof(szTmp[0])); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 598 | |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 599 | ModifyMenuW(ci->hWindowMenu, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 600 | ci->idFirstChild + MDI_MOREWINDOWSLIMIT, |
| 601 | MF_BYCOMMAND | MF_STRING, |
| 602 | ci->idFirstChild + MDI_MOREWINDOWSLIMIT, |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 603 | szTmp); |
| 604 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 605 | |
| 606 | if( IsIconic(hwnd) && ci->hwndActiveChild ) |
Dmitry Timoshkov | 73968f0 | 2000-09-09 19:38:52 +0000 | [diff] [blame] | 607 | { |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 608 | TRACE("Minimizing created MDI child %p\n", hwnd); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 609 | ShowWindow( hwnd, SW_SHOWMINNOACTIVE ); |
Dmitry Timoshkov | 73968f0 | 2000-09-09 19:38:52 +0000 | [diff] [blame] | 610 | } |
Alexandre Julliard | 18f92e7 | 1996-07-17 20:02:21 +0000 | [diff] [blame] | 611 | else |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 612 | { |
Rein Klazes | 4f7abc0 | 1998-10-31 12:18:17 +0000 | [diff] [blame] | 613 | /* WS_VISIBLE is clear if a) the MDI client has |
| 614 | * MDIS_ALLCHILDSTYLES style and 2) the flag is cleared in the |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 615 | * MDICreateStruct. If so the created window is not shown nor |
Rein Klazes | 4f7abc0 | 1998-10-31 12:18:17 +0000 | [diff] [blame] | 616 | * activated. |
| 617 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 618 | if (IsWindowVisible(hwnd)) ShowWindow(hwnd, SW_SHOW); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 619 | } |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 620 | TRACE("created child - %p\n",hwnd); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 621 | } |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 622 | else |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 623 | { |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 624 | ci->nActiveChildren--; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 625 | DeleteMenu(ci->hWindowMenu,wIDmenu,MF_BYCOMMAND); |
| 626 | if( IsWindow(hwndMax) ) |
| 627 | ShowWindow(hwndMax, SW_SHOWMAXIMIZED); |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 628 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 629 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 630 | return hwnd; |
| 631 | } |
| 632 | |
| 633 | /********************************************************************** |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 634 | * MDI_ChildGetMinMaxInfo |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 635 | * |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 636 | * Note: The rule here is that client rect of the maximized MDI child |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 637 | * is equal to the client rect of the MDI client window. |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 638 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 639 | static void MDI_ChildGetMinMaxInfo( HWND client, HWND hwnd, MINMAXINFO* lpMinMax ) |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 640 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 641 | RECT rect; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 642 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 643 | GetClientRect( client, &rect ); |
| 644 | AdjustWindowRectEx( &rect, GetWindowLongW( hwnd, GWL_STYLE ), |
| 645 | 0, GetWindowLongW( hwnd, GWL_EXSTYLE )); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 646 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 647 | lpMinMax->ptMaxSize.x = rect.right -= rect.left; |
| 648 | lpMinMax->ptMaxSize.y = rect.bottom -= rect.top; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 649 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 650 | lpMinMax->ptMaxPosition.x = rect.left; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 651 | lpMinMax->ptMaxPosition.y = rect.top; |
Alexandre Julliard | ac9c9b0 | 1996-07-28 18:50:11 +0000 | [diff] [blame] | 652 | |
Dan Kegel | 0fd521f | 2003-01-08 21:09:25 +0000 | [diff] [blame] | 653 | TRACE("max rect (%ld,%ld - %ld, %ld)\n", |
Alexandre Julliard | ac9c9b0 | 1996-07-28 18:50:11 +0000 | [diff] [blame] | 654 | rect.left,rect.top,rect.right,rect.bottom); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | /********************************************************************** |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 658 | * MDI_SwitchActiveChild |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 659 | * |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 660 | * Note: SetWindowPos sends WM_CHILDACTIVATE to the child window that is |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 661 | * being activated |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 662 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 663 | static void MDI_SwitchActiveChild( HWND clientHwnd, HWND childHwnd, |
| 664 | BOOL bNextWindow ) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 665 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 666 | HWND hwndTo = 0; |
| 667 | HWND hwndPrev = 0; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 668 | MDICLIENTINFO *ci = get_client_info( clientHwnd ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 669 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 670 | hwndTo = MDI_GetWindow(ci, childHwnd, bNextWindow, 0); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 671 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 672 | TRACE("from %p, to %p\n",childHwnd,hwndTo); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 673 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 674 | if ( !hwndTo ) return; /* no window to switch to */ |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 675 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 676 | hwndPrev = ci->hwndActiveChild; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 677 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 678 | if ( hwndTo != hwndPrev ) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 679 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 680 | SetWindowPos( hwndTo, HWND_TOP, 0, 0, 0, 0, |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 681 | SWP_NOMOVE | SWP_NOSIZE ); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 682 | |
| 683 | if( bNextWindow && hwndPrev ) |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 684 | SetWindowPos( hwndPrev, HWND_BOTTOM, 0, 0, 0, 0, |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 685 | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE ); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 686 | } |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 687 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 688 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 689 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 690 | /********************************************************************** |
| 691 | * MDIDestroyChild |
| 692 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 693 | static LRESULT MDIDestroyChild( HWND parent, MDICLIENTINFO *ci, |
Dmitry Timoshkov | 2b560c7 | 2001-02-12 18:09:51 +0000 | [diff] [blame] | 694 | HWND child, BOOL flagDestroy ) |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 695 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 696 | if( child == ci->hwndActiveChild ) |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 697 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 698 | MDI_SwitchActiveChild(parent, child, TRUE); |
| 699 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 700 | if( child == ci->hwndActiveChild ) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 701 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 702 | ShowWindow( child, SW_HIDE); |
| 703 | if( child == ci->hwndChildMaximized ) |
| 704 | { |
| 705 | HWND frame = GetParent(parent); |
| 706 | MDI_RestoreFrameMenu( frame, child ); |
| 707 | ci->hwndChildMaximized = 0; |
| 708 | MDI_UpdateFrameText( frame, parent, TRUE, NULL); |
| 709 | } |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 710 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 711 | MDI_ChildActivate(parent, 0); |
Alexandre Julliard | a1ce916 | 2000-09-06 19:40:07 +0000 | [diff] [blame] | 712 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 713 | } |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 714 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 715 | MDI_MenuDeleteItem(parent, child); |
| 716 | |
| 717 | ci->nActiveChildren--; |
| 718 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 719 | TRACE("child destroyed - %p\n",child); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 720 | |
| 721 | if (flagDestroy) |
| 722 | { |
| 723 | MDI_PostUpdate(GetParent(child), ci, SB_BOTH+1); |
| 724 | DestroyWindow(child); |
| 725 | } |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 726 | return 0; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 727 | } |
| 728 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 729 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 730 | /********************************************************************** |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 731 | * MDI_ChildActivate |
| 732 | * |
| 733 | * Note: hWndChild is NULL when last child is being destroyed |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 734 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 735 | static LONG MDI_ChildActivate( HWND client, HWND child ) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 736 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 737 | MDICLIENTINFO *clientInfo = get_client_info( client ); |
| 738 | HWND prevActiveWnd = clientInfo->hwndActiveChild; |
| 739 | BOOL isActiveFrameWnd; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 740 | |
Gerard Patel | 1e8b025 | 2001-10-15 18:00:09 +0000 | [diff] [blame] | 741 | if (child && (!IsWindowEnabled( child ))) return 0; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 742 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 743 | /* Don't activate if it is already active. Might happen |
Francis Beaudet | 458719d | 1999-10-31 17:35:06 +0000 | [diff] [blame] | 744 | since ShowWindow DOES activate MDI children */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 745 | if (clientInfo->hwndActiveChild == child) return 0; |
Francis Beaudet | 458719d | 1999-10-31 17:35:06 +0000 | [diff] [blame] | 746 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 747 | TRACE("%p\n", child); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 748 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 749 | isActiveFrameWnd = (GetActiveWindow() == GetParent(client)); |
| 750 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 751 | /* deactivate prev. active child */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 752 | if(prevActiveWnd) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 753 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 754 | SetWindowLongA( prevActiveWnd, GWL_STYLE, |
| 755 | GetWindowLongA( prevActiveWnd, GWL_STYLE ) | WS_SYSMENU ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 756 | SendMessageA( prevActiveWnd, WM_NCACTIVATE, FALSE, 0L ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 757 | SendMessageA( prevActiveWnd, WM_MDIACTIVATE, (WPARAM)prevActiveWnd, (LPARAM)child); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 758 | /* uncheck menu item */ |
| 759 | if( clientInfo->hWindowMenu ) |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 760 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 761 | UINT prevID = GetWindowLongA( prevActiveWnd, GWL_ID ); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 762 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 763 | if (prevID - clientInfo->idFirstChild < MDI_MOREWINDOWSLIMIT) |
| 764 | CheckMenuItem( clientInfo->hWindowMenu, prevID, 0); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 765 | else |
| 766 | CheckMenuItem( clientInfo->hWindowMenu, |
| 767 | clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT - 1, 0); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 768 | } |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 769 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 770 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 771 | /* set appearance */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 772 | if (clientInfo->hwndChildMaximized && clientInfo->hwndChildMaximized != child) |
Jesper Skov | 5c3e457 | 1998-11-01 19:27:22 +0000 | [diff] [blame] | 773 | { |
Dmitry Timoshkov | 040b3e1 | 2003-05-19 19:01:56 +0000 | [diff] [blame] | 774 | INT cmd = SW_SHOWNORMAL; |
| 775 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 776 | if( child ) |
| 777 | { |
Dmitry Timoshkov | 040b3e1 | 2003-05-19 19:01:56 +0000 | [diff] [blame] | 778 | UINT state = GetMenuState(GetSystemMenu(child, FALSE), SC_MAXIMIZE, MF_BYCOMMAND); |
| 779 | if (state != 0xFFFFFFFF && (state & (MF_DISABLED | MF_GRAYED))) |
| 780 | SendMessageW(clientInfo->hwndChildMaximized, WM_SYSCOMMAND, SC_RESTORE, 0); |
| 781 | else |
| 782 | cmd = SW_SHOWMAXIMIZED; |
| 783 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 784 | clientInfo->hwndActiveChild = child; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 785 | } |
Dmitry Timoshkov | 040b3e1 | 2003-05-19 19:01:56 +0000 | [diff] [blame] | 786 | |
| 787 | ShowWindow( clientInfo->hwndActiveChild, cmd ); |
Jesper Skov | 5c3e457 | 1998-11-01 19:27:22 +0000 | [diff] [blame] | 788 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 789 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 790 | clientInfo->hwndActiveChild = child; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 791 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 792 | /* check if we have any children left */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 793 | if( !child ) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 794 | { |
| 795 | if( isActiveFrameWnd ) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 796 | SetFocus( client ); |
| 797 | return 0; |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 798 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 799 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 800 | /* check menu item */ |
| 801 | if( clientInfo->hWindowMenu ) |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 802 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 803 | UINT id = GetWindowLongA( child, GWL_ID ); |
| 804 | /* The window to be activated must be displayed in the "Windows" menu */ |
| 805 | if (id >= clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT) |
| 806 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 807 | MDI_SwapMenuItems( GetParent(child), |
| 808 | id, clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT - 1); |
| 809 | id = clientInfo->idFirstChild + MDI_MOREWINDOWSLIMIT - 1; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 810 | MDI_MenuModifyItem( GetParent(child), child ); |
| 811 | } |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 812 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 813 | CheckMenuItem(clientInfo->hWindowMenu, id, MF_CHECKED); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 814 | } |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 815 | /* bring active child to the top */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 816 | SetWindowPos( child, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 817 | |
| 818 | if( isActiveFrameWnd ) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 819 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 820 | SendMessageA( child, WM_NCACTIVATE, TRUE, 0L); |
| 821 | if( GetFocus() == client ) |
| 822 | SendMessageA( client, WM_SETFOCUS, (WPARAM)client, 0L ); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 823 | else |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 824 | SetFocus( client ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 825 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 826 | SendMessageA( child, WM_MDIACTIVATE, (WPARAM)prevActiveWnd, (LPARAM)child ); |
| 827 | return TRUE; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 828 | } |
| 829 | |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 830 | /* -------------------- MDI client window functions ------------------- */ |
| 831 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 832 | /********************************************************************** |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 833 | * CreateMDIMenuBitmap |
| 834 | */ |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 835 | static HBITMAP CreateMDIMenuBitmap(void) |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 836 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 837 | HDC hDCSrc = CreateCompatibleDC(0); |
| 838 | HDC hDCDest = CreateCompatibleDC(hDCSrc); |
Alexandre Julliard | cc2d382 | 2002-01-03 02:35:23 +0000 | [diff] [blame] | 839 | HBITMAP hbClose = LoadBitmapW(0, MAKEINTRESOURCEW(OBM_OLD_CLOSE) ); |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 840 | HBITMAP hbCopy; |
| 841 | HBITMAP hobjSrc, hobjDest; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 842 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 843 | hobjSrc = SelectObject(hDCSrc, hbClose); |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 844 | hbCopy = CreateCompatibleBitmap(hDCSrc,GetSystemMetrics(SM_CXSIZE),GetSystemMetrics(SM_CYSIZE)); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 845 | hobjDest = SelectObject(hDCDest, hbCopy); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 846 | |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 847 | BitBlt(hDCDest, 0, 0, GetSystemMetrics(SM_CXSIZE), GetSystemMetrics(SM_CYSIZE), |
| 848 | hDCSrc, GetSystemMetrics(SM_CXSIZE), 0, SRCCOPY); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 849 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 850 | SelectObject(hDCSrc, hobjSrc); |
| 851 | DeleteObject(hbClose); |
| 852 | DeleteDC(hDCSrc); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 853 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 854 | hobjSrc = SelectObject( hDCDest, GetStockObject(BLACK_PEN) ); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 855 | |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 856 | MoveToEx( hDCDest, GetSystemMetrics(SM_CXSIZE) - 1, 0, NULL ); |
| 857 | LineTo( hDCDest, GetSystemMetrics(SM_CXSIZE) - 1, GetSystemMetrics(SM_CYSIZE) - 1); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 858 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 859 | SelectObject(hDCDest, hobjSrc ); |
| 860 | SelectObject(hDCDest, hobjDest); |
| 861 | DeleteDC(hDCDest); |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 862 | |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 863 | return hbCopy; |
| 864 | } |
| 865 | |
| 866 | /********************************************************************** |
| 867 | * MDICascade |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 868 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 869 | static LONG MDICascade( HWND client, MDICLIENTINFO *ci ) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 870 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 871 | HWND *win_array; |
| 872 | BOOL has_icons = FALSE; |
| 873 | int i, total; |
| 874 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 875 | if (ci->hwndChildMaximized) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 876 | SendMessageA( client, WM_MDIRESTORE, |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 877 | (WPARAM)ci->hwndChildMaximized, 0); |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 878 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 879 | if (ci->nActiveChildren == 0) return 0; |
Alexandre Julliard | 7cbe657 | 1995-01-09 18:21:16 +0000 | [diff] [blame] | 880 | |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 881 | if (!(win_array = WIN_ListChildren( client ))) return 0; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 882 | |
| 883 | /* remove all the windows we don't want */ |
| 884 | for (i = total = 0; win_array[i]; i++) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 885 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 886 | if (!IsWindowVisible( win_array[i] )) continue; |
| 887 | if (GetWindow( win_array[i], GW_OWNER )) continue; /* skip owned windows */ |
| 888 | if (IsIconic( win_array[i] )) |
| 889 | { |
| 890 | has_icons = TRUE; |
| 891 | continue; |
| 892 | } |
| 893 | win_array[total++] = win_array[i]; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 894 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 895 | win_array[total] = 0; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 896 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 897 | if (total) |
| 898 | { |
| 899 | INT delta = 0, n = 0, i; |
| 900 | POINT pos[2]; |
| 901 | if (has_icons) delta = GetSystemMetrics(SM_CYICONSPACING) + GetSystemMetrics(SM_CYICON); |
| 902 | |
| 903 | /* walk the list (backwards) and move windows */ |
| 904 | for (i = total - 1; i >= 0; i--) |
| 905 | { |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 906 | TRACE("move %p to (%ld,%ld) size [%ld,%ld]\n", |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 907 | win_array[i], pos[0].x, pos[0].y, pos[1].x, pos[1].y); |
| 908 | |
| 909 | MDI_CalcDefaultChildPos(client, n++, pos, delta); |
| 910 | SetWindowPos( win_array[i], 0, pos[0].x, pos[0].y, pos[1].x, pos[1].y, |
| 911 | SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER); |
| 912 | } |
| 913 | } |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 914 | HeapFree( GetProcessHeap(), 0, win_array ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 915 | |
| 916 | if (has_icons) ArrangeIconicWindows( client ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 917 | return 0; |
| 918 | } |
| 919 | |
| 920 | /********************************************************************** |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 921 | * MDITile |
| 922 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 923 | static void MDITile( HWND client, MDICLIENTINFO *ci, WPARAM wParam ) |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 924 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 925 | HWND *win_array; |
| 926 | int i, total; |
| 927 | BOOL has_icons = FALSE; |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 928 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 929 | if (ci->hwndChildMaximized) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 930 | SendMessageA( client, WM_MDIRESTORE, (WPARAM)ci->hwndChildMaximized, 0); |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 931 | |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 932 | if (ci->nActiveChildren == 0) return; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 933 | |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 934 | if (!(win_array = WIN_ListChildren( client ))) return; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 935 | |
| 936 | /* remove all the windows we don't want */ |
| 937 | for (i = total = 0; win_array[i]; i++) |
| 938 | { |
| 939 | if (!IsWindowVisible( win_array[i] )) continue; |
| 940 | if (GetWindow( win_array[i], GW_OWNER )) continue; /* skip owned windows (icon titles) */ |
| 941 | if (IsIconic( win_array[i] )) |
| 942 | { |
| 943 | has_icons = TRUE; |
| 944 | continue; |
| 945 | } |
| 946 | if ((wParam & MDITILE_SKIPDISABLED) && !IsWindowEnabled( win_array[i] )) continue; |
| 947 | win_array[total++] = win_array[i]; |
| 948 | } |
| 949 | win_array[total] = 0; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 950 | |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 951 | TRACE("%u windows to tile\n", total); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 952 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 953 | if (total) |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 954 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 955 | HWND *pWnd = win_array; |
| 956 | RECT rect; |
| 957 | int x, y, xsize, ysize; |
| 958 | int rows, columns, r, c, i; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 959 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 960 | GetClientRect(client,&rect); |
| 961 | rows = (int) sqrt((double)total); |
| 962 | columns = total / rows; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 963 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 964 | if( wParam & MDITILE_HORIZONTAL ) /* version >= 3.1 */ |
| 965 | { |
| 966 | i = rows; |
| 967 | rows = columns; /* exchange r and c */ |
| 968 | columns = i; |
| 969 | } |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 970 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 971 | if (has_icons) |
| 972 | { |
| 973 | y = rect.bottom - 2 * GetSystemMetrics(SM_CYICONSPACING) - GetSystemMetrics(SM_CYICON); |
| 974 | rect.bottom = ( y - GetSystemMetrics(SM_CYICON) < rect.top )? rect.bottom: y; |
| 975 | } |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 976 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 977 | ysize = rect.bottom / rows; |
| 978 | xsize = rect.right / columns; |
Alexandre Julliard | 23946ad | 1997-06-16 17:43:53 +0000 | [diff] [blame] | 979 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 980 | for (x = i = 0, c = 1; c <= columns && *pWnd; c++) |
| 981 | { |
| 982 | if (c == columns) |
| 983 | { |
| 984 | rows = total - i; |
| 985 | ysize = rect.bottom / rows; |
| 986 | } |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 987 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 988 | y = 0; |
| 989 | for (r = 1; r <= rows && *pWnd; r++, i++) |
| 990 | { |
| 991 | SetWindowPos(*pWnd, 0, x, y, xsize, ysize, |
| 992 | SWP_DRAWFRAME | SWP_NOACTIVATE | SWP_NOZORDER); |
| 993 | y += ysize; |
| 994 | pWnd++; |
| 995 | } |
| 996 | x += xsize; |
| 997 | } |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 998 | } |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 999 | HeapFree( GetProcessHeap(), 0, win_array ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1000 | if (has_icons) ArrangeIconicWindows( client ); |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1001 | } |
| 1002 | |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1003 | /* ----------------------- Frame window ---------------------------- */ |
| 1004 | |
| 1005 | |
| 1006 | /********************************************************************** |
| 1007 | * MDI_AugmentFrameMenu |
| 1008 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1009 | static BOOL MDI_AugmentFrameMenu( HWND frame, HWND hChild ) |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1010 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1011 | HMENU menu = GetMenu( frame ); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1012 | WND* child = WIN_FindWndPtr(hChild); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1013 | HMENU hSysPopup = 0; |
Abey George | 967ec70 | 1999-06-26 11:44:18 +0000 | [diff] [blame] | 1014 | HBITMAP hSysMenuBitmap = 0; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1015 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1016 | TRACE("frame %p,child %p\n",frame,hChild); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1017 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1018 | if( !menu || !child->hSysMenu ) |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1019 | { |
| 1020 | WIN_ReleaseWndPtr(child); |
| 1021 | return 0; |
| 1022 | } |
| 1023 | WIN_ReleaseWndPtr(child); |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1024 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1025 | /* create a copy of sysmenu popup and insert it into frame menu bar */ |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1026 | |
Bertho Stultiens | d1895a7 | 1999-04-25 18:31:35 +0000 | [diff] [blame] | 1027 | if (!(hSysPopup = LoadMenuA(GetModuleHandleA("USER32"), "SYSMENU"))) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1028 | return 0; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1029 | |
| 1030 | AppendMenuA(menu,MF_HELP | MF_BITMAP, |
Juergen Schmied | 7851394 | 1999-04-18 14:40:32 +0000 | [diff] [blame] | 1031 | SC_MINIMIZE, (LPSTR)(DWORD)HBMMENU_MBAR_MINIMIZE ) ; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1032 | AppendMenuA(menu,MF_HELP | MF_BITMAP, |
Juergen Schmied | 7851394 | 1999-04-18 14:40:32 +0000 | [diff] [blame] | 1033 | SC_RESTORE, (LPSTR)(DWORD)HBMMENU_MBAR_RESTORE ); |
Francois Boisvert | 197a8e1 | 1999-02-13 09:10:17 +0000 | [diff] [blame] | 1034 | |
Abey George | 967ec70 | 1999-06-26 11:44:18 +0000 | [diff] [blame] | 1035 | /* In Win 95 look, the system menu is replaced by the child icon */ |
| 1036 | |
| 1037 | if(TWEAK_WineLook > WIN31_LOOK) |
| 1038 | { |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 1039 | HICON hIcon = (HICON)GetClassLongA(hChild, GCL_HICONSM); |
Abey George | 967ec70 | 1999-06-26 11:44:18 +0000 | [diff] [blame] | 1040 | if (!hIcon) |
Michael Stefaniuc | bc54d78 | 2002-10-10 21:22:09 +0000 | [diff] [blame] | 1041 | hIcon = (HICON)GetClassLongA(hChild, GCL_HICON); |
Abey George | 967ec70 | 1999-06-26 11:44:18 +0000 | [diff] [blame] | 1042 | if (hIcon) |
| 1043 | { |
| 1044 | HDC hMemDC; |
| 1045 | HBITMAP hBitmap, hOldBitmap; |
| 1046 | HBRUSH hBrush; |
| 1047 | HDC hdc = GetDC(hChild); |
| 1048 | |
| 1049 | if (hdc) |
| 1050 | { |
| 1051 | int cx, cy; |
| 1052 | cx = GetSystemMetrics(SM_CXSMICON); |
| 1053 | cy = GetSystemMetrics(SM_CYSMICON); |
| 1054 | hMemDC = CreateCompatibleDC(hdc); |
| 1055 | hBitmap = CreateCompatibleBitmap(hdc, cx, cy); |
| 1056 | hOldBitmap = SelectObject(hMemDC, hBitmap); |
| 1057 | SetMapMode(hMemDC, MM_TEXT); |
| 1058 | hBrush = CreateSolidBrush(GetSysColor(COLOR_MENU)); |
| 1059 | DrawIconEx(hMemDC, 0, 0, hIcon, cx, cy, 0, hBrush, DI_NORMAL); |
| 1060 | SelectObject (hMemDC, hOldBitmap); |
| 1061 | DeleteObject(hBrush); |
| 1062 | DeleteDC(hMemDC); |
| 1063 | ReleaseDC(hChild, hdc); |
| 1064 | hSysMenuBitmap = hBitmap; |
| 1065 | } |
| 1066 | } |
| 1067 | } |
| 1068 | else |
| 1069 | hSysMenuBitmap = hBmpClose; |
| 1070 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1071 | if( !InsertMenuA(menu,0,MF_BYPOSITION | MF_BITMAP | MF_POPUP, |
Alexandre Julliard | 7ef66af | 2002-11-22 04:47:10 +0000 | [diff] [blame] | 1072 | (UINT_PTR)hSysPopup, (LPSTR)hSysMenuBitmap)) |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1073 | { |
Alexandre Julliard | 359f497e | 1999-07-04 16:02:24 +0000 | [diff] [blame] | 1074 | TRACE("not inserted\n"); |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1075 | DestroyMenu(hSysPopup); |
| 1076 | return 0; |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1077 | } |
Huw D M Davies | bc1d1df | 1999-02-14 09:20:01 +0000 | [diff] [blame] | 1078 | |
Patrik Stridvall | 0f8bc5b | 1999-04-22 16:27:50 +0000 | [diff] [blame] | 1079 | /* The close button is only present in Win 95 look */ |
Huw D M Davies | bc1d1df | 1999-02-14 09:20:01 +0000 | [diff] [blame] | 1080 | if(TWEAK_WineLook > WIN31_LOOK) |
| 1081 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1082 | AppendMenuA(menu,MF_HELP | MF_BITMAP, |
Juergen Schmied | 7851394 | 1999-04-18 14:40:32 +0000 | [diff] [blame] | 1083 | SC_CLOSE, (LPSTR)(DWORD)HBMMENU_MBAR_CLOSE ); |
Huw D M Davies | bc1d1df | 1999-02-14 09:20:01 +0000 | [diff] [blame] | 1084 | } |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1085 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1086 | EnableMenuItem(hSysPopup, SC_SIZE, MF_BYCOMMAND | MF_GRAYED); |
| 1087 | EnableMenuItem(hSysPopup, SC_MOVE, MF_BYCOMMAND | MF_GRAYED); |
| 1088 | EnableMenuItem(hSysPopup, SC_MAXIMIZE, MF_BYCOMMAND | MF_GRAYED); |
Juergen Schmied | 9090502 | 1999-05-17 15:05:08 +0000 | [diff] [blame] | 1089 | SetMenuDefaultItem(hSysPopup, SC_CLOSE, FALSE); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1090 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1091 | /* redraw menu */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1092 | DrawMenuBar(frame); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1093 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1094 | return 1; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1095 | } |
| 1096 | |
| 1097 | /********************************************************************** |
| 1098 | * MDI_RestoreFrameMenu |
| 1099 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1100 | static BOOL MDI_RestoreFrameMenu( HWND frame, HWND hChild ) |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1101 | { |
Dmitry Timoshkov | aab85d7 | 2001-01-15 20:21:15 +0000 | [diff] [blame] | 1102 | MENUITEMINFOW menuInfo; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1103 | HMENU menu = GetMenu( frame ); |
| 1104 | INT nItems = GetMenuItemCount(menu) - 1; |
| 1105 | UINT iId = GetMenuItemID(menu,nItems) ; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1106 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1107 | TRACE("frame %p,child %p,nIt=%d,iId=%d\n",frame,hChild,nItems,iId); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1108 | |
Francois Boisvert | 197a8e1 | 1999-02-13 09:10:17 +0000 | [diff] [blame] | 1109 | if(!(iId == SC_RESTORE || iId == SC_CLOSE) ) |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1110 | return 0; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1111 | |
Francis Beaudet | 4691d0c | 1999-07-30 18:02:04 +0000 | [diff] [blame] | 1112 | /* |
| 1113 | * Remove the system menu, If that menu is the icon of the window |
| 1114 | * as it is in win95, we have to delete the bitmap. |
| 1115 | */ |
Dmitry Timoshkov | aab85d7 | 2001-01-15 20:21:15 +0000 | [diff] [blame] | 1116 | memset(&menuInfo, 0, sizeof(menuInfo)); |
| 1117 | menuInfo.cbSize = sizeof(menuInfo); |
Francis Beaudet | 4691d0c | 1999-07-30 18:02:04 +0000 | [diff] [blame] | 1118 | menuInfo.fMask = MIIM_DATA | MIIM_TYPE; |
| 1119 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1120 | GetMenuItemInfoW(menu, |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1121 | 0, |
Francis Beaudet | 4691d0c | 1999-07-30 18:02:04 +0000 | [diff] [blame] | 1122 | TRUE, |
| 1123 | &menuInfo); |
| 1124 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1125 | RemoveMenu(menu,0,MF_BYPOSITION); |
Huw D M Davies | bc1d1df | 1999-02-14 09:20:01 +0000 | [diff] [blame] | 1126 | |
Francis Beaudet | 4691d0c | 1999-07-30 18:02:04 +0000 | [diff] [blame] | 1127 | if ( (menuInfo.fType & MFT_BITMAP) && |
| 1128 | (LOWORD(menuInfo.dwTypeData)!=0) && |
Alexandre Julliard | a8a422f | 2002-11-22 20:43:01 +0000 | [diff] [blame] | 1129 | (LOWORD(menuInfo.dwTypeData)!=HBITMAP_16(hBmpClose)) ) |
Francis Beaudet | 4691d0c | 1999-07-30 18:02:04 +0000 | [diff] [blame] | 1130 | { |
Alexandre Julliard | a8a422f | 2002-11-22 20:43:01 +0000 | [diff] [blame] | 1131 | DeleteObject(HBITMAP_32(LOWORD(menuInfo.dwTypeData))); |
Francis Beaudet | 4691d0c | 1999-07-30 18:02:04 +0000 | [diff] [blame] | 1132 | } |
| 1133 | |
Francois Boisvert | 197a8e1 | 1999-02-13 09:10:17 +0000 | [diff] [blame] | 1134 | if(TWEAK_WineLook > WIN31_LOOK) |
| 1135 | { |
Patrik Stridvall | 0f8bc5b | 1999-04-22 16:27:50 +0000 | [diff] [blame] | 1136 | /* close */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1137 | DeleteMenu(menu,GetMenuItemCount(menu) - 1,MF_BYPOSITION); |
Francois Boisvert | 197a8e1 | 1999-02-13 09:10:17 +0000 | [diff] [blame] | 1138 | } |
Patrik Stridvall | 0f8bc5b | 1999-04-22 16:27:50 +0000 | [diff] [blame] | 1139 | /* restore */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1140 | DeleteMenu(menu,GetMenuItemCount(menu) - 1,MF_BYPOSITION); |
Patrik Stridvall | 0f8bc5b | 1999-04-22 16:27:50 +0000 | [diff] [blame] | 1141 | /* minimize */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1142 | DeleteMenu(menu,GetMenuItemCount(menu) - 1,MF_BYPOSITION); |
Francois Boisvert | 47e2b85 | 1999-02-09 14:11:19 +0000 | [diff] [blame] | 1143 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1144 | DrawMenuBar(frame); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1145 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1146 | return 1; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1147 | } |
| 1148 | |
Francois Boisvert | 197a8e1 | 1999-02-13 09:10:17 +0000 | [diff] [blame] | 1149 | |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1150 | /********************************************************************** |
| 1151 | * MDI_UpdateFrameText |
| 1152 | * |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1153 | * used when child window is maximized/restored |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1154 | * |
| 1155 | * Note: lpTitle can be NULL |
| 1156 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1157 | static void MDI_UpdateFrameText( HWND frame, HWND hClient, |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1158 | BOOL repaint, LPCWSTR lpTitle ) |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1159 | { |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1160 | WCHAR lpBuffer[MDI_MAXTITLELENGTH+1]; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1161 | MDICLIENTINFO *ci = get_client_info( hClient ); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1162 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1163 | TRACE("repaint %i, frameText %s\n", repaint, debugstr_w(lpTitle)); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1164 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1165 | if (!ci) return; |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 1166 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1167 | if (!lpTitle && !ci->frameTitle) /* first time around, get title from the frame window */ |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1168 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1169 | GetWindowTextW( frame, lpBuffer, sizeof(lpBuffer)/sizeof(WCHAR) ); |
| 1170 | lpTitle = lpBuffer; |
Francois Boisvert | 3a3cd9f | 1999-03-28 12:42:52 +0000 | [diff] [blame] | 1171 | } |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 1172 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1173 | /* store new "default" title if lpTitle is not NULL */ |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1174 | if (lpTitle) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1175 | { |
Alexandre Julliard | da2892c | 2001-02-23 01:13:42 +0000 | [diff] [blame] | 1176 | if (ci->frameTitle) HeapFree( GetProcessHeap(), 0, ci->frameTitle ); |
Alexandre Julliard | ef06b4a | 2001-07-22 23:08:10 +0000 | [diff] [blame] | 1177 | if ((ci->frameTitle = HeapAlloc( GetProcessHeap(), 0, (strlenW(lpTitle)+1)*sizeof(WCHAR)))) |
| 1178 | strcpyW( ci->frameTitle, lpTitle ); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1179 | } |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1180 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1181 | if (ci->frameTitle) |
| 1182 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1183 | if (ci->hwndChildMaximized) |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1184 | { |
| 1185 | /* combine frame title and child title if possible */ |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1186 | |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1187 | static const WCHAR lpBracket[] = {' ','-',' ','[',0}; |
| 1188 | static const WCHAR lpBracket2[] = {']',0}; |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 1189 | int i_frame_text_length = strlenW(ci->frameTitle); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1190 | |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1191 | lstrcpynW( lpBuffer, ci->frameTitle, MDI_MAXTITLELENGTH); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1192 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1193 | if( i_frame_text_length + 6 < MDI_MAXTITLELENGTH ) |
| 1194 | { |
Alexandre Julliard | c7e7df8 | 2000-08-14 14:41:19 +0000 | [diff] [blame] | 1195 | strcatW( lpBuffer, lpBracket ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1196 | if (GetWindowTextW( ci->hwndChildMaximized, lpBuffer + i_frame_text_length + 4, |
| 1197 | MDI_MAXTITLELENGTH - i_frame_text_length - 5 )) |
| 1198 | strcatW( lpBuffer, lpBracket2 ); |
| 1199 | else |
| 1200 | lpBuffer[i_frame_text_length] = 0; /* remove bracket */ |
| 1201 | } |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1202 | } |
| 1203 | else |
| 1204 | { |
Dmitry Timoshkov | 04da8b8 | 2000-07-10 12:09:31 +0000 | [diff] [blame] | 1205 | lstrcpynW(lpBuffer, ci->frameTitle, MDI_MAXTITLELENGTH+1 ); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1206 | } |
| 1207 | } |
| 1208 | else |
| 1209 | lpBuffer[0] = '\0'; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1210 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1211 | DefWindowProcW( frame, WM_SETTEXT, 0, (LPARAM)lpBuffer ); |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1212 | if( repaint == MDI_REPAINTFRAME) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1213 | SetWindowPos( frame, 0,0,0,0,0, SWP_FRAMECHANGED | |
| 1214 | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER ); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1215 | } |
| 1216 | |
| 1217 | |
| 1218 | /* ----------------------------- Interface ---------------------------- */ |
| 1219 | |
| 1220 | |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1221 | /********************************************************************** |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1222 | * MDIClientWndProc_common |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1223 | */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1224 | static LRESULT MDIClientWndProc_common( HWND hwnd, UINT message, |
| 1225 | WPARAM wParam, LPARAM lParam, BOOL unicode ) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1226 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1227 | MDICLIENTINFO *ci; |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1228 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1229 | if (!(ci = get_client_info( hwnd ))) return 0; |
Eric Pouech | fa9724f | 1999-07-23 19:21:56 +0000 | [diff] [blame] | 1230 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1231 | switch (message) |
| 1232 | { |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1233 | case WM_CREATE: |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1234 | { |
| 1235 | RECT rect; |
| 1236 | /* Since we are using only cs->lpCreateParams, we can safely |
| 1237 | * cast to LPCREATESTRUCTA here */ |
| 1238 | LPCREATESTRUCTA cs = (LPCREATESTRUCTA)lParam; |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1239 | WND *wndPtr = WIN_GetPtr( hwnd ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1240 | |
| 1241 | /* Translation layer doesn't know what's in the cs->lpCreateParams |
| 1242 | * so we have to keep track of what environment we're in. */ |
| 1243 | |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1244 | if( wndPtr->flags & WIN_ISWIN32 ) |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1245 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1246 | #define ccs ((LPCLIENTCREATESTRUCT)cs->lpCreateParams) |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1247 | ci->hWindowMenu = ccs->hWindowMenu; |
| 1248 | ci->idFirstChild = ccs->idFirstChild; |
| 1249 | #undef ccs |
| 1250 | } |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1251 | else |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1252 | { |
Alexandre Julliard | 982a223 | 2000-12-13 20:20:09 +0000 | [diff] [blame] | 1253 | LPCLIENTCREATESTRUCT16 ccs = MapSL((SEGPTR)cs->lpCreateParams); |
Alexandre Julliard | a8a422f | 2002-11-22 20:43:01 +0000 | [diff] [blame] | 1254 | ci->hWindowMenu = HMENU_32(ccs->hWindowMenu); |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1255 | ci->idFirstChild = ccs->idFirstChild; |
| 1256 | } |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1257 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1258 | |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1259 | ci->hwndChildMaximized = 0; |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 1260 | ci->nActiveChildren = 0; |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1261 | ci->nTotalCreated = 0; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1262 | ci->frameTitle = NULL; |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1263 | ci->mdiFlags = 0; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1264 | SetWindowLongW( hwnd, GWL_STYLE, GetWindowLongW(hwnd,GWL_STYLE) | WS_CLIPCHILDREN ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1265 | |
Alexandre Julliard | cc2d382 | 2002-01-03 02:35:23 +0000 | [diff] [blame] | 1266 | if (!hBmpClose) hBmpClose = CreateMDIMenuBitmap(); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 1267 | |
Matthew Cline | c448c5c | 2000-02-13 15:05:07 +0000 | [diff] [blame] | 1268 | if (ci->hWindowMenu != 0) |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1269 | AppendMenuW( ci->hWindowMenu, MF_SEPARATOR, 0, NULL ); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1270 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1271 | GetClientRect( GetParent(hwnd), &rect); |
| 1272 | MoveWindow( hwnd, 0, 0, rect.right, rect.bottom, FALSE ); |
| 1273 | |
| 1274 | MDI_UpdateFrameText( GetParent(hwnd), hwnd, MDI_NOFRAMEREPAINT, NULL); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1275 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1276 | TRACE("Client created - hwnd = %p, idFirst = %u\n", hwnd, ci->idFirstChild ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1277 | return 0; |
| 1278 | } |
Alexandre Julliard | d2e1c1a | 1996-03-09 16:12:43 +0000 | [diff] [blame] | 1279 | |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1280 | case WM_DESTROY: |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1281 | { |
| 1282 | INT nItems; |
| 1283 | if( ci->hwndChildMaximized ) |
| 1284 | MDI_RestoreFrameMenu( GetParent(hwnd), ci->hwndChildMaximized); |
| 1285 | if((ci->hWindowMenu != 0) && |
| 1286 | (nItems = GetMenuItemCount(ci->hWindowMenu)) > 0) |
| 1287 | { |
| 1288 | ci->idFirstChild = nItems - 1; |
| 1289 | ci->nActiveChildren++; /* to delete a separator */ |
| 1290 | while( ci->nActiveChildren-- ) |
| 1291 | DeleteMenu(ci->hWindowMenu,MF_BYPOSITION,ci->idFirstChild--); |
| 1292 | } |
| 1293 | if (ci->frameTitle) HeapFree( GetProcessHeap(), 0, ci->frameTitle ); |
| 1294 | return 0; |
| 1295 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1296 | |
| 1297 | case WM_MDIACTIVATE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1298 | if( ci->hwndActiveChild != (HWND)wParam ) |
| 1299 | SetWindowPos((HWND)wParam, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1300 | return 0; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1301 | |
| 1302 | case WM_MDICASCADE: |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1303 | return MDICascade(hwnd, ci); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1304 | |
| 1305 | case WM_MDICREATE: |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1306 | if (lParam) |
| 1307 | return (LRESULT)MDICreateChild( hwnd, ci, (MDICREATESTRUCTA *)lParam, unicode ); |
| 1308 | return 0; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1309 | |
| 1310 | case WM_MDIDESTROY: |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1311 | return MDIDestroyChild( hwnd, ci, WIN_GetFullHandle( (HWND)wParam ), TRUE ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1312 | |
| 1313 | case WM_MDIGETACTIVE: |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1314 | if (lParam) *(BOOL *)lParam = (ci->hwndChildMaximized != 0); |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1315 | return (LRESULT)ci->hwndActiveChild; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1316 | |
| 1317 | case WM_MDIICONARRANGE: |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1318 | ci->mdiFlags |= MDIF_NEEDUPDATE; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1319 | ArrangeIconicWindows( hwnd ); |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 1320 | ci->sbRecalc = SB_BOTH+1; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1321 | SendMessageW( hwnd, WM_MDICALCCHILDSCROLL, 0, 0 ); |
| 1322 | return 0; |
| 1323 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1324 | case WM_MDIMAXIMIZE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1325 | ShowWindow( (HWND)wParam, SW_MAXIMIZE ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1326 | return 0; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1327 | |
Alexandre Julliard | 77b9918 | 1997-09-14 17:17:23 +0000 | [diff] [blame] | 1328 | case WM_MDINEXT: /* lParam != 0 means previous window */ |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1329 | MDI_SwitchActiveChild( hwnd, WIN_GetFullHandle( (HWND)wParam ), !lParam ); |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1330 | break; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1331 | |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1332 | case WM_MDIRESTORE: |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1333 | SendMessageW( (HWND)wParam, WM_SYSCOMMAND, SC_RESTORE, 0); |
| 1334 | return 0; |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1335 | |
| 1336 | case WM_MDISETMENU: |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1337 | return MDISetMenu( hwnd, (HMENU)wParam, (HMENU)lParam ); |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1338 | |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 1339 | case WM_MDIREFRESHMENU: |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1340 | return MDIRefreshMenu( hwnd, (HMENU)wParam, (HMENU)lParam ); |
Alexandre Julliard | 85ed45e | 1998-08-22 19:03:56 +0000 | [diff] [blame] | 1341 | |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1342 | case WM_MDITILE: |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1343 | ci->mdiFlags |= MDIF_NEEDUPDATE; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1344 | ShowScrollBar( hwnd, SB_BOTH, FALSE ); |
| 1345 | MDITile( hwnd, ci, wParam ); |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1346 | ci->mdiFlags &= ~MDIF_NEEDUPDATE; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1347 | return 0; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 1348 | |
| 1349 | case WM_VSCROLL: |
| 1350 | case WM_HSCROLL: |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1351 | ci->mdiFlags |= MDIF_NEEDUPDATE; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1352 | ScrollChildren( hwnd, message, wParam, lParam ); |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1353 | ci->mdiFlags &= ~MDIF_NEEDUPDATE; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1354 | return 0; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 1355 | |
| 1356 | case WM_SETFOCUS: |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1357 | if (ci->hwndActiveChild && !IsIconic( ci->hwndActiveChild )) |
| 1358 | SetFocus( ci->hwndActiveChild ); |
| 1359 | return 0; |
| 1360 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1361 | case WM_NCACTIVATE: |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 1362 | if( ci->hwndActiveChild ) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1363 | SendMessageW(ci->hwndActiveChild, message, wParam, lParam); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1364 | break; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1365 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1366 | case WM_PARENTNOTIFY: |
Alexandre Julliard | a0b2b1d | 1997-11-16 17:38:29 +0000 | [diff] [blame] | 1367 | if (LOWORD(wParam) == WM_LBUTTONDOWN) |
Alexandre Julliard | e2bfa4c | 1996-05-16 18:21:06 +0000 | [diff] [blame] | 1368 | { |
Alexandre Julliard | 83f52d1 | 2000-09-26 22:20:14 +0000 | [diff] [blame] | 1369 | HWND child; |
| 1370 | POINT pt; |
| 1371 | pt.x = SLOWORD(lParam); |
| 1372 | pt.y = SHIWORD(lParam); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1373 | child = ChildWindowFromPoint(hwnd, pt); |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 1374 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1375 | TRACE("notification from %p (%li,%li)\n",child,pt.x,pt.y); |
Alexandre Julliard | c981d0b | 1996-03-31 16:40:13 +0000 | [diff] [blame] | 1376 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1377 | if( child && child != hwnd && child != ci->hwndActiveChild ) |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1378 | SetWindowPos(child, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE ); |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1379 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1380 | return 0; |
Alexandre Julliard | 5819953 | 1994-04-21 01:20:00 +0000 | [diff] [blame] | 1381 | |
| 1382 | case WM_SIZE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1383 | if( IsWindow(ci->hwndChildMaximized) ) |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1384 | { |
Patrik Stridvall | 0f8bc5b | 1999-04-22 16:27:50 +0000 | [diff] [blame] | 1385 | RECT rect; |
| 1386 | |
| 1387 | rect.left = 0; |
| 1388 | rect.top = 0; |
| 1389 | rect.right = LOWORD(lParam); |
| 1390 | rect.bottom = HIWORD(lParam); |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1391 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1392 | AdjustWindowRectEx(&rect, GetWindowLongA(ci->hwndChildMaximized,GWL_STYLE), |
| 1393 | 0, GetWindowLongA(ci->hwndChildMaximized,GWL_EXSTYLE) ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1394 | MoveWindow(ci->hwndChildMaximized, rect.left, rect.top, |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1395 | rect.right - rect.left, rect.bottom - rect.top, 1); |
| 1396 | } |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1397 | else |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1398 | MDI_PostUpdate(hwnd, ci, SB_BOTH+1); |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 1399 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1400 | break; |
| 1401 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 1402 | case WM_MDICALCCHILDSCROLL: |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1403 | if( (ci->mdiFlags & MDIF_NEEDUPDATE) && ci->sbRecalc ) |
| 1404 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1405 | CalcChildScroll(hwnd, ci->sbRecalc-1); |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1406 | ci->sbRecalc = 0; |
| 1407 | ci->mdiFlags &= ~MDIF_NEEDUPDATE; |
| 1408 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1409 | return 0; |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1410 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1411 | return unicode ? DefWindowProcW( hwnd, message, wParam, lParam ) : |
| 1412 | DefWindowProcA( hwnd, message, wParam, lParam ); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1413 | } |
| 1414 | |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1415 | /*********************************************************************** |
| 1416 | * MDIClientWndProcA |
| 1417 | */ |
| 1418 | static LRESULT WINAPI MDIClientWndProcA( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) |
| 1419 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1420 | if (!IsWindow(hwnd)) return 0; |
| 1421 | return MDIClientWndProc_common( hwnd, message, wParam, lParam, FALSE ); |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1422 | } |
| 1423 | |
| 1424 | /*********************************************************************** |
| 1425 | * MDIClientWndProcW |
| 1426 | */ |
| 1427 | static LRESULT WINAPI MDIClientWndProcW( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) |
| 1428 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1429 | if (!IsWindow(hwnd)) return 0; |
| 1430 | return MDIClientWndProc_common( hwnd, message, wParam, lParam, TRUE ); |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1431 | } |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1432 | |
| 1433 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1434 | * DefFrameProc (USER.445) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1435 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1436 | LRESULT WINAPI DefFrameProc16( HWND16 hwnd, HWND16 hwndMDIClient, |
| 1437 | UINT16 message, WPARAM16 wParam, LPARAM lParam ) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1438 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1439 | switch (message) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1440 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1441 | case WM_SETTEXT: |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1442 | lParam = (LPARAM)MapSL(lParam); |
| 1443 | /* fall through */ |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1444 | case WM_COMMAND: |
| 1445 | case WM_NCACTIVATE: |
| 1446 | case WM_SETFOCUS: |
| 1447 | case WM_SIZE: |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1448 | return DefFrameProcA( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient), |
| 1449 | message, wParam, lParam ); |
Guy Albertelli | 4a6af35 | 1999-03-13 17:03:41 +0000 | [diff] [blame] | 1450 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1451 | case WM_NEXTMENU: |
| 1452 | { |
| 1453 | MDINEXTMENU next_menu; |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 1454 | DefFrameProcW( WIN_Handle32(hwnd), WIN_Handle32(hwndMDIClient), |
| 1455 | message, wParam, (LPARAM)&next_menu ); |
Alexandre Julliard | 7ef66af | 2002-11-22 04:47:10 +0000 | [diff] [blame] | 1456 | return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1457 | } |
| 1458 | default: |
| 1459 | return DefWindowProc16(hwnd, message, wParam, lParam); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1460 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1461 | } |
| 1462 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1463 | |
| 1464 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1465 | * DefFrameProcA (USER32.@) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1466 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1467 | LRESULT WINAPI DefFrameProcA( HWND hwnd, HWND hwndMDIClient, |
| 1468 | UINT message, WPARAM wParam, LPARAM lParam) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1469 | { |
| 1470 | if (hwndMDIClient) |
| 1471 | { |
| 1472 | switch (message) |
| 1473 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1474 | case WM_SETTEXT: |
| 1475 | { |
Alexandre Julliard | 193cf50 | 2002-01-01 00:24:30 +0000 | [diff] [blame] | 1476 | DWORD len = MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, NULL, 0 ); |
| 1477 | LPWSTR text = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); |
| 1478 | MultiByteToWideChar( CP_ACP, 0, (LPSTR)lParam, -1, text, len ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1479 | MDI_UpdateFrameText(hwnd, hwndMDIClient, MDI_REPAINTFRAME, text ); |
| 1480 | HeapFree( GetProcessHeap(), 0, text ); |
| 1481 | } |
| 1482 | return 1; /* success. FIXME: check text length */ |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1483 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1484 | case WM_COMMAND: |
| 1485 | case WM_NCACTIVATE: |
| 1486 | case WM_NEXTMENU: |
| 1487 | case WM_SETFOCUS: |
| 1488 | case WM_SIZE: |
| 1489 | return DefFrameProcW( hwnd, hwndMDIClient, message, wParam, lParam ); |
| 1490 | } |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1491 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1492 | return DefWindowProcA(hwnd, message, wParam, lParam); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1493 | } |
| 1494 | |
| 1495 | |
| 1496 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1497 | * DefFrameProcW (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1498 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1499 | LRESULT WINAPI DefFrameProcW( HWND hwnd, HWND hwndMDIClient, |
| 1500 | UINT message, WPARAM wParam, LPARAM lParam) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1501 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1502 | MDICLIENTINFO *ci = get_client_info( hwndMDIClient ); |
| 1503 | |
| 1504 | if (ci) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1505 | { |
| 1506 | switch (message) |
| 1507 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1508 | case WM_COMMAND: |
| 1509 | { |
| 1510 | WORD id = LOWORD(wParam); |
| 1511 | /* check for possible syscommands for maximized MDI child */ |
| 1512 | if (id < ci->idFirstChild || id >= ci->idFirstChild + ci->nActiveChildren) |
| 1513 | { |
| 1514 | if( (id - 0xf000) & 0xf00f ) break; |
| 1515 | if( !ci->hwndChildMaximized ) break; |
| 1516 | switch( id ) |
| 1517 | { |
| 1518 | case SC_SIZE: |
| 1519 | case SC_MOVE: |
| 1520 | case SC_MINIMIZE: |
| 1521 | case SC_MAXIMIZE: |
| 1522 | case SC_NEXTWINDOW: |
| 1523 | case SC_PREVWINDOW: |
| 1524 | case SC_CLOSE: |
| 1525 | case SC_RESTORE: |
| 1526 | return SendMessageW( ci->hwndChildMaximized, WM_SYSCOMMAND, |
| 1527 | wParam, lParam); |
| 1528 | } |
| 1529 | } |
| 1530 | else |
| 1531 | { |
| 1532 | HWND childHwnd; |
| 1533 | if (id - ci->idFirstChild == MDI_MOREWINDOWSLIMIT) |
| 1534 | /* User chose "More Windows..." */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1535 | childHwnd = MDI_MoreWindowsDialog(hwndMDIClient); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1536 | else |
| 1537 | /* User chose one of the windows listed in the "Windows" menu */ |
| 1538 | childHwnd = MDI_GetChildByID(hwndMDIClient,id); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1539 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1540 | if( childHwnd ) |
| 1541 | SendMessageW( hwndMDIClient, WM_MDIACTIVATE, (WPARAM)childHwnd, 0 ); |
| 1542 | } |
| 1543 | } |
| 1544 | break; |
| 1545 | |
| 1546 | case WM_NCACTIVATE: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1547 | SendMessageW(hwndMDIClient, message, wParam, lParam); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1548 | break; |
| 1549 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1550 | case WM_SETTEXT: |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1551 | MDI_UpdateFrameText(hwnd, hwndMDIClient, MDI_REPAINTFRAME, (LPWSTR)lParam ); |
| 1552 | return 1; /* success. FIXME: check text length */ |
| 1553 | |
| 1554 | case WM_SETFOCUS: |
| 1555 | SetFocus(hwndMDIClient); |
| 1556 | break; |
| 1557 | |
| 1558 | case WM_SIZE: |
| 1559 | MoveWindow(hwndMDIClient, 0, 0, LOWORD(lParam), HIWORD(lParam), TRUE); |
| 1560 | break; |
| 1561 | |
| 1562 | case WM_NEXTMENU: |
| 1563 | { |
| 1564 | MDINEXTMENU *next_menu = (MDINEXTMENU *)lParam; |
| 1565 | |
| 1566 | if (!IsIconic(hwnd) && ci->hwndActiveChild && !ci->hwndChildMaximized) |
| 1567 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1568 | /* control menu is between the frame system menu and |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1569 | * the first entry of menu bar */ |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1570 | WND *wndPtr = WIN_GetPtr(hwnd); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1571 | |
| 1572 | if( (wParam == VK_LEFT && GetMenu(hwnd) == next_menu->hmenuIn) || |
| 1573 | (wParam == VK_RIGHT && GetSubMenu(wndPtr->hSysMenu, 0) == next_menu->hmenuIn) ) |
| 1574 | { |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1575 | WIN_ReleasePtr(wndPtr); |
| 1576 | wndPtr = WIN_GetPtr(ci->hwndActiveChild); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1577 | next_menu->hmenuNext = GetSubMenu(wndPtr->hSysMenu, 0); |
| 1578 | next_menu->hwndNext = ci->hwndActiveChild; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1579 | } |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1580 | WIN_ReleasePtr(wndPtr); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1581 | } |
| 1582 | return 0; |
| 1583 | } |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1584 | } |
| 1585 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1586 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1587 | return DefWindowProcW( hwnd, message, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1588 | } |
| 1589 | |
| 1590 | |
| 1591 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1592 | * DefMDIChildProc (USER.447) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1593 | */ |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1594 | LRESULT WINAPI DefMDIChildProc16( HWND16 hwnd, UINT16 message, |
| 1595 | WPARAM16 wParam, LPARAM lParam ) |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1596 | { |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1597 | switch (message) |
| 1598 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1599 | case WM_SETTEXT: |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1600 | return DefMDIChildProcA( WIN_Handle32(hwnd), message, wParam, (LPARAM)MapSL(lParam) ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1601 | case WM_MENUCHAR: |
| 1602 | case WM_CLOSE: |
| 1603 | case WM_SETFOCUS: |
| 1604 | case WM_CHILDACTIVATE: |
| 1605 | case WM_SYSCOMMAND: |
| 1606 | case WM_SETVISIBLE: |
| 1607 | case WM_SIZE: |
| 1608 | case WM_SYSCHAR: |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1609 | return DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, lParam ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1610 | case WM_GETMINMAXINFO: |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1611 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1612 | MINMAXINFO16 *mmi16 = (MINMAXINFO16 *)MapSL(lParam); |
| 1613 | MINMAXINFO mmi; |
| 1614 | STRUCT32_MINMAXINFO16to32( mmi16, &mmi ); |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1615 | DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&mmi ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1616 | STRUCT32_MINMAXINFO32to16( &mmi, mmi16 ); |
| 1617 | return 0; |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1618 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1619 | case WM_NEXTMENU: |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1620 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1621 | MDINEXTMENU next_menu; |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1622 | DefMDIChildProcW( WIN_Handle32(hwnd), message, wParam, (LPARAM)&next_menu ); |
Alexandre Julliard | 7ef66af | 2002-11-22 04:47:10 +0000 | [diff] [blame] | 1623 | return MAKELONG( HMENU_16(next_menu.hmenuNext), HWND_16(next_menu.hwndNext) ); |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 1624 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1625 | default: |
| 1626 | return DefWindowProc16(hwnd, message, wParam, lParam); |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1627 | } |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1628 | } |
| 1629 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1630 | |
| 1631 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1632 | * DefMDIChildProcA (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1633 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1634 | LRESULT WINAPI DefMDIChildProcA( HWND hwnd, UINT message, |
| 1635 | WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1636 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1637 | HWND client = GetParent(hwnd); |
| 1638 | MDICLIENTINFO *ci = get_client_info( client ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1639 | |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1640 | hwnd = WIN_GetFullHandle( hwnd ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1641 | if (!ci) return DefWindowProcA( hwnd, message, wParam, lParam ); |
Ulrich Weigand | 1848c80 | 2000-10-19 20:24:06 +0000 | [diff] [blame] | 1642 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1643 | switch (message) |
| 1644 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1645 | case WM_SETTEXT: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1646 | DefWindowProcA(hwnd, message, wParam, lParam); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1647 | MDI_MenuModifyItem( client, hwnd ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1648 | if( ci->hwndChildMaximized == hwnd ) |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1649 | MDI_UpdateFrameText( GetParent(client), client, MDI_REPAINTFRAME, NULL ); |
| 1650 | return 1; /* success. FIXME: check text length */ |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1651 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1652 | case WM_GETMINMAXINFO: |
| 1653 | case WM_MENUCHAR: |
| 1654 | case WM_CLOSE: |
| 1655 | case WM_SETFOCUS: |
| 1656 | case WM_CHILDACTIVATE: |
| 1657 | case WM_SYSCOMMAND: |
| 1658 | case WM_SETVISIBLE: |
| 1659 | case WM_SIZE: |
| 1660 | case WM_NEXTMENU: |
| 1661 | case WM_SYSCHAR: |
| 1662 | return DefMDIChildProcW( hwnd, message, wParam, lParam ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1663 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1664 | return DefWindowProcA(hwnd, message, wParam, lParam); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1665 | } |
| 1666 | |
| 1667 | |
| 1668 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1669 | * DefMDIChildProcW (USER32.@) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1670 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1671 | LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, |
| 1672 | WPARAM wParam, LPARAM lParam ) |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1673 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1674 | HWND client = GetParent(hwnd); |
| 1675 | MDICLIENTINFO *ci = get_client_info( client ); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1676 | |
Alexandre Julliard | f44bbb8 | 2001-09-14 00:24:39 +0000 | [diff] [blame] | 1677 | hwnd = WIN_GetFullHandle( hwnd ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1678 | if (!ci) return DefWindowProcW( hwnd, message, wParam, lParam ); |
Ulrich Weigand | 1848c80 | 2000-10-19 20:24:06 +0000 | [diff] [blame] | 1679 | |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1680 | switch (message) |
| 1681 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1682 | case WM_SETTEXT: |
| 1683 | DefWindowProcW(hwnd, message, wParam, lParam); |
| 1684 | MDI_MenuModifyItem( client, hwnd ); |
| 1685 | if( ci->hwndChildMaximized == hwnd ) |
| 1686 | MDI_UpdateFrameText( GetParent(client), client, MDI_REPAINTFRAME, NULL ); |
| 1687 | return 1; /* success. FIXME: check text length */ |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1688 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1689 | case WM_GETMINMAXINFO: |
| 1690 | MDI_ChildGetMinMaxInfo( client, hwnd, (MINMAXINFO *)lParam ); |
| 1691 | return 0; |
NF Stevens | 9552483 | 1998-10-26 10:44:17 +0000 | [diff] [blame] | 1692 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1693 | case WM_MENUCHAR: |
| 1694 | return 0x00010000; /* MDI children don't have menu bars */ |
| 1695 | |
| 1696 | case WM_CLOSE: |
| 1697 | SendMessageW( client, WM_MDIDESTROY, (WPARAM)hwnd, 0 ); |
| 1698 | return 0; |
| 1699 | |
| 1700 | case WM_SETFOCUS: |
| 1701 | if (ci->hwndActiveChild != hwnd) MDI_ChildActivate( client, hwnd ); |
| 1702 | break; |
| 1703 | |
| 1704 | case WM_CHILDACTIVATE: |
| 1705 | MDI_ChildActivate( client, hwnd ); |
| 1706 | return 0; |
| 1707 | |
| 1708 | case WM_SYSCOMMAND: |
| 1709 | switch( wParam ) |
| 1710 | { |
| 1711 | case SC_MOVE: |
| 1712 | if( ci->hwndChildMaximized == hwnd) return 0; |
| 1713 | break; |
| 1714 | case SC_RESTORE: |
| 1715 | case SC_MINIMIZE: |
Matthew Davison | 3f17416 | 2002-11-24 22:13:26 +0000 | [diff] [blame] | 1716 | SetWindowLongW( hwnd, GWL_STYLE, |
| 1717 | GetWindowLongW( hwnd, GWL_STYLE ) | WS_SYSMENU ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1718 | break; |
| 1719 | case SC_MAXIMIZE: |
| 1720 | if (ci->hwndChildMaximized == hwnd) |
| 1721 | return SendMessageW( GetParent(client), message, wParam, lParam); |
| 1722 | SetWindowLongW( hwnd, GWL_STYLE, |
| 1723 | GetWindowLongW( hwnd, GWL_STYLE ) & ~WS_SYSMENU ); |
| 1724 | break; |
| 1725 | case SC_NEXTWINDOW: |
| 1726 | SendMessageW( client, WM_MDINEXT, 0, 0); |
| 1727 | return 0; |
| 1728 | case SC_PREVWINDOW: |
| 1729 | SendMessageW( client, WM_MDINEXT, 0, 1); |
| 1730 | return 0; |
| 1731 | } |
| 1732 | break; |
| 1733 | |
| 1734 | case WM_SETVISIBLE: |
| 1735 | if( ci->hwndChildMaximized) ci->mdiFlags &= ~MDIF_NEEDUPDATE; |
| 1736 | else MDI_PostUpdate(client, ci, SB_BOTH+1); |
| 1737 | break; |
| 1738 | |
| 1739 | case WM_SIZE: |
| 1740 | if( ci->hwndActiveChild == hwnd && wParam != SIZE_MAXIMIZED ) |
| 1741 | { |
| 1742 | ci->hwndChildMaximized = 0; |
| 1743 | MDI_RestoreFrameMenu( GetParent(client), hwnd ); |
| 1744 | MDI_UpdateFrameText( GetParent(client), client, MDI_REPAINTFRAME, NULL ); |
| 1745 | } |
| 1746 | |
| 1747 | if( wParam == SIZE_MAXIMIZED ) |
| 1748 | { |
| 1749 | HWND hMaxChild = ci->hwndChildMaximized; |
| 1750 | |
| 1751 | if( hMaxChild == hwnd ) break; |
| 1752 | if( hMaxChild) |
| 1753 | { |
| 1754 | SendMessageW( hMaxChild, WM_SETREDRAW, FALSE, 0 ); |
| 1755 | MDI_RestoreFrameMenu( GetParent(client), hMaxChild ); |
| 1756 | ShowWindow( hMaxChild, SW_SHOWNOACTIVATE ); |
| 1757 | SendMessageW( hMaxChild, WM_SETREDRAW, TRUE, 0 ); |
| 1758 | } |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1759 | TRACE("maximizing child %p\n", hwnd ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1760 | |
| 1761 | /* keep track of the maximized window. */ |
| 1762 | ci->hwndChildMaximized = hwnd; /* !!! */ |
| 1763 | |
| 1764 | /* The maximized window should also be the active window */ |
| 1765 | MDI_ChildActivate( client, hwnd ); |
| 1766 | MDI_AugmentFrameMenu( GetParent(client), hwnd ); |
| 1767 | MDI_UpdateFrameText( GetParent(client), client, MDI_REPAINTFRAME, NULL ); |
| 1768 | } |
| 1769 | |
| 1770 | if( wParam == SIZE_MINIMIZED ) |
| 1771 | { |
| 1772 | HWND switchTo = MDI_GetWindow(ci, hwnd, TRUE, WS_MINIMIZE); |
| 1773 | |
| 1774 | if (switchTo) SendMessageW( switchTo, WM_CHILDACTIVATE, 0, 0); |
| 1775 | } |
| 1776 | MDI_PostUpdate(client, ci, SB_BOTH+1); |
| 1777 | break; |
| 1778 | |
| 1779 | case WM_NEXTMENU: |
| 1780 | { |
| 1781 | MDINEXTMENU *next_menu = (MDINEXTMENU *)lParam; |
| 1782 | HWND parent = GetParent(client); |
| 1783 | |
| 1784 | if( wParam == VK_LEFT ) /* switch to frame system menu */ |
| 1785 | { |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1786 | WND *wndPtr = WIN_GetPtr( parent ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1787 | next_menu->hmenuNext = GetSubMenu( wndPtr->hSysMenu, 0 ); |
Alexandre Julliard | 8fd26b9 | 2001-10-15 17:56:45 +0000 | [diff] [blame] | 1788 | WIN_ReleasePtr( wndPtr ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1789 | } |
| 1790 | if( wParam == VK_RIGHT ) /* to frame menu bar */ |
| 1791 | { |
| 1792 | next_menu->hmenuNext = GetMenu(parent); |
| 1793 | } |
| 1794 | next_menu->hwndNext = parent; |
| 1795 | return 0; |
| 1796 | } |
| 1797 | |
| 1798 | case WM_SYSCHAR: |
| 1799 | if (wParam == '-') |
| 1800 | { |
| 1801 | SendMessageW( hwnd, WM_SYSCOMMAND, (WPARAM)SC_KEYMENU, (DWORD)VK_SPACE); |
| 1802 | return 0; |
| 1803 | } |
| 1804 | break; |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1805 | } |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1806 | return DefWindowProcW(hwnd, message, wParam, lParam); |
Alexandre Julliard | 2d93d00 | 1996-05-21 15:01:41 +0000 | [diff] [blame] | 1807 | } |
| 1808 | |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1809 | /********************************************************************** |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1810 | * CreateMDIWindowA (USER32.@) Creates a MDI child |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1811 | * |
| 1812 | * RETURNS |
| 1813 | * Success: Handle to created window |
| 1814 | * Failure: NULL |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1815 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1816 | HWND WINAPI CreateMDIWindowA( |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1817 | LPCSTR lpClassName, /* [in] Pointer to registered child class name */ |
| 1818 | LPCSTR lpWindowName, /* [in] Pointer to window name */ |
| 1819 | DWORD dwStyle, /* [in] Window style */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1820 | INT X, /* [in] Horizontal position of window */ |
| 1821 | INT Y, /* [in] Vertical position of window */ |
| 1822 | INT nWidth, /* [in] Width of window */ |
| 1823 | INT nHeight, /* [in] Height of window */ |
| 1824 | HWND hWndParent, /* [in] Handle to parent window */ |
| 1825 | HINSTANCE hInstance, /* [in] Handle to application instance */ |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1826 | LPARAM lParam) /* [in] Application-defined value */ |
| 1827 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1828 | MDICLIENTINFO *pCi = get_client_info( hWndParent ); |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1829 | MDICREATESTRUCTA cs; |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1830 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1831 | TRACE("(%s,%s,%ld,%d,%d,%d,%d,%p,%p,%ld)\n", |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1832 | debugstr_a(lpClassName),debugstr_a(lpWindowName),dwStyle,X,Y, |
| 1833 | nWidth,nHeight,hWndParent,hInstance,lParam); |
| 1834 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1835 | if (!pCi) |
Dmitry Timoshkov | 2b560c7 | 2001-02-12 18:09:51 +0000 | [diff] [blame] | 1836 | { |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1837 | ERR("bad hwnd for MDI-client: %p\n", hWndParent); |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1838 | return 0; |
| 1839 | } |
| 1840 | cs.szClass=lpClassName; |
| 1841 | cs.szTitle=lpWindowName; |
| 1842 | cs.hOwner=hInstance; |
| 1843 | cs.x=X; |
| 1844 | cs.y=Y; |
| 1845 | cs.cx=nWidth; |
| 1846 | cs.cy=nHeight; |
| 1847 | cs.style=dwStyle; |
| 1848 | cs.lParam=lParam; |
| 1849 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1850 | return MDICreateChild(hWndParent, pCi, &cs, FALSE); |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1851 | } |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1852 | |
Patrik Stridvall | 54fe838 | 2000-04-06 20:21:16 +0000 | [diff] [blame] | 1853 | /*********************************************************************** |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1854 | * CreateMDIWindowW (USER32.@) Creates a MDI child |
Alexandre Julliard | 46ea8b3 | 1998-05-03 19:01:20 +0000 | [diff] [blame] | 1855 | * |
| 1856 | * RETURNS |
| 1857 | * Success: Handle to created window |
| 1858 | * Failure: NULL |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1859 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1860 | HWND WINAPI CreateMDIWindowW( |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1861 | LPCWSTR lpClassName, /* [in] Pointer to registered child class name */ |
| 1862 | LPCWSTR lpWindowName, /* [in] Pointer to window name */ |
| 1863 | DWORD dwStyle, /* [in] Window style */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1864 | INT X, /* [in] Horizontal position of window */ |
| 1865 | INT Y, /* [in] Vertical position of window */ |
| 1866 | INT nWidth, /* [in] Width of window */ |
| 1867 | INT nHeight, /* [in] Height of window */ |
| 1868 | HWND hWndParent, /* [in] Handle to parent window */ |
| 1869 | HINSTANCE hInstance, /* [in] Handle to application instance */ |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1870 | LPARAM lParam) /* [in] Application-defined value */ |
| 1871 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1872 | MDICLIENTINFO *pCi = get_client_info( hWndParent ); |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1873 | MDICREATESTRUCTW cs; |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1874 | |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1875 | TRACE("(%s,%s,%ld,%d,%d,%d,%d,%p,%p,%ld)\n", |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1876 | debugstr_w(lpClassName), debugstr_w(lpWindowName), dwStyle, X, Y, |
| 1877 | nWidth, nHeight, hWndParent, hInstance, lParam); |
| 1878 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1879 | if (!pCi) |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1880 | { |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 1881 | ERR("bad hwnd for MDI-client: %p\n", hWndParent); |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1882 | return 0; |
| 1883 | } |
| 1884 | cs.szClass = lpClassName; |
| 1885 | cs.szTitle = lpWindowName; |
| 1886 | cs.hOwner = hInstance; |
| 1887 | cs.x = X; |
| 1888 | cs.y = Y; |
| 1889 | cs.cx = nWidth; |
| 1890 | cs.cy = nHeight; |
| 1891 | cs.style = dwStyle; |
| 1892 | cs.lParam = lParam; |
| 1893 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1894 | return MDICreateChild(hWndParent, pCi, (MDICREATESTRUCTA *)&cs, TRUE); |
Rein Klazes | 5c6fc1b | 1998-11-01 14:50:06 +0000 | [diff] [blame] | 1895 | } |
| 1896 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1897 | /********************************************************************** |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1898 | * TranslateMDISysAccel (USER32.@) |
| 1899 | */ |
| 1900 | BOOL WINAPI TranslateMDISysAccel( HWND hwndClient, LPMSG msg ) |
| 1901 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1902 | if (msg->message == WM_KEYDOWN || msg->message == WM_SYSKEYDOWN) |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1903 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1904 | MDICLIENTINFO *ci = get_client_info( hwndClient ); |
| 1905 | WPARAM wParam = 0; |
Alexandre Julliard | 7e56f68 | 1996-01-31 19:02:28 +0000 | [diff] [blame] | 1906 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1907 | if (!ci || !IsWindowEnabled(ci->hwndActiveChild)) return 0; |
Francois Boisvert | d753a99 | 1999-05-01 10:19:35 +0000 | [diff] [blame] | 1908 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1909 | /* translate if the Ctrl key is down and Alt not. */ |
Francois Boisvert | d753a99 | 1999-05-01 10:19:35 +0000 | [diff] [blame] | 1910 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 1911 | if( (GetKeyState(VK_CONTROL) & 0x8000) && !(GetKeyState(VK_MENU) & 0x8000)) |
| 1912 | { |
| 1913 | switch( msg->wParam ) |
| 1914 | { |
| 1915 | case VK_F6: |
| 1916 | case VK_TAB: |
| 1917 | wParam = ( GetKeyState(VK_SHIFT) & 0x8000 ) ? SC_NEXTWINDOW : SC_PREVWINDOW; |
| 1918 | break; |
| 1919 | case VK_F4: |
| 1920 | case VK_RBUTTON: |
| 1921 | wParam = SC_CLOSE; |
| 1922 | break; |
| 1923 | default: |
| 1924 | return 0; |
| 1925 | } |
| 1926 | TRACE("wParam = %04x\n", wParam); |
| 1927 | SendMessageW(ci->hwndActiveChild, WM_SYSCOMMAND, wParam, (LPARAM)msg->wParam); |
| 1928 | return 1; |
| 1929 | } |
Alexandre Julliard | 7ff1c41 | 1997-05-25 13:58:18 +0000 | [diff] [blame] | 1930 | } |
| 1931 | return 0; /* failure */ |
Alexandre Julliard | 8d24ae6 | 1994-04-05 21:42:43 +0000 | [diff] [blame] | 1932 | } |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 1933 | |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 1934 | /*********************************************************************** |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 1935 | * CalcChildScroll (USER32.@) |
| 1936 | */ |
| 1937 | void WINAPI CalcChildScroll( HWND hwnd, INT scroll ) |
| 1938 | { |
Alex Korobka | d208584 | 1998-10-18 10:37:46 +0000 | [diff] [blame] | 1939 | SCROLLINFO info; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1940 | RECT childRect, clientRect; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1941 | HWND *list; |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 1942 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1943 | GetClientRect( hwnd, &clientRect ); |
| 1944 | SetRectEmpty( &childRect ); |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 1945 | |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 1946 | if ((list = WIN_ListChildren( hwnd ))) |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1947 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1948 | int i; |
| 1949 | for (i = 0; list[i]; i++) |
| 1950 | { |
| 1951 | DWORD style = GetWindowLongW( list[i], GWL_STYLE ); |
| 1952 | if (style & WS_MAXIMIZE) |
| 1953 | { |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 1954 | HeapFree( GetProcessHeap(), 0, list ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1955 | ShowScrollBar( hwnd, SB_BOTH, FALSE ); |
| 1956 | return; |
| 1957 | } |
| 1958 | if (style & WS_VISIBLE) |
| 1959 | { |
| 1960 | WND *pWnd = WIN_FindWndPtr( list[i] ); |
| 1961 | UnionRect( &childRect, &pWnd->rectWindow, &childRect ); |
| 1962 | WIN_ReleaseWndPtr( pWnd ); |
| 1963 | } |
| 1964 | } |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 1965 | HeapFree( GetProcessHeap(), 0, list ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 1966 | } |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1967 | UnionRect( &childRect, &clientRect, &childRect ); |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 1968 | |
Andrew M. Johnston | 3e7b710 | 2002-10-09 20:40:33 +0000 | [diff] [blame] | 1969 | /* set common info values */ |
| 1970 | info.cbSize = sizeof(info); |
| 1971 | info.fMask = SIF_POS | SIF_RANGE; |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 1972 | |
Andrew M. Johnston | 3e7b710 | 2002-10-09 20:40:33 +0000 | [diff] [blame] | 1973 | /* set the specific */ |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 1974 | switch( scroll ) |
Alexandre Julliard | a0d7731 | 1998-09-13 16:32:00 +0000 | [diff] [blame] | 1975 | { |
Andrew M. Johnston | 3e7b710 | 2002-10-09 20:40:33 +0000 | [diff] [blame] | 1976 | case SB_BOTH: |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 1977 | case SB_HORZ: |
Andrew M. Johnston | 3e7b710 | 2002-10-09 20:40:33 +0000 | [diff] [blame] | 1978 | info.nMin = childRect.left; |
| 1979 | info.nMax = childRect.right - clientRect.right; |
| 1980 | info.nPos = clientRect.left - childRect.left; |
| 1981 | SetScrollInfo(hwnd, scroll, &info, TRUE); |
| 1982 | if (scroll == SB_HORZ) break; |
| 1983 | /* fall through */ |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 1984 | case SB_VERT: |
Andrew M. Johnston | 3e7b710 | 2002-10-09 20:40:33 +0000 | [diff] [blame] | 1985 | info.nMin = childRect.top; |
| 1986 | info.nMax = childRect.bottom - clientRect.bottom; |
| 1987 | info.nPos = clientRect.top - childRect.top; |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1988 | SetScrollInfo(hwnd, scroll, &info, TRUE); |
Alexandre Julliard | cdcdede | 1996-04-21 14:57:41 +0000 | [diff] [blame] | 1989 | break; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 1990 | } |
Alexandre Julliard | bd34d4f | 1995-06-20 19:08:12 +0000 | [diff] [blame] | 1991 | } |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 1992 | |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1993 | |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 1994 | /*********************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 1995 | * ScrollChildren (USER32.@) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1996 | */ |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 1997 | void WINAPI ScrollChildren(HWND hWnd, UINT uMsg, WPARAM wParam, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 1998 | LPARAM lParam) |
Alexandre Julliard | f0cbfa0 | 1997-02-15 14:29:56 +0000 | [diff] [blame] | 1999 | { |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2000 | INT newPos = -1; |
| 2001 | INT curPos, length, minPos, maxPos, shift; |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2002 | RECT rect; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2003 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2004 | GetClientRect( hWnd, &rect ); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2005 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2006 | switch(uMsg) |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 2007 | { |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2008 | case WM_HSCROLL: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2009 | GetScrollRange(hWnd,SB_HORZ,&minPos,&maxPos); |
| 2010 | curPos = GetScrollPos(hWnd,SB_HORZ); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2011 | length = (rect.right - rect.left) / 2; |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 2012 | shift = GetSystemMetrics(SM_CYHSCROLL); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2013 | break; |
| 2014 | case WM_VSCROLL: |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2015 | GetScrollRange(hWnd,SB_VERT,&minPos,&maxPos); |
| 2016 | curPos = GetScrollPos(hWnd,SB_VERT); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2017 | length = (rect.bottom - rect.top) / 2; |
Marcus Meissner | ddca315 | 1999-05-22 11:33:23 +0000 | [diff] [blame] | 2018 | shift = GetSystemMetrics(SM_CXVSCROLL); |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2019 | break; |
| 2020 | default: |
Francois Boisvert | 6b1b41c | 1999-03-14 17:25:32 +0000 | [diff] [blame] | 2021 | return; |
| 2022 | } |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2023 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 2024 | switch( wParam ) |
| 2025 | { |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2026 | case SB_LINEUP: |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2027 | newPos = curPos - shift; |
| 2028 | break; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2029 | case SB_LINEDOWN: |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2030 | newPos = curPos + shift; |
| 2031 | break; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2032 | case SB_PAGEUP: |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2033 | newPos = curPos - length; |
| 2034 | break; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2035 | case SB_PAGEDOWN: |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2036 | newPos = curPos + length; |
| 2037 | break; |
| 2038 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2039 | case SB_THUMBPOSITION: |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2040 | newPos = LOWORD(lParam); |
| 2041 | break; |
| 2042 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2043 | case SB_THUMBTRACK: |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2044 | return; |
| 2045 | |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2046 | case SB_TOP: |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2047 | newPos = minPos; |
| 2048 | break; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2049 | case SB_BOTTOM: |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2050 | newPos = maxPos; |
| 2051 | break; |
| 2052 | case SB_ENDSCROLL: |
Dmitry Timoshkov | 56a1992 | 2001-07-02 01:21:26 +0000 | [diff] [blame] | 2053 | CalcChildScroll(hWnd,(uMsg == WM_VSCROLL)?SB_VERT:SB_HORZ); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2054 | return; |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 2055 | } |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2056 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 2057 | if( newPos > maxPos ) |
| 2058 | newPos = maxPos; |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2059 | else |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 2060 | if( newPos < minPos ) |
| 2061 | newPos = minPos; |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2062 | |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2063 | SetScrollPos(hWnd, (uMsg == WM_VSCROLL)?SB_VERT:SB_HORZ , newPos, TRUE); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2064 | |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 2065 | if( uMsg == WM_VSCROLL ) |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2066 | ScrollWindowEx(hWnd ,0 ,curPos - newPos, NULL, NULL, 0, NULL, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2067 | SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); |
Alexandre Julliard | 60ce85c | 1998-02-01 18:33:27 +0000 | [diff] [blame] | 2068 | else |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2069 | ScrollWindowEx(hWnd ,curPos - newPos, 0, NULL, NULL, 0, NULL, |
Alexandre Julliard | 670cdc4 | 1997-08-24 16:00:30 +0000 | [diff] [blame] | 2070 | SW_INVALIDATE | SW_ERASE | SW_SCROLLCHILDREN ); |
Alexandre Julliard | d471965 | 1995-12-12 18:49:11 +0000 | [diff] [blame] | 2071 | } |
| 2072 | |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2073 | |
| 2074 | /****************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2075 | * CascadeWindows (USER32.@) Cascades MDI child windows |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2076 | * |
| 2077 | * RETURNS |
| 2078 | * Success: Number of cascaded windows. |
| 2079 | * Failure: 0 |
| 2080 | */ |
| 2081 | WORD WINAPI |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2082 | CascadeWindows (HWND hwndParent, UINT wFlags, const LPRECT lpRect, |
| 2083 | UINT cKids, const HWND *lpKids) |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2084 | { |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 2085 | FIXME("(%p,0x%08x,...,%u,...): stub\n", hwndParent, wFlags, cKids); |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2086 | return 0; |
| 2087 | } |
| 2088 | |
| 2089 | |
| 2090 | /****************************************************************************** |
Patrik Stridvall | 2ece70e | 2000-12-22 01:38:01 +0000 | [diff] [blame] | 2091 | * TileWindows (USER32.@) Tiles MDI child windows |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2092 | * |
| 2093 | * RETURNS |
| 2094 | * Success: Number of tiled windows. |
| 2095 | * Failure: 0 |
| 2096 | */ |
| 2097 | WORD WINAPI |
Alexandre Julliard | a396029 | 1999-02-26 11:11:13 +0000 | [diff] [blame] | 2098 | TileWindows (HWND hwndParent, UINT wFlags, const LPRECT lpRect, |
| 2099 | UINT cKids, const HWND *lpKids) |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2100 | { |
Alexandre Julliard | aff7dda | 2002-11-22 21:22:14 +0000 | [diff] [blame] | 2101 | FIXME("(%p,0x%08x,...,%u,...): stub\n", hwndParent, wFlags, cKids); |
Alexandre Julliard | f90efa9 | 1998-06-14 15:24:15 +0000 | [diff] [blame] | 2102 | return 0; |
| 2103 | } |
| 2104 | |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2105 | /************************************************************************ |
| 2106 | * "More Windows..." functionality |
| 2107 | */ |
| 2108 | |
| 2109 | /* MDI_MoreWindowsDlgProc |
| 2110 | * |
| 2111 | * This function will process the messages sent to the "More Windows..." |
| 2112 | * dialog. |
| 2113 | * Return values: 0 = cancel pressed |
| 2114 | * HWND = ok pressed or double-click in the list... |
| 2115 | * |
| 2116 | */ |
| 2117 | |
Dmitry Timoshkov | 601a3ab | 2002-10-31 01:04:39 +0000 | [diff] [blame] | 2118 | static INT_PTR WINAPI MDI_MoreWindowsDlgProc (HWND hDlg, UINT iMsg, WPARAM wParam, LPARAM lParam) |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2119 | { |
| 2120 | switch (iMsg) |
| 2121 | { |
| 2122 | case WM_INITDIALOG: |
| 2123 | { |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2124 | UINT widest = 0; |
| 2125 | UINT length; |
| 2126 | UINT i; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2127 | MDICLIENTINFO *ci = get_client_info( (HWND)lParam ); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2128 | HWND hListBox = GetDlgItem(hDlg, MDI_IDC_LISTBOX); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2129 | HWND *list, *sorted_list; |
| 2130 | |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2131 | if (!(list = WIN_ListChildren( (HWND)lParam ))) return TRUE; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2132 | if (!(sorted_list = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, |
| 2133 | sizeof(HWND) * ci->nActiveChildren ))) |
| 2134 | { |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2135 | HeapFree( GetProcessHeap(), 0, list ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2136 | return FALSE; |
| 2137 | } |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2138 | |
| 2139 | /* Fill the list, sorted by id... */ |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2140 | for (i = 0; list[i]; i++) |
| 2141 | { |
| 2142 | UINT id = GetWindowLongW( list[i], GWL_ID ) - ci->idFirstChild; |
| 2143 | if (id < ci->nActiveChildren) sorted_list[id] = list[i]; |
| 2144 | } |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2145 | HeapFree( GetProcessHeap(), 0, list ); |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2146 | |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2147 | for (i = 0; i < ci->nActiveChildren; i++) |
| 2148 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2149 | WCHAR buffer[128]; |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2150 | |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2151 | if (!GetWindowTextW( sorted_list[i], buffer, sizeof(buffer)/sizeof(WCHAR) )) |
| 2152 | continue; |
| 2153 | SendMessageW(hListBox, LB_ADDSTRING, 0, (LPARAM)buffer ); |
| 2154 | SendMessageW(hListBox, LB_SETITEMDATA, i, (LPARAM)sorted_list[i] ); |
| 2155 | length = strlenW(buffer); /* FIXME: should use GetTextExtentPoint */ |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2156 | if (length > widest) |
| 2157 | widest = length; |
| 2158 | } |
| 2159 | /* Make sure the horizontal scrollbar scrolls ok */ |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 2160 | SendMessageW(hListBox, LB_SETHORIZONTALEXTENT, widest * 6, 0); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2161 | |
| 2162 | /* Set the current selection */ |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 2163 | SendMessageW(hListBox, LB_SETCURSEL, MDI_MOREWINDOWSLIMIT, 0); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2164 | return TRUE; |
| 2165 | } |
| 2166 | |
| 2167 | case WM_COMMAND: |
| 2168 | switch (LOWORD(wParam)) |
| 2169 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2170 | default: |
| 2171 | if (HIWORD(wParam) != LBN_DBLCLK) break; |
| 2172 | /* fall through */ |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2173 | case IDOK: |
| 2174 | { |
| 2175 | /* windows are sorted by menu ID, so we must return the |
| 2176 | * window associated to the given id |
| 2177 | */ |
| 2178 | HWND hListBox = GetDlgItem(hDlg, MDI_IDC_LISTBOX); |
Dmitry Timoshkov | 91adf0a | 2001-02-12 03:40:41 +0000 | [diff] [blame] | 2179 | UINT index = SendMessageW(hListBox, LB_GETCURSEL, 0, 0); |
Alexandre Julliard | d23a82b | 2001-09-19 20:37:04 +0000 | [diff] [blame] | 2180 | LRESULT res = SendMessageW(hListBox, LB_GETITEMDATA, index, 0); |
| 2181 | EndDialog(hDlg, res); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2182 | return TRUE; |
| 2183 | } |
| 2184 | case IDCANCEL: |
| 2185 | EndDialog(hDlg, 0); |
| 2186 | return TRUE; |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2187 | } |
| 2188 | break; |
| 2189 | } |
| 2190 | return FALSE; |
| 2191 | } |
| 2192 | |
| 2193 | /* |
| 2194 | * |
| 2195 | * MDI_MoreWindowsDialog |
| 2196 | * |
| 2197 | * Prompts the user with a listbox containing the opened |
| 2198 | * documents. The user can then choose a windows and click |
| 2199 | * on OK to set the current window to the one selected, or |
| 2200 | * CANCEL to cancel. The function returns a handle to the |
| 2201 | * selected window. |
| 2202 | */ |
| 2203 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2204 | static HWND MDI_MoreWindowsDialog(HWND hwnd) |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2205 | { |
| 2206 | LPCVOID template; |
| 2207 | HRSRC hRes; |
| 2208 | HANDLE hDlgTmpl; |
| 2209 | |
| 2210 | hRes = FindResourceA(GetModuleHandleA("USER32"), "MDI_MOREWINDOWS", RT_DIALOGA); |
| 2211 | |
| 2212 | if (hRes == 0) |
| 2213 | return 0; |
| 2214 | |
| 2215 | hDlgTmpl = LoadResource(GetModuleHandleA("USER32"), hRes ); |
| 2216 | |
| 2217 | if (hDlgTmpl == 0) |
| 2218 | return 0; |
| 2219 | |
| 2220 | template = LockResource( hDlgTmpl ); |
| 2221 | |
| 2222 | if (template == 0) |
| 2223 | return 0; |
| 2224 | |
| 2225 | return (HWND) DialogBoxIndirectParamA(GetModuleHandleA("USER32"), |
| 2226 | (LPDLGTEMPLATEA) template, |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2227 | hwnd, MDI_MoreWindowsDlgProc, (LPARAM) hwnd); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2228 | } |
| 2229 | |
| 2230 | /* |
| 2231 | * |
| 2232 | * MDI_SwapMenuItems |
| 2233 | * |
| 2234 | * Will swap the menu IDs for the given 2 positions. |
| 2235 | * pos1 and pos2 are menu IDs |
Vincent Béron | 9a62491 | 2002-05-31 23:06:46 +0000 | [diff] [blame] | 2236 | * |
| 2237 | * |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2238 | */ |
| 2239 | |
Alexandre Julliard | 4ff32c8 | 2001-08-18 18:08:26 +0000 | [diff] [blame] | 2240 | static void MDI_SwapMenuItems(HWND parent, UINT pos1, UINT pos2) |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2241 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2242 | HWND *list; |
| 2243 | int i; |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2244 | |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2245 | if (!(list = WIN_ListChildren( parent ))) return; |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2246 | for (i = 0; list[i]; i++) |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2247 | { |
Alexandre Julliard | 0801ffc | 2001-08-24 00:26:59 +0000 | [diff] [blame] | 2248 | UINT id = GetWindowLongW( list[i], GWL_ID ); |
| 2249 | if (id == pos1) SetWindowLongW( list[i], GWL_ID, pos2 ); |
| 2250 | else if (id == pos2) SetWindowLongW( list[i], GWL_ID, pos1 ); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2251 | } |
Alexandre Julliard | 9d9dac0 | 2001-08-24 19:28:21 +0000 | [diff] [blame] | 2252 | HeapFree( GetProcessHeap(), 0, list ); |
David Lassonde | f58d80d | 2000-06-15 01:03:32 +0000 | [diff] [blame] | 2253 | } |