the SetCapture API will make windows send all mouse events to one window, ReleaseCapture sets it back to the window it's over, but whenever a mouse event is fired and code is executed the capture will be relesed.
here's the declorations
Code:
Public Declare Function SetCapture Lib "user32" Alias "SetCapture" (ByVal hwnd As Long) As Long
Public Declare Function ReleaseCapture Lib "user32" Alias "ReleaseCapture" () As Long
set the capture to Command1 with
Code:
SetCapture Command1.hWnd
If theres no code in you're mouse move event for your command button there's no need to set the muose captiure in it again, but if there's any code in your mousemove event make sure you set the capture there as well, you also need to set the capture at the end of your click dblClick, mouseup and mousedown events to keep the messages being sent.
to release it just use
on it's own.
setting the capture to a command button will cause vb to raise it's mouse events to that command button wherever the mouse is on the screen. N.B. if you set the capture to an object that is invisible it will majicly become visible.
hope this helps.