Solved

How to write some codes for Right Clicking mouse?

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now