Click here to Skip to main content
15,881,803 members
Please Sign up or sign in to vote.
2.50/5 (2 votes)
See more:
Good afternoon fellow coders!
Can someone please tell me how to hide the main form upon load (startup)??? I have tried Me.Hide() And some others ones, but none of them actually HIDE the form upon startup. It also has a NotifyIcon but once again it will not hide the main form..
Thanks in advance! :)
Posted
Comments
Sergey Alexandrovich Kryukov 25-May-11 16:26pm    
Why on Earth?!
--SA
NY Andrew 25-May-11 16:54pm    
Why? Because my application is mainly a System Tray program. And if the user needs to access the form, then he shall use the Tray Context Menu.. But I am having trouble hiding the main form window upon start..
Sergey Alexandrovich Kryukov 28-May-11 1:40am    
I see. This is quite possible, but I see you're already done by now.
Cheers,
--SA
Kschuler 25-May-11 17:22pm    
What are your project settings on the application tab, specifically what is your Startup form set to and what is your shutdown mode? And what do you mean it's not hiding with Me.Hide()? What can you still see when you use that?
NY Andrew 25-May-11 17:35pm    
Startup: Form1 Shutdown: when startup form closes. What I mean is when I have Me.Hide() inside the: Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load And it still shows the main form upon start.. And I still see the main form.. It never is hidden..

Check these links out;

How to:Make a startup form invisible[^]
Making a Startup Windows Form Invisible[^]

-or maybe something like this-

Edit the 'Main' procedure to do whatever you need and then launch your
main form when required.
The example below, simply delays opening the main form.
It could have waited for your (unspecified) external event, rather
than just shown a mesage box.

static void Main()
{
while (MessageBox.Show("show main form now?", "",
MessageBoxButtons.YesNo) == DialogResult.No)
{
MessageBox.Show("MainForm not run yet");
}
Application.Run(new Form1());
}


Good luck,
Orc
 
Share this answer
 
Comments
NY Andrew 25-May-11 16:03pm    
Hmmm.. I appreciate your response, but I have already come across that solution a few hours ago and it just isn't working.. Actually the: Application.Run(new Form1()) Did seem to work although I get this error message: "Starting a second message loop on a single thread is not a valid operation. Use Form.ShowDialog instead." Any ideas?
Sergey Alexandrovich Kryukov 25-May-11 16:28pm    
My 5 even it it is not working. I'm sure to make it working would take a few minutes. I'm not sure why. I guess you will have to figure this out in code...
--SA
Sergey Alexandrovich Kryukov 25-May-11 16:30pm    
By the way, I know it would work; recently tried a similar thing.
Andrew, just try it accurately.
--SA
NY Andrew 25-May-11 17:01pm    
I have still been messing around with this code but for some reason VB2010 doesn't like it.. I Keep getting that error from the debugger..
Orcun Iyigun 25-May-11 17:18pm    
The thing is that I can come up with is you may be using Application.Run more than once on the same thread. Check this first. if thats not the case, try this as well ( I am not sure about it tho!) uncheck the Enable Application Framework option from the Startup object dropdown. Other than these two I cant think of some other option to help you out.
I actually got it working!!! I forgot that in the Form1_Load thread, that I had some code in there to fade the window in upon startup, I FORGOT TO DELETE THIS CODE AFTER I CREATED THE Form1_Shown thread!! Stupid me.. THANK YOU ALL FOR THE PROMPT SUGGESTIONS!! Creating a SHOWN thread and then adding Me.Hide() inside, worked like a charm!! Thanks again!! I look forward to using codeproject more in the future! :) God Bless!
 
Share this answer
 
Set the Opacity to be 0 to hide it (in the designer mode or set it dynamically). To show the form, set it back to 100.
Initially set the Visible property of NotifyIcon to be False and when you change the opacity back to 100, set its visibility to True again.
 
Share this answer
 
v2
Comments
NY Andrew 26-May-11 12:25pm    
Thank you! If only I saw this a few hours earlier. But yes that is what I did included inside the Form_Shown thread I created along with Me.Hide().

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900