Before removing menu items in the MDI Window menu check whether a menu
item following a separator has our "magic" value.
This commit is contained in:
parent
759aff6a23
commit
e6e15c36b5
|
@ -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,
|
||||||
*/
|
*/
|
||||||
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)
|
||||||
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,30 +384,43 @@ 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 & MF_SEPARATOR)
|
||||||
|
{
|
||||||
|
separator_pos = i;
|
||||||
|
|
||||||
if (mii.fType & MFT_SEPARATOR)
|
/* Windows checks only ID of the menu item */
|
||||||
separator_pos = i;
|
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 (visible == MDI_MOREWINDOWSLIMIT)
|
|
||||||
{
|
|
||||||
LoadStringW(user32_module, IDS_MDI_MOREWINDOWS, buf, sizeof(buf)/sizeof(WCHAR));
|
|
||||||
AppendMenuW(ci->hWindowMenu, MF_STRING, id, buf);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (GetWindowLongW(ci->child[i], GWL_STYLE) & WS_VISIBLE)
|
if (GetWindowLongW(ci->child[i], GWL_STYLE) & WS_VISIBLE)
|
||||||
{
|
{
|
||||||
if (!visible && !separator_pos)
|
id = ci->idFirstChild + visible;
|
||||||
|
|
||||||
|
if (visible == MDI_MOREWINDOWSLIMIT)
|
||||||
|
{
|
||||||
|
LoadStringW(user32_module, IDS_MDI_MOREWINDOWS, buf, sizeof(buf)/sizeof(WCHAR));
|
||||||
|
AppendMenuW(ci->hWindowMenu, MF_STRING, id, buf);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!visible)
|
||||||
/* 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,
|
||||||
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,
|
||||||
}
|
}
|
||||||
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);
|
||||||
|
|
Loading…
Reference in New Issue