I have a user control to display a thumbnail. When the mouse moves over the
thumbnail a blue square highlights the control and when it moves out of the
control it goes back to default.
All this works well except for one thing.
I create an array of 50 usercontrols and use a Picture Control and Scoll
bars to sroll the pics up and down. ie a Viewport.
I have 2 buttons at the bottom. Back & Forward
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.
I hope someone can point me in the right direction
Here is the code I use. Again what I would like to happen is the
ReleaseCapture to fire either when I leave the control which it does OR as
soon as the mouse moves over the Viewport Border
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 <> UserControl.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
Thanks in Advance
Garry
WindowFromPoint Function ()
http://msdn.microsoft.com/en-us/library/ms633558(VS.85).aspx
?
--
[.NET: It's About Trust!]
Just tried that but i cannot get it to do what i need.
It gives me the screen X Y position.
Is it possible to get the viewport (picturebox) X Y as I could say if YPoint
> Picturebox.height then ResleaseCapture etc
thanks
Garry
"Karl E. Peterson" <ka...@exmvps.org> wrote in message
news:#Zuu#c9aKH...@TK2MSFTNGP06.phx.gbl...
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)
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
"Karl E. Peterson" <ka...@exmvps.org> wrote in message
news:uzloxZH...@TK2MSFTNGP02.phx.gbl...
Why not just use the TrackMouseEvent() function?
It saves having to faff around with capturing the mouse (the root cause
of your problems) and gives you a nice "mouse left" message.
--
Dee Earley (dee.e...@icode.co.uk)
i-Catcher Development Team
iCode Systems
See http://vb.mvps.org/samples/WndPick/
> 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
It's pretty simple, really. The concept is just:
If WindowFromPoint() <> MyButton.hWnd Then ReleaseCapture
> Below is some of the code i have placed in my usercontrol. (Contains a
> Picturebox,Label & Shape)
Well, that's just getting more complicated than a quick glance can work
out. You're aware that labels and shapes are windowless, right?
> When it gets to the white area (Picturebox) at the bottom , i am trying to
> release the capture
Then you'd change the test above to something like:
If WindowFromPoint() = MyPicturebox.hWnd Then ReleaseCapture
> 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.
Become familiar with the APIs you're trying to use, before trying to
use them for a specific task. Take a look at that sample I pointed to
above, and figure out how it's working. That should let you transfer
that understanding to your own situation.
thanks. do you have an example of how to use TrackMouseEvent() function
Garry
"Dee Earley" <dee.e...@icode.co.uk> wrote in message
news:et$n3yObK...@TK2MSFTNGP04.phx.gbl...
It occurs to me this link might be of use to you...
http://vb.mvps.org/samples/apixref.asp
Just to let you all know that i managed to sort out the problem with the
TrackMouseEvent() function and Highlighting my usercontrol.
I dont know why this happens but here is what i i have found.
I created a simple user control. on this control I placed a picturebox and
in resize of usercontrol made the picturebox the same size as usercontrol.
Inside this i placed another picturebox which would hold my picture.
below this i added a label which would be the width of the usercontrol
(cosmetic appearance) , on this i placed another label to hold the movie
name and centre it. Also a Shape control that would be the height & width of
the usercontrol. This is what i would change colour to highlight my control.
I also had click/Dblclick/move events etc
I then used the TrackMouseEvent() function and set it to monitor the
usercontrol but this did not work as the MouseMove event of the usercontrol
did not fire.
(Because the picturebox was covering it.)
So i set the 1st Picturebox to be tracked and it appeared to work (ie my
control would be highlighted) except if I moved my mouse fast over a few of
my usercontrols they would all highlight.
I then went back to basics and got the TrackMouseEvent() function working
correctly ie highlighting my control.
I then added one object at a time until it did not work.
I found that if I had 2 picture boxes (one in the other ) it caused problems
If anyone is interested in my code then let me know and i would be happy to
email an example
thanks
Garry
"Karl E. Peterson" <ka...@exmvps.org> wrote in message
news:#38fwLUb...@TK2MSFTNGP02.phx.gbl...