Sign in with Microsoft
Sign in or create an account.
Hello,
Select a different account.
You have multiple accounts
Choose the account you want to sign in with.

適用對象

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 Long
Sub Form_Activate()
Dim intWindowHandle As Long
intWindowHandle = Screen.ActiveForm.hWnd
If Not IsZoomed(intWindowHandle) Then
DoCmd.Maximize
End If
End Sub

Need more help?

Want more options?

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

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

Was this information helpful?

How satisfied are you with the translation quality?
What affected your experience?
By pressing submit, your feedback will be used to improve Microsoft products and services. Your IT admin will be able to collect this data. Privacy Statement.

Thank you for your feedback!

×