Results 1 to 3 of 3

Thread: [Solved] Closing Application on Mouse Click

  1. #1
    New Member
    Join Date
    Aug 12
    Posts
    2

    Resolved [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.
    Last edited by Halibu; Aug 19th, 2012 at 12:40 AM.

  2. #2
    vb Coda .paul.'s Avatar
    Join Date
    May 07
    Location
    Chelmsford UK
    Posts
    16,473

    Re: Closing Application on Mouse Click

    you need to handle the MouseClick event:

    vb.net Code:
    1. Public Class BS
    2.  
    3.     Private Sub BS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    4.         Me.StartPosition = FormStartPosition.CenterScreen
    5.         Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
    6.         Me.WindowState = FormWindowState.Maximized
    7.         Me.BackColor = Color.Black
    8.         System.Windows.Forms.Cursor.Hide()
    9.     End Sub
    10.  
    11.     Private Sub BS_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick
    12.         If e.Button = Windows.Forms.MouseButtons.Left Then
    13.             Application.Exit()
    14.         End If
    15.     End Sub
    16.  
    17. End Class

  3. #3
    New Member
    Join Date
    Aug 12
    Posts
    2

    Resolved 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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •