Valhalla Legends Forums Archive | Visual Basic Programming | MouseMove Event

AuthorMessageTime
FuZe
I'm using vb 6 and I noticed that for key pressing events, there is a keypreview property which intercepts all the keys when the focus is directed on a control instead of the form and that triggers the event for the Form instead of the control. I'm wondering if there was something like this for the mousemove event so I don't have to write code for every control.
August 30, 2003, 5:50 PM
FuZe
Another question I have is how to trigger a mousemove event while a mouse button is being held down. Thanks.
August 30, 2003, 6:29 PM
Camel
I believe there is a property of the form that allows it to preview keys before the control they belong to.

The mousemove event shouldn't change from the norm while the mouse is held down.
August 30, 2003, 7:21 PM
FuZe
[quote author=Camel link=board=5;threadid=2510;start=0#msg19534 date=1062271319]
I believe there is a property of the form that allows it to preview keys before the control they belong to.

The mousemove event shouldn't change from the norm while the mouse is held down.

[/quote]

The thing is.. it does .. I think
Actually, I think the mousemove event executes, but only after you let go of the mouse button. I need for the event to happen right away.

I'm actually trying to make a image box (with a picture of a line in it) be able to drag across the screen horizontally like a drag and drop operation except I don't want the little frame around control.
August 30, 2003, 9:49 PM
Camel
[quote author=FuZe- link=board=5;threadid=2510;start=0#msg19547 date=1062280153]
I think the mousemove event executes, but only after you let go of the mouse button. I need for the event to happen right away.[/quote]

I use the mousemove event to resize my controls while the mouse is down in my bot, and it works fine.

[code]Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, Y As Single)
...
If (x > (txtChat.Left + txtChat.Width)) And (x < UL.Left) Then
MDown = 1
...
ElseIf (Y > (txtChat.Top + txtChat.Height)) And (Y < txtSend.Top) Then
If Y > (txtWhisper.Top + (txtWhisper.Height / 2)) Then
MDown = 2
Else
MDown = 3
End If
...
End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, x As Single, Y As Single)
Select Case MDown
Case 1 'userlist resize
...
Case 2 'chatwindow resize
sndHeight = Me.ScaleHeight - Y
Case 3 'whisperwindow resize
...
Call Form_Resize
...
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, Y As Single)
MDown = 0
...
End Sub[/code]
August 31, 2003, 12:57 AM
Adron
In some cases, all the mousemoves while the mouse button is down are sent to the control that received the mousedown. Then after the mouseup, mousemoves return to being sent to whomever the mouse is over. It's called capturing the mouse - SetCapture in win32 api.
August 31, 2003, 1:41 AM
Camel
[quote author=Adron link=board=5;threadid=2510;start=0#msg19570 date=1062294105]In some cases, all the mousemoves while the mouse button is down are sent to the control that received the mousedown. Then after the mouseup, mousemoves return to being sent to whomever the mouse is over. It's called capturing the mouse - SetCapture in win32 api.[/quote]

Know how it is decided in VB? Same way as the keypreview thing?
August 31, 2003, 1:44 AM
FuZe
Thanks Adron and Camel.

For some reason, if I hold the mouse button down on certain controls (an imagebox and a rich text box), the mouse move event occurs for that control even if the mouse is out of the border of the control, but for a different control (a listview control), the mouse move event occurs, but when the mouse is out of the border of the control, the mousemove event of the new control occurs.
September 1, 2003, 12:42 AM
Adron
I found very little on what decides if a particular object captures the mouse or not. The only references I found to capturing were these:

MouseMove:
[quote]
The MouseMove event is generated continually as the mouse pointer moves across objects. Unless another object has captured the mouse, an object recognizes a MouseMove event whenever the mouse position is within its borders.
[/quote]

MouseUp/MouseDown:
[quote]
If mouse buttons are pressed in succession, the object that captures the mouse after the first press receives all mouse events until all buttons are released.
[/quote]


Perhaps you could try capturing the mouse with the API call yourself?
September 1, 2003, 4:18 PM

Search