Swap Mouse Buttons

Posted on 1999-07-18
Medium Priority
Last Modified: 2013-11-20
Is there a way to swap the mouse buttons, like you can in the mouse control panel?  I know that there is a registry entry, but once edited, you have to restart windows to take effect. I dont want to do that, I want to do it right now  :)   is there a way to program that in C++\mfc?  thanks.
Question by:Nitro187
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
LVL 86

Accepted Solution

jkr earned 200 total points
ID: 1310338
Simply use this Win32 API function (the following is taken from the MS online docs:

SwapMouseButton (Win32)

BOOL SwapMouseButton(fSwap)

BOOL fSwap;      /* reverse or restore buttons      */

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

Parameter      Description

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


If the meaning of the mouse buttons was reversed previously, before the function was called, the return value is
TRUE; otherwise, it is FALSE.


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.

LVL 86

Expert Comment

ID: 1310339
Ooops, sorry - this one seems to be a duplicate: See http://www.experts-exchange.com/Computers/Programming/Languages/C++/Q.10184017 (posted on  Saturday, July 17 1999 - 10:17PM PDT) - anyway, both naveenkohli as WxW gave a correct answer...

Author Comment

ID: 1310340
Thanks  :D
LVL 86

Expert Comment

ID: 1310341
Err - my pointer to the duplicate was meant that you should grant _them_ the points, as they were earlier...

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…

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