Closing events ?

H

HANG LAM

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
 
B

Bernie Yaeger

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
 
T

Tom Shelton

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/premier/mgznarch/vbpj/2001/11nov01/qa0111/qa0111.asp

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top