Badr Hari
Badr Hari

Reputation: 8404

Change window opacity when opening a form

I'm trying to change a Form's opacity automatically before loading. I am using built in Settings function to save the value what opacity the window should have. The problem is, when I'm debugging my application, it all works well, when I compile it and try to open the executable, the window just dissapears... I don't get any errors.

This is how I'm trying to do it:

First there is a value in settings called opacity (int) from 0-100

    private void Form1_Load(object sender, EventArgs e)
    {
        this.Opacity = WindowsFormsApplication1.Properties.Settings.Default.opacity * 0.01;
    }

Upvotes: 3

Views: 1858

Answers (2)

Entity
Entity

Reputation: 8202

Your problem is that the Opacity value has 1.0 as fully visible, and 0.0 as fully invisible. Anything above 1.0 counts as fully visible, too.


EDIT

ok, so after re-reading your question... maybe instead of using the default, use a constant like 0.5 to test it.

Upvotes: 1

Andrew Hanlon
Andrew Hanlon

Reputation: 7421

When you debug, the settings that you save will be kept from run to run. When you deploy, it will copy the default settings file.

Do a check to see if the settings file opacity is actually being loaded correctly when you run the release exe. I have a feeling that either the default is 0, or it's not being loaded.

Upvotes: 2

Related Questions