1,486
社区成员
发帖
与我相关
我的任务
分享
Private Const SM_CYCAPTION As Long=4
Private Declare Function GetSystemMetrics Lib "user32"(ByVal nIndex As Long)As Long
Private Sub Command1_Click()
'单位是像素。Windows XP以下操作系统这个值是26,上边框是4个像素,标题栏高度加上上边框共为30个像素。
Debug.Print GetSystemMetrics(SM_CYCAPTION)
End Sub
Private Sub Command1_Click()
MsgBox "窗口上边框的高度为:" & Form1.Height - Form1.ScaleHeight - (Form1.Width - Form1.ScaleWidth) / 2
MsgBox "窗口左边框的宽度为:" & (Form1.Width - Form1.ScaleWidth) / 2
End Sub
Private Sub Form_Load()
Dim a, a1, b, b1, c, c1 As Double
Form1.BorderStyle = 1
Form1.Caption = "Form1"
a = Form1.Height
b = Form1.Width
Form1.BorderStyle = 0
Form1.Caption = ""
a1 = Form1.Height
b1 = Form1.Width
c = (b - b1) / 2
c1 = a - a1 - c
MsgBox "窗口上边框的高度为:" & c1
MsgBox "窗口左边框的宽度为:" & c
Form1.BorderStyle = 1
Form1.Caption = "Form1"
End Sub