Fix MDISetMenu in the case it is called before a Windows Menu exists

as Agent newsreader does.
This commit is contained in:
Rein Klazes 2003-09-23 22:47:55 +00:00 committed by Alexandre Julliard
parent e0fffb6c7c
commit c99b26d985
1 changed files with 9 additions and 12 deletions

View File

@ -378,22 +378,21 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame,
if( ci->hwndChildMaximized && hmenuFrame && hmenuFrame!=oldFrameMenu )
MDI_RestoreFrameMenu( GetParent(hwnd), ci->hwndChildMaximized );
if( hmenuWindow && ci->hWindowMenu && hmenuWindow!=ci->hWindowMenu )
if( hmenuWindow && hmenuWindow != ci->hWindowMenu )
{
/* delete menu items from ci->hWindowMenu
* and add them to hmenuWindow */
INT i = GetMenuItemCount(ci->hWindowMenu) - 1;
INT pos = GetMenuItemCount(hmenuWindow) + 1;
AppendMenuA( hmenuWindow, MF_SEPARATOR, 0, NULL);
if( ci->nActiveChildren )
/* Agent newsreader calls this function with ci->hWindowMenu == NULL */
if( ci->hWindowMenu && ci->nActiveChildren )
{
INT j;
LPWSTR buffer = NULL;
MENUITEMINFOW mii;
INT nbWindowsMenuItems; /* num of documents shown + "More Windows..." if present */
INT i = GetMenuItemCount(ci->hWindowMenu) - 1;
INT pos = GetMenuItemCount(hmenuWindow) + 1;
AppendMenuA( hmenuWindow, MF_SEPARATOR, 0, NULL);
if (ci->nActiveChildren <= MDI_MOREWINDOWSLIMIT)
nbWindowsMenuItems = ci->nActiveChildren;
@ -424,11 +423,9 @@ static LRESULT MDISetMenu( HWND hwnd, HMENU hmenuFrame,
buffer = NULL;
}
}
/* remove separator */
DeleteMenu(ci->hWindowMenu, i, MF_BYPOSITION);
}
/* remove separator */
DeleteMenu(ci->hWindowMenu, i, MF_BYPOSITION);
ci->hWindowMenu = hmenuWindow;
}