LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc ;
hdc=GetDC(hwnd); switch (message)
{ case WM_LBUTTONDOWN://deals with left mouse button down if (wParam & MK_SHIFT)//deals with shift key press followed by left button down
{
wsprintf(mousestr,TEXT("shift & left button down %d,%d"),LOWORD(lParam),HIWORD(lParam));
TextOut(hdc,LOWORD(lParam),HIWORD(lParam),mousestr,_tcslen(mousestr));
} elseif (wParam & MK_CONTROL)//deals with control key press followed by left button down
{
wsprintf(mousestr,TEXT("control & left button down %d,%d"),LOWORD(lParam),HIWORD(lParam));
TextOut(hdc,LOWORD(lParam),HIWORD(lParam),mousestr,_tcslen(mousestr));
} elseif (wParam & MK_RBUTTON)//deals with and right button down followed by left button down
{
wsprintf(mousestr,TEXT("left and right button %d,%d"),LOWORD(lParam),HIWORD(lParam));
TextOut(hdc,LOWORD(lParam),HIWORD(lParam),mousestr,_tcslen(mousestr));
} else//default left mouse button only
{
wsprintf(mousestr,TEXT("left button down at %d,%d"),LOWORD(lParam),HIWORD(lParam));
TextOut(hdc,LOWORD(lParam),HIWORD(lParam),mousestr,_tcslen(mousestr));
}
ReleaseDC(hwnd,hdc); break; case WM_LBUTTONUP://deals with left mouse button up
wsprintf(mousestr,TEXT("left button up at %d,%d"),LOWORD(lParam),HIWORD(lParam));
TextOut(hdc,LOWORD(lParam),HIWORD(lParam),mousestr,_tcslen(mousestr));
ReleaseDC(hwnd,hdc); break; case WM_RBUTTONDOWN://deals with right mouse button down
wsprintf(mousestr,TEXT("right button down at %d,%d"),LOWORD(lParam),HIWORD(lParam));
TextOut(hdc,LOWORD(lParam),HIWORD(lParam),mousestr,_tcslen(mousestr));
ReleaseDC(hwnd,hdc); break; case WM_RBUTTONUP://deals with right mouse button up
wsprintf(mousestr,TEXT("right button up at %d,%d"),LOWORD(lParam),HIWORD(lParam));
TextOut(hdc,LOWORD(lParam),HIWORD(lParam),mousestr,_tcslen(mousestr));
ReleaseDC(hwnd,hdc); break; case WM_DESTROY:
PostQuitMessage (0) ; return0;
} return DefWindowProc (hwnd, message, wParam, lParam) ;
}