Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do I remap mouse buttons (Delphi 2006)?

Status
Not open for further replies.

Andre721

Programmer
Mar 26, 2010
5
US
I have a need to develop a utility where a user left (or right) clicks on a button in the form and then their mouse gets mapped so that when they left-click, they will actually perform a right-click instead.

How do I go about remapping mouse buttons?

Thanks in advance.
 
Will this need to be a windows level setting or just in your application?
 
It would have to be window level. The idea is that the user left-clicks on anything in this state and it will be interpreted as a right-click.
 
In the Mouse control panel you may have the option to switch the mouse from right-handed to left-handed. That's probably setting a registry entry - you could probably do the same thing.
 
I need to do this through a utility. The environment that I'm dealing with is a touchscreen where the user's finger is like a mouse. If they tap the screen, it is interpreted as a left mouse click. There is no way through the touchscreen itself to have a "right-click" operation. So, my idea to counter this is to provide a utility with a simple interface... if the user taps the button on the interface, it switches the left-click to be a right-click.
 
If you would need a right-click in the touch-screen app, then that's the part to re-design, do not mess with the user-experience familiar with a touch-screen.
 
TonHu, unfortunately, I don't have the luxury of being able to re-do some of the apps as I have no control on them (believe me, I would like to). So, my question still stands.
 
Right-clicking with a mouse typically opens a pop-up menu.
if the user taps the button on the interface, it switches the left-click to be a right-click.
So why not just have the button activate the pop-up menu and be done with it?

Roo
Delphi Rules!
 
I have basically answered my own question. While browsing through the functions of the "Windows" uses clause, I found a function simply called "SwapMouseButton(boolean)". The function will swap the operations of the mouse buttons based on the boolean value you pass into it.

Coupled with using a hook method, I think I can get things so that a user taps the button in my utility (via the touchscreen), then perform a right-click operation anywhere they wish, then have the mouse button functions automatically restored after their right-click on the touchscreen.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top