473,322 Members | 1,846 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,322 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 2374
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: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.