Run VB.net program minimized - vb.net

As shown in the picture, I want my vb.net application to run minimized like that a show a pop-up when the minimize button is hit. Is there a way I can do that?

Try this...
You can use the notifyicon control...Hide the form when it's minimized and show the notifyicon, otherwise, show the form and hide the notifyicon control...
Add notifyicon control
Add this code under the form resize event
If Me.WindowState = FormWindowState.Minimized Then
Me.WindowState = FormWindowState.Minimized
NotifyIcon1.Visible = True
NotifyIcon1.ShowBalloonTip(5, "System", "DoubleClick on the Icon to restore the application.", ToolTipIcon.Info)
Me.Hide()
End If
Under the doubleclick event of notifyicon control, add this code...
Me.Show()
Me.WindowState = FormWindowState.Maximized
NotifyIcon1.Visible = False

Related

Minimize form when minimize button is clicked in VB.NET

I have a form which is maximized with this property:
Me.WindowState = FormWindowState.Maximized
and with FormBorderStyle = None. This means that when this form is opened, it can not be minimized, which is the behavior I want.
From this main form, there is a button which open another small form called 'Console' where I can see some messages thrown by the main form. This 'Console' form is with FormBorderStyle = FixedSingle, and this means that can be minimized.
The problem with this, is that when I minimize the 'Console' form, I can not opened again because the main form occupy the whole screen.
What I am trying to do is to minimize the 'Console' and be able to see it to maximize it again when I wish.
I tried to use events of the 'Console' form like SizeChanged or KeyUp and control when the minimize button is pressed.
All things I tried have gone wrong, and always when I press the minimize button, the form minimizes normally.
It is possible when I minimize the form by clicking on the minimize button, to see the minimize window down to maximize it when I want?
I accept any suggestions!
Finaly I've used this option: when I click to minimize, I just relocate the form and resize it. Maybe is a simple and manual option and for sure it will be better ways to do it, but this gives me what I need for now.
#HansPassant thanks for your help! I am going to look for information about docking layout manager as you suggested.
Here is the code:
Private Sub frmConsole_Move(sender As Object, e As EventArgs) Handles MyBase.Move
If Me.WindowState = FormWindowState.Minimized Then
Me.Size = New System.Drawing.Size(247, 0)
Me.WindowState = FormWindowState.Normal
Me.Location = New Point(padre.GMapControl.Location.X, padre.GMapControl.Location.Y + 1000)
Me.TopMost = True
ElseIf Me.WindowState = FormWindowState.Maximized Then
Me.Size = New System.Drawing.Size(447, 900)
Me.WindowState = FormWindowState.Normal
Me.Location = New Point(padre.Location.X + padre.GMapControl.Width * 0.9, padre.Location.Y)
End If
End Sub
I've used some buttons location of the main form to locate the 'Console' form, but it can be any value.
Thanks!

VB.NET Icon in taskbar disappears when maximizing form

I set WindowState to Maximized in From1 properties but when I run the project, the icon in the taskbar disappear. If I set it to Normal the icon appear normally.
I tried to set the windowState to normal and then during form load setting it to maximized but without success.
Private Sub index_Load(sender As Object, e As EventArgs) Handles Me.Load
Btn_home.Visible = False
Me.WindowState = FormWindowState.Maximized
Panel1.Controls.Add(_menù)
currentPanel = _menù
'Me.ShowInTaskbar = True
End Sub
If I move Me.WindowState = FormWindowState.Maximized after currentPanel = _menù
is showing normally but I don't know why and also I have to get the size of the form maximized in the panel _menù.

How can I "unhide" this form without triggering the _load event?

I'll just get straight to it, I have this code:
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
startup.Show()
Me.WindowState = FormWindowState.Minimized
Me.ShowInTaskbar = False
Me.Hide()
End Sub
This is going to be the form which loads first, having the entire project shutting down when this form closes (hence why I have to load this form first & calling the startup from this)
After the startup form has finished it's code, I have this code:
...
frmMain.ShowInTaskbar = True
frmMain.WindowState = FormWindowState.Normal
Me.Close()
How can I get the main form to load again without actually triggering it's _load event (thus avoiding it to trigger an infinite loop).
did you mean show the main form?
frmMain.Show()
frmMain.BringToFront()
Try this in order to show the hidden form:
frmMain.Show()
I'd suggest a better way to tackle this is to show the startup form from the application startup event. Your main form can then be a main form instead of being hidden.
startup.WindowState = FormWindowState.Normal
Call startup.Show()
Call startup.BringToFront()
Call startup.Activate()
The essential step to unhide from windowstate minimized, which is the windowstate of hidden forms, is to change the windowstate to normal. An example of this is shown in my first line of code. The other lines are for showing, bringing to the front and activating the formerly hidden form with the name startup. Goodluck!

VB.net form restore not showing form

I'm currently using VB.Net 2008.
The project has the "make single instance application" checkbox checked.
The application works by hiding the form when the form is minimized.
Private Sub Form1_Resize(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Resize
If Me.WindowState = FormWindowState.Minimized Then
Me.Hide()
End If
End Sub
When the appropriate menu item is pressed within the notifyicon the form should show itself again.
Private Sub ShowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles ShowToolStripMenuItem.Click
Me.Show()
Me.WindowState = FormWindowState.Normal
End Sub
This works fine until the user tries to open the same application while the form is minimized. When this occurs the application will block a new instance of the application the user was trying to open as expected, however when the user then goes to show the form from the notifyicon's menu it will have seemed to open (it shows the form in the taskbar) but no window is shown.
At this point the window can be maximized and works as intended but by using the restore button the window will not be drawn but will still be shown in the taskbar.
If any help can be given on how to restore the form correctly from being hidden it would be most appreciated.
Thanks in advance
Just a couple of suggestions...
Instead of using Hide() and Show(), could you use the ShowInTaskbar property of the form instead?
Set it to false where you use Hide() and true where you currently use Show(), and see if that makes any difference.
Or perhaps set the WindowState to Normal before calling Show().

Forcing form to be on the screen

Is there a way to force a form to be active and shown?
From another form i am doing:
Me.Hide
Form2.Show
When this code is run, the Form2 is minimized.
I've also tried:
Me.WindowState = FormWindowState.Normal
in the load event, and it still loaded it in minimized mode.
Try Me.BringToFront(); or you can set the property TopMost true and thus the form will be always on top.