Solved

Make next Mouse Click a Right-CLick

Posted on 2001-08-06
10
221 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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

746 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

11 Experts available now in Live!

Get 1:1 Help Now