Avatar of Cheng_sam
Cheng_sam
 asked on

Tmousemove in Tmainmenu

hi,Experts
    the Tmainmenu component has no Tmouse event.
    I would like to use the Tmousemove/Tmousedown event in Tmainmenu.how to get?

thanks
regards
Windows 2000Delphi

Avatar of undefined
Last Comment
Cheng_sam

8/22/2022 - Mon
aikimark

what version of Delphi are you using?
Cheng_sam

ASKER
hi,
    delphi 2010


thanks
regards
developmentguru

As is usual with many of the base Delphi components, the TMainMenu is a wrapper for a windows control.  In this case it is an OLE2 Menu.  In order to handle this you would likely need to bypass the Delphi control altogether and use OLE2 to try to set it up.  Personally I would find it easier to make my own menu components if I needed that functionality.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
SOLUTION
aikimark

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ASKER CERTIFIED SOLUTION
BlueVD

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
lomo74

menu bars are windowless, so you can't get mouse move messages from the menu bar area.
a possible approach: intercept WM_NCHITTEST; when result is HTMENU, then it means the mouse is inside the menu bar area.
you can then use the message's X and Y coordinates (into LParam) and read button state (using GetAsyncKeyState) to mimic WM_MOUSEMOVE, WM_LBUTTONDOWN, WM_RBUTTONDOWN, and so on, accordingly.
Cheng_sam

ASKER
HI,
   Thanks all experts' comment.
   lomo74,would you give a example ?

thanks
regards
SOLUTION
lomo74

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
Cheng_sam

ASKER
hi,thanks the demo
 i test the example.it  only run in mainmenu.there isn't response in submenu.can it be improve?

thanks
regards
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
lomo74

well, that's hard.
when you press the menu, it enters a message loop controlled by windows.
don't really know how you can hook into this loop.
what's exactly your goal?
Cheng_sam

ASKER
hi,

    sorry for my late response.
    sometime we need to make some different style operation.to use the mousedown event in Tmainmenu is a cool one i think.i have downloaded the file that BlueVD suggested and tested it.it look fine but need to modified.
thanks
regards
Cheng_sam

ASKER
Thanks for experts' canswer
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck