Picking coordinates outside your window(s)

Picking coordinates outside your window(s)

How do I make my program respond to “mousedown” outside my form? For instance: How would I get my program to tell me the pixel coordinants of my cursor when I click?

You really can’t do that under Win32. However, you *can* have it respond to MouseUp! I showed, in some detail, how to do this in the Q&A column (VBPJ, Sept 97).

In short, you create a drop-target, using the DragIcon property of a picture box. When MouseDown fires, call SetCapture, and that control’s MouseMove and MouseUp events will then fire regardless of where the cursor is. In MouseUp, call GetCursorPosition to obtain the screen coordinates of the cursor.


Share the Post: