Solved

Finding the position where a Tmenuitem was clicked

Posted on 2006-11-25
7
1,000 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
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows Drag & Drop Location 2 100
FMX enumerated colours 2 98
Intraweb download file link ? 1 132
URL for downloading Google Chrome for Win XP 2 152
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

776 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