|
-
September 29th, 2005, 01:20 PM
#1
Force Windows Form to stay Open even if attempted to be Closed?
I am trying to cancel Close form option for the user. For example when user clicks on “X” close the form I want the to give user Message that the form can not be closed
and keep it open. I tried to catch Form.Closing event and I inputted message there but I am not sure how to force it stay open.
Can you please help
Thanks
"We act as though comfort and luxury were the chief requirements of
life, when all that we need to make us happy is something to be
enthusiastic about."
- Einstein
-
September 29th, 2005, 01:26 PM
#2
Re: Force Windows Form to stay Open even if attempted to be Closed?
If you don't want to close the form, then in your Closing event write
Code:
//This will force the form to stay open
e.Cancel=True
-
September 29th, 2005, 03:59 PM
#3
Re: Force Windows Form to stay Open even if attempted to be Closed?
Thanks A LOT. I have done it once but forgot . I new it was so easy but could not remember.
Thanks!!!
"We act as though comfort and luxury were the chief requirements of
life, when all that we need to make us happy is something to be
enthusiastic about."
- Einstein
-
September 29th, 2005, 04:08 PM
#4
Re: Force Windows Form to stay Open even if attempted to be Closed?
 Originally Posted by stardv
Thanks A LOT. I have done it once but forgot  . I new it was so easy but could not remember.
Thanks!!!
I am glad it helped.
-
September 30th, 2005, 02:35 AM
#5
Re: Force Windows Form to stay Open even if attempted to be Closed?
If you specifically want to prevent the user from closing the form using the Close button on the title bar then I suggest you disable it. I don't know why so many people seem to want to distinguish between that and other methods of closing a form, by I've written a helper class that you can use to disable the Close button and also to make a form immovable. It edits the system menu to achieve this, but that is all hidden. You simply create an instance of the class in your form with the appropriate constructor and you're done.
SystemMenuManager class
Last edited by jmcilhinney; September 30th, 2005 at 05:14 PM.
Reason: Fix incorrect link
-
September 30th, 2005, 11:50 AM
#6
Re: Force Windows Form to stay Open even if attempted to be Closed?
jmcilhinney, your helper class sounds interesting, but the link you gave states:
Edit:
Attachment removed. See post #1.
So, is the class at some other url? Is there a C# version?
-
September 30th, 2005, 05:11 PM
#7
Re: Force Windows Form to stay Open even if attempted to be Closed?
Sorry, my mistake. Here's a link to the entire thread. The class file is attached, as per that other link, to post #1.
SystemMenuManager class
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|