Displaying mouse coordinates in status bar
This article shows how to display mouse coordinates on the status bar. The coordinates are displayed only if the cursor is in the view window. But if the toolbar is kept floating in the view window and cursor is placed on the toolbar the coordinates are not displayed. In the OnMouseMove( ) handler the mouse is captured so that even if mouse cursor goes out of the client area our window continues to receive the mouse messages. Then it is made sure that the given mouse coordinates are in our window. This is done by calling WindowFromPoint( ) function and passing to it the address CPoint object. WindowFromPoint( ) takes the coordinates relative to the screen. Therefore the coordinates which we get in the last parameter of OnMouseMove( ) are converted into screen coordinates by calling ClientToScreen( ) function.
Labels: Visual C++