Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Make next Mouse Click a Right-CLick

Posted on 2001-08-06
10
Medium Priority
?
244 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
[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
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
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.

 

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
 
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 400 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
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…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

618 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