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