private uint InsertMenuItemPrivate( IntPtr menuHandle, string textName, int position, RightClickActionDelegate actionDelegate ) { if ( mMenuItemsAddedCount >= mMenuMaximumItemsWeCanAdd ) return 0; // Create a new Menu Item to add to the popup menu MENUITEMINFO mii = new MENUITEMINFO(); mii.cbSize = ( uint )Marshal.SizeOf( typeof( MENUITEMINFO ) ); mii.fMask = ( uint )MIIM.ID | ( uint )MIIM.TYPE | ( uint )MIIM.STATE; mii.wID = ( uint )( mMenuCmdFirst + mMenuItemsAddedCount ); mii.fType = ( uint )MF.STRING; mii.dwTypeData = textName; mii.cch = 0; mii.fState = ( uint )MF.ENABLED; // Add it to the item if ( DllImports.InsertMenuItem( menuHandle, (uint)position, true, ref mii ) == 0 ) { // failed //int error = Marshal.GetLastWin32Error(); //System.Windows.Forms.MessageBox.Show( "InsertMenuItem failed + 0x" + error.ToString( "X" ) + " : " + ( new System.ComponentModel.Win32Exception( error ) ).Message ); return 0; } else { mMenuIdsMap.Add( mMenuItemsAddedCount, actionDelegate ); mMenuItemsAddedCount++; return mii.wID; } }
public uint InsertMenuItemIntoSubMenu( IntPtr subMenu, string textName, int position, Bitmap bitmap, RightClickActionDelegate actionDelegate ) { return InsertMenuItemIntoSubMenu( subMenu, textName, position, bitmap, bitmap, actionDelegate ); }
public uint InsertMenuItemIntoSubMenu( IntPtr subMenu, string textName, int position, Bitmap uncheckedBitmap, Bitmap checkedBitmap, RightClickActionDelegate actionDelegate ) { uint id = InsertMenuItemPrivate( subMenu, textName, position, actionDelegate ); if ( id != 0 ) { SetMenuItemBitmapPrivate( subMenu, id, uncheckedBitmap, checkedBitmap ); } return id; }
/// <summary> /// Call this within OnBuildMenu() to build menu /// </summary> public uint InsertMenuItem( string textName, int position, RightClickActionDelegate actionDelegate ) { return InsertMenuItemPrivate( mMenuHandle, textName, -1, actionDelegate ); }
private uint InsertMenuItemPrivate(IntPtr menuHandle, string textName, int position, RightClickActionDelegate actionDelegate) { if (mMenuItemsAddedCount >= mMenuMaximumItemsWeCanAdd) { return(0); } // Create a new Menu Item to add to the popup menu MENUITEMINFO mii = new MENUITEMINFO(); mii.cbSize = ( uint )Marshal.SizeOf(typeof(MENUITEMINFO)); mii.fMask = ( uint )MIIM.ID | ( uint )MIIM.TYPE | ( uint )MIIM.STATE; mii.wID = ( uint )(mMenuCmdFirst + mMenuItemsAddedCount); mii.fType = ( uint )MF.STRING; mii.dwTypeData = textName; mii.cch = 0; mii.fState = ( uint )MF.ENABLED; // Add it to the item if (DllImports.InsertMenuItem(menuHandle, (uint)position, true, ref mii) == 0) { // failed //int error = Marshal.GetLastWin32Error(); //System.Windows.Forms.MessageBox.Show( "InsertMenuItem failed + 0x" + error.ToString( "X" ) + " : " + ( new System.ComponentModel.Win32Exception( error ) ).Message ); return(0); } else { mMenuIdsMap.Add(mMenuItemsAddedCount, actionDelegate); mMenuItemsAddedCount++; return(mii.wID); } }
public uint InsertMenuItemIntoSubMenu(IntPtr subMenu, string textName, int position, Bitmap uncheckedBitmap, Bitmap checkedBitmap, RightClickActionDelegate actionDelegate) { uint id = InsertMenuItemPrivate(subMenu, textName, position, actionDelegate); if (id != 0) { SetMenuItemBitmapPrivate(subMenu, id, uncheckedBitmap, checkedBitmap); } return(id); }
public uint InsertMenuItemIntoSubMenu(IntPtr subMenu, string textName, int position, Bitmap bitmap, RightClickActionDelegate actionDelegate) { return(InsertMenuItemIntoSubMenu(subMenu, textName, position, bitmap, bitmap, actionDelegate)); }
/// <summary> /// Call this within OnBuildMenu() to build menu /// </summary> public uint InsertMenuItem(string textName, int position, RightClickActionDelegate actionDelegate) { return(InsertMenuItemPrivate(mMenuHandle, textName, -1, actionDelegate)); }