Game Development Reference
In-Depth Information
The following method is used to add a submenu item to the parent menu item at
the specified position.
void AddMenuItem(uint menu, string text, int id, uint position)
{
MenuItemInfo menuItemInfo = new MenuItemInfo();
menuItemInfo.Size = 48;
menuItemInfo.ID = id;
menuItemInfo.TypeData = text;
menuItemInfo.Mask = (uint)Native.MaskFlags.ID |
(uint)Native.MaskFlags.Type |
(uint)Native.MaskFlags.State;
menuItemInfo.Type = (uint)Native.MenuFlags.String;
menuItemInfo.State = (uint)Native.MenuFlags.Enabled;
Native.InsertMenuItem(menu, position, 1, ref menuItemInfo);
}
The following method is very similar to AddMenuItem() , except it inserts a separator
into the parent menu item at the specified position.
void AddMenuSeparator(uint menu, uint position)
{
MenuItemInfo separator = new MenuItemInfo();
separator.Size = 48;
separator.Mask = (uint)Native.MaskFlags.Type;
separator.Type = (uint)Native.MenuFlags.Separator;
Native.InsertMenuItem(menu, position, 1, ref separator);
}
As mentioned earlier, IContextMenu.InvokeCommand() is called when a submenu item
is activated from the context menu. This is where we get the command informa-
tion and pass it off to the extension to handle.
void IContextMenu.InvokeCommand(IntPtr pointer)
{
try
{
Type type = typeof(InvokeCommandInfo);
InvokeCommandInfo info = Marshal.PtrToStructure(pointer, type)
as InvokeCommandInfo;
Search Nedrilad ::




Custom Search