mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
tinus <o112w8r02@sneakemail.com>
Don't allow selecting disabled menu items svn path=/trunk/; revision=13246
This commit is contained in:
parent
5888e99ef3
commit
87be65443f
1 changed files with 60 additions and 38 deletions
|
@ -1884,46 +1884,56 @@ MenuMoveSelection(HWND WndOwner, PROSMENUINFO MenuInfo, INT Offset)
|
||||||
{
|
{
|
||||||
INT i;
|
INT i;
|
||||||
ROSMENUITEMINFO ItemInfo;
|
ROSMENUITEMINFO ItemInfo;
|
||||||
|
INT OrigPos;
|
||||||
|
|
||||||
DPRINT("hwnd=%x menu=%x off=0x%04x\n", WndOwner, MenuInfo, Offset);
|
DPRINT("hwnd=%x menu=%x off=0x%04x\n", WndOwner, MenuInfo, Offset);
|
||||||
|
|
||||||
|
/* Prevent looping */
|
||||||
|
if (0 == MenuInfo->MenuItemCount || 0 == Offset)
|
||||||
|
return;
|
||||||
|
else if (Offset < -1)
|
||||||
|
Offset = -1;
|
||||||
|
else if (Offset > 1)
|
||||||
|
Offset = 1;
|
||||||
|
|
||||||
MenuInitRosMenuItemInfo(&ItemInfo);
|
MenuInitRosMenuItemInfo(&ItemInfo);
|
||||||
if (NO_SELECTED_ITEM != MenuInfo->FocusedItem)
|
|
||||||
|
OrigPos = MenuInfo->FocusedItem;
|
||||||
|
if (OrigPos == NO_SELECTED_ITEM) /* NO_SELECTED_ITEM is not -1 ! */
|
||||||
{
|
{
|
||||||
if (1 == MenuInfo->MenuItemCount)
|
OrigPos = 0;
|
||||||
{
|
i = -1;
|
||||||
MenuCleanupRosMenuItemInfo(&ItemInfo);
|
}
|
||||||
return;
|
else
|
||||||
}
|
{
|
||||||
else
|
i = MenuInfo->FocusedItem;
|
||||||
{
|
|
||||||
for (i = MenuInfo->FocusedItem + Offset;
|
|
||||||
0 <= i && i < MenuInfo->MenuItemCount;
|
|
||||||
i += Offset)
|
|
||||||
{
|
|
||||||
if (MenuGetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo) &&
|
|
||||||
0 == (ItemInfo.fType & MF_SEPARATOR))
|
|
||||||
{
|
|
||||||
MenuSelectItem(WndOwner, MenuInfo, i, TRUE, NULL);
|
|
||||||
MenuCleanupRosMenuItemInfo(&ItemInfo);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = (0 < Offset) ? 0 : MenuInfo->MenuItemCount - 1;
|
do
|
||||||
0 <= i && i < MenuInfo->MenuItemCount; i += Offset)
|
|
||||||
{
|
{
|
||||||
|
/* Step */
|
||||||
|
i += Offset;
|
||||||
|
/* Clip and wrap around */
|
||||||
|
if (i < 0)
|
||||||
|
{
|
||||||
|
i = MenuInfo->MenuItemCount - 1;
|
||||||
|
}
|
||||||
|
else if (i >= MenuInfo->MenuItemCount)
|
||||||
|
{
|
||||||
|
i = 0;
|
||||||
|
}
|
||||||
|
/* If this is a good candidate; */
|
||||||
if (MenuGetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo) &&
|
if (MenuGetRosMenuItemInfo(MenuInfo->Self, i, &ItemInfo) &&
|
||||||
0 == (ItemInfo.fType & MF_SEPARATOR))
|
0 == (ItemInfo.fType & MF_SEPARATOR) &&
|
||||||
|
0 == (ItemInfo.fState & (MFS_DISABLED | MFS_GRAYED)) )
|
||||||
{
|
{
|
||||||
MenuSelectItem(WndOwner, MenuInfo, i, TRUE, NULL);
|
MenuSelectItem(WndOwner, MenuInfo, i, TRUE, NULL);
|
||||||
MenuCleanupRosMenuItemInfo(&ItemInfo);
|
MenuCleanupRosMenuItemInfo(&ItemInfo);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
} while (i != OrigPos);
|
||||||
|
|
||||||
|
/* Not found */
|
||||||
MenuCleanupRosMenuItemInfo(&ItemInfo);
|
MenuCleanupRosMenuItemInfo(&ItemInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2276,15 +2286,19 @@ MenuButtonDown(MTRACKER* Mt, HMENU PtMenu, UINT Flags)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MenuInfo.FocusedItem != Index)
|
if (!(Item.fType & MF_SEPARATOR) &&
|
||||||
{
|
!(Item.fState & (MFS_DISABLED | MFS_GRAYED)) )
|
||||||
MenuSwitchTracking(Mt, &MenuInfo, Index);
|
{
|
||||||
}
|
if (MenuInfo.FocusedItem != Index)
|
||||||
|
{
|
||||||
|
MenuSwitchTracking(Mt, &MenuInfo, Index);
|
||||||
|
}
|
||||||
|
|
||||||
/* If the popup menu is not already "popped" */
|
/* If the popup menu is not already "popped" */
|
||||||
if (0 == (Item.fState & MF_MOUSESELECT))
|
if (0 == (Item.fState & MF_MOUSESELECT))
|
||||||
{
|
{
|
||||||
Mt->CurrentMenu = MenuShowSubPopup(Mt->OwnerWnd, &MenuInfo, FALSE, Flags);
|
Mt->CurrentMenu = MenuShowSubPopup(Mt->OwnerWnd, &MenuInfo, FALSE, Flags);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuCleanupRosMenuItemInfo(&Item);
|
MenuCleanupRosMenuItemInfo(&Item);
|
||||||
|
@ -2422,6 +2436,7 @@ MenuMouseMove(MTRACKER *Mt, HMENU PtMenu, UINT Flags)
|
||||||
{
|
{
|
||||||
UINT Index;
|
UINT Index;
|
||||||
ROSMENUINFO MenuInfo;
|
ROSMENUINFO MenuInfo;
|
||||||
|
ROSMENUITEMINFO ItemInfo;
|
||||||
|
|
||||||
if (NULL != PtMenu)
|
if (NULL != PtMenu)
|
||||||
{
|
{
|
||||||
|
@ -2454,8 +2469,15 @@ MenuMouseMove(MTRACKER *Mt, HMENU PtMenu, UINT Flags)
|
||||||
}
|
}
|
||||||
else if (MenuInfo.FocusedItem != Index)
|
else if (MenuInfo.FocusedItem != Index)
|
||||||
{
|
{
|
||||||
MenuSwitchTracking(Mt, &MenuInfo, Index);
|
MenuInitRosMenuItemInfo(&ItemInfo);
|
||||||
Mt->CurrentMenu = MenuShowSubPopup(Mt->OwnerWnd, &MenuInfo, FALSE, Flags);
|
if (MenuGetRosMenuItemInfo(MenuInfo.Self, Index, &ItemInfo) &&
|
||||||
|
!(ItemInfo.fType & MF_SEPARATOR) &&
|
||||||
|
!(ItemInfo.fState & (MFS_DISABLED | MFS_GRAYED)) )
|
||||||
|
{
|
||||||
|
MenuSwitchTracking(Mt, &MenuInfo, Index);
|
||||||
|
Mt->CurrentMenu = MenuShowSubPopup(Mt->OwnerWnd, &MenuInfo, FALSE, Flags);
|
||||||
|
}
|
||||||
|
MenuCleanupRosMenuItemInfo(&ItemInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -4026,9 +4048,9 @@ InsertMenuItemW(
|
||||||
BOOL res = FALSE;
|
BOOL res = FALSE;
|
||||||
mi.hbmpItem = (HBITMAP)0;
|
mi.hbmpItem = (HBITMAP)0;
|
||||||
|
|
||||||
// while we could just pass 'lpmii' to win32k, we make a copy so that
|
/* while we could just pass 'lpmii' to win32k, we make a copy so that
|
||||||
// if a bad user passes bad data, we crash his process instead of the
|
if a bad user passes bad data, we crash his process instead of the
|
||||||
// entire kernel
|
entire kernel */
|
||||||
|
|
||||||
if((lpmii->cbSize == sizeof(MENUITEMINFOW)) ||
|
if((lpmii->cbSize == sizeof(MENUITEMINFOW)) ||
|
||||||
(lpmii->cbSize == sizeof(MENUITEMINFOW) - sizeof(HBITMAP)))
|
(lpmii->cbSize == sizeof(MENUITEMINFOW) - sizeof(HBITMAP)))
|
||||||
|
|
Loading…
Reference in a new issue