Link to home
Start Free TrialLog in
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
Avatar of aikimark
aikimark
Flag of United States of America image

what version of Delphi are you using?
Avatar of Cheng_sam
Cheng_sam

ASKER

hi,
    delphi 2010


thanks
regards
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.
SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
HI,
   Thanks all experts' comment.
   lomo74,would you give a example ?

thanks
regards
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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?
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
Thanks for experts' canswer