I have a Trust GXT-25 mouse and it has 4 buttons: left, right, back and next.
I can only catch left and right. How can I detect the remaining 2 more events in Delphi XE3?
I have a Trust GXT-25 mouse and it has 4 buttons: left, right, back and next.
I can only catch left and right. How can I detect the remaining 2 more events in Delphi XE3?
Depending on how the mouse implements those buttons, you will have to either:
handle the WM_XBUTTONDOWN
and WM_XBUTTONUP
messages directly, or the WM_APPCOMMAND
message. Refer to MSDN for more details:
A Delphi implementation could be, by using an ApplicationEvents.OnMessage
event handler:
const
{$EXTERNALSYM MK_XBUTTON1}
MK_XBUTTON1 = $20;
{$EXTERNALSYM MK_XBUTTON2}
MK_XBUTTON2 = $40;
{$EXTERNALSYM XBUTTON1}
XBUTTON1 = $1;
{$EXTERNALSYM XBUTTON2}
XBUTTON2 = $2;
procedure TForm1.ApplicationEvents1Message(var Msg: tagMSG;
var Handled: Boolean);
begin
case Msg.message of
WM_XBUTTONDOWN:
case LoWord(Msg.wParam) of
MK_XBUTTON1: { Handle Back };
MK_XBUTTON2: { Handle Forward };
end;
WM_XBUTTONUP:
case HiWord(Msg.wParam) of
XBUTTON1: { Handle Back };
XBUTTON2: { Handle Forward };
end;
end;
end;
use the Raw Input API to register your desired window to receive WM_INPUT
messages for mouse input.
Depending on the mouse driver it is even posible that pressing one of the special mouse buttons won't even generate any mouse event, but instead the driver may programatically send a keyboard command instead.
You are talking about back and next buttons. Does these buttons serve for back and forward navigation in your browser?
If they do then it is quite possible that the mouse drivers are generating keyboard equivalent shourtcuts for this which are (ALT+Left for Back and ALT+Right for Next).
So I recomend you try using the OnKeyDown and OnKeyUp events to see if that is the case.