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
Solved

Finding the position where a Tmenuitem was clicked

Posted on 2006-11-25
7
1,011 Views
Last Modified: 2010-04-05
Hi

I need to find out if the user clicked the image on a tmenuitem.

I tried the following :

   GetMenuItemRect(TMenuItem(Sender).GetParentMenu.WindowHandle, TMenuItem(Sender).GetParentMenu.Handle, TMenuItem(Sender).MenuIndex, Rect);
//   GetMenuItemRect(Ftube.WindowHandle, TMenuItem(Sender).GetParentMenu.Handle, TMenuItem(Sender).MenuIndex, Rect);
   Windows.GetCursorPos(CPos);

but i can't find the menuitemrect relative to the screen (or anything else for that matter).

Please help!

Regards Helge
0
Comment
Question by:UniqSoft
7 Comments
 
LVL 3

Expert Comment

by:Ghitza
ID: 18012758
You mean like Mouse.CursorPos.X ?

0
 

Author Comment

by:UniqSoft
ID: 18012901
I mean how do i determine if the user clicked on the text or the icon in the menuitem. I want to do special processing if the user clicked on the icon.
0
 
LVL 16

Accepted Solution

by:
CodedK earned 125 total points
ID: 18012914
You can get the handle of the submenu associated with an item by using the
GetSubMenu or GetMenuItemInfo function.
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
GetSubMenu
( HMENU hMenu,      // handle of menu
  int nPos      // menu item position
);
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
See if this PAQ helps you :
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20256094.html
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:UniqSoft
ID: 18013149
It's not the submenu icon i'm interested in. The menu has items to the left of the text (TMenu.Imagelist, TMenuItem.ImageIndex)
0
 
LVL 4

Assisted Solution

by:Meldrachaun
Meldrachaun earned 125 total points
ID: 18015042
The problem here is that a menu item can be executed by the keyboard, as well as with the mouse, so the component is written to be independent of the mouse position.
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21135801
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

808 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