C
Colin McGuire
Hi again, thanks everyone for your previous help. But having resolved
past problems, I'm moving on to new problems
This one is a simple winforms application with two buttons, named
Button1 and Button2, on it (code below). When I press the mouse button
over Button2, and don't release it, in the IDE output window it prints
"Button2_MouseDown" only. If I release the mouse button over the
button, over the form, or even over ANY other application that is
running I also see "Button2_MouseUp" in the output window. This is
what I want and expected.
But when I do exactly the same for Button1, I don't see this. I press
button1, don't release the mouse button, a yellow form is displayed,
and what I am wanting is that when I release the mousebutton the
yellow form is hidden/disappear. Depending on where I release the
mouse button seems to change whether the "MouseUp" event is fired and
therefore whether I hide my yellow form. Why? For example, press the
left mouse button while over Button1, and keep the mousebutton
depressed, a yellow backcolor form will be displayed, now move the
cursor somewhere (over the desktop) still holding down the mouse
button, release the mouse button, and the "MouseUp" event isn't fired!
Ha? I want it to be fired so I can hide the yellow form. So there has
to be a trick - but what is it.
Thank you again
Colin
Public Class Form1
Inherits System.Windows.Forms.Form
//and include the Windows Form Designer Code in here
Dim WithEvents f As Form
Private Sub Button1_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button1.MouseDown
Debug.WriteLine("Button1_MouseDown")
f = New Form
f.Size = New Size(80, 80)
f.BackColor = Color.Yellow
f.Show()
End Sub
Private Sub Button1_MouseUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button1.MouseUp
Debug.WriteLine("Button1_MouseUp")
f.Close()
f.Hide()
f = Nothing
End Sub
Private Sub Button2_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button2.MouseDown
Debug.WriteLine("Button2_MouseDown")
End Sub
Private Sub Button2_MouseUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button2.MouseUp
Debug.WriteLine("Button2_MouseUp")
End Sub
End Class
past problems, I'm moving on to new problems
This one is a simple winforms application with two buttons, named
Button1 and Button2, on it (code below). When I press the mouse button
over Button2, and don't release it, in the IDE output window it prints
"Button2_MouseDown" only. If I release the mouse button over the
button, over the form, or even over ANY other application that is
running I also see "Button2_MouseUp" in the output window. This is
what I want and expected.
But when I do exactly the same for Button1, I don't see this. I press
button1, don't release the mouse button, a yellow form is displayed,
and what I am wanting is that when I release the mousebutton the
yellow form is hidden/disappear. Depending on where I release the
mouse button seems to change whether the "MouseUp" event is fired and
therefore whether I hide my yellow form. Why? For example, press the
left mouse button while over Button1, and keep the mousebutton
depressed, a yellow backcolor form will be displayed, now move the
cursor somewhere (over the desktop) still holding down the mouse
button, release the mouse button, and the "MouseUp" event isn't fired!
Ha? I want it to be fired so I can hide the yellow form. So there has
to be a trick - but what is it.
Thank you again
Colin
Public Class Form1
Inherits System.Windows.Forms.Form
//and include the Windows Form Designer Code in here
Dim WithEvents f As Form
Private Sub Button1_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button1.MouseDown
Debug.WriteLine("Button1_MouseDown")
f = New Form
f.Size = New Size(80, 80)
f.BackColor = Color.Yellow
f.Show()
End Sub
Private Sub Button1_MouseUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button1.MouseUp
Debug.WriteLine("Button1_MouseUp")
f.Close()
f.Hide()
f = Nothing
End Sub
Private Sub Button2_MouseDown(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button2.MouseDown
Debug.WriteLine("Button2_MouseDown")
End Sub
Private Sub Button2_MouseUp(ByVal sender As Object, _
ByVal e As System.Windows.Forms.MouseEventArgs) _
Handles Button2.MouseUp
Debug.WriteLine("Button2_MouseUp")
End Sub
End Class