Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[MFC] Capture mouse?

Status
Not open for further replies.

Skute

Programmer
Jul 21, 2003
272
GB
Hi,

i want to create a simple mouse macro (as a basic intro to learning MFC). I can get the mouse to be captured when holding down a mouse button, but i cant get it to be captured *all* the time.

I know the requirement is to only capture when the mouse button is held down, but is there any way to override this? ie, anyway to "pretend" that the mouse button is held down?
 
this is a copy/paste from MSDN:
Mouse capture is also affected by the Windows 95/98 and Windows NT/Windows 2000 localized input queues. If the mouse is captured on mouse down, the window capturing the mouse receives mouse input until the mouse button is released, as in Windows 3.x. But if the mouse is captured while the mouse button is up, the window receives mouse input only as long as the mouse is over that window or another window created by the same thread.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
yeah i know, ive been trying to "fool" windows into thinking the mouse is being held down by having a seperate thread make calls to SendMessage(WM_LBUTTONDOWN, , ).
 
you can try to set a hook, see SetWindowsHook/SetWindowsHookEx

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Cool thanks,

following on, i think i have 3 options:

a) SetWindowHookEx with WH_GETMESSAGE to watch for WM_MOUSEMOVE messages
b) SetWindowHookEx with LowLevelMouseProc
c) Use mouse_event to constantly send left mouse button down messages


What would you recommend?
 
I recommend you the first one(a). But is up to you.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top