Question

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
Was it helpful?

Solution

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

OTHER TIPS

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top