473,395 Members | 1,413 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,395 software developers and data experts.

Closing events ?

hi,

How do I capture the closing events coming from the 'X' icon in the
top-right corner of a form and the
Form.Close() command?
I want to be able to differentiate between the Closing Event coming from the
'X' icon in the top-right corner of a form and the closing event coming from
the Form.Close() command.

I don't want the user to be able to close the application by clicking on the
"X" icon on the top-right corner in a form so I override the Closing event
but I want the form to close when Form.Close() is called.

In Wisual Basic 6.0, I used to do it by checking the Unload Mode against
vbFormControMenu variable.
Thanks,
Scott
Nov 20 '05 #1
4 2386
Hi Hang,

This is probably not the most elegant way to do this, but this will work:
1. set a public variable in the declarations section of the form with
Public closetest As Boolean = True

2. in the close button event, enter

closetest = False

Me.Close()

3. in the closing event of the form enter

If closetest = True Then

e.Cancel = True

End If

HTH,

Bernie Yaeger

"HANG LAM" <ha*****@hotmail.com> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
hi,

How do I capture the closing events coming from the 'X' icon in the
top-right corner of a form and the
Form.Close() command?
I want to be able to differentiate between the Closing Event coming from the 'X' icon in the top-right corner of a form and the closing event coming from the Form.Close() command.

I don't want the user to be able to close the application by clicking on the "X" icon on the top-right corner in a form so I override the Closing event
but I want the form to close when Form.Close() is called.

In Wisual Basic 6.0, I used to do it by checking the Unload Mode against
vbFormControMenu variable.
Thanks,
Scott

Nov 20 '05 #2
Hi Hang,

This is probably not the most elegant way to do this, but this will work:
1. set a public variable in the declarations section of the form with
Public closetest As Boolean = True

2. in the close button event, enter

closetest = False

Me.Close()

3. in the closing event of the form enter

If closetest = True Then

e.Cancel = True

End If

HTH,

Bernie Yaeger

"HANG LAM" <ha*****@hotmail.com> wrote in message
news:uk**************@TK2MSFTNGP12.phx.gbl...
hi,

How do I capture the closing events coming from the 'X' icon in the
top-right corner of a form and the
Form.Close() command?
I want to be able to differentiate between the Closing Event coming from the 'X' icon in the top-right corner of a form and the closing event coming from the Form.Close() command.

I don't want the user to be able to close the application by clicking on the "X" icon on the top-right corner in a form so I override the Closing event
but I want the form to close when Form.Close() is called.

In Wisual Basic 6.0, I used to do it by checking the Unload Mode against
vbFormControMenu variable.
Thanks,
Scott

Nov 20 '05 #3
On 2004-04-06, HANG LAM <ha*****@hotmail.com> wrote:
hi,

How do I capture the closing events coming from the 'X' icon in the
top-right corner of a form and the
Form.Close() command?
I want to be able to differentiate between the Closing Event coming from the
'X' icon in the top-right corner of a form and the closing event coming from
the Form.Close() command.

I don't want the user to be able to close the application by clicking on the
"X" icon on the top-right corner in a form so I override the Closing event
but I want the form to close when Form.Close() is called.

In Wisual Basic 6.0, I used to do it by checking the Unload Mode against
vbFormControMenu variable.
Thanks,
Scott


Here's an article that discusses one way to accomplish this...

http://www.fawcette.com/archives/pre...111/qa0111.asp

HTH
--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
Even bytes get lonely for a little bit.
Nov 20 '05 #4
On 2004-04-06, HANG LAM <ha*****@hotmail.com> wrote:
hi,

How do I capture the closing events coming from the 'X' icon in the
top-right corner of a form and the
Form.Close() command?
I want to be able to differentiate between the Closing Event coming from the
'X' icon in the top-right corner of a form and the closing event coming from
the Form.Close() command.

I don't want the user to be able to close the application by clicking on the
"X" icon on the top-right corner in a form so I override the Closing event
but I want the form to close when Form.Close() is called.

In Wisual Basic 6.0, I used to do it by checking the Unload Mode against
vbFormControMenu variable.
Thanks,
Scott


Here's an article that discusses one way to accomplish this...

http://www.fawcette.com/archives/pre...111/qa0111.asp

HTH
--
Tom Shelton [MVP]
Powered By Gentoo Linux 1.4
Even bytes get lonely for a little bit.
Nov 20 '05 #5

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

Similar topics

1
by: HANG LAM | last post by:
hi, How do I capture the closing events coming from the 'X' icon in the top-right corner of a form and the Form.Close() command? I want to be able to differentiate between the Closing Event...
1
by: Chris Bruce | last post by:
In my application I need a way to distiguish between the following events: 1. When a user closes an MDI child window. 2. When the user closes the MDI parent window which subsequently closes the...
6
by: Barry Gast | last post by:
Hi. I have an MDI Parent form with multiple child windows. When I close the parent form, the Closing events of the children forms are not executing. Do I have to close all the child forms in the...
2
by: HANG LAM | last post by:
hi, How do I capture the closing events coming from the 'X' icon in the top-right corner of a form and the Form.Close() command? I want to be able to differentiate between the Closing Event...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
1
by: Marius Groenendijk | last post by:
Dear Group, I have a MDI with children which may be editing data. If a MDI child closes its Closing handler asks a question 'exit w/out saving?'. On closing the MDI its pops a question 'Exit...
9
by: G .Net | last post by:
Hi I'm soooo sorry but I've had to re-post this message again. I have no idea what has been happening but for some reason I couldn't seem to be able to see messages that I'd posted earlier. ...
4
by: Academic | last post by:
Does it make sense to put this If e.Cancel Then Exit Sub at the beginning of form closing events so if the user cancels the app's exiting in one Closing routine he will not be asked again by...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.