CodeDoctorJL
CodeDoctorJL

Reputation: 1274

How do I get the mouse's position off the dialog continuously? (MFC)

My question is: How do i continuously get the mouse's position even when it isn't on any dialogs, in mfc?

Upvotes: 0

Views: 690

Answers (2)

rrirower
rrirower

Reputation: 4590

You can always install a mouse hook. It's a bit overkill, but, it will give you what you want.

Upvotes: 0

IInspectable
IInspectable

Reputation: 51497

It depends on your specific requirements. If you need to direct mouse input temporarily to a control you can call SetCapture. This will request the system to send all mouse messages to a specific window until you not longer need it by calling ReleaseCapture, or you lose it, when another window gains input focus. The latter is signaled through a WM_CAPTURECHANGED message.

If, on the other hand, you need continuous information about mouse positions you can install a timer (SetTimer) and call GetCursorPos.

Upvotes: 2

Related Questions