怎样判定是窗体被最大化、最小化或被还原引发生的Resize事件?
在Resize事件中,怎样才知道是窗体被最大化、最小化或被还原引发生的该事件?
[解决办法]
检查Me.WindowState属性,
0:表示普通大小
1:最小化
2:最大化
Option Explicit
Private Sub Form_Resize()
Select Case Me.WindowState
Case 0
Me.Caption = "普通大小"
Case 1
Me.Caption = "最小化"
Case 2
Me.Caption = "最大化"
End Select
End Sub
Option Explicit
Private Declare Function IsIconic Lib "user32.dll" (ByVal hwnd As Long) As Long
Private Declare Function IsZoomed Lib "user32.dll" (ByVal hwnd As Long) As Long
Private Mmax As Long, Mmin As Long
Private Sub Form_Load()
Timer1.Enabled = True
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
Mmax = IsZoomed(Me.hwnd)
Mmin = IsIconic(Me.hwnd)
If Mmax > 0 Then
Me.Caption = "窗口已最大化"
Else
If Mmin > 0 Then
Me.Caption = "窗口已最小化"
Else
Me.Caption = "窗口已被还原"
End If
End If
End Sub