> From: Rohit Gupta <[EMAIL PROTECTED]>
> How can I make a TMenuItem respond to both left and right clicks
> and be able to ell which occurred.
this is kind of a pain, but i don't see an easier way to do it:
in your form add a data member:
type TMenuButton = (mbLeft, mbRight);
//...
mMenuButton:TMenuButton;
and declare WMNCLButtonDown and WMNCRButtonDown messagehandlers:
procedure WMNCLButtonDown(var Message: TWMNCLButtonDown);
message WM_NCLBUTTONDOWN;
procedure WMNCRButtonDown(var Message: TWMNCLButtonDown);
message WM_NCRBUTTONDOWN;
in the WMNCLButtonDown handler, look at Message.Wparam and if it
is HTMENU set mMenuButton := mbLeft. Then call the inherited
implementation.
procedure Form1.WMNCLButtonDown(var Message: TWMNCLButtonDown);
begin
if Message.WParam = HTMENU then mMenuButton:=mbLeft;
inherited;
end;
in the WMNCLButtonDown handler, look at Message.Wparam and if it
is HTMENU set mMenuButton := mbRight. Then call the inherited
implementation.
// same as above
finally, in the "OnClick" event handlers for your TMenuItem
you can examine mMenuButton to see which mouse button
fired the click.
if you're willing to hang the menu off of a tool button
you can take a look at the TrackButton property which sort of
does the same thing.
i've never tried either of these, and there could easily be
embarrassing errors in the above. But i think the idea will
work.
good luck
ns
---------------------------------------------------------------------------
New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"