ElektroStudios
ElektroStudios

Reputation: 20484

Hide a form on Form Load event?

I need to add a commandline option to hide mi application if the parameter to hide the form is passed...

It's a Windowsform.

This is what I've tried but the form don't hides:

Private Sub Parse_Arguments()
    For I As Integer = 0 To My.Application.CommandLineArgs.Count - 1

        If My.Application.CommandLineArgs.Item(I).ToLower = "/s" Then
            Me.Visible = False
            Me.Hide()
            'Me.Visible = True
        End If

    Next
End Sub

Upvotes: 0

Views: 2773

Answers (2)

Idle_Mind
Idle_Mind

Reputation: 39142

Set Opacity() to 0 (zero), and FormBorderStyle() to SizableToolWindow:

Private Sub Parse_Arguments()
    For I As Integer = 0 To My.Application.CommandLineArgs.Count - 1
        If My.Application.CommandLineArgs.Item(I).ToLower = "/s" Then
            Me.Opacity = 0 ' completely invisible
            Me.FormBorderStyle = FormBorderStyle.SizableToolWindow ' hide from alt-tab
            Me.ShowInTaskbar = False
        End If
    Next
End Sub

Upvotes: 1

ArthurCPPCLI
ArthurCPPCLI

Reputation: 1082

Try this technique : it wont hide it, but it will be minimized:

Me.WindowState = FormWindowState.Minimized

if you don't want it showing on the task bar either, you can add this line:

Me.ShowInTaskbar = False

Upvotes: 4

Related Questions