Small clean up of the MDI menu code and a couple of bugfixes for Visio
Dmitry Timoshkov
dmitry at baikal.ru
Sun Jan 25 07:34:26 CST 2004
Hello,
here is a small clean up of the MDI menu code and a couple of bugfixes
for Visio.
Changelog:
Dmitry Timoshkov <dmitry at codeweavers.com>
In the WM_MDISETMENU handler use an existing frame menu if the passed
value is 0.
Visio expects that separator in the Window menu has ID 0.
Cope with a destroyed menu handle in WM_MDIREFRESHMENU handler.
--- cvs/hq/wine/windows/mdi.c 2004-01-20 19:05:18.000000000 +0800
+++ wine/windows/mdi.c 2004-01-25 21:26:46.000000000 +0800
@@ -320,9 +320,10 @@ static LRESULT MDISetMenu( HWND hwnd, HM
MDI_RefreshMenu(ci);
}
else
+ {
+ ci->hWindowMenu = hmenuWindow;
ci->add_pos = GetMenuItemCount(hmenuWindow);
-
- ci->hWindowMenu = hmenuWindow;
+ }
}
if (hmenuFrame)
@@ -341,8 +342,12 @@ static LRESULT MDISetMenu( HWND hwnd, HM
}
else
{
- INT nItems = GetMenuItemCount(ci->hFrameMenu) - 1;
- UINT iId = GetMenuItemID(ci->hFrameMenu, nItems);
+ INT nItems;
+ UINT iId;
+
+ ci->hFrameMenu = GetMenu(hwndFrame);
+ nItems = GetMenuItemCount(ci->hFrameMenu) - 1;
+ iId = GetMenuItemID(ci->hFrameMenu, nItems);
if( !(iId == SC_RESTORE || iId == SC_CLOSE) )
{
@@ -365,7 +370,6 @@ static LRESULT MDISetMenu( HWND hwnd, HM
*/
static LRESULT MDI_RefreshMenu(MDICLIENTINFO *ci)
{
- HMENU hFrameMenu;
UINT i, count, visible;
WCHAR buf[MDI_MAXTITLELENGTH];
@@ -374,6 +378,12 @@ static LRESULT MDI_RefreshMenu(MDICLIENT
if (!ci->hWindowMenu)
return 0;
+ if (!IsMenu(ci->hWindowMenu))
+ {
+ WARN("Window menu handle %p is no more valid\n", ci->hWindowMenu);
+ return 0;
+ }
+
count = GetMenuItemCount(ci->hWindowMenu);
for (i = ci->add_pos; i < count; i++)
RemoveMenu(ci->hWindowMenu, ci->add_pos, MF_BYPOSITION);
@@ -393,7 +403,8 @@ static LRESULT MDI_RefreshMenu(MDICLIENT
if (IsWindowVisible(ci->child[i]))
{
if (!visible)
- AppendMenuW(ci->hWindowMenu, MF_SEPARATOR, -1, NULL);
+ /* Visio expects that separator has id 0 */
+ AppendMenuW(ci->hWindowMenu, MF_SEPARATOR, 0, NULL);
visible++;
@@ -403,6 +414,7 @@ static LRESULT MDI_RefreshMenu(MDICLIENT
buf[1] = '0' + visible;
buf[2] = ' ';
InternalGetWindowText(ci->child[i], buf + 3, sizeof(buf)/sizeof(WCHAR) - 3);
+ TRACE("Adding %u %s\n", id, debugstr_w(buf));
AppendMenuW(ci->hWindowMenu, MF_STRING, id, buf);
if (ci->child[i] == ci->hwndActiveChild)
@@ -410,9 +422,7 @@ static LRESULT MDI_RefreshMenu(MDICLIENT
}
}
- hFrameMenu = ci->hFrameMenu;
-
- return (LRESULT)hFrameMenu;
+ return (LRESULT)ci->hFrameMenu;
}
@@ -482,6 +492,8 @@ static LRESULT MDIDestroyChild( HWND par
{
UINT i;
+ TRACE("# of managed children %u\n", ci->nActiveChildren);
+
if( child == ci->hwndActiveChild )
{
MDI_SwitchActiveChild(parent, child, TRUE);
@@ -510,19 +522,19 @@ static LRESULT MDIDestroyChild( HWND par
memcpy(new_child + i, ci->child + i + 1, (ci->nActiveChildren - i - 1) * sizeof(HWND));
HeapFree(GetProcessHeap(), 0, ci->child);
ci->child = new_child;
+
+ ci->nActiveChildren--;
+ break;
}
}
- ci->nActiveChildren--;
-
- TRACE("child destroyed - %p\n",child);
-
if (flagDestroy)
{
MDI_PostUpdate(GetParent(child), ci, SB_BOTH+1);
DestroyWindow(child);
}
+ TRACE("child destroyed - %p\n", child);
return 0;
}
More information about the wine-patches
mailing list