Solved

How to write some codes for Right Clicking mouse?

Posted on 2001-08-24
5
152 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 33

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

786 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