Hide Form on Load

M

mqudsi

I'm making a system tray application, and I just can't figure out how
to make it hide on execution just like it used to in C++.

If I have a button the form and in the button's Click method i have
{this.Hide();}
The entire form will disappear.

But if I put "this.Hide()" in the from's onLoad code, it *doesn't* get
hidden.
Can anyone advise me as to what I'm doing wrong? Why would the same
code that hides the form just fine as an onClick method *not* work for
onLoad?

By Hide I mean for it to disappear from the taskbar, alt-tab, and main
window, but remain in the system tray.

Does .NET not allow hiding of forms upon load for security reasons or
something? Because that sounds pretty naive to me...
I'm sure there's a way though...

Thanks!
 
A

Andy

I'm making a system tray application, and I just can't figure out how
to make it hide on execution just like it used to in C++.

If I have a button the form and in the button's Click method i have
{this.Hide();}
The entire form will disappear.

But if I put "this.Hide()" in the from's onLoad code, it *doesn't* get
hidden.
Can anyone advise me as to what I'm doing wrong? Why would the same
code that hides the form just fine as an onClick method *not* work for
onLoad?

By Hide I mean for it to disappear from the taskbar, alt-tab, and main
window, but remain in the system tray.

Does .NET not allow hiding of forms upon load for security reasons or
something? Because that sounds pretty naive to me...
I'm sure there's a way though...

Thanks!

You may want to check out this article:
http://www.windowsforms.net/articles/notifyiconapplications.aspx

Basically, you don't want to have a form show at all; just start your
custom ApplicationContext to put the icon in the tray.
 
M

mqudsi

You may want to check out this article:http://www.windowsforms.net/articles/notifyiconapplications.aspx

Basically, you don't want to have a form show at all; just start your
custom ApplicationContext to put the icon in the tray.

Thanks a bunch!

I was following the MSDN docs, and I put this in the Main()
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Form F1 = new BackupWindow();
//So it doesn't exit..
Application.Run();

But when I when F1 exits, Application doesn't...
This custom context takes care of it!
 

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