用vb来制作屏幕画圆代码
用vb来制作屏幕画圆代码 。
代码
- 01
'演示在屏幕上自动画圆的程序。如对参数、变量作改变,将有不同的效果。 '申明API函数 Private Declare Function GetWindowDC Lib "user32" (ByVal hWnd 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 Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Private Type POINTAPI x As Long y As Long End Type Dim xx As Integer, yy As Integer, ss As Integer Private Sub Command1_Click() Timer1.Enabled = True Me.Visible = False End Sub Private Sub Form_Load() xx = 0 yy = 0 ss = 0 Me.Caption = "在屏幕上自动画圆" Me.WindowState = 0 Command1.Caption = "开始" Timer1.Interval = 100 Timer1.Enabled = False Me.AutoRedraw = True CurrentX = 50 CurrentY = 100 Print "点击按钮后开始自动画圆。过一会儿程序会自动打住。" CurrentX = 50 CurrentY = 100 Print "试一试吧。OK?" End Sub '画椭圆 Sub Timer1_Timer() xx = xx + 5 yy = yy + 5 ss = ss + 1 Dim Position As POINTAPI '获取鼠标指针 GetCursorPos Position '在屏幕指针所在处画椭圆 Ellipse GetWindowDC(0), Position.x - xx, Position.y - yy, Position.x + xx, Position.y + yy If ss >= 350 Then Timer1.Enabled = False MsgBox "画圆结束。点击确定退出程序。请用刷新方式回复原桌面状态。", vbOKOnly, "再见" End End If End Sub</pre><br>