Solved

MenuItemFromPoint()and GetMenuItemRect()

Posted on 1997-07-28
5
1,052 Views
Last Modified: 2013-12-03
Hi,
Actually, I'd like to know whether a mouse click was inside a menu (or a menu item). I thought that WM_LBBUTTONDOWN will give me the mouse click coordinates, and that MenuItemFromRect() will give the menu item selected.

However, this does not work (at least not always). I've tried to find an example of using MenuItemFromPoint() or GetMenuItemRect(), but I couldn't find any.

Do you have any idea?

Thanks,
Yarden Admon
(working with Windows NT 4.0, Visual C++ 5.0)
0
Comment
Question by:yarden
  • 3
  • 2
5 Comments
 

Author Comment

by:yarden
ID: 1402170
Edited text of question
0
 
LVL 3

Accepted Solution

by:
jaba earned 150 total points
ID: 1402171
You cant dispatch WM_LBUTTONDOW while menu activated.  Becouse menu is WINDOW , sysmodal window. It have  mouse and keyboard capture. All messages translating to menu`s window and dispatching by it. What why you cant work with mouse /keyboard messages when menu opened :-( Try to use other way to do what you want.
0
 

Author Comment

by:yarden
ID: 1402172
I didn't fully understand your answer. Perhaps I should elaborate a little more.

I'm already receiving WM_LBUTTONDOWN from the window. At that point I would like to know whether the mouse click was inside or outside a menu.

However, it seems that the coordinates used by the menu functions  - MenuItemFromPoint() and GetMenuItemRect() - use coordinates which do not correspond to the mouse click coordinates.

If someone has any experience using these functions, please tell me ...


0
 

Author Comment

by:yarden
ID: 1402173
I didn't fully understand your answer. Perhaps I should elaborate a little more.

I'm already receiving WM_LBUTTONDOWN from the window. At that point I would like to know whether the mouse click was inside or outside a menu.

However, it seems that the coordinates used by the menu functions  - MenuItemFromPoint() and GetMenuItemRect() - use coordinates which do not correspond to the mouse click coordinates.

If someone has any experience using these functions, please tell me ...


0
 
LVL 3

Expert Comment

by:jaba
ID: 1402174
What king of menu you using ?
About cooridinates not corresponding to other. WM_LBUTTONDOWN point coordinates relative to the upper-left corner of the client area of the Window. GetMenuItemRect function return coordinates expressed in screen coordinates.
You should you ClientToScreen And ScreenToClient function to convert coordinates

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question