共用方式為


Visio) (Window.GetWindowRect 方法

會取得視窗中用戶端區域的大小及位置。

語法

運算式GetWindowRect( _pnLeft_ , _pnTop_ , _pnWidth_ , _pnHeight_ )

一個代表 視窗 物件的變數。

參數

名稱 必要/選用 資料類型 描述
pn左翼 必要 Long 視窗左側的座標
pnTop 必要 Long 視窗頂端的座標
pn寬度 必要 Long 從視窗左側到右側以像素表示的距離
pn身高 必要 Long 從視窗頂端到底端以像素表示的距離

傳回值

註解

GetWindowRect 方法會取得視窗之用戶端區域的大小及位置,此視窗與擁有其所屬之 Windows 集合的視窗有關。 若為 Application 物件的 Windows 集合,「相關」視窗是 Microsoft Visio 主視窗的 MDICLIENT 視窗。 若為 Window 物件的 Windows 集合,「相關」視窗則是繪圖視窗的用戶端區域。

範例

以下範例展示了如何使用 GetWindowRect 方法來取得 視窗 物件的大小與位置。 它會開啟 [全景和縮放] 視窗,並在 [即時運算] 視窗中列出座標、寬度及高度。

Public Sub GetWindowRect_Example() 
 
 Dim vsoApplication As Visio.Application 
 Dim vsoPZWindow As Visio.Window 
 Dim pinLeft As Long, pinTop As Long, pinWidth As Long, pinHeight As Long 
 
 Set vsoApplication = Visio.Application 
 
 'Display the Pan & Zoom window 
 Set vsoPZWindow = vsoApplication.ActiveWindow.Windows.ItemFromID(visWinIDPanZoom) 
 vsoPZWindow.Visible = True 
 
 'Get the existing window size and position 
 vsoPZWindow.GetWindowRect pinLeft, pinTop, pinWidth, pinHeight 
 Debug.Print pinLeft, pinTop, pinWidth, pinHeight 
 
 'Change the window height and get the new values 
 vsoPZWindow.SetWindowRect pinLeft, pinTop, pinWidth, pinHeight + 50 
 vsoPZWindow.GetWindowRect pinLeft, pinTop, pinWidth, pinHeight 
 Debug.Print pinLeft, pinTop, pinWidth, pinHeight 
 
End Sub

支援和意見反應

有關於 Office VBA 或這份文件的問題或意見反應嗎? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應