[C#]Transparant form

Posts 1–5 of 5 · Page 1 of 1
[C#]Transparant form
Open MSVC# and create a new windows application

From your toolbox add
- 3 buttons

In the properties of each button, change the names respectively

Button1 Name = Hide
Button2 Name = UnHide
Button3 Name = Exit

Note: For quick keys, you can add the '&' symbol infront of a character in the CAPTION of the button which will allow Alt + key (where key is the character after the '&' Symbol)

Example:

Button1 Caption = &Hide
Button2 Caption = &Unhide
Button3 Caption = E&xit

This will allow the user to press alt + H to hide the form, Alt + U To Unhide the form and Alt + X to exit the application.

Now change the form's FormBorderStyle propertie to "None"
This will remove the border from the form.
You can do it by selecting the main form and chosing it from the properties, or you can do it by making your applications 'public Form1()' look like this:
Code:
    public Form1()
    {
        this.FormBorderStyle = FormBorderStyle.None;
        InitializeComponent();
    }
Now that that is out of the way, double click each of your buttons in the form editor to have MSVC# generate the ButtonName_OnClick event for you.

Code:
    private void Hide_Click(object sender, EventArgs e)
    {
            
    }

    private void Unhide_Click(object sender, EventArgs e)
    {

    }

    private void Exit_Click(object sender, EventArgs e)
    {

    }
Now add the following code to your Hide button's OnClick event:

Code:
TransparencyKey = BackColor;
The code below goes in your Unhide button's OnClick event:
Code:
TransparencyKey = Color.White;
And the final piece of code goes in the Exit button's OnClick event:
Code:
Dispose();
That's it, it's that simple.

Credits go to:
tremaster
NextGen1

Attached is the sample project
TransparantForm.rarattachment deleted · 18 downloads before removal
Looks good, thanks for the creds.

Why I get credits..?
Quote Originally Posted by NextGen1 View Post
Looks good, thanks for the creds.

Why I get credits..?
You made the 'tutorial' *cough*fkn ugly post that contained nothing more then the word TransparancyKey*cough* into a nice looking tut
Ha Ha m Awesome
Quote Originally Posted by NextGen1 View Post
Ha Ha m Awesome
Totally agreed
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us