Solved

What event fires when...

Posted on 2012-03-15
2
238 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 86

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 34

Author Closing Comment

by:Mike Eghtebas
ID: 37728107
Thank you
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

628 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