Applies To
Access for Microsoft 365 Access 2024 Access 2021 Access 2019 Access 2016

適用對象

Form 物件

Report 物件

您可以使用 hWnd 屬性來判斷由 Microsoft Windows 指派給目前視窗的控點 (唯一長整數)。 讀/寫長整數

expression.Hwnd

運算式 必要。 傳回 [套用至] 清單中其中一個對象的表達式。

備註

此屬性只能在使用巨集或 Visual Basic for Applications (VBA) 程式碼時取得。

當您呼叫 Windows 應用程式開發介面 (API) 函數或其他需要以 hWnd 屬性做為引數的外部程序時,您可以在 VBA 程式碼中使用此屬性。 有許多 Windows 函數都需要以目前視窗的 hWnd 屬性值做為引數。

因為此屬性的值可能會在程式執行期間變更,因此請不要將 hWnd 屬性值儲存在公開變數中。

範例

下列範例會使用 hWnd 屬性與 Windows API IsZoomed 函數來判斷是否視窗已最大化。

' Enter on single line in Declarations ' section of Module window.Declare Function IsZoomed Lib "user32" _    (ByVal hWnd As Long) As LongSub Form_Activate()    Dim intWindowHandle As Long    intWindowHandle = Screen.ActiveForm.hWnd    If Not IsZoomed(intWindowHandle) Then        DoCmd.Maximize    End IfEnd Sub

Need more help?

Want more options?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。