Solved

left and right mouse button

Posted on 1998-11-22
6
130 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 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
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…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses
Course of the Month7 days, 19 hours left to enroll

617 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