Solved

left and right mouse button

Posted on 1998-11-22
6
119 Views
Last Modified: 2010-04-04
hi,

in the onclick event I execute the code for the left mouse button, but how do I also execute a code for the rightmousebutton.

Something like this.

TForm1.Button1Click(Sender : TObject);
begin
if (leftmousebutton clicked??) then begin
...
end;
if (Rightmousebutton clicked??) then begin
...
end;
end;

Anyone knows the code for this...Thanks
0
Comment
Question by:hellfire052497
  • 3
  • 2
6 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1347542
hi hellfire,

try

procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  case button of
    mbleft : edit1.text := 'LeftClick';
    mbright : edit1.text := 'RightClick';
  end;
end;

meikl
0
 
LVL 4

Accepted Solution

by:
jack_p50 earned 100 total points
ID: 1347543
Use onMouseUp/onMouseDown to see if some of buttons releases/presses.
Also you can use onMouseMove and check:
for left:            if ssLeft in Shift then...
for right:          if ssRight in Shift then...
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1347544
and for right double click ?
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Expert Comment

by:bryan7
ID: 1347545
and for right double click ?
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 1347546
hi bryan7,

this will it detects

procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  case button of
    mbright : begin
                if ssdouble in shift then
                  edit1.text := 'DoubleRightClick'
                else
                  edit1.text := 'RightClick';
              end;
    mbleft  : Begin
                if ssdouble in shift then
                  edit1.text := 'DoubleLeftClick'
                else
                  edit1.text := 'LeftClick';
              end;
  end;
end;


meikl
0
 
LVL 3

Expert Comment

by:bryan7
ID: 1347547
yeah, great !!!!

thanx a lot.

bryan

0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

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…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

708 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

16 Experts available now in Live!

Get 1:1 Help Now