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