vb.net maximize program from notification area - vb.net

I have a program which contains few project and get reference to them. When I start program the Main Form is open. Now, I can click button and start form one of my project. I set Main Form to minimize to Notify Icon. Now when I finish with Form (from project) I want to maximize Main Form from Notify Icon.
How can I do this?
This is how I start Form and minimize Main Form to Notify Icon:
Dim instance As New Machines.FormMain
instance.Show()
NotifyIcon1.BalloonTipTitle = "TF Tools"
NotifyIcon1.BalloonTipText = "Machines Readings"
NotifyIcon1.ShowBalloonTip(5)
Me.WindowState = FormWindowState.Minimized
ShowInTaskbar = False
I have Solution with 3 projects. Main project is TF Tools when I stat TF_Tools.Form1 start. I click button which start project Machines.Form1. TF_Tools.Form1 is minimized to Notify Icon. I want TF_Tools.Form1 maximized when Machines.Form1 is closing. I was try to do this like that:
ShowInTaskbar = True
Me.WindowState = FormWindowState.Maximized
NotifyIcon1.Visible = True
This is work when I double click on icon in Notify Icon. But when I put this in Machines.Form1 closing event it’s not work. I was try to change Me. WindowState for TF_Tools.Form1.WindowState but it’s not work. I was think to add TF_Tools as a reference to Machines but I can’t do this.

Related

How to disable clicking Webbrowser, but still able to scroll WebBroswer

I have a WebBrowser in my VB.net form. I want to disable from users clicking links in the Webbrowser, but still able to scroll the Webbrowser.
I found this code but it locks up the whole WebBroswers so I can't click links or scroll, but I need to be able to scroll.
DirectCast(WebBrowser1, Control).Enabled = False
Just set the following property:
WebBrowser1.AllowNavigation = False
A hacky work-around to change the address from code would be to turn AllowNavigation on again, but it requires a BeginInvoke to allow the navigation to take place before turning it off again:
WebBrowser1.AllowNavigation = True
WebBrowser1.Navigate("new web address...")
Me.BeginInvoke(New Action(Sub() WebBrowser1.AllowNavigation = False))

Form border style none was closed while minimized to tray will not restore

Created a form in VB.net 2013 with
Me.FormBorderStyle = Windows.Forms.FormBorderStyle.None
And a button with
Me.WindowState = System.Windows.Forms.FormWindowState.Minimized
The issue is, if the User closes the form while the form was minimized to the taskbar, when you start the program back up again... you can see the program in the taskbar, but clicking on the taskbar icon for the program does nothing... clicking on the notification tray icon for the program does nothing... EVEN if the notification tray icon is set to
Form.Show
Form.Activate
Form.WindowState = System.Windows.Forms.FormWindowState.Normal
I have tried forcing the form to refresh.
I have tried forcing the form to redraw itself at the initial size.
The only thing that works to show it again after this defunct state is to put
Me.WindowState = System.Windows.Forms.FormWindowState.Maximized
in the form_load event, then let the form load, stop debugging, and then comment out the line again so the form goes back to how it is suppose to be.
Am I missing something?
Also, hovering over the taskbar icon for the program shows the full form in peek... so it does appear to be loaded, just not in the state that it should be in.
Chances are that you are writing the WindowState or the location and size properties when you close the form.
If saving the location and size, make sure to first check the WindowState property:
If Me.WindowState = FormWindowState.Normal Then
'// save your form size and location
End If

VB.NET - form inside a panel resize

I can't figure this out! I've researched docking, anchoring etc. but I'm yet to get it to correctly resize when the parent form resizes.
Edit:
Quick Overview:
I have a main form with a menustrip docked to the top and a panel set to fill. I have links within the menustrip which open forms within the panel. See code below. I am struggling to get the form within the panel to resize with the panel.
I've set the panel background to black and my form inside the panel to white. I can see the panel resizing with the form correctly. The form within the panel stays in its original position. If i start my app in maximized, then click on my menustrip sure enough the form within the panel resizes correctly. However, once it is maximized it doesn't shrink with the form like the panel container does.
I've deleted everything on my whole form, added 1 panel to it and set to fill then on form load do the following:
Dim f As New Contactdetails With {.TopLevel = False, .AutoSize = True}
f.Dock = DockStyle.Fill
Me.Panel2.Controls.Add(f)
f.Show()
This still doesn't work. When i maximize my main form, the form inside the panel does not resize but the panel does as i've changed it's background to monitor its change in size
Turn AutoSize off:
Dim f As New Contactdetails With {.TopLevel = False, .AutoSize = False}
f.Dock = DockStyle.Fill
Me.Panel2.Controls.Add(f)
f.Show()
If the previous form in the panel isn't being used anymore, then you should first dispose of it:
While Me.Panel2.Controls.Count > 0
Me.Panel2.Controls(0).Dispose()
End While
Set the WindowState to Normal in properties of the child form
and
Me.Dock = DockStyle.
Fill in the Load sub of the child form

Get tab and enter event in form in panel

In Visual Studio 2012 I have a panel in FormA which loads FormB.
FormB = New FormB
FormB.TopLevel = False
FormB.WindowState = FormWindowState.Maximized
FormB.FormBorderStyle = Windows.Forms.FormBorderStyle.None
FormB.Visible = True
Panel1.Controls.Add(FormB)
FormB contains some TextBoxes and a Button. When I try to tab through the TextBoxes in FormB the focus jumps to controls in FormA. I'm not able to get the keyboard enter event in FormB neither. I started with a bunch of independent forms but I am now trying use Tabs and Panels to navigate through the app. It would be great if I could use my existing form in panels to achieve this.
do you know "KeyPreview"? If you activate this, it may help you to catch the events directly on your active form. By default this is disabled and you can find it in your form-properties.

Keep Popup Window in WebBrowser control instead of a new window

When using the WebBrowser control, is it possible to cause popup windows to
appear within the WebBrowser control itself instead of a new window?
I can't figure out how to get the popup to appear in the same browser window. please help me :)
PS : The language I use is VB
If you have multiple tabs with WebBrowsers, use this under the "New Window" Event:
((WebBrowser)TabControl1.SelectedTab.Controls[0]).Navigate(((WebBrowser)
TabControl1.SelectedTab.Controls[0]).StatusText)
'next input <cancel[IE]>
e.Cancel = True
If just a plain browser put this under the New Window Event:
webBrowser1.Navigate(webBrowser1.StatusText)
e.Cancel = True