打开表单时更改窗口不透明度

发布于 2024-09-29 03:03:53 字数 380 浏览 2 评论 0原文

我试图在加载之前自动更改表单的不透明度。 我正在使用内置的设置功能来保存窗口应具有的不透明度值。 问题是,当我调试我的应用程序时,一切正常,当我编译它并尝试打开可执行文件时,窗口就消失了......我没有收到任何错误。

这就是我尝试这样做的方法:

首先,设置中有一个名为 opacity (int) 的值,范围为 0-100

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

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;
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

丿*梦醉红颜 2024-10-06 03:03:53

调试时,您保存的设置将在每次运行时保留。部署时,它将复制默认设置文件。

检查运行发行版 exe 时设置文件不透明度是否确实正确加载。我有一种感觉,要么默认为 0,要么没有被加载。

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.

梦冥 2024-10-06 03:03:53

您的问题是,不透明度值 1.0 表示完全可见,0.0 表示完全不可见。任何高于 1.0 的内容也都算作完全可见。


编辑

好的,所以在重新阅读你的问题之后...也许不使用默认值,而是使用像 0.5 这样的常量来测试它。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文