I have a form that has some controls on itself(btnCreateReport,pnlDarkLayer).I have a panel that fit to form(Dock = Fill) and it is on the back of all controls.when user click on the btnCreateReport button ,I call pnlDarkLayer BringToFront method and after some calculation I call SendToBack() method of the button.I want to draw a dark layer on form controls and disable all of controls on the form.
Is it possible? Thanks.
Maybe this code help u to understand my purpose:
private void btnCreateReport_Click(object sender, EventArgs e)
{
pnlDarkLayer.BackColor = Color.FromArgb(100, Color.Gray);
pnlDarkLayer.BringToFront();
btnCreateReport.Enabled = false;
Thread ProcessReport = new Thread(new ThreadStart(ProcessingReport));
ProcessReport.Start();
while (ProcessReport.IsAlive)
{
Application.DoEvents();
}
pnlDarkLayer.SendToBack();
btnCreateReport.Enabled = true;
}
This code hide all of controls but i don’t want to hide controls on the form.I want to draw a dark layer on them.And User must can see controls.
I need something like opacity property of forms for their controls.
I have test this:
pnlDarkLayer.CreateGraphics().CompositingMode=System.Drawing.Drawing2D.CompositingMode.SourceOver;
Update: I have test this one: (use a form instead of panel)
private void btnCreateReport_Click(object sender, EventArgs e)
{
btnCreateReport.Enabled = false;
frmProgress ProgressForm = new frmProgress();
ProgressForm.TopLevel = false;
ProgressForm.Parent = this;
ProgressForm.BringToFront();
this.Controls.Add(ProgressForm);
ProgressForm.Show();
Thread ProcessReport = new Thread(new ThreadStart(ProcessingReport));
ProcessReport.Start();
while (ProcessReport.IsAlive)
{
Application.DoEvents();
}
ProgressForm.Close();
btnCreateReport.Enabled = true;
}
But I can’t see the ProgressForm in my form.
From
http://support.microsoft.com/kb/943454The page also provides a code example (in vb, sadly) to show how this is done.