Solved

Make next Mouse Click a Right-CLick

Posted on 2001-08-06
10
233 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
Technology Partners: 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!

 

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
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…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

719 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