Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

OnMouseDown in TPopupMenu

Posted on 1997-06-30
7
Medium Priority
?
388 Views
Last Modified: 2010-04-04
I need to be able to react to mousedowns on menu items that have subitems.

normally, the menu only reacts (closes) when the user clicks on a leaf (a menu item without subitems).

The only available event in TMenuItem is OnClick, but this also gets triggered if an item is highlighted.

Can anyone show me how to implement this handler, 'cause i'm slightly stuck (understatement of the year)
0
Comment
Question by:jmstolting
[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
  • 4
  • 2
7 Comments
 

Author Comment

by:jmstolting
ID: 1337987
Adjusted points to 200
0
 
LVL 1

Expert Comment

by:ygolan
ID: 1337988
You will need to capture the WM_MenuSelect message.
0
 

Author Comment

by:jmstolting
ID: 1337989
ygolan :

thanks for your proposed answer.

WM_MenuSelect won't work for two reasons :

1. The T(Popup)Menu triggers this message on two occasions. [A] the user clicks on a menuitem which doesn't have any subitems (so far so good) and [B] the user positions the mousecursor over an item which has subitems. (automatic opening of the sub-menu). I need to be able to determine if the user generates a mousedown over a menuitem wether it has subitems or not.

2. when the user clicks on a menuitem which has subitems, windows doesn't send _any_ message to the menu.WinProc handler.

-----

I know, this problem is slightly bigger than I first thought it to be. oh well, another 101 points then.

ps: I think using a mousehook should do the trick, but I don't have the time to explore this subject extensively.

jeroen

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:jmstolting
ID: 1337990
Adjusted points to 301
0
 
LVL 1

Expert Comment

by:Gabor
ID: 1337991
Which version of Delphi do you use?I think it's a difficult task to handle mouse events on a menu, because it's made to be a MENU (select one, and send back the result)It would help if you write down exactly what you want to do.
0
 

Author Comment

by:jmstolting
ID: 1337992
Gabor,

I'm using Delphi 3.0 professional.

What I want to do is this : I want users to be able to select items from a tree, represented by a (popup)menu.

When a user selects an item, all parents of this item should be selected. This isn't difficult if the user would only able to select the leaves of the tree, but that's not what I want.

They should be able to select an item, for example, halfway down the tree. If this item has children, my problem occurs...

Thanks for your reaction,

jeroen.
0
 
LVL 1

Accepted Solution

by:
Gabor earned 600 total points
ID: 1337993
I have found what you want.

1. To avoid to show submenus make all subitems' Visible property to FALSE at initialization.

2. You can use the OnClick event to handle selections.

This is not enought for you, because you want to handle mouse-button event too.
You can determine if the OnClick event is occured by the left button with using GetAsyncKeyState API function:

{OnClick event}
...
if GetAsyncKeyState(VK_LBUTTON)<0 then begin
  {you can do everithing you want, for example make subitems' Visible property to true}
end;
...

It works, I have tried it.

Good luck!

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

598 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