Glowing Label

Heres your chance to share your own tutorials with the community. Just post them on here. If your lucky they may even be posted on the main site.
11 posts Page 1 of 2
User avatar
3aaBrSbeel
Top Poster
Top Poster
Posts: 139
Joined: Fri Jun 01, 2012 9:34 am

Glowing Label
3aaBrSbeel
We will be making a Glowing Label not the Blinking Label. Sorry guys, I don't have a deep explanation for this thread. But let me just show you what it is.
4-22-2013 8-47-23 PM.png
As you look closer, you can see the Label is glowing.
Okay, so here it is on how to add the Glowing Label.

First, let's create a new project or just use your current project you are making.
Then, let's add a new class to our project. When you have created a new class, let's now add our code.

First, let's import
Code: Select all
System.Runtime.InteropServices
and
Code: Select all
System.Drawing.Imaging
to our class.
When we have done that, let's add the codes.
Code: Select all
Public Class GlowingLabel
    Inherits Label

    Private _glowColor As Color = Color.White

    Public Overridable Property GlowColor() As Color
        Get
            Return _glowColor
        End Get
        Set(ByVal value As Color)
            _glowColor = value
            Me.Invalidate()
        End Set
    End Property

    Protected Overrides Sub OnPaintBackground(ByVal pevent As System.Windows.Forms.PaintEventArgs)
        MyBase.OnPaintBackground(pevent)

        Using b As New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height)
            Using g As Graphics = Graphics.FromImage(b)
                Dim e As New PaintEventArgs(g, pevent.ClipRectangle)

                Me.OnPaint(e)
            End Using

            BlurImage(b)

            pevent.Graphics.DrawImageUnscaled(b, 0, 0)
        End Using
    End Sub

    <StructLayout(LayoutKind.Explicit)>
    Private Structure ColorArgb
        <FieldOffset(0)> Public Value As Integer
        <FieldOffset(3)> Public A As Byte
        <FieldOffset(2)> Public R As Byte
        <FieldOffset(1)> Public G As Byte
        <FieldOffset(0)> Public B As Byte
    End Structure

    Private Sub BlurImage(ByVal b As Bitmap)
        Const Radius As Integer = 1

        Dim bd As BitmapData = b.LockBits(New Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb)
        Dim arr(bd.Width * bd.Height - 1) As Integer
        Dim arr2(arr.Length - 1) As Integer
        Marshal.Copy(bd.Scan0, arr, 0, arr.Length)
        Marshal.Copy(bd.Scan0, arr2, 0, arr2.Length)

        Dim vals(8) As ColorArgb
        Dim val As ColorArgb
        val.R = Me.GlowColor.R
        val.G = Me.GlowColor.G
        val.B = Me.GlowColor.B

        For i As Integer = 1 To Radius
            For x As Integer = 1 To bd.Width - 2
                For y As Integer = 1 To bd.Height - 2
                    For dX As Integer = -1 To 1
                        For dY As Integer = -1 To 1
                            vals(dY * 3 + dX + 4).Value = arr2((y + dY) * bd.Width + x + dX)
                        Next
                    Next

                    val.A = CByte((From z As ColorArgb In vals Select CInt(z.A)).Sum() \ 9)

                    arr(y * bd.Width + x) = val.Value
                Next
            Next
            If i < Radius Then arr2 = DirectCast(arr.Clone(), Integer())
        Next

        Marshal.Copy(arr, 0, bd.Scan0, arr.Length)
        b.UnlockBits(bd)
    End Sub
End Class
Done? Now, let's debug. After we have debug our project let's check our Toolbox if there is a new Element added.
It's named GlowingLabel. Add that to your new form/current form. You can change the Text Color, if you want to change the Glow Color. Click the Label and in it's properties there is GlowColor, it's default color is White.

Well, that's all. I hope this will be useful in your project. Thanks! loove;

Author here: http://www.vbforums.com/showthread.php? ... g-Controls
You do not have the required permissions to view the files attached to this post.
Last edited by 3aaBrSbeel on Wed Jul 24, 2013 3:37 am, edited 1 time in total.
Code'n'Stuff Signature Of 3aaBrSbeel
®║▌│█│║▌║││█║▌║▌║▌
✔ Verified Official Code'n'Stuff account ᵀᴴᴱ ᴼᴿᴵᴳᴵᴻᴬᴸ
Image
User avatar
AnoPem
VIP - Donator
VIP - Donator
Posts: 441
Joined: Sat Jul 24, 2010 10:55 pm

Re: Glowing Label
AnoPem
Very nice, can it be used on picture ?
https://t.me/pump_upp
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Glowing Label
Dummy1912
sure #AnoPem
just need a few changes and will work :) on a picturebox

even change Inherits Label to Inherits Picturebox
and a few other changes :)
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Glowing Label
Codex
..And the credit goes to http://www.vbforums.com/showthread.php? ... g-Controls
In there they explain how to use it on other controls.
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Re: Glowing Label
smashapps
This is nice but I don't see the glow very well also I think this should probably of been posted in the Snippets section as you don't really explain much. You've told us what you're going to do and then just given us the code.
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
Shim
VIP - Donator
VIP - Donator
Posts: 882
Joined: Wed Dec 14, 2011 5:02 am

Re: Glowing Label
Shim
smashapps wrote:
This is nice but I don't see the glow very well also I think this should probably of been posted in the Snippets section as you don't really explain much. You've told us what you're going to do and then just given us the code.
snippet = piece of code !! so this is not a snippet !

very nice tutorial ! cooll;
Find my programs on Softpedia
User avatar
smashapps
Coding Guru
Coding Guru
Posts: 961
Joined: Tue Apr 05, 2011 8:41 am

Re: Glowing Label
smashapps
It is more of a snippet than a tutorial though. He isn't explaining the code only what the entire thing is.
My name is Tom | Visit my blog where I post new content every day! Tom's Daily Blog | MineCraft is awesome!
User avatar
noypikami
VIP - Donator
VIP - Donator
Posts: 151
Joined: Sat Dec 22, 2012 1:49 am

Re: Glowing Label
noypikami
very nice .............. good work
User avatar
Livengood
Serious Programmer
Serious Programmer
Posts: 444
Joined: Tue Feb 16, 2010 6:24 am

Re: Glowing Label
Livengood
Hmmmm, very interesting ill have to take a look at this.
Image
User avatar
noypikami
VIP - Donator
VIP - Donator
Posts: 151
Joined: Sat Dec 22, 2012 1:49 am

Re: Glowing Label
noypikami
i've tried it,,, its owesome... i changed the glow to red and to any different colors... looks COOL...
11 posts Page 1 of 2
Return to “Tutorials”