說明:
EnableWindow 函式可指定視窗或控制項是否使用鍵盤輸入及滑鼠事件
引用函式庫:
User32
適用系統:
Windows NT 3.1 或 Windows 95以上
函式原型:
Declare Function EnableWindow Lib "user32" Alias "EnableWindow" ( _ ByVal hwnd As Long, _ ByVal fEnable As Long _ ) As Long
參數型態及說明:
hwnd:Long 要檢查判斷的視窗代碼(Handle)
fEnable:Long 指定視窗或控制項是否產生作用。若為 True 則產生作用;反之為 False 則無任何作用。
回傳值:
Long 呼叫成功的話,將會回傳非零的數值;若呼叫失敗的話,則回傳 0
.NET Framework API:
System.Windows.Forms.Form.Enabled
VB範例:
檢視原始碼 Visual Basic
1 2 3 4 5 6 7 8 9 10 | 'VB的宣告 Private Declare Function EnableWindow Lib "user32" ( _ ByVal hwnd As Long, _ ByVal fEnable As Long _ ) As Long Dim rtvl As Long '啟用目前執行視窗的鍵盤及滑鼠事件 rtvl = EnableWindow(Form1.hwnd, 1) |
RB範例:
檢視原始碼 REALBasic
1 2 3 4 5 6 7 8 9 10 | 'RB的宣告 Declare Function EnableWindow Lib "user32" ( _ hwnd As Integer, _ fEnable As Boolean _ ) As Boolean Dim rtvl As Boolean '啟用目前執行視窗的鍵盤及滑鼠事件 rtvl = EnableWindow(Window1.WinHWND, True) |
VB.NET範例:
檢視原始碼 VB.NET
1 2 3 4 5 6 7 8 9 10 11 12 | 'VB.NET的宣告 <DllImport("user32.dll")> _ Shared Function EnableWindow( _ ByVal hwnd As IntPtr, _ ByVal fEnable As Boolean _ ) As Boolean End Function Dim rtvl As Boolean '啟用目前執行視窗的鍵盤及滑鼠事件 rtvl = EnableWindow(Me.Handle, True) |
C#範例:
檢視原始碼 C#
1 2 3 4 5 6 7 8 9 10 11 | //C#的宣告 [DllImport("user32")] public static extern bool EnableWindow( IntPtr hwnd, bool fEnable ); bool rtvl; //啟用目前執行視窗的鍵盤及滑鼠事件 rtvl = EnableWindow(this.Handle, true); |