当用户移动 Explorer 或 Inspector 时发生。该事件在开始后可以取消。
Private Sub expression_BeforeMove(Cancel As Boolean)
expression 该表达式返回“应用于”列表中的一个对象,该对象在类模块中以事件形式声明。
Cancel 必选,Boolean 类型。当事件发生时为 False。如果事件过程将此参数设为 True,则不完成该操作,并且不移动浏览器或检查器。
以下示例在用户移动浏览器前向用户弹出一条消息。如果用户单击“是”,则允许用户移动浏览器。
Private Sub objExplorer_BeforeMove(Cancel As Boolean)
'Prompts the user before moving the window
Dim lngAns As Long
lngAns = MsgBox("Are you sure you want to move the current window?", vbYesNo)
If lngAns = vbYes Then
Cancel = False
Else
Cancel = True
End If
End Sub