Board index » cppbuilder » How can I make right click emulate left click

How can I make right click emulate left click

I want all the buttons (including those on a header control) in my app to
have a right click function as well as a left click. In order to do this
I've created several components that respond (visually as well
programatically) to right clicks as they would to left clicks (heavy use of
Perform).

I was thinking though that surely there is an easier way of doing this. Is
there any way I can trap all right clicks from the app and change these so
Windows responds as if they were left clicks at the same screen point.
Remember I want the response to be visual (e.g. right click a TSpeedButton
and it appears pressed etc.) as well as programatically so the likes of
TSpeedButton::Click is no good.

 

Re:How can I make right click emulate left click


(untested) Try using the TApplication::OnMessage() event, intercept the
desired messages, set Handled to true to shallow them, then dispatch your
own messages.

Gambit

Quote
"Tom Byars" <tamby...@yahoo.com> wrote in message

news:3e86f710@newsgroups.borland.com...

Quote
> I was thinking though that surely there is an easier way of
> doing this. Is there any way I can trap all right clicks from
> the app and change these so Windows responds as if they
> were left clicks at the same screen point. Remember I want
> the response to be visual (e.g. right click a TSpeedButton
> and it appears pressed etc.) as well as programatically so
> the likes of TSpeedButton::Click is no good.

---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.463 / Virus Database: 262 - Release Date: 3/17/03

Re:How can I make right click emulate left click


Thanks Remy. It seems to be as simple as this

void __fastcall TMain::ApplicationMessage(tagMSG &Msg,bool &Handled)
{
    if (Msg.message==WM_RBUTTONDOWN)
    {
        Msg.message = WM_LBUTTONDOWN;
        Msg.wParam &= ~MK_RBUTTON;
        Msg.wParam |= MK_LBUTTON;
    }

Quote
}

A little additional code (e.g. setting a global variable RightClicked) will
allow me to respond appropriately in each objects OnClick method. I can now
delete some rather ugly code ;-)

Cheers

Tam

"Remy Lebeau (TeamB)" <gambi...@yahoo.com> wrote in message
news:3e875df4$1@newsgroups.borland.com...

Quote
> (untested) Try using the TApplication::OnMessage() event, intercept the
> desired messages, set Handled to true to shallow them, then dispatch your
> own messages.

> Gambit

> "Tom Byars" <tamby...@yahoo.com> wrote in message
> news:3e86f710@newsgroups.borland.com...

> > I was thinking though that surely there is an easier way of
> > doing this. Is there any way I can trap all right clicks from
> > the app and change these so Windows responds as if they
> > were left clicks at the same screen point. Remember I want
> > the response to be visual (e.g. right click a TSpeedButton
> > and it appears pressed etc.) as well as programatically so
> > the likes of TSpeedButton::Click is no good.

> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.463 / Virus Database: 262 - Release Date: 3/17/03

Other Threads