Solved

Make next Mouse Click a Right-CLick

Posted on 2001-08-06
10
222 Views
Last Modified: 2010-04-06
I have an application used on a pen-based computer. The pen itself, is a simple stylus and the screen is a touch-screen.  There is no right-click ability. However, the hardware includes an app that changes the next-click to a right-click. You tap the icon they provide, and then tap wherever you want a right-click.  I want to duplicate the functionality in my app, rather than rely on their app which is always on top, and I can't do much with.

SO!...I want to click a button, and then the next place I click (always a left-mouse) I want windows to think it is a right-click.  

Thanks, in advance.
0
Comment
Question by:espeterson
10 Comments
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6356817
SwapMouseButton

The SwapMouseButton function reverses or restores the meaning of the left and right mouse buttons.

BOOL SwapMouseButton(

    BOOL fSwap      // reverse or restore buttons
   );    
 

Parameters

fSwap

Specifies whether the mouse button meanings are reversed or restored. If this parameter is TRUE, the left button generates right-button messages and the right button generates left-button messages. If this parameter is FALSE, the buttons are restored to their original meanings.

 

Return Values

If the meaning of the mouse buttons was reversed previously, before the function was called, the return value is nonzero.
If the meaning of the mouse buttons was not reversed, the return value is zero.

Remarks

Button swapping is provided as a convenience to people who use the mouse with their left hands. The SwapMouseButton function is usually called by Control Panel only. Although an application is free to call the function, the mouse is a shared resource and reversing the meaning of its buttons affects all applications.
0
 
LVL 44

Expert Comment

by:CrazyOne
ID: 6356845
The comment is from the Win32 Programmers Reference help file.

To switch

SwapMouseButton(True);

To reset

SwapMouseButton(False);

0
 

Author Comment

by:espeterson
ID: 6357184
I need it to revert back after the next click... how will I do that?   I dont want a permanent Swap.  You did answer the original question... but any ideas on getting it back?  
0
 

Author Comment

by:espeterson
ID: 6357281
I need it to revert back after the next click... how will I do that?   I dont want a permanent Swap.  You did answer the original question... but any ideas on getting it back?  
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 44

Expert Comment

by:CrazyOne
ID: 6357390
Ok let me make sure I am clear on this. After the user clicks on whatever you have designated this will switch the button to a more or less right click and then they go go and do something with the stylus then the mouse button should automatically revert to its normall state. Am I on the right track?
0
 
LVL 1

Accepted Solution

by:
Dennis9 earned 100 total points
ID: 6359796
Hi espeterson.
I have made a demo showing how to do it for u.

Download it here:
http://members.fortunecity.com/dtntspace/Left_To_Right_Click.zip

Its easy and i use the SwapMouseButton method.

Hope it help u.

Dennis
0
 

Expert Comment

by:ComTech
ID: 6360250
Dennis9, I have rejected your Proposed Answer.  You have been an expert long enough to know the rules.  If you have forgotten them, they are at the bottom of this page, follow the link there as well.

ComTech
Community Support
0
 

Author Comment

by:espeterson
ID: 6360432
CrazyOne, you are correct.  CLick on the button...goes to "right click mode"...next click is a right click, then goes back to "left click normal mode"  
0
 

Author Comment

by:espeterson
ID: 6360453
It looks like Dennis9 got it for me.  I will post his code:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Button2MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
  private
    { Private declarations }
    procedure AppMessage(var Msg: TMsg; var Handled: Boolean);
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  Swap:Boolean;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
Swap := True;
SwapMouseButton(True);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Application.OnMessage := AppMessage;
end;

procedure TForm1.AppMessage(var Msg: TMsg; var Handled: Boolean);
begin
if Msg.message = WM_RBUTTONDOWN then
begin
  If Swap then
  begin
   SwapMouseButton(false);
   Swap := false;
  end;
end;
Handled := False;
end;

procedure TForm1.Button2MouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
 if Button = mbLeft then Showmessage('You Left-Clicked');
 if Button = mbRight then Showmessage('You Right-Clicked');
end;

end.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

910 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

22 Experts available now in Live!

Get 1:1 Help Now