Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have an invisible start up form?

I have an application that is a part of a solution of projects. In this project I would like for it to start up form to be invisible, but still have a notification icon in the tray visible for this form.

I know that adding me.hide into the form_load doesn't work. I tried adding a module that instantiates the startup form and I set it as the startup object. Although that didn't work either. I am running out of ideas to have this form invisible. Could anyone help out? I am using VB.NET.

like image 440
user1632018 Avatar asked Sep 12 '12 17:09

user1632018


4 Answers

Use Me.Opacity = 0 to hide the form on load event.

Then use the following code in the form.Shown event

Me.Hide()
Me.Opacity = 100
like image 93
SimpleCoder Avatar answered Oct 19 '22 22:10

SimpleCoder


Paste this in your form code:

Protected Overrides Sub SetVisibleCore(ByVal value As Boolean)
    If Not Me.IsHandleCreated Then
        Me.CreateHandle()
        value = False
    End If
    MyBase.SetVisibleCore(value)
End Sub

The way that works is that the very first request to show the form, done by the Application class, this code overrides the Visible property back to False. The form will behave as normal after this, you can call Show() to make it visible and Close() to close it, even when it was never visible. Note that the Load event doesn't fire until you show it so be sure to move any code in your event handler for it, if any, to the constructor or this override.

like image 27
Hans Passant Avatar answered Nov 04 '22 03:11

Hans Passant


Put this in the form's Shown event

Me.Visible = False
like image 6
UnhandledExcepSean Avatar answered Nov 04 '22 02:11

UnhandledExcepSean


The easiest way is to set the opacity of the form to 0%. When you want it to appear, set it back to 100%

like image 6
craisin Avatar answered Nov 04 '22 04:11

craisin