Solved

MenuItemFromPoint()and GetMenuItemRect()

Posted on 1997-07-28
5
1,072 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

This tutorial is about how to put some of your C++ program's functionality into a standard DLL, and how to make working with the EXE and the DLL simple and seamless.   We'll be using Microsoft Visual Studio 2008 and we will cut out the noise; that i…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

617 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