用API是为了获得最好的运行速度。Private Declare Function LineTo Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long) As Long Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long Private Type POINTAPI x As Long y As Long End TypePrivate Sub Command1_Click() Dim pt As POINTAPI
Private Declare Function MoveToEx Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, lpPoint As POINTAPI) As Long
Private Type POINTAPI
x As Long
y As Long
End TypePrivate Sub Command1_Click()
Dim pt As POINTAPI
'画边框
MoveToEx Me.hdc, 100, 100, pt
LineTo Me.hdc, 200, 100
LineTo Me.hdc, 200, 200
LineTo Me.hdc, 100, 200
LineTo Me.hdc, 100, 100
'画对角线
LineTo Me.hdc, 200, 200
MoveToEx Me.hdc, 100, 200, pt
LineTo Me.hdc, 200, 100
Me.Refresh
End SubPrivate Sub Form_Load()
Me.AutoRedraw = True
Me.ScaleMode = 3
End Sub
MoveToEx Printer.hdc, 100, 200, pt
LineTo Printer.hdc, 200, 100