Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

What event fires when...

Posted on 2012-03-15
2
Medium Priority
?
242 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 86

Accepted Solution

by:
Mike Tomlinson earned 2000 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

963 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