Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End TypePrivate Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, ByRef lpRect As RECT) As Long
Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End TypePrivate Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, ByRef lpRect As RECT) As LongPrivate Sub Form_Load() Dim rec As RECT GetWindowRect h, rec Dim chang As Long Dim kuang As Long chang = rec.Top - rec.Bottom kuang = rec.Right - rec.Left End Sub
楼上的错误。Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End TypePrivate Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, ByRef lpRect As RECT) As LongPrivate Sub Form_Load() Dim rc As RECT GetWindowRect Me.hWnd, rc debug.ping rc.Top - rc.Bottom, rc.Right - rc.Left End Sub
'提醒一下,Modest(塞北雪貂) --- (偶最欣赏楼主的分),这位,你那也错误哦.... Private Type RECT Left As Long Top As Long Right As Long Bottom As Long End TypePrivate Declare Function GetWindowRect Lib "user32.dll" (ByVal hWnd As Long, ByRef lpRect As RECT) As LongPrivate Sub Form_Load() Dim rWindow As RECT Dim hWnd As Long hWnd = Me.hWnd '你自己写了,要获得的窗体的句柄 GetWindowRect hWnd, rWindow Debug.Print rWindow.Left & "," & rWindow.Top & "," & rWindow.Right - rWindow.Left & "," & rWindow.Bottom - rWindow.Top '注意单位是像素,和VB里的单位不同......这个的结果和VB的比应该是1:15 '还有这个的结果是包括标题栏和边框的,而VB里好像是不包括的 End Sub
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypePrivate Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, ByRef lpRect As RECT) As Long
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypePrivate Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, ByRef lpRect As RECT) As LongPrivate Sub Form_Load()
Dim rec As RECT
GetWindowRect h, rec
Dim chang As Long
Dim kuang As Long
chang = rec.Top - rec.Bottom
kuang = rec.Right - rec.Left
End Sub
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypePrivate Declare Function GetWindowRect Lib "user32.dll" (ByVal hwnd As Long, ByRef lpRect As RECT) As LongPrivate Sub Form_Load()
Dim rc As RECT
GetWindowRect Me.hWnd, rc
debug.ping rc.Top - rc.Bottom, rc.Right - rc.Left
End Sub
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End TypePrivate Declare Function GetWindowRect Lib "user32.dll" (ByVal hWnd As Long, ByRef lpRect As RECT) As LongPrivate Sub Form_Load()
Dim rWindow As RECT
Dim hWnd As Long
hWnd = Me.hWnd '你自己写了,要获得的窗体的句柄
GetWindowRect hWnd, rWindow
Debug.Print rWindow.Left & "," & rWindow.Top & "," & rWindow.Right - rWindow.Left & "," & rWindow.Bottom - rWindow.Top
'注意单位是像素,和VB里的单位不同......这个的结果和VB的比应该是1:15
'还有这个的结果是包括标题栏和边框的,而VB里好像是不包括的
End Sub