![]() structure, which defines the beginning point of the Convert the cursor coordinates into a POINTS SetRect(&rcClient, ptClientUL.x, ptClientUL.y, to the client area by passing the rcClient structure Copy the client coordinates of the client area include the far left and lowermost pixels. coordinates retrieved by GetClientRect do not Add one to the right and bottom sides, because the and convert them into client coordinates. Retrieve the screen coordinates of the client area, Static BOOL fPrevLine = FALSE // previous line flag Static POINTS ptsPrevEnd // previous endpoint Static POINTS ptsBegin // beginning point POINT ptClientLR // client lower right corner POINT ptClientUL // client upper left corner LRESULT APIENTRY MainWndProc(HWND hwndMain, UINT uMsg, WPARAM wParam, LPARAM lParam) The window procedure releases the mouse capture and frees the mouse from the client area. The WM_LBUTTONUP message signals the end of the drawing operation. Then it draws a new line from the starting point to the new position of the cursor. During subsequent WM_MOUSEMOVE messages, the window procedure erases the previous line by drawing over it with an inverted pen color. It also uses the ClipCursor function to confine the cursor to the client area during the line drawing operation.ĭuring the first WM_MOUSEMOVE message, the window procedure draws a line from the starting point to the current position of the cursor. When the window procedure receives a WM_LBUTTONDOWN message, it captures the mouse and saves the coordinates of the cursor, using the coordinates as the starting point of the line. It contains portions of a window procedure that enables the user to draw lines in a window's client area by dragging the mouse. The example in this section demonstrates how to track the mouse cursor. The WM_NCMOUSEHOVER and WM_NCMOUSELEAVE messages are the corresponding messages for the nonclient areas. It posts the WM_MOUSELEAVE message when the cursor leaves the client area. The system posts the WM_MOUSEHOVER message when the cursor hovers over the client area for a certain time period. In addition, an application can call the TrackMouseEvent function to have the system send other messages that are useful for tracking the cursor. A window uses the WM_LBUTTONUP message as a signal to stop tracking the cursor. For example, a drawing application might redraw a line repeatedly as the mouse moves. Processing the WM_MOUSEMOVE message typically involves a repetitive painting or drawing operation in the client area. For example, a word-processing application would begin tracking the cursor only if the WM_LBUTTONDOWN message occurred while the cursor was on a line of text, but not if it was past the end of the document.Ī window tracks the position of the cursor by processing the stream of WM_MOUSEMOVE messages posted to the window as the mouse moves. A window determines when to begin tracking the cursor by checking the cursor position provided in the lParam parameter of the WM_LBUTTONDOWN message. Tracking the cursor typically involves processing the WM_LBUTTONDOWN, WM_MOUSEMOVE, and WM_LBUTTONUP messages. Word-processing applications also track the cursor, enabling the user to select a word or block of text by clicking and dragging the mouse. Most drawing applications, for example, track the position of the mouse cursor during drawing operations, allowing the user to draw in a window's client area by dragging the mouse. Retrieving the Number of Mouse Wheel Scroll LinesĪpplications often perform tasks that involve tracking the position of the mouse cursor.Using a Mouse Wheel in a Document with Embedded Objects.This section covers tasks associated with mouse input.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |