Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

left and right mouse button

Posted on 1998-11-22
6
Medium Priority
?
133 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
[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
  • 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 400 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

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…
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…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Suggested Courses

721 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