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
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.
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 ?
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