Dear all
What i would like to achieve is placing something like a glass panel over the form while is doing some processing and show a proress bar. Little something like that , which would informa the user that something is happening:)
Any ideas or advice Is there any code examples
Cheers

Put a glass panel over form while processing?
Frank Miller
It seems to have alot to do with the alpha blending. The lower the alpha, the greater its apparent need to redraw.
Andrey M.
You could add the following control to your form. Just change Visibility and BringToFront as needed.
class EventBlockPanel : Panel
{
protected override CreateParams CreateParams
{
get
{
CreateParams cp = base.CreateParams;
cp.ExStyle += 0x20;
return cp;
}
}
protected override void OnPaintBackground(PaintEventArgs e)
{
//base.OnPaintBackground(e);
this.Parent.Invalidate(this.ClientRectangle);
}
protected override void OnPaint(PaintEventArgs e)
{
//base.OnPaint(e);
using (SolidBrush paintBrush = new SolidBrush(Color.FromArgb(32, 128, 128, 128)))
{
e.Graphics.FillRectangle(paintBrush, this.ClientRectangle);
}
}
}
Thomas LEBRUN
Where i got the original idea from was on one of the asp.net forums.
There is one controll that you can notice urself when you try and make a post. What it does is when selecting the category for your post it pops up a box for making a selection. But at the same time everything in the backround is bloacked. So the users atention is focused on making a selection. So what i thought might be a useful concept if we apply the same thing on the windows forms. Users in general in the organisation where i work try to wonder around and click arund while the processing is done. And if there is not some notification that the processing is taking place they will continue clicking the PROCESS button million times. I know that just disabling that button while the processing goes is the easiest solution, but why not something better then that.
What is your general opinion on this
Cheers
ziman
I would probably opt to show a Modal Dialog.
Giritharan
Hmm.
biscuithead
I don't see Flickering, but I do see an obvious Paint from Top to Bottom depending on the size of the control.
You would get better results using GDI instead of GDI+, but I can't get a 32BppPargb BackBuffer bitmap to bitblt to the surface correctly.
Perhaps someone with more of an idea on BitBlt can help with this task.
Suby786
I've had a brief search around and it seems a glass panel is not easy. Due to the nature of Winforms, any control behind the panel will be hidden so transparency will not work. You'd have to manually iterate through all your controls and draw them (with transparency) onto the panel, which could become very processor intensive.
I think your best (read easiest) option will be to iterate through all your controls and disable them. Then when the progress completed do the same to re-enable them. I've done a quick example with a timer to show you what I mean:
private void button1_Click(object sender, EventArgs e)
{
foreach (Control c in Controls)
{
c.Enabled = false;
}
timer1.Start();
}
private void timer1_Tick(object sender, EventArgs e)
{
foreach (Control c in Controls)
{
c.Enabled = true;
}
timer1.Stop();
}
Bulldog.NET
(2) It should be cp.ExStyle |= 0x20;
(ie use the OR operator rather than adding it.)
William Bartholomew
This control is ideal for the use outlined in the original question, but is no good as an interactive control.
This control must Paint it's Parent and every child of it's Parent to it's Background before it paints itself. This is why you see Flicker when trying to use it as a Transparent Control.
For Shaped Controls, you should be using Regions to cut away the transparent parts. See the example on my site to create a shaped Control:
http://www.dotnetrix.co.uk/custom.html
spartakiran
Nice one. Could you explain this:
cp.ExStyle += 0x20;
andien_geo
David d48701
something fancy like that
a transparent would be good.....what i would like to is to block all the buttons and the user cant click on them......maybe not 100% transparent. and the progress bar would be notifying them how far in the process we are. and when it is finished the buttons would become active again
cheers
Little
Why not use another form rather than a panel. Set the opacity to 1%, give it the same text, size and location as the form doing the processing.
You could also make it TopMost if you wanted to be really annoying.
Esterill
Correct on both counts: