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
the Tmainmenu component has no Tmouse event.
I would like to use the Tmousemove/Tmousedown event in Tmainmenu.how to get?
thanks
regards
what version of Delphi are you using?
ASKER
hi,
delphi 2010
thanks
regards
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
ASKER
HI,
Thanks all experts' comment.
lomo74,would you give a example ?
thanks
regards
Thanks all experts' comment.
lomo74,would you give a example ?
thanks
regards
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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?
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?
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
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
ASKER
Thanks for experts' canswer