• Welcome to Valhalla Legends Archive.
 

MouseMove Event

Started by FuZe, August 30, 2003, 12:50 PM

Previous topic - Next topic

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.

FuZe

Another question I have is how to trigger a mousemove event while a mouse button is being held down.  Thanks.

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.

FuZe

#3
Quote from: Camel on August 30, 2003, 02:21 PM
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.


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.

Camel

Quote from: FuZe- on August 30, 2003, 04:49 PM
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 use the mousemove event to resize my controls while the mouse is down in my bot, and it works fine.

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

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.

Camel

Quote from: Adron on August 30, 2003, 08:41 PMIn 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.

Know how it is decided in VB? Same way as the keypreview thing?

FuZe

#7
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.

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.

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.


Perhaps you could try capturing the mouse with the API call yourself?