Solved

What event fires when...

Posted on 2012-03-15
2
233 Views
Last Modified: 2012-03-15
What event fires when mouse moves over X to close the form.

I guess X is part of the form because I tried using on MouseLeave but it didn't work.

Background:

I have few text boxes on a form to accept user input. I also have a button "Default Values" to populate these text boxes if the user chooses to use it.

Because the text boxes have Validated events and doesn't allow blank entries, I have:

    Private Sub butDefaultValues_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles butDefaultValues.MouseEnter

        'to pacify _Validated to use "Default Values" button
        bolUsingDefault = True

    End Sub

 Private Sub butDefaultValues_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles butDefaultValues.MouseLeave

        'to keep _Validated active on leaving butDefaultValues
        bolUsingDefault = False

    End Sub

This means, as soon as the mouse enters "Default Values" button, the flag bolUsingDefault is set True thus using:

Private Sub txtVinNumber_Validated(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtVinNumber.Validated

        If bolUsingDefault = True Then Exit Sub
.
.

is bypassed.

Question is how I can implement a similar technique when the user moves the mouse to close the form without _Validated event firing.

Thank you.
0
Comment
Question by:Mike Eghtebas
2 Comments
 
LVL 85

Accepted Solution

by:
Mike Tomlinson earned 500 total points
ID: 37727941
You can do:
Public Class Form1
 
    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Const SC_CLOSE As Integer = &HF060&
        Const WM_SYSCOMMAND As Integer = &H112
 
        Select Case m.Msg
            Case WM_SYSCOMMAND
                Select Case m.WParam.ToInt32
                    Case SC_CLOSE
                        bolUsingDefault = True
 
                End Select
 
        End Select
 
        MyBase.WndProc(m)
    End Sub

End Class

Open in new window

0
 
LVL 33

Author Closing Comment

by:Mike Eghtebas
ID: 37728107
Thank you
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question