
Need help with SetCapture & Release Capture API
Re-Post as email did not appear
Hi Karl
I have searched the internet for some code re WindowFromPoint Function() or
examples .
I have found a few and tried them , but i have still been unable to make the
ReleaseCatpure happen when i move out of the scrollport onto the Picture
Container
Below is some of the code i have placed in my usercontrol. (Contains a
Picturebox,Label & Shape)
When it gets to the white area (Picturebox) at the bottom , i am trying to
release the capture and allow my app to respond, as it stands , I have to
click the form or button once before I can then click the button.
I do this as a hobby as I love mucking around and making small applications.
I would very much appreciate it if you could show me an example of what i am
trying to acheive.
'Declarations
Private Declare Function ReleaseCapture Lib "user32.dll" () As Long
Private Declare Function SetCapture Lib "user32.dll" (ByVal hwnd As Long) As
Long
Private Declare Function GetCapture Lib "user32.dll" () As Long
Event OnMouseLeave()
Event OnMouseEnter()
Event OnMouseMove(Button As Integer, Shift As Integer, x As Single, y As
Single)
'This is the Picture Box within the usercontrol
Private Sub imgMoviePicture_MouseMove(Button As Integer, Shift As Integer, x
As Single, y As Single)
RaiseEvent MouseMove(Button, Shift, x, y)
If ((x < 0) Or (x > UserControl.Width) Or (y < 0) Or (y >
UserControl.Height)) Then
'Mouse Leave (The mouse rolls out the control)
RaiseEvent OnMouseLeave
Call ReleaseCapture
ElseIf GetCapture <> imgMoviePicture.hwnd Then
'Mouse Enter (The mouse rolls over the control
'and GetCapture <> UserControl.hWnd which means first time mouse move)
RaiseEvent OnMouseEnter
Call SetCapture(UserControl.hwnd)
Else
'Mouse Move
RaiseEvent OnMouseMove(Button, Shift, x, y)
End If
End Sub
Quote:
> k_zeon explained on 11/22/2009 :
>>>> Now if I scoll down and hover over a usercontrol that is half displayed
>>>> at the bottom and then move downwards to click the forward button the
>>>> ReleaseCapture event is not being fired until i reach the outside of
>>>> the hidden user control.
>>>> What I would like to happen is that as soon as I move the mouse over
>>>> the form to get to the Buttons , the Release is fired and does not wait
>>>> till it goes outside of the usercontrol.
>>> WindowFromPoint Function ()
>>> http://msdn.microsoft.com/en-us/library/ms633558(VS.85).aspx
>> Just tried that but i cannot get it to do what i need.
> Well, that's what you need to focus on, then.
>> It gives me the screen X Y position.
> No, it gives you a window handle, based on the screen position you pass
> it. If you don't know the screen position, you'll probably want to figure
> that out first. (GetCursorPos)
> --
> [.NET: It's About Trust!]