Solved

How to write some codes for Right Clicking mouse?

Posted on 2001-08-24
5
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…

690 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