Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms645616%28v=vs.85%29.aspx" rel="nofollow">documentation for <code>WM_MOUSEMOVE</code></a> clearly states:</p> <blockquote> <p>Use the following code to obtain the horizontal and vertical position:</p> <pre><code>xPos = GET_X_LPARAM(lParam); yPos = GET_Y_LPARAM(lParam); </code></pre> <p>As noted above, the x-coordinate is in the low-order short of the return value; the y-coordinate is in the high-order short (both represent signed values because they can take negative values on systems with multiple monitors). If the return value is assigned to a variable, you can use the MAKEPOINTS macro to obtain a POINTS structure from the return value. You can also use the GET_X_LPARAM or GET_Y_LPARAM macro to extract the x- or y-coordinate. </p> <p><strong>Important</strong> Do not use the LOWORD or HIWORD macros to extract the x- and y- coordinates of the cursor position because these macros return incorrect results on systems with multiple monitors. Systems with multiple monitors can have negative x- and y- coordinates, and LOWORD and HIWORD treat the coordinates as unsigned quantities.</p> </blockquote> <p>Change this:</p> <pre><code>short nX; nX = (short)LOWORD(lParam); short nY; nY = (short)HIWORD(lParam); </code></pre> <p>To this:</p> <pre><code>short nX; nX = GET_X_LPARAM(lParam); short nY; nY = GET_Y_LPARAM(lParam); </code></pre> <p>Or this:</p> <pre><code>POINTS pt; pt = MAKEPOINTS(lParam); short nX; nX = pt.x; short nY; nY = pt.y; </code></pre> <p><strong>Update:</strong> something else to note from the <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ms645616%28v=vs.85%29.aspx" rel="nofollow">documentation</a>:</p> <blockquote> <p>Posted to a window when the cursor moves. If the mouse is not captured, the message is posted to the window that contains the cursor. Otherwise, the message is posted to the window that has captured the mouse.</p> </blockquote> <p>That means if the mouse has been captured via <code>SetCapture()</code>, the reported coordinates will be relative to the window that is doing the capturing, not the window that the mouse is actually moving over.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload