[Solved] Closing Application on Mouse Click
Hi Guys,
I found this small code to create a simple black windows to cover my screen.
Code:
Public Class BS
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.StartPosition = FormStartPosition.CenterScreen
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.WindowState = FormWindowState.Maximized
Me.BackColor = Color.Black
System.Windows.Forms.Cursor.Hide()
End Sub
End Class
I would really like to close it on a simple left mouse click.
I tried to work this out with a couple of google suggestions, but I have no experience in vb so im consulting for help here.
Thanks in advance.
Re: Closing Application on Mouse Click
you need to handle the MouseClick event:
vb.net Code:
Public Class BS
Private Sub BS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.StartPosition = FormStartPosition.CenterScreen
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
Me.WindowState = FormWindowState.Maximized
Me.BackColor = Color.Black
System.Windows.Forms.Cursor.Hide()
End Sub
Private Sub BS_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
If e.Button = Windows.Forms.MouseButtons.Left Then
Application.Exit()
End If
End Sub
End Class
Re: Closing Application on Mouse Click
Thank you for your help paul. Works like a charm.
I tried this kind of mouse click event, but, as i see the differences, failed at some details ;)