Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / June 2004

Tip: Looking for answers? Try searching our database.

Minimise form when the close [X] button is clicked

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John O'Neill - 29 Jun 2004 10:41 GMT
Hi

Instead of closing the form when the close button [X] is clicked, I want the
form to minimise. Does anyone know how to do this (using C#)?

Thanks for any help

John
Fran?ois J. Miton - 29 Jun 2004 11:37 GMT
Hi John,

You can hook the "closing" event of the form and minimaze it (and cancel the
event)

private void Form1_Closing(object sender,
System.ComponentModel.CancelEventArgs e)

{

this.WindowState = FormWindowState.Minimized;

e.Cancel=true;

}

HTH

Fran?ois J Miton

> Hi
>
[quoted text clipped - 4 lines]
>
> John
John O'Neill - 29 Jun 2004 12:01 GMT
Thanks for your suggestion Fran?ois, but thats not quite what I was hoping
for. When my application is running and I choose to shut-down my computer,
my application just gets minimised and stays running and my computer does
not shutdown (because the Closing event is cancelled). What I think I need
to know is how can I tell if the user has clicked on the [X] button so I can
handle that instead of hooking in to the Closing event?

Thanks again

John

> Hi John,
>
[quoted text clipped - 25 lines]
> >
> > John
"Ying-Shen Yu[MSFT]" - 30 Jun 2004 07:13 GMT
Hi John,
Maybe you can try overriding the WndProc and handling the WM_SYSCOMMAND
message, then change the SC_CLOSE command to SC_MINIMIZE before passing it
to base.WndProc method. For more information , you may read the
documentation of the WM_SYSCOMMAND message.

Does it resolve your problem?
Please feel free to reply this thread if you still have problem on it.

Have a nice day.
Best regards,

Ying-Shen Yu [MSFT]
Microsoft Community Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.
This mail should not be replied directly, please remove the word "online"
before sending mail.
John O'Neill - 30 Jun 2004 11:52 GMT
Hi Ying-Shen

Your suggestion has solved my problem.

Thank you very much.

John

> Hi John,
> Maybe you can try overriding the WndProc and handling the WM_SYSCOMMAND
[quoted text clipped - 15 lines]
> This mail should not be replied directly, please remove the word "online"
> before sending mail.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.