PDA

Click to See Complete Forum and Search --> : System Context Menu


But_Why
Feb 19th, 2001, 06:41 PM
How do i change the Grayed portion of a menu. EG i have used AppendMenu to add it with the WM_STRING and the WM_GRAYED flags set. How do i remove the Grayed part so it is enabled again, without removing it and re-adding it?
Surely there is a way?
BW :cool:

heavenhell
Feb 19th, 2001, 08:56 PM
Take a look at this post© http://forums©vb-world©net/showthread©php?threadid=55637

But_Why
Feb 19th, 2001, 09:01 PM
But it doesn't cover the Grayed or enabled part of it. It talks about the Checked state, which is fine. I wanna know about the Grayed state.
BW :cool:

heavenhell
Feb 21st, 2001, 01:43 AM
You can make use of EnableMenuItem to enable and Gray a menu item© By the way, does anyone know how you can assign Keyboard Accelerator to a menu item?? For example, if you press Shift+Y, it will be like selecting the menu item©
Thanks


Public Declare Function EnableMenuItem Lib "user32" Alias "EnableMenuItem" ¥ByVal hMenu As Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long¤ As Long


lret = GetMenuState¥a, 998, MF_STRING¤
If lret = MF_GRAYED Then
EnableMenuItem a, 998, MF_STRING
Else
EnableMenuItem a, 998, MF_GRAYED
End If

Lord Orwell
Feb 21st, 2001, 05:37 AM
Declare Function SetMenuItemInfo& Lib "user32" Alias "SetMenuItemInfoA" (ByVal _
hMenu As Long, ByVal un As Long, ByVal bypos As Long, lpcMenuItemInfo As _
MENUITEMINFO)
Type MENUITEMINFO ' 44 Bytes
cbSize As Long
fMask As Long
fType As Long
fState As Long
wID As Long
hSubMenu As Long
hbmpChecked As Long
hbmpUnchecked As Long
dwItemData As Long
dwTypeData As Long
cch As Long
End Type

cbSize Long—Size of this structure, currently at 44 bytes.
fMask Long—Specifies the information to set or get. Any combination of the following:MIIM_CHECKMARKS: Sets or gets the hbmpChecked and hbmpUnchecked fields.MIIM_DATA: Sets or gets the dwItemData field.MIIM_ID: Sets or gets the wID field.MIIM_STATE: Sets or gets the fState field.MIIM_SUBMENU: Sets or gets the hSubMenu field.MIIM_TYPE: Sets or gets the fType and dwTypeData fields.
fType Long—Menu item type, any combination of the following with the exception that MFT_BITMAP, MFT_SEPARATOR, and MFT_STRING cannot be combined with one another:MFT_BITMAP: Displays the menu item using a bitmap. dwTypeData contains the bitmap handle.MFT_MENUBARBREAK: The menu item is placed on a new line for top level menus, a new column for popup menus. Places a line between the columns.MFT_MENUBREAK: Same as MFT_MENUBREAK without the vertical line.MFT_OWNERDRAW: The menu item is an owner-draw menu.MFT_RADIOCHECK: Uses a radio button (option button) bullet to indicate the checked state instead of a check mark. Applies if no custom bitmap is specified.MFT_RIGHTJUSTIFY: Right-justifies a top level menu item.MFT_SEPARATOR: The entry is a separator line in a pop-up menu.MFT_STRING: The entry contains a string. dwTypeData contains the address of the string, and the cch field contains the length of the string.
fState Long—Current menu entry state or action to take. May be any combination of the following:MFS_CHECKED: Entry is checked.MFS_DEFAULT: The entry is a default item
The easiest way to make a hotkey for a menu is put a & in front of one of the letters.

(appears in bold).MFS_DISABLED: Entry is disabled.MFS_ENABLED: Entry is enabled.MFS_GRAYED: Entry is grayed and disabled.MFS_HILITE: Entry is highlighted.MFS_UNCHECKED: Entry is unchecked.MFS_UNHILITE: Entry is unhighlighted.
wID Long—Menu entry identifier. The high 16 bits are not used.
hSubMenu Long—Handle to a pop-up menu if one is associated with the menu entry.
hbmpChecked Long—Handle to a bitmap to display for a menu entry when checked. Zero to use the default.
hbmpUnchecked Long—Handle to a bitmap to display for a menu entry when unchecked. Zero to use the default.
dwItemData Long—User-defined value associated with this entry.
dwTypeData Long—Depends on the menu type.
cch Long—Length of the menu string when MFT_STRING is specified. Zero for other menu types.

Lord Orwell
Feb 21st, 2001, 05:39 AM
You can choose which letter of a menu option is the accellerator key by putting a & in front of it.