Solved

Finding the position where a Tmenuitem was clicked

Posted on 2006-11-25
7
979 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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now