VB中在一个圆中画一段圆弧

2024-12-16 00:20:38
推荐回答(1个)
回答1:

用API函数Arc
函数声明
Public Declare Function Arc Lib "gdi32" Alias "Arc" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long, ByVal X3 As Long, ByVal Y3 As Long, ByVal X4 As Long, ByVal Y4 As Long) As Long
这个声明最好声明在标准模块里面,不然的话Public 就要改成Private
下面就可以直接用这个函数画弧线了
hdc是一个要画弧线的DC 可以去me.hdc
x1,y1是这个圆弧的椭圆的外接矩形左上角坐标
x2,y2是右下角
x3,y3是圆弧开始的X,Y坐标,
x4,y4是结束的XY坐标

Arc me.hdc,0,0,500,500,252,0,0,250

注意如果要看到画的弧线需要设置窗口的AutoReDraw属性为TRUE
这样才能持续输出不被擦出