C#最佳方法屏幕变暗,多个Windows窗体? [英] C# Best Method to Dim Screen, Multiple Windows Forms?

查看:282
本文介绍了C#最佳方法屏幕变暗,多个Windows窗体?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,我编写的代码,以创建即全屏,黑色和80%的不透明度来创建一个调光效果父一个新的Windows窗体。

So I've written code to create a new Windows form from the parent that is fullscreen, black and opacity of 80% to create a dimming effect.

然后。其它的形式表示这上面显示进度

Then another form is shown above this to show progress.

目前的代码看起来像这样:

The code is currently looking like this:

    this.Enabled = false;

    frmDimScreen.BackColor = Color.Black;
    frmDimScreen.Opacity = .8;
    frmDimScreen.FormBorderStyle = FormBorderStyle.None;
    frmDimScreen.Size = new Size(splitContainerMain.Width - 4, splitContainerMain.Height - 2);
    frmDimScreen.StartPosition = FormStartPosition.Manual;
    frmDimScreen.ShowIcon = false;
    frmDimScreen.ShowInTaskbar = false;
    frmDimScreen.Show();
    frmDimScreen.Location = new Point(splitContainerMain.Location.X + 2,         ((splitContainerMain.Location.Y + tsMainTools.Height) - 4));

    addImgIL.ShowIcon = false;
    addImgIL.ShowInTaskbar = false;
    addImgIL.TopMost = true;
    addImgIL.Show();
    addImgIL.Location = new Point((this.Width - addImgIL.Width) / 2, (this.Height -         addImgIL.Height) / 2);
    addImgIL.BringToFront();



Obvioulsy我质疑这是,如果父窗口失去焦点的主要原因,那么孩子的形式走出秩序和不分层正确。我知道我可以通过OnPaint中处理这个问题,但在寻找最佳的解决方案。

Obvioulsy the main reason I'm questioning this is if the parent window loses focus, then the child forms get out of order and are not layered correctly. I know I can handle this via OnPaint, but looking for the best solution.

问题/问题,这是实现我所尝试的最好方法?我应该用表格或图形来创建调光?什么是每个人有这样的经历?

The question/problem, is this the best method to achieve what I am attempting? Should I be using forms or graphics to create the dimming? What's everyones experience with this?

在此先感谢!

推荐答案

只使用一个单一的窗口的另一种方法是使用一个alpha混合图像绘制透明黑暗的背景(甚至可以有一个梯度)用非透明的自定义绘制进度条。请参见 http://www.codeproject.com/KB/GDI-plus/perpxalpha_sharp。 ASPX

Another approach using only a single window would be to use an alpha blended image to draw the transparent dark background (you could even have a gradient) with a non-transparent custom drawn progress bar. See http://www.codeproject.com/KB/GDI-plus/perpxalpha_sharp.aspx .

在该项目中,你可以找到一个类,您可以用它来轻松地分配一个alpha混合位图,以表格的背景。这种方法的问题是,你必须自定义窗体上绘制的一切,包括你需要它的进度条或任何其他控件。

In that project you can find a class that you can use to easily assign an alpha blended Bitmap to a form's background. The problem with this method is that you must custom draw everything on the form, including the progress bar or whatever other controls you need on it.

这是你正在尝试的影响实现是一个Windows应用程序一种不同寻常的,这就是为什么最好的方法是不是很简单。

The effect that you are trying to achieve is kind of unusual for a windows application, that is why the best method is not very straightforward.

这篇关于C#最佳方法屏幕变暗,多个Windows窗体?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆