7,763
社区成员
发帖
与我相关
我的任务
分享
Private Sub Form_Paint()
MsgBox "?", vbSystemModal
End Sub
Private Sub Timer1_Timer()
Text1 = Time
End Sub
' 标准模块中的代码
Option Explicit
' 把工程设置成从 Sub Main 启动
Sub Main()
Load Form1: Form1.Caption = "‘模态’窗口!"
Form1.Show 1
Load Form1: Form1.Caption = "‘非模态’窗口!"
Form1.Show 0
' 即使直接 form1.Show 1、form1.show 0 ,结果也是一样
End Sub
' Form1 中的代码
Option Explicit
Private Declare Function GetWindow Lib "user32" (ByVal hWnd As Long, ByVal wCmd As Long) As Long
Private Declare Function IsWindowEnabled Lib "user32" (ByVal hWnd As Long) As Long
Private Const GW_OWNER As Long = 4
Private Const GW_HWNDNEXT As Long = 2
Private Sub Command1_Click()
' 单击 Command1 后, 始终输出“非模态”
Print GetWindow(hWnd, GW_OWNER) '输出非0
Print GetWindow(GetWindow(hWnd, GW_OWNER), GW_HWNDNEXT)
If (IsWindowEnabled(GetWindow(hWnd, GW_OWNER)) = 0) Then
Print "模态!"
Else
Print "非模态!"
End If
End Sub