2
I am beginner in the area, I could not find my question elsewhere.
Is there any code, which shows the state of the form?
For example: if it is in focus, if it is minimized or maximized?
Thanks in advance!
2
I am beginner in the area, I could not find my question elsewhere.
Is there any code, which shows the state of the form?
For example: if it is in focus, if it is minimized or maximized?
Thanks in advance!
2
To get or change the status of a form, use Form.WindowState
.
MessageBox.Show(WindowState.ToString()) ' Normal, Maximizado ou Minimizado '
Or if you need to perform an action in a given state, you can do:
If WindowState = FormWindowState.Maximized Then
' O formulário está maximizado '
ElseIf WindowState = FormWindowState.Minimized Then
' O formulário está minimizado '
ElseIf WindowState = FormWindowState.Normal Then
' O formulário está normal '
Else
' Estado desconhecido '
End If
To know if a control is in focus, use Control.Focused
.
If Me.Focused Then
' Este formulário está em foco '
Else
' Não está em foco '
End If
1
You would have to put two events in your form to annotate their state in a variable. For example:
Private formAtivo As Boolean
Private Sub meuForm_Activated(sender As Object, e As EventArgs) Handles MyBase.Activated
formAtivo = True
End Sub
Private Sub meuForm_Deactivate(sender As Object, e As EventArgs) Handles MyBase.Deactivate
formAtivo = False
End Sub
To know if the form is active, just read formAtivo
. I got the answer from here.
formAtivo
doesn’t have to be Private
.
Browser other questions tagged .net visual-studio-2013 vb.net form visual-basic-6
You are not signed in. Login or sign up in order to post.