user2576484
user2576484

Reputation:

How can I run my application in background (VB 2008-10)?

Sorry if such a question like this has been posted before. How do I make my VB application run in background so that I can click on the hidden icons in the tray of hidden icons (near the clock and the date) of my Windows 7 PC and re-activate it?

I tried to hide my form to do this, but I did not know how to re-activate its window back. On the OnClick() method of my button cmdRunBG, I typed:

Me.visible = false

Well, that thing just hid the form. I want it to really run in the background, having an icon in the tray of icons (near the system clock). How do I do that?

If you have any clarifications regarding this, please respond.

Thanks.

Upvotes: 1

Views: 6417

Answers (1)

dkar
dkar

Reputation: 2123

What you really want is to programmatically minimize your form. Try that:

Me.WindowState = FormWindowState.Minimized

EDIT:

If you want to put the application on system tray, a simple way to do it is the following:

  1. add a NotifyIcon control to your application and set its properties
  2. add the following code in the Resize event of your form:

    If Me.WindowState = FormWindowState.Minimized Then
       Me.Hide()
    End If
    
  3. add the following code in the MouseClick event of your NotifyIcon:

    If Me.WindowState = FormWindowState.Minimized Then
        Me.Show()
        Me.WindowState = FormWindowState.Normal
    End If
    

Upvotes: 1

Related Questions