Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

EnableMenuItem (coredll)
 

coredll is for smart devices, not desktop Windows. Therefore, this information only applies to code using the .NET Compact Framework. To see if information for EnableMenuItem in other DLLs exists, click on Find References to the right.

.
Summary
This function enables or disables (grays) the specified menu item.

C# Signature:

[DllImport("coredll.dll", SetLastError=true)]
static extern uint EnableMenuItem(IntPtr hMenu, uint itemId, uint uEnable);

VB.NET Signature:

<DllImport("user32.dll", CallingConvention:=CallingConvention.Cdecl)> _

Public Function EnableMenuItem(ByVal hMenu As IntPtr, ByVal wIDEnableItem As UInteger, ByVal wEnable As UInteger) As IntPtr

End Function;

User-Defined Types:

[uEnable]

    uint MF_BYCOMMAND = 0x00000000;
    uint MF_BYPOSITION = 0x00000400;
    uint MF_ENABLED = 0x00000000;
    uint MF_GRAYED = 0x00000001;
    uint MF_STRING = 0x00000000;

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

Use MF_BYCOMMAND to specify the item ID on [itemId] parameter or use MF_BYPOSITION to specify the zero-based index of the item, if neither MF_BYCOMMAND nor MF_BYPOSITION is specified the item ID is used.

Sample Code:

    IntPtr hMenu = CreatePopupMenu();
    AppendMenu(hMenu, MF_STRING, 1001, "Enabled Item");
    AppendMenu(hMenu, MF_STRING, 1002, "Disabled Item");
    EnableMenuItem(hMenu, 0, MF_BYPOSITION | MF_ENABLED);
    EnableMenuItem(hMenu, 1002, MF_BYCOMMAND | MF_GRAYED);

Documentation

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions