나는 어디에서나 보았고 대답을 찾을 수 없습니다. 양식이 활성 또는 비활성 인 경우 부울 값을 가져 오는 방법은 무엇입니까?vb.net에서 양식 활성 상태 값을 얻는 방법
의사 :
'If the form is active
'Do this
'else If the form is not active
'Do this
당신이 방법에 대해
나는 어디에서나 보았고 대답을 찾을 수 없습니다. 양식이 활성 또는 비활성 인 경우 부울 값을 가져 오는 방법은 무엇입니까?vb.net에서 양식 활성 상태 값을 얻는 방법
의사 :
'If the form is active
'Do this
'else If the form is not active
'Do this
당신이 방법에 대해
이것은 내가 결국 사용하는 것입니다 : 다음
Private formActive As Boolean
Private Sub form1_Activated(sender As Object, e As EventArgs) Handles MyBase.Activated
formActive = True
End Sub
Private Sub mainForm_Deactivate(sender As Object, e As EventArgs) Handles MyBase.Deactivate
formActive = False
End Sub
:
는If formActive = True
'If the form is active
else
'If the form is not active
End If
감사? Form 클래스의 ActiveForm property을 사용하고 있습니다 :
If Form.ActiveForm.Name = "yourForm" Then
'Do Events 1
Else
'Do Events 2
End If
나는 이것을 시도하고 다음과 같은 오류 메시지가 나타납니다 : "개체 참조가 개체의 인스턴스로 설정되지 않았습니다." –
사용이, 그것은 활성 윈도우의 HWND를 얻을 다음 폼의 HWND 비교합니다.
Public Declare Function GetActiveWindow Lib "user32"() As System.IntPtr
If GetActiveWindow() = Me.Handle Then
lblIsActive.Text = "active"
Else
lblIsActive.Text = "not active"
End If
아무도 없다, 당신은 당신의 자신을 만들 수 있습니다. 활성화 및 비활성화 이벤트를 사용하십시오. –
그건 의미가 있습니다! 고마워. 고마워. –