Ejemplo n.º 1
0
        private void MenuItem_Popup(object sender, EventArgs e)
        {
            MENUITEMINFO_T_RW menuItemInfo = new MENUITEMINFO_T_RW();

            // get the menu items collection
            Menu.MenuItemCollection mi = sender.GetType() == typeof(ContextMenu)
                                             ? ((ContextMenu)sender).MenuItems
                                             : ((MenuItem)sender).MenuItems;

            // we have to track the menuPosition ourselves
            // because MenuItem.Index is only correct when
            // all the menu items are visible.
            int miOn = 0;

            for (int i = 0; i < mi.Count; i++)
            {
                if (mi[i].Visible)
                {
                    Properties p = ((Properties)properties[mi[i]]);

                    if (p != null)
                    {
                        menuItemInfo.hbmpItem = p.renderBmpHbitmap;

                        //refresh the menu item where ((Menu)sender).Handle is the parent handle
                        SetMenuItemInfo(new HandleRef(null, ((Menu)sender).Handle),
                                        miOn,
                                        true,
                                        menuItemInfo);
                    }

                    miOn++;
                }
            }
        }
Ejemplo n.º 2
0
        private void MenuItem_Popup(object sender, EventArgs e)
        {
            MENUITEMINFO_T_RW menuItemInfo = new MENUITEMINFO_T_RW();

            // get the menu items collection
            Menu.MenuItemCollection mi = sender.GetType() == typeof (ContextMenu)
                                             ? ((ContextMenu) sender).MenuItems
                                             : ((MenuItem) sender).MenuItems;

            // we have to track the menuPosition ourselves
            // because MenuItem.Index is only correct when
            // all the menu items are visible.
            int miOn = 0;
            for (int i = 0; i < mi.Count; i++)
            {
                if (mi[i].Visible)
                {
                    Properties p = ((Properties) properties[mi[i]]);

                    if (p != null)
                    {
                        menuItemInfo.hbmpItem = p.renderBmpHbitmap;

                        //refresh the menu item where ((Menu)sender).Handle is the parent handle
                        SetMenuItemInfo(new HandleRef(null, ((Menu) sender).Handle),
                                        miOn,
                                        true,
                                        menuItemInfo);
                    }

                    miOn++;
                }
            }
        }
Ejemplo n.º 3
0
 public static extern bool SetMenuItemInfo(HandleRef hMenu, int uItem, bool fByPosition, MENUITEMINFO_T_RW lpmii);
Ejemplo n.º 4
0
 public static extern bool SetMenuItemInfo(HandleRef hMenu, int uItem, bool fByPosition, MENUITEMINFO_T_RW lpmii);