Re: Can a context menu have side-by-side menu items?
From: Mattias Sjögren (mattias.dont.want.spam_at_mvps.org)
Date: 10/16/04
- Next message: Tony Thijs: "C# or VB.net?"
- Previous message: Willy Denoyette [MVP]: "Re: Creating user in active directory"
- In reply to: VMI: "Can a context menu have side-by-side menu items?"
- Messages sorted by: [ date ] [ thread ]
Date: Sat, 16 Oct 2004 22:33:21 +0200
>Is it possible to make a Context menu so that the menu items were
>side-to-side:
>
>Copy / Paste
>Cut / Process
>... / ...
The Win32 API lets you split a menu in multiple columns. You can use
code such as this
struct MENUITEMINFO {
public int cbSize;
public uint fMask;
public uint fType;
public uint fState;
public uint wID;
public IntPtr hSubMenu;
public IntPtr hbmpChecked;
public IntPtr hbmpUnchecked;
public IntPtr dwItemData;
public IntPtr dwTypeData;
public uint cch;
public IntPtr hbmpItem;
}
...
[DllImport("user32.dll", CharSet=CharSet.Auto)]
static extern bool SetMenuItemInfo(IntPtr hMenu, uint uItem, bool
fByPosition, ref MENUITEMINFO lpmii);
...
const uint MIIM_FTYPE = 0x100;
const uint MFT_MENUBARBREAK = 0x20;
const uint MFT_MENUBREAK = 0x40;
MENUITEMINFO mii = new MENUITEMINFO();
mii.cbSize = Marshal.SizeOf( typeof(MENUITEMINFO) );
mii.fMask = MIIM_FTYPE;
mii.fType = MFT_MENUBREAK;
SetMenuItemInfo( YourContextMenu.Handle, idx, true, ref mii );
where idx is the index of the item you want to break on. Replace
MFT_MENUBREAK with MFT_MENUBARBREAK if you want a vertical divider to
appear between the columns.
Mattias
-- Mattias Sjögren [MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup.
- Next message: Tony Thijs: "C# or VB.net?"
- Previous message: Willy Denoyette [MVP]: "Re: Creating user in active directory"
- In reply to: VMI: "Can a context menu have side-by-side menu items?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|