Commit e6e15c36 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

Before removing menu items in the MDI Window menu check whether a menu

item following a separator has our "magic" value.
parent 759aff6a
...@@ -316,7 +316,6 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame, ...@@ -316,7 +316,6 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame,
/* Add items to the new Window menu */ /* Add items to the new Window menu */
ci->nActiveChildren = nActiveChildren_old; ci->nActiveChildren = nActiveChildren_old;
AppendMenuW(hmenuWindow, MF_SEPARATOR, 0, NULL);
MDI_RefreshMenu(ci); MDI_RefreshMenu(ci);
} }
else else
...@@ -357,7 +356,7 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame, ...@@ -357,7 +356,7 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame,
*/ */
static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci) static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci)
{ {
UINT i, count, visible, separator_pos; UINT i, count, visible, separator_pos, id;
WCHAR buf[MDI_MAXTITLELENGTH]; WCHAR buf[MDI_MAXTITLELENGTH];
TRACE("children %u, window menu %p\n", ci->nActiveChildren, ci->hWindowMenu); TRACE("children %u, window menu %p\n", ci->nActiveChildren, ci->hWindowMenu);
...@@ -371,9 +370,11 @@ static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci) ...@@ -371,9 +370,11 @@ static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci)
return 0; return 0;
} }
/* Windows finds the last separator in the menu, removes all existing /* Windows finds the last separator in the menu, and if after it
* there is a menu item with MDI magic ID removes all existing
* menu items after it, and then adds visible MDI children. * menu items after it, and then adds visible MDI children.
*/ */
id = (UINT)-1;
separator_pos = 0; separator_pos = 0;
count = GetMenuItemCount(ci->hWindowMenu); count = GetMenuItemCount(ci->hWindowMenu);
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
...@@ -383,19 +384,34 @@ static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci) ...@@ -383,19 +384,34 @@ static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci)
memset(&mii, 0, sizeof(mii)); memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii); mii.cbSize = sizeof(mii);
mii.fMask = MIIM_TYPE; mii.fMask = MIIM_TYPE;
GetMenuItemInfoW(ci->hWindowMenu, i, TRUE, &mii); if (GetMenuItemInfoW(ci->hWindowMenu, i, TRUE, &mii))
{
if (mii.fType & MFT_SEPARATOR) if (mii.fType & MF_SEPARATOR)
{
separator_pos = i; separator_pos = i;
/* Windows checks only ID of the menu item */
memset(&mii, 0, sizeof(mii));
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_ID;
if (GetMenuItemInfoW(ci->hWindowMenu, i + 1, TRUE, &mii))
id = mii.wID;
}
}
} }
for (i = separator_pos + 1; i < count; i++) if (separator_pos && id == ci->idFirstChild)
RemoveMenu(ci->hWindowMenu, separator_pos + 1, MF_BYPOSITION); {
for (i = separator_pos; i < count; i++)
RemoveMenu(ci->hWindowMenu, separator_pos, MF_BYPOSITION);
}
visible = 0; visible = 0;
for (i = 0; i < ci->nActiveChildren; i++) for (i = 0; i < ci->nActiveChildren; i++)
{ {
UINT id = ci->idFirstChild + i; if (GetWindowLongW(ci->child[i], GWL_STYLE) & WS_VISIBLE)
{
id = ci->idFirstChild + visible;
if (visible == MDI_MOREWINDOWSLIMIT) if (visible == MDI_MOREWINDOWSLIMIT)
{ {
...@@ -404,9 +420,7 @@ static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci) ...@@ -404,9 +420,7 @@ static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci)
break; break;
} }
if (GetWindowLongW(ci->child[i], GWL_STYLE) & WS_VISIBLE) if (!visible)
{
if (!visible && !separator_pos)
/* Visio expects that separator has id 0 */ /* Visio expects that separator has id 0 */
AppendMenuW(ci->hWindowMenu, MF_SEPARATOR, 0, NULL); AppendMenuW(ci->hWindowMenu, MF_SEPARATOR, 0, NULL);
...@@ -1410,6 +1424,7 @@ LRESULT WINAPI DefMDIChildProcA( HWND hwnd, UINT message, ...@@ -1410,6 +1424,7 @@ LRESULT WINAPI DefMDIChildProcA( HWND hwnd, UINT message,
case WM_SETFOCUS: case WM_SETFOCUS:
case WM_CHILDACTIVATE: case WM_CHILDACTIVATE:
case WM_SYSCOMMAND: case WM_SYSCOMMAND:
case WM_SHOWWINDOW:
case WM_SETVISIBLE: case WM_SETVISIBLE:
case WM_SIZE: case WM_SIZE:
case WM_NEXTMENU: case WM_NEXTMENU:
...@@ -1488,6 +1503,7 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message, ...@@ -1488,6 +1503,7 @@ LRESULT WINAPI DefMDIChildProcW( HWND hwnd, UINT message,
} }
break; break;
case WM_SHOWWINDOW:
case WM_SETVISIBLE: case WM_SETVISIBLE:
if (IsZoomed(ci->hwndActiveChild)) ci->mdiFlags &= ~MDIF_NEEDUPDATE; if (IsZoomed(ci->hwndActiveChild)) ci->mdiFlags &= ~MDIF_NEEDUPDATE;
else MDI_PostUpdate(client, ci, SB_BOTH+1); else MDI_PostUpdate(client, ci, SB_BOTH+1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment