Solved

How to write some codes for Right Clicking mouse?

Posted on 2001-08-24
5
153 Views
Last Modified: 2010-04-06
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
0
Comment
Question by:jl2001
5 Comments
 
LVL 1

Expert Comment

by:sundayboys
ID: 6424078
Use OnContextPopup event.like this:
procedure TForm1.Label1ContextPopup(Sender: TObject; MousePos: TPoint;
  var Handled: Boolean);
begin
   showmessage('ok');
end;
0
 
LVL 34

Accepted Solution

by:
Slick812 earned 50 total points
ID: 6424208
hello jl2001, the mouse down event has a "Button" property that you can use to determine which mouse button was used with mbLeft, mbRight and mbMiddle

Form1.Label1.MouseDown(Sender,Button,Shift,X, Y);
begin
if Button = mbRight then ShowMessage('Right Mouse button was down') else
if Button = mbLeft then ShowMessage('Left Mouse button was down');
end;
0
 
LVL 3

Expert Comment

by:rondi
ID: 6424546
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;
0
 

Author Comment

by:jl2001
ID: 6425449
simple, straight forward and no bugs
0
 

Author Comment

by:jl2001
ID: 6425454
Thanks a lot, guys.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question