PC Review


Reply
Thread Tools Rate Thread

Closing events ?

 
 
HANG LAM
Guest
Posts: n/a
 
      6th Apr 2004
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


 
Reply With Quote
 
 
 
 
Bernie Yaeger
Guest
Posts: n/a
 
      6th Apr 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Tom Shelton
Guest
Posts: n/a
 
      6th Apr 2004
On 2004-04-06, HANG LAM <(E-Mail Removed)> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Closing Excel and Events =?Utf-8?B?WmlwQ3Vycw==?= Microsoft Excel Programming 4 15th May 2007 08:06 PM
Closing events? HANG LAM Microsoft Dot NET Framework 1 6th Apr 2004 11:39 AM
Closing events? HANG LAM Microsoft Dot NET 1 6th Apr 2004 09:25 AM
Multiple Closing Events Fired BuddahDog Microsoft Dot NET Compact Framework 2 9th Dec 2003 08:44 PM
Predicting that Excel is closing using events Todd Webb Microsoft Excel Programming 1 20th Sep 2003 02:50 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:43 AM.