jl2001
asked on
How to write some codes for Right Clicking mouse?
Hi, experts:
Can anyone solve the problem?
I must use mousedown to allocate clicking position(leftclick) on a label. How can I use mouse rightclick on the label to show a message?
thanks a lot!
John
Can anyone solve the problem?
I must use mousedown to allocate clicking position(leftclick) on a label. How can I use mouse rightclick on the label to show a message?
thanks a lot!
John
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
var
clickpos:TPoint;
procedure TForm.Label1MouseUp(Sender : TObject; Button: TMouseButton; Shift: TShiftState; X, Y:integer);
const
RADIUS = 4;
begin
if Button = mbRight then
begin
clickpos.X := X;
clickpos.Y := Y;
ShowMessage('The new click position is X:' + IntToStr(X) + ' Y:' + IntToStr(Y));
end
else if Button = mbLeft then
begin
if (X >= clickpos.X - RADIUS) and (X <= clickpos.X + RADIUS) and (Y >= clickpos.Y - RADIUS) and (Y <= clickpos.Y + RADIUS) then
ShowMessage('CLICKED !!');
end;
end;
clickpos:TPoint;
procedure TForm.Label1MouseUp(Sender
const
RADIUS = 4;
begin
if Button = mbRight then
begin
clickpos.X := X;
clickpos.Y := Y;
ShowMessage('The new click position is X:' + IntToStr(X) + ' Y:' + IntToStr(Y));
end
else if Button = mbLeft then
begin
if (X >= clickpos.X - RADIUS) and (X <= clickpos.X + RADIUS) and (Y >= clickpos.Y - RADIUS) and (Y <= clickpos.Y + RADIUS) then
ShowMessage('CLICKED !!');
end;
end;
ASKER
simple, straight forward and no bugs
ASKER
Thanks a lot, guys.
procedure TForm1.Label1ContextPopup(
var Handled: Boolean);
begin
showmessage('ok');
end;