📄 polyline.frm
字号:
VERSION 5.00
Begin VB.Form Form1
BackColor = &H80000000&
Caption = "Form1"
ClientHeight = 6435
ClientLeft = 60
ClientTop = 360
ClientWidth = 6330
LinkTopic = "Form1"
ScaleHeight = 6435
ScaleWidth = 6330
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command2
Caption = "Command2"
Height = 495
Left = 4800
TabIndex = 1
Top = 1080
Width = 735
End
Begin VB.CommandButton Command1
Caption = "Command1"
Height = 615
Left = 5640
TabIndex = 0
Top = 0
Width = 615
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Type Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type POLYTEXT
x As Long
y As Long
n As Long
lpStr As String
uiFlags As Long
rcl As Rect
pdx As Long
End Type
Private Type POINTAPI
x As Long
y As Long
End Type
Private Const PS_SOLID = 0
Private Const PS_DASH = 1 ' -------
Private Const PS_DOT = 2 ' .......
Private Const PS_DASHDOTDOT = 4 ' _.._.._
Private Const PS_JOIN_ROUND = &H0
Private Const PS_NULL = 5
Private Const PS_INSIDEFRAME = 6
Private Declare Function Polyline Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Declare Function PolyTextOut Lib "gdi32" Alias "PolyTextOutA" (ByVal hdc As Long, pptxt As POLYTEXT, ByVal cStrings As Long) As Long
Private Declare Function Polygon Lib "gdi32" (ByVal hdc As Long, lpPoint As POINTAPI, ByVal nCount As Long) As Long
Private Declare Function CreatePen Lib "gdi32" (ByVal nPenStyle As Long, ByVal nWidth As Long, ByVal crColor As Long) As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
Dim TxtEdCod As Long
Dim Pts(0 To 6) As POINTAPI
Private Sub Command1_Click()
Dim Rec As Rect
Rec.Top = 10: Rec.Bottom = 100
Rec.Left = 10: Rec.Right = 60
Me.AutoRedraw = True
DrawRect Rec, Me.hdc, "liao"
Me.Refresh
End Sub
Private Sub DrawRect(Rect As Rect, hdc As Long, Str As String)
Dim PTxt As POLYTEXT
Dim PenhDC As Long
Dim LineY As Single, Tmp As Single
PTxt.n = Len(Str)
PTxt.lpStr = Str
PenhDC = CreatePen(PS_JOIN_ROUND, 1, vbRed)
SelectObject hdc, PenhDC
Tmp = Rect.Bottom - Rect.Top
LineY = Tmp * 0.3 + Rect.Top
Pts(0).x = Rect.Left: Pts(0).y = Rect.Top
Pts(1).x = Rect.Right: Pts(1).y = Rect.Top
Pts(2).x = Rect.Right: Pts(2).y = Rect.Bottom
Pts(3).x = Rect.Left: Pts(3).y = Rect.Bottom
Polygon hdc, Pts(0), 4
Pts(0).x = Rect.Left: Pts(0).y = LineY
Pts(1).x = Rect.Right: Pts(1).y = LineY
Polyline hdc, Pts(0), 2
PTxt.x = (Rect.Right - Rect.Left) / 3
PTxt.y = Rect.Top + LineY / 3
PolyTextOut hdc, PTxt, 1
End Sub
Private Sub Command2_Click()
CMD.Show
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -