应用API函数在用户窗体中画圆代码与示例-十段
Access软件网QQ交流学习群(群号码198465573),欢迎您的加入!
首页 >技术文章> 源码示例


应用API函数在用户窗体中画圆代码与示例

发表时间:2011/9/8 评论(1) 浏览(9193)  评论 | 加入收藏 | 复制
   
摘 要:应用API函数在用户窗体中画圆代码与示例
正 文:

Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
 Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
 Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject 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 CreateSolidBrush Lib "gdi32" (ByVal crColor As Long) As Long                    '
 Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
 Private Declare Function Ellipse Lib "gdi32" (ByVal hdc As Long, ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
 
Sub MyCircle(obj As Object, pX As Long, pY As Long, pR As Long, lcColor As Long, lcFill As Long)
 'obj 指定圆所在的对象
 'pX 圆心在对象体上X轴
 'pY 圆心在对象体上Y轴
 'pR 圆的半径
 'lcColor 圆的轮廓颜色
 'lcFill 圆的填充色
 Dim hdc As Long, hpen As Long, hcolor As Long
     hdc = GetDC(FindWindow(vbNullString, obj.Caption))
     hpen = CreatePen(0, 1, lcColor)
     hcolor = CreateSolidBrush(lcFill)
     SelectObject hdc, hpen
     SelectObject hdc, hcolor
     Ellipse hdc, pX - pR, pY - pR, pX + pR, pY + pR
     DeleteObject hpen
     DeleteObject hcolor
 End Sub
 
Private Sub CommandButton1_Click()
     MyCircle UserForm1, 100, 100, 50, vbRed, vbBlue
 End Sub

附件:

点击下载此附件 (56.02 KB)


Access软件网交流QQ群(群号:198465573)
 
 相关文章
字符数函数与字节数API函数区别实例演示  【江羽  2011/7/11】
应用API函数在用户窗体中画圆代码与示例  【十段  2011/9/8】
Windows API函数大全  【麥田  2012/1/4】
API函数参考手册_VB_API函数大全  【ihcn  2012/8/4】
常见问答
技术分类
相关资源
文章搜索
关于作者

十段

文章分类

文章存档

友情链接