我在我的vb.net应用程序中使用了一个激活的事件,然后是一个if语句,导致一个消息框因为一个条件而导致apear ..
问题是,消息框导致我的表单失去焦点,然后每次点击消息框时再次重新激活,导致一种循环,我现在陷入困境,如何绕过这个?
std::find(vector.begin,vector.end, element)
“外部文档是绘图环境”这一行是由autodesk发明人返回的可变结果,用于确定哪种类型的绘图环境是活动文档...(这只是缩短了整个说明)
答案 0 :(得分:0)
未经测试。但这可能有用......
Private WarningShowed As Boolean = False
Private Sub form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
If Not WarningShowed Then
WarningShowed = True
If "EXTERNAL DOCUMENT IS A DRAWING ENVIRONMENT" Then
'NOTHING
Else
MsgBox("Select drawing environmet first")
Me.Close()
End If
End If
End Sub
答案 1 :(得分:0)
你可以使用Malcor说的标志,或者你可以在显示消息之前删除处理程序,所以:
Private Sub form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
if "EXTERNAL DOCUMENT IS A DRAWING ENVIRONMENT" then
'NOTHING
Else
RemoveHandler Me.Activated, addressof form1_Activated
msgbox("Select drawing environment first")
me.close()
end if
end sub