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 6006997
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:37:08+00:00 2026-05-23T01:37:08+00:00

I am trying to get the menu item from another application. I can do

  • 0

I am trying to get the menu item from another application.

I can do this by manually getting the handle to the main menu and loop through its sub menu. But it is very difficult to find out how many levels of sub menus are there for a given menu. For example if we look at outlook view menu some thing like this, View -> Arrange by -> Current View -> Messages.

So i decided to get the menu item based on mouse position. But i cant find a way to do that.

Please suggest some idea to do this.

  • 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-23T01:37:09+00:00Added an answer on May 23, 2026 at 1:37 am

    I suspect that what you’re trying to achieve is more or less made impossible by how the menu system in windows is designed.

    Note that there might be some non-conventional ways around this, however I doubt you’ll find such a solution to carry less amount of work than your current strategy of traversing the menu hierarchy.

    The thing is, a hierarchy of menus and submenus is actually a tree of regular menus. In MFC you have a tree of CMenu objects and in the win32 C api it’s a tree of HMENU handles.

    Each menu, regardless if it’s a submenu or main menu, have a number of items which by themselves are not objects. I.e. there’s no MFC class called CMenuItem and no win32 API handle type called HMENUITEM. If you look at any function dealing with menus, it’s always about passing an ID of a menu item. For instance look at CMenu::EnableMenuItem or CMenu::GetDefaultItem.

    Now, the real problem is comprised of two facts – Menu items are local to the menu they’re located in. If you look at any function in the C API, you always need to specify both menu handle and menu item ID, due to the fact that item IDs can’t be resolved unless the framework knows which menu object you’re talking about. Hence IDs are not global. In MFC you usually don’t need to specify the menu handle, but that’s ofcourse because the CMenu object itself wraps the HMENU handle.

    The second part of the problem is that there’s no natural way of retrieving a menu (CMenu or HMENU) from position. You can get a menu item from position through MenuItemFromPoint, but as you can see you also need the menu handle and the returned ID is only valid in combination with the menu handle you specify. Since you can’t get that menu handle any other way than traversing the submenu hierarchy – you’re back to square one.

    As a final note – the capabilities of Visual C++ menus (CMenu) are always limited to the capabilities of the Win32 C API menu functions, so any functionality not found there is more or less out of reach.

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

Sidebar

Related Questions

Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
I am trying to get an image to appear next to a menu item
I am trying to get the Edit with Vim context menu to open files
I'm trying get values from a GridView using the following code: foreach (GridViewRow row
Trying to get my css / C# functions to look like this: body {
Trying to get an ASP application deployed; it worked for a while but then
Im trying to get into some basic JavaFX game development and I'm getting confused
Just trying to get my head around Generics by reading this enlightening article by
Im trying to get a completly data copy from a gridview, itryed clone(), tryed
I'm trying to add a text-only item to a databound menu control. So far

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.