Hi guys,
I would like to know which method that I could use the code to control on label?
Here it is the code:
Code:Public Class Form1 Private Const FADESPEED As Integer = 20 Private Structure FadeLabel Dim Color As Color Dim Alpha As Byte Dim X, Y As Integer Dim Text As String Dim Font As Font Public Sub New(ByVal text As String, ByVal color As Color, ByVal x As Integer, ByVal y As Integer, ByVal font As Font) Me.Text = text Me.Color = color Me.Alpha = 255 Me.X = x Me.Y = y Me.Font = font End Sub End Structure Dim lbl As FadeLabel = New FadeLabel("Test label", Color.Blue, 20, 20, New Font("Verdana", 15)) Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick If lbl.Alpha - FADESPEED >= 0 Then lbl.Alpha -= FADESPEED Else FadeDone() Me.Invalidate() End Sub Private Sub FadeDone() Me.Timer1.Stop() lbl.Alpha = 0 End Sub Protected Overrides Sub OnPaint(ByVal e As System.Windows.Forms.PaintEventArgs) Dim g As Graphics = e.Graphics g.DrawString(lbl.Text, lbl.Font, New SolidBrush(Color.FromArgb(lbl.Alpha, lbl.Color)), lbl.X, lbl.Y) MyBase.OnPaint(e) End Sub End Class
I hope that it is still possible to use the code to control on label. If so, please could you tell me what I need to replace with.
Thanks,
Mark


Reply With Quote
