Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6374703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:31:16+00:00 2026-05-25T01:31:16+00:00

Okay this may seem too simple of a question but I’ve wasted enough time

  • 0

Okay this may seem too simple of a question but I’ve wasted enough time looking for how to do this. I am using CE 6.5 on a mobile device and I have a ContextMenu with six MenuItems. When the Menu pops up the first Item in the list is automatically highlighted. I want to remove this highlight as it is confusing some of my users in thinking that it is the current state. I looked into ContextMenu and all its variables and MenuItem and haven’t found out how to remove automatic highlight of first item. Same goes for a MainMenu’s too.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:31:17+00:00Added an answer on May 25, 2026 at 1:31 am

    I think the answer is, unfortunately, you can’t. I put in a strong effort this afternoon to get hold of that menu and I just couldn’t get a valid HMENU that the OS would allow me to use. If you want to continue trying to chase the path I was on the code is below, but I really think it’s a dead-end. At this point I’d consider P/Invoking everything for the menu (creation, population, etc) if you really need that feature.

    using System;
    using System.Linq;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Text;
    using System.Windows.Forms;
    using System.Reflection;
    using System.Runtime.InteropServices;
    
    using UINT = System.UInt32;
    using HMENU = System.IntPtr;
    using HBITMAP = System.IntPtr;
    using DWORD = System.UInt32;
    using LPTSTR = System.IntPtr;
    
    namespace MenuTest
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
    
                contextMenu.MenuItems.Add(new MenuItem() { Text = "Item A" });
                contextMenu.MenuItems.Add(new MenuItem() { Text = "Item B" });
                contextMenu.MenuItems.Add(new MenuItem() { Text = "Item C" });
                contextMenu.MenuItems.Add(new MenuItem() { Text = "Item D" });
    
                this.MouseDown += new MouseEventHandler(Form1_MouseDown);
                contextMenu.Popup += new EventHandler(contextMenu_Popup);
            }
    
            void contextMenu_Popup(object sender, EventArgs e)
            {
                var type = contextMenu.GetType();
                var members = type.GetMembers(
                              BindingFlags.NonPublic | BindingFlags.Instance);
                var menuMember = type.GetField("m_hmnu", 
                                 BindingFlags.NonPublic | BindingFlags.Instance);
                var hMenu = (HMENU)menuMember.GetValue(contextMenu);
    
                var info = new MENUITEMINFO();
                info.cbSize = (uint)Marshal.SizeOf(info);
                info.fMask = MIIM_STATE;
                var result = GetMenuItemInfo(hMenu, 0, true, out info);
                if (!result)
                {
                    var err = Marshal.GetLastWin32Error();
                    if (err == 0x0579) MessageBox.Show("Invalid menu handle");
                    return;
                }
                info.fMask = MIIM_STATE;
                info.fState &= (~MFS_HILITE);
                result = SetMenuItemInfo(hMenu, 0, true, ref info); 
            }
    
            void Form1_MouseDown(object sender, MouseEventArgs e)
            {
                contextMenu.Show(this, new Point(e.X, e.Y));
            }
    
            private const uint MIIM_STATE = 1;
            private const uint MFS_UNHILITE = 0;
            private const uint MFS_HILITE = 0x80;        
    
            //typedef struct tagMENUITEMINFO {
            //  UINT cbSize; 
            //  UINT fMask; 
            //  UINT fType; 
            //  UINT fState; 
            //  UINT wID; 
            //  HMENU hSubMenu; 
            //  HBITMAP hbmpChecked; 
            //  HBITMAP hbmpUnchecked; 
            //  DWORD dwItemData; 
            //  LPTSTR dwTypeData; 
            //  UINT cch; 
            //} MENUITEMINFO, FAR* LPMENUITEMINFO; 
            private struct MENUITEMINFO
            {
                public UINT cbSize;
                public UINT fMask;
                public UINT fType;
                public UINT fState;
                public UINT wID;
                public HMENU hSubMenu;
                public HBITMAP hbmpChecked;
                public HBITMAP hbmpUnchecked;
                public DWORD dwItemData;
                public LPTSTR dwTypeData;
                public UINT cch; 
            }
    
            //BOOL SetMenuItemInfo(
            //  HMENU hMenu,
            //  UINT uItem,
            //  BOOL fByPosition,
            //  LPCMENUITEMINFO lpmii
            //);
            [DllImport("coredll", SetLastError = true)]
            private static extern bool SetMenuItemInfo(HMENU hMenu, UINT uItem, 
                                       [MarshalAs(UnmanagedType.Bool)]bool fByPosition, 
                                       ref MENUITEMINFO lpmii);
    
            //BOOL GetMenuItemInfo(
            //  HMENU hMenu,
            //  UINT uItem,
            //  BOOL fByPosition,
            //  LPMENUITEMINFO lpmii
            //);
            [DllImport("coredll", SetLastError = true)]
            private static extern bool GetMenuItemInfo(HMENU hMenu, UINT uItem, 
                                       [MarshalAs(UnmanagedType.Bool)]bool fByPosition, 
                                       out MENUITEMINFO lpmii);
    
            //HMENU GetSubMenu(
            //  HMENU hMenu,
            //  int nPos
            //);
            [DllImport("coredll", SetLastError = true)]
            private static extern HMENU GetSubMenu(HMENU hMenu, int nPos);
        }
    }
    

    EDIT

    I knew I had code somewhere for doing all of this. We used to sell a commercial PopupMenu control that wrapped up all of the P/Invokes for menu creation. Sales for the control were small, so we pulled it from our product line a few years ago. I’ve now released it as open source over on Codeplex.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Okay this may be a simple question but I have yet to come with
Okay, this may seem silly, but on an ASP.NET .ascx control, I'm trying to
Okay, this may be a dumb question, but I've not been able to find
Okay, this might seem like a weird question, but bear with me. So I
Okay, this may be a silly question but I'm still on my path to
Okay the answer to this may be really simple but I have been searching
Okay, This may be really simple or it may not even be possible, or
Okay, so this one may be difficult but I will do my best to
Okay this question is very simple: I have a facebook page, and a website.
Okay this is definitely a n00b question but here goes. The way I understand

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.