473,379 Members | 1,184 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Dectecting close (X) click

Hello.

I may have missed something simple here but I want to know that when a form is closed whether it was closed when the X is clicked.

How is this achieved?

Jul 21 '05 #1
3 1518
On Wed, 06 Oct 2004 09:38:04 GMT, Nick Zdunic wrote:
Hello.

I may have missed something simple here but I want to know that when a form is closed whether it was closed when the X is clicked.

How is this achieved?


What I do is when the user selects a "close" button (not the X button), I
set a boolean variable. That way if it is set, I know they did not click
the X but instead clicked the close button. If they clicked the X, the
boolean is not set.

In the form_closing event:

Private bCloseButtonClicked As Boolean

Public Sub Form_Closing(...)
If bCloseButtonClicked then
MsgBox("Closing from close button")
Else
MsgBox("Closing from clicking the X button")
End IF
End Sub

Public Sub Close_Button_Click(...)
bCloseButtonClicked = True
End Sub
This is a workaround but it can work reliably. You may also be able to
intecept the windows messages in the WndProc override and determine it that
way.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Jul 21 '05 #2
On Wed, 06 Oct 2004 09:38:04 GMT, Nick Zdunic wrote:
Hello.

I may have missed something simple here but I want to know that when a form is closed whether it was closed when the X is clicked.

How is this achieved?


What I do is when the user selects a "close" button (not the X button), I
set a boolean variable. That way if it is set, I know they did not click
the X but instead clicked the close button. If they clicked the X, the
boolean is not set.

In the form_closing event:

Private bCloseButtonClicked As Boolean

Public Sub Form_Closing(...)
If bCloseButtonClicked then
MsgBox("Closing from close button")
Else
MsgBox("Closing from clicking the X button")
End IF
End Sub

Public Sub Close_Button_Click(...)
bCloseButtonClicked = True
End Sub
This is a workaround but it can work reliably. You may also be able to
intecept the windows messages in the WndProc override and determine it that
way.

--
Chris

dunawayc[AT]sbcglobal_lunchmeat_[DOT]net

To send me an E-mail, remove the "[", "]", underscores ,lunchmeat, and
replace certain words in my E-Mail address.
Jul 21 '05 #3
Hi Nick,

I'd like to know if this issue has been resolved yet. Is there anything
that I can help. I'm still monitoring on it. If you have any questions,
please feel free to post them in the community.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Carol Lyn | last post by:
Could use your assistance with this. I have a window that opens via onclick and it is a small window with info about a site. If the user is interested in visiting that site, there is a link to...
6
by: Sujan | last post by:
Hello all, Help me! -------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script language="JavaScript"> <!--
1
by: dibyendu_k | last post by:
Hi, There is a problem i cant solve regarding Internet Explorer 5.5. It is regarding the Print Dialog Box. From a webpage if I open a popup window (window.open()) containing buttons Print and...
4
by: Hitesh | last post by:
Hi, I am opening an Modal dialog box using the window.Showmodaldialogbox(), and in that window i am having an aspx form with say one ASP.NET Button control. i am doing some operation on the...
6
by: Mike Fellows | last post by:
I have a windows form with a tabcontrol on it within each tabpage there is a button that does basically the same thing except with the difference of one variable at the end of each of the...
2
by: Bruce Wiebe | last post by:
hi all im having a problem accessing a text file on my hard disk after ive created it and added some text to it it would appear that the file is still locked. What happens is this i have...
7
by: Alice | last post by:
Hi, In my program, the user can navigate to many different forms. When they go to the next form, I want the form they have left to close. However, the forms aren't closing. Can anyone tell me...
3
by: Shelby | last post by:
Hi, I still fail to properly end a function call with the below codes. How can I terminate all function calls? -------------------------------------------------------------- Connect.vb...
3
by: Nick Zdunic | last post by:
Hello. I may have missed something simple here but I want to know that when a form is closed whether it was closed when the X is clicked. How is this achieved?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.