473,388 Members | 1,400 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,388 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 1519
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?
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: 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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.