Hi!
I have a Logitech Mouse, and I am trying to catch mouse clicks on the “side-button”, using Windows.
I believe this is identified as the XBUTTON1, XBUTTON2, XBUTTON3 etc. by Windows.
When I press the “side-button”, it is identified as WM_MBUTTONDOWN by Windows, instead of WM_XBUTTONDOWN.
This is a code snippet that I am using to test:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
TCHAR szHello[MAX_LOADSTRING];
LoadString(hInst, IDS_HELLO, szHello, MAX_LOADSTRING);
short fwKeys;
short fwButton;
switch (message)
{
case WM_LBUTTONDOWN:
MessageBox(NULL,"WM_LBUTTONDOWN", "Test",MB_OK);
break;
case WM_RBUTTONDOWN:
MessageBox(NULL,"WM_RBUTTONDOWN", "Test",MB_OK);
break;
case WM_MBUTTONDOWN:
//Use the following code to crack the wParam parameter:
fwKeys = GET_KEYSTATE_WPARAM (wParam);
fwButton = GET_XBUTTON_WPARAM (wParam);
if (fwKeys == MK_XBUTTON1 | | fwButton == XBUTTON1)
MessageBox(NULL,"WM_MBUTTONDOWN-XBUTTON1", "Test",MB_OK);
else if (fwKeys == MK_XBUTTON2 | | fwButton == XBUTTON2)
MessageBox(NULL,"WM_MBUTTONDOWN-XBUTTON2", "Test",MB_OK);
else
MessageBox(NULL,"WM_MBUTTONDOWN", "Test",MB_OK);
break;
case WM_XBUTTONDOWN:
MessageBox(NULL,"WM_XBUTTONDOWN", "Test",MB_OK);
//Use the following code to crack the wParam parameter:
// fwKeys = GET_KEYSTATE_WPARAM (wParam);
// fwButton = GET_XBUTTON_WPARAM (wParam);
//Use the following code to obtain the horizontal and vertical position:
// xPos = GET_X_LPARAM(lParam);
// yPos = GET_Y_LPARAM(lParam);
break;