Results 1 to 2 of 2

Thread: [RESOLVED] How to use the control on label

  1. #1

    Thread Starter
    Banned
    Join Date
    Oct 2009
    Posts
    315

    Resolved [RESOLVED] How to use the control on label

    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: How to use the control on label

    I don't understand what "control on label" means. That code looks like it's intended to fade some text in and/or out. is that what you're trying to do? Have you tried the code? Does it do what you want? If so then you have your answer. If not then what happened that you didn't want or what didn't happen that you did want? Please provide a full and clear explanation of the problem.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width