enable full background transparency png in form

0

Well I have a C # form, but I use a png render, which contains shadows and smoke effects, the only way I found it to give transparency was the key, but it does not look totally transparent, example image below. / p>

I wanted to know if there is any way to make it completely transparent.

    
asked by anonymous 02.04.2018 / 12:24

1 answer

0

You can cancel the event where BackGround is painted and fill with an image like this:

public SeuForm()
{
    InitializeComponent();
    FormBorderStyle = FormBorderStyle.None;
    StartPosition = FormStartPosition.CenterScreen;
}
protected override void OnPaintBackground(PaintEventArgs e)
{
    //Definir sua imagem.
    Image newImage = Properties.Resources
        ._0_cKbBcUPJTfpFwuQi_;

    //Posição e tamanho da imagem
    //Aconselho deixar o seu form do tamanho da imagem já design time, para facilitar o desenvolvimento
    //ou pode setar os tamanhos do form para o da imagem pelo codigo tambem(ex: this.Width = newImage.Width;)

    //Caso deseje centralizar a imagem automaticamente:
    //x = (Width - newImage.Width) / 2; y = (Height - newImage.Height) / 2;
    int x = 100;
    int y = 100;

    //Desenhar imagem
    e.Graphics.DrawImage(newImage, x, y, width, height);
}

It's not a good practice, but I do not see another way to achieve the result you want in WF.

    
02.04.2018 / 20:26