运行此代码,在对话框打开时通过我的应用程序创建BMP,以减少用户对无法访问的内容的混淆(直到对话框关闭)。
Bitmap bmp = new Bitmap(DisplayRectangle.Width, DisplayRectangle.Height);
using (Graphics G = Graphics.FromImage(bmp))
{
G.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceOver;
G.CopyFromScreen(this.PointToScreen(new Point(0, 0)), new Point(0, 0), this.DisplayRectangle.Size);
double percent = 0.60;
Color darken = Color.FromArgb((int)(255 * percent), Color.Black);
using (Brush brsh = new SolidBrush(darken))
{
G.FillRectangle(brsh, this.DisplayRectangle);
}
}
// put the darkened screenshot into a Panel and bring it to the front:
using (Panel p = new Panel())
{
p.Location = new Point(0, 0);
p.Size = this.ClientRectangle.Size;
p.BackgroundImage = bmp;
this.Controls.Add(p);
p.BringToFront();
// display your dialog somehow:
frmcollecting frmcollecting = new frmcollecting(pxid);
frmcollecting.ShowDialog();
问题在于它创建了面板上的bmp(pnlActive),但我希望它在整个应用程序上。 如何获得尺寸并将DisplayRectangle更改为“frmMainPage”?
Ty求助