VB获取窗体的位置和大小

在窗体中添加一个计时器Timer,代码如下:
Option Explicit
Private Declare Function GetWindowRect Lib “user32” (ByVal hwnd As Long, lpRect As Rect) As Long
Private Type Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Dim Moveform As Rect

Private Sub Form_Load()
Me.AutoRedraw = True
Timer1.Interval = 10
End Sub

Private Sub Timer1_Timer()
GetWindowRect Me.hwnd, Moveform
Me.Cls
Me.Print “Left:” & Moveform.Left * 15 & vbCrLf & “Top:” & Moveform.Top * 15 & vbCrLf & “Width:” & (Moveform.Right - Moveform.Left) * 15 & vbCrLf & “Height:” & (Moveform.Bottom - Moveform.Top) * 15
End Sub

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 1024 设计师:白松林 返回首页