Custom "Skin" for your forms

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.
43 posts Page 1 of 5
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Custom "Skin" for your forms
CodenStuff
Hello,

A few of you seem to be asking how to make a form with round edges and skin/theme and I think I have made a tutorial about this somewhere I cant seem to find it :? . I decided to write another one and explain how its done.

The first thing you need to do is open up our chosen paint software (I use microsoft paint as my choice) and start a new image. Your image dimensions need to be the same size as your form so make sure you set its size before you get started.

Then you get to work on creating our forms custom skin and for this example I just draw some basic shapes to show you:
sshot-21.png
Once you are happy with your design you need to choose a color that will become transparent when your application is run. I always use the color purple and have done so for this example. Once you have chosen your transparent color use it to fill in the areas of your skin that you dont want to show up when you run your application:
sshot-18.png
Now go into VB and change the followin properties on your form:

TransparencyKey - Change this to your transparent color (In my case I change it to purple)
FormBorderStyle - Change this to "None"
BackgroundImage - Change this to the skin you have just created.
Size - Make sure this is the same size as you skin
sshot-19.png
Thats the hard part done and we now move onto the code that will let you move your form.

Underneath "Public Class Form" add this code:
Code: Select all
Public Const WM_NCLBUTTONDOWN As Integer = &HA1
    Public Const HTCAPTION As Integer = &H2
    <Runtime.InteropServices.DllImport("User32.dll")> _
    Public Shared Function ReleaseCapture() As Boolean
    End Function
    <Runtime.InteropServices.DllImport("User32.dll")> _
    Public Shared Function SendMessage(ByVal hWnd As IntPtr, ByVal Msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
    End Function
Then in the "Form_MouseDown" event add this code:
Code: Select all
If e.Button = MouseButtons.Left Then
            ReleaseCapture()
            SendMessage(Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0)
        End If
Build and run your project to see the results. If you did it all correctly then when you run your application it should look something like this:
sshot-20.png
Thats it your finished!!

You can do different designs of almost anything you want like one with round edges:
sshot-22.png
Or even a weird splatter shaped form:
sshot-23.png

These are the project files for this tutorial
Download:
CustomForm.zip
Happy coding! cooll;
You do not have the required permissions to view the files attached to this post.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
TheET
VIP-Member
VIP-Member
Posts: 105
Joined: Sun Nov 01, 2009 2:41 am

Re: Custom "Skin" for your forms
TheET
WOW ! THank you very much ! I love this !

You are the best ! Woohoo Codenstuff rocks!!!!!!!
User avatar
TheET
VIP-Member
VIP-Member
Posts: 105
Joined: Sun Nov 01, 2009 2:41 am

Re: Custom "Skin" for your forms
TheET
I try it but it still show a little bit purple , how can i remove that?
User avatar
Nery
Co-Admin Moderator
Co-Admin Moderator
Posts: 1117
Joined: Mon Sep 07, 2009 8:11 pm

Re: Custom "Skin" for your forms
Nery
Yes, its a mistery, everytime you use that method, on the borders, you can see a line of your background color.
User avatar
Robby
VIP - Donator
VIP - Donator
Posts: 417
Joined: Mon Aug 03, 2009 4:01 am

Re: Custom "Skin" for your forms
Robby
wow that is realli good. I GUESS NOW can make a templte so i ca use tht
My current Projects Listed Below:
Toixt++ Text Editor Just 10 or less more features to go!
Image
Image
NoWayIn
VIP - Donator
VIP - Donator
Posts: 444
Joined: Sat Nov 21, 2009 11:16 pm

Re: Custom "Skin" for your forms
NoWayIn
All I do is add a skin or picture, make it the same size and done :P
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4392
Joined: Tue Aug 04, 2009 1:47 am

Re: Custom "Skin" for your forms
CodenStuff
Hello,

Sometimes it still shows part of the transparent color on the edges I dont know why, mainly happens on curves.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
MasterCoding
Top Poster
Top Poster
Posts: 156
Joined: Sat Oct 24, 2009 4:26 pm

gerryhill welcome to codenstuff
User avatar
tvs praveen
Top Poster
Top Poster
Posts: 205
Joined: Tue Dec 08, 2009 6:20 am

Re: Custom "Skin" for your forms
tvs praveen
Hi, This tutorial is too helpful to me to create transparent splash screen background for my superb TV Broadcast, TV Playout Software!, Power TV Magic Express 18.2

Tell me do you like it or not? ;)

Image
User avatar
Usman55
VIP - Site Partner
VIP - Site Partner
Posts: 2821
Joined: Thu Dec 24, 2009 7:52 pm

Re: Custom "Skin" for your forms
Usman55
Hello TVS Praveen!

It is just great! I wonder how people like Hungryhounduk (and you too) make designs like this? But whatever I say, this is wonderful!

Thanks for sharing!
Image
43 posts Page 1 of 5
Return to “Tutorials”