Hide the form when the form is minimized, and double-click the tray icon to display the main form. Private Sub MainForm_SizeChanged () Sub MainForm_SizeChanged (ByVal sender As Object, ByVal e As System. EventArgs) Handles MyBase. SizeChanged
If Me. WindowState = FormWindowState. Minimized Then
Me. Visible = False
End If
End Sub
Private Sub policyiconmain_doubleclick () Sub policyiconmain_doubleclick (ByVal sender As Object, ByVal e As System. EventArgs) Handles policyiconmain. DoubleClick
If Me. Visible = False Then
Me. Visible = True
Me. WindowState = FormWindowState. Normal
End If
End Sub
Since I started to put Me. Visible = True behind Me. WindowState = FormWindowState. Normal, the displayed interface is not in the Normal state, and only a small part of the title bar is displayed. Then you can adjust the order!
The following code does not work properly:
Me. WindowState = FormWindowState. Normal
Me. Visible = True
However, the following code works properly:
Me. WindowState = FormWindowState. Maximized
Me. Visible = True
According to this analysis, when the form is hidden, setting the WindowState of the form to be equal to FormWindowState. Normal is invalid, or there is a problem, but setting it to Maximized is OK, strange!
Remember later.