Reputation: 1
I have a button created with
//Create Compass
HWND hWndCompass = CreateWindowEx(NULL, "BUTTON", "Compass", WS_TABSTOP|WS_VISIBLE|WS_CHILD|BS_DEFPUSHBUTTON,
600, 10, 50, 24, hWnd, (HMENU)IDC_COMPASS, GetModuleHandle(NULL), NULL);
I will add the picture in the future but I need to know where on the button they clicked so I can determine if they clicked on N, S, E, W or some other point of the compass.
My call is:
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Do I need to look in the message for that infomration?
Upvotes: 0
Views: 270
Reputation: 6448
In order to retrieve the X and Y coordinates of a mouse click on your button, you should :
WM_MOUSEMOVE
eventwParam
will give you the type of event (Which button has been pressed)lParam
Something like that :
RESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_MOUSEMOVE:
{
if (lParam == MK_LBUTTON)
{
myXCoord = GET_X_LPARAM(lParam);
myYCoord = GET_Y_LPARAM(lParam);
}
}
break;
default:
DefWindowProc(hWnd, message, wParam, lParam);
}
}
Upvotes: 1