Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I program the x button?

Posted on 2007-03-27
2
Medium Priority
?
164 Views
Last Modified: 2010-04-23
How do I program the x button in the top right to do whatever I want?
0
Comment
Question by:Kael1
[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 7

Expert Comment

by:JuanCarniglia
ID: 18799579
You don't do that exactly, but you can do this.

Capture the Event (Unload) on that form, and choose to close it or not, or to do something else.
Try this:

------

Private Sub Form_Unload(Cancel As Integer)

    MsgBox ("This will appear when I click the x button !!! ")

    if (I_Want_To_Close_This_Window) Then
           
           'Close all files and handles

           Cancel = 0      'This means that this event will get passed on
    Else
           'Do something else

           Cancel = 1     'This means that this event will NOT get passed on
    End If

End Sub

-------

Greetings
0
 
LVL 86

Accepted Solution

by:
Mike Tomlinson earned 150 total points
ID: 18800597
For VB.Net, it's similar...

In VB.Net 2005:

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Select Case e.CloseReason
            Case CloseReason.UserClosing
                If somecondition Then
                    e.Cancel = True
                End If

        End Select
    End Sub
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

636 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