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

GetMenuItemInfo (user32)
 
.
Summary

C# Signature:

[DllImport("user32.dll")]
static extern bool GetMenuItemInfo(IntPtr hMenu, UInt32 uItem, bool fByPosition, [In,Out] MENUITEMINFO lpmii);

User-Defined Types:

MIIM

MENUITEMINFO

Notes:

[StructLayout(LayoutKind.Sequential)]
public class MENUITEMINFO{
     public Int32 cbSize = Mashal.SizeOf(typeof(MENUITEMINFO));
     public MIIM fMask;
     public UInt32 fType;
     public UInt32 fState;
     public UInt32 wID;
     public IntPtr hSubMenu;
     public IntPtr hbmpChecked;
     public IntPtr hbmpUnchecked;
     public IntPtr dwItemData;
     public string dwTypeData = null;
     public UInt32 cch;
     public IntPtr hbmpItem;

     public MENUITEMINFO() { }
     public MENUITEMINFO(MIIM pfMask) {
     fMask = pfMask;
     }
}

public const UInt32 MF_BYCOMMAND = 0x00000000;
public const UInt32 MF_BYPOSITION = 0x00000400;

// Values for the fMask parameter
[Flags]
public enum MIIM {
     BITMAP = 0x00000080,
     CHECKMARKS = 0x00000008,
     DATA = 0x00000020,
     FTYPE = 0x00000100,
     ID = 0x00000002,
     STATE = 0x00000001,
     STRING = 0x00000040,
     SUBMENU = 0x00000004,
     TYPE = 0x00000010
}

Tips & Tricks:

Please add some!

Sample Code:

MENUITEMINFO mif = new MENUITEMINFO(MIIM.STRING | MIIM.ID);
bool res = GetMenuItemInfo(hMenu, 0, true, mif);
if (res) {
     ++mif.cch;
     mif.dwTypeData = new String(' ', (int)mif.cch);
     res = GetMenuItemInfo(hMenu, 0, true, mif);
}

Alternative Managed API:

Do you know one? Please contribute it!

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
Find References
Show Printable Version
Revisions