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