Changing Icon like in skype

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.
4 posts Page 1 of 1
Contributors
User avatar
Bogoh67
VIP - Site Partner
VIP - Site Partner
Posts: 656
Joined: Sun Apr 18, 2010 8:20 pm

Changing Icon like in skype
Bogoh67
Introduction:

So as most of you may know when you receive a notification in skype, the icon will show the amount of notifications you have.

Image

Today i will teach you how to achieve such effect.

Tutorial:

1. First of make a picturebox in your application with your image (later you can get rid of it, but for now make it big so you can see your work)

Image

2. Now add a button or find an event in which it will change the icon of the form

Image

3. Now for the code!

3a. First we want to declare the image so write this
Code: Select all
Dim ti As Bitmap = PictureBox1.Image 'Or whatever image you want, could be Me.Icon.ToBitmap
3b. Then declare the variable we want to show on the image
Code: Select all
Dim int As Integer = 1 'Enter your value here
3c. We now get the graphics of the image
Code: Select all
Dim g As Graphics = Graphics.FromImage(ti) 'Gets ti's graphics
3d. Add one more variable, the icon
Code: Select all
Dim ico As Icon 'Icon variable
3e. Ok this is where things get tricky so you will need to adjust this a lot because this is all your preference. This will be the circle which encloses 'int'. I went for a gold background which starts in the bottom left of my picture.
Code: Select all
g.FillEllipse(Brushes.Gold, New Rectangle(New Point(PictureBox1.Size.Width - 40, PictureBox1.Size.Height - 40), New Size(70, 70))) 'This is the circle
3f. Finally we get rid of the graphics
Code: Select all
g.Dispose()
3g. Now we declare what the icon will look like
Code: Select all
ico = Icon.FromHandle(ti.GetHicon)
3h. Set the form's icon as the one we just got
Code: Select all
 Me.Icon = ico 'Sets the new icon
_____________________________________________________________________________________________________________________

End Results:

Your code should now look something like this

Image

Some things people might mention are you don't really need to declare the ico variable. You could just get rid of it and at the end right this
Code: Select all
Me.Icon = Icon.FromHandle(ti.GetHicon)
Here is what i got in the end

Image

Thanks for reading and bye!
User avatar
MrAksel
C# Coder
C# Coder
Posts: 1758
Joined: Fri Mar 26, 2010 12:27 pm

Re: Changing Icon like in skype
MrAksel
I'm sure that Skype uses another, much simpler method. #Agust1337 has already posted a tutorial for .NET Agust1337 - windows 7 taskbar things
LMAOSHMSFOAIDMT
Laughing my a** of so hard my sombrero fell off and I dropped my taco lmao;


Over 30 projects with source code!
Please give reputation to helpful members!

Image
Image
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Changing Icon like in skype
Dummy1912
nice one #Bogoh67 :D looking cool :lol: thanks for sharing.
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
Bogoh67
VIP - Site Partner
VIP - Site Partner
Posts: 656
Joined: Sun Apr 18, 2010 8:20 pm

Re: Changing Icon like in skype
Bogoh67
MrAksel wrote:
I'm sure that Skype uses another, much simpler method. #Agust1337 has already posted a tutorial for .NET Agust1337 - windows 7 taskbar things

Good good point :). I guess this is a way without windows API code pack
4 posts Page 1 of 1
Return to “Tutorials”