新学GDI+,写的一个很好玩的代码

bucher 2002-11-14 11:00:01
Public NotInheritable Class AniForm
Private Delegate Sub AniControlSub(ByVal ControlSource As Control)
Private _Source As Form
Public Sub New(ByVal SourceForm As Form)
_Source = SourceForm
End Sub
Public Sub StartAni()
Dim mC As Control
Dim mS(_Source.Controls.Count - 1) As AniControlSub
Dim i As Integer
For Each mC In _Source.Controls
mC.Visible = False
Next
For Each mC In _Source.Controls
mS(i) = New AniControlSub(AddressOf DrawControl)
mS(i).BeginInvoke(mC, Nothing, Nothing)
i = i + 1
Next
End Sub
Private Sub DrawControl(ByVal ControlSource As Control)
Dim C As Integer = 5 '循环次数
Dim G As Graphics = _Source.CreateGraphics()
Dim pen As Pen = New Pen(Color.Black, 1)
Dim epen As Pen = New Pen(_Source.BackColor, 1)
Dim rect As Rectangle = New Rectangle(ControlSource.Left + ControlSource.Width \ 2, ControlSource.Top + ControlSource.Height \ 2, 1, 1)
Dim i As Integer
Dim cx As Integer = ControlSource.Width \ C \ 2
Dim cy As Integer = ControlSource.Height \ C \ 2
'ControlSource.Visible = False
For i = 0 To C - 1
G.DrawRectangle(epen, rect)
rect.Inflate(cx, cy)
G.DrawRectangle(pen, rect)
Threading.Thread.Sleep(30)
Next
G.DrawRectangle(epen, rect)
ControlSource.Visible = True
'ControlSource.Refresh()
End Sub

End Class


用法:
dim a as myform=new myform
dim p as AniForm=new AniForm(a)
a.show
p.StartAni

你会看到控件像泡泡一样冒出来
如果你的窗体上面空间很多的话,效果很好的 :-)

如果你喜欢这段代码,请给一个回复。我会继续写更好玩的代码 :-)
...全文
99 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
nannanwang 2002-11-15
  • 打赏
  • 举报
回复
看一看 !thanks
zytp 2002-11-15
  • 打赏
  • 举报
回复
支持
cimoka 2002-11-15
  • 打赏
  • 举报
回复
支持!Thanks
xdd1125 2002-11-15
  • 打赏
  • 举报
回复
我看看,3x

16,549

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧