应用API函数在用户窗体中画圆

原创 2007年09月23日 14:23:00

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(MyObject As Object, pX As Long, pY As Long, pR As Long, lcColor As Long, lcFill As Long)
'MyObject 指定圆所在的对象
'
'pX 圆心在对象体上X轴
'
'pY 圆心在对象体上Y轴
'
'pR 圆的半径
'
'lcColor 圆的轮廓颜色
'
'lcFill 圆的填充色

Dim hdc As Long, hpen As Long, hcolor As Long
hdc = GetDC(FindWindow(vbNullString, MyObject.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 UserForm_Click()
MyCircle UserForm1, 100, 100, 50, vbRed, vbBlue
End Sub

VB6围棋:窗体画线和画圆的应用

Option Explicit Dim qipan(1 To 19, 1 To 19) As Integer '棋盘数组,0:无 1:黑子 2:白子Private Sub Form_Load() Me...

Vb.net/VB 声明API函数实现父窗体功能

回顾第一次敲机房收费,自己调用了api函数实现了父窗体及其子窗体最小化的功能,如今再次遇到,自己就在思考,能不能继续使用API函数呢?答案当然是Of Course! 其实仔细看两者并没有多大的区...

用API函数在DELPHI中实现“非典型”窗体

====================================================== 注:本文源代码点此下载 =============================...

Vb.net/VB 声明API函数实现父窗体功能

回顾第一次敲机房收费,自己调用了api函数实现了父窗体及其子窗体最小化的功能,如今再次遇到,自己就在思考,能不能继续使用API函数呢?答案当然是Of Course!...

winForm用户登陆(window窗体应用程序,有改进版)

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:应用API函数在用户窗体中画圆
举报原因:
原因补充:

(最多只允许输入30个字)