說明:
IsWindowVisible 函式可用來判斷指定的視窗代碼(Handle)的狀態是顯示或隱藏
引用函式庫:
User32
適用系統:
Windows NT 3.1 或 Windows 95以上
函式原型:
Declare Function IsWindowVisible Lib "user32" Alias "IsWindowVisible" ( _
ByVal hwnd As Long _
) As Long
參數型態及說明:
hwnd:Long 要檢查判斷的視窗代碼(Handle)
回傳值:
Long 若指定的視窗(Handle)為顯示狀態時,將會回傳非零的數值;反之則回傳 0
.NET Framework API:
System.Windows.Forms.Form.Visible
VB範例:
檢視原始碼 Visual Basic
1 2 3 4 5 6 7 8 9 | 'VB的宣告 Private Declare Function IsWindowVisible Lib "user32" ( _ ByVal hwnd As Long _ ) As Long Dim rtvl As Long '檢查視窗是否顯示或隱藏 rtvl = IsWindowVisible(Form1.hwnd) |
RB範例:
檢視原始碼 REALBasic
1 2 3 4 5 6 7 8 9 | 'RB的宣告 Declare Function IsWindowVisible Lib "user32" ( _ hwnd As Integer _ ) As Boolean Dim rtvl As Boolean '檢查視窗是否顯示或隱藏 rtvl = IsWindowVisible(Window1.WinHWND) |
VB.NET範例:
檢視原始碼 VB.NET
1 2 3 4 5 6 7 8 9 10 11 | 'VB.NET的宣告 <DllImport("user32.dll")> _ Shared Function IsWindowVisible( _ ByVal hwnd As IntPtr _ ) As Boolean End Function Dim rtvl As Boolean '檢查視窗是否顯示或隱藏 rtvl = IsWindowVisible(Me.Handle) |
C#範例:
檢視原始碼 C#
1 2 3 4 5 6 7 8 9 10 | //C#的宣告 [DllImport("user32")] public static extern bool IsWindowVisible( IntPtr hwnd ); bool rtvl; //檢查視窗是否顯示或隱藏 rtvl = IsWindowVisible(this.Handle); |
註釋:
雖然沒隱藏起來,但也有可能被其它視窗蓋住