37.1.3 Mouse Configuration

Although the mouse is an important input device for Windows applications, you shouldn't assume that a mouse will always be present. You can determine whether the system includes a mouse by passing the SM_MOUSEPRESENT value to the GetSystemMetrics function.

Windows supports a mouse that has up to three buttons. On a three button mouse, the buttons are designated as the left, middle, and right buttons. The Windows messages and named constants related to the mouse buttons use the letters L, M, and R to identify the buttons. The button on a single button mouse is considered to be the left button. Although Windows supports a mouse with multiple buttons, most applications use the left mouse button primarily and use the others little, if at all.

You can find out the number of buttons on the mouse by passing the SM_CMOUSEBUTTONS value to the GetSystemMetrics function. You can configure the mouse for a left-handed user by using the SwapMouseButton function to reverse the meaning of the left and right mouse buttons. Alternatively, you can pass the SPI_SETMOUSEBUTTONSWAP value to the SystemParametersInfo function to reverse the meaning of the buttons. Note, however, that the mouse is a shared resource, so reversing the meaning of the buttons affects all applications.