Flickers

  • Thread starter Alhambra Eidos Kiquenet
  • Start date
A

Alhambra Eidos Kiquenet

Hi all,

We have a windows forms application with different controls used
inside, each control has several input items such as textboxes , custom
labels, user controls, and some treeviews.. etc.


We have been trying to eliminate flickering issues when loading different
controls or switching to different views with no luck, and have been trying
different suggested methods to get rid of the flickering such as:
- this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SuspendItemsLayout();
- ResumeItemsLayout();


Unfortunately using the above code in each control or the main form
didn't help too, I'm wondering desperately if there is another way to
fix this annoying problem?


FYI: We are using Visual Studio 2005 Team Suite SP2/ .NET 2.0 running on
mainly
Windows XP Professional SP2 on 3.20 GHz multithreaded CPU and 1GB RAM.


Thanks for your help. Regards, greetings
 
U

Udo Nesshoever

=== original message ===
from: Alhambra Eidos Kiquenet
date: 01.08.2008 09:49
Hi all,

We have a windows forms application with different controls used
inside, each control has several input items such as textboxes , custom
labels, user controls, and some treeviews.. etc.


We have been trying to eliminate flickering issues when loading different
controls or switching to different views with no luck, and have been trying
different suggested methods to get rid of the flickering such as:
- this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SuspendItemsLayout();
- ResumeItemsLayout();


Unfortunately using the above code in each control or the main form
didn't help too, I'm wondering desperately if there is another way to
fix this annoying problem?

Did you try the simple 'DoubleBuffer = true;'

Cheers,
Udo
 
P

Pavel Minaev

 Hi all,

We have a windows forms application with different controls used
inside, each control has several input items such as textboxes , custom
labels, user controls, and some treeviews.. etc.

We have been trying to eliminate flickering issues when loading different
controls or switching to different views with no luck, and have been trying
different suggested methods to get rid of the flickering such as:
- this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
- this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
- SuspendItemsLayout();
- ResumeItemsLayout();

Unfortunately using the above code in each control or the main form
didn't help too, I'm wondering desperately if there is another way to
fix this annoying problem?

One dangerous trick is to use P/Invoke to send WM_SETREDRAW message to
enable/disable redrawing for a specific control. You disable redrawing
before a batch of updates, and enable them once you're done. Something
like this:

internal const int WM_SETREDRAW = 0x000B;

[DllImport("user32", CharSet = CharSet.Auto)]
internal static extern IntPtr SendMessage(IntPtr hWnd, int
msg, int wParam, IntPtr lParam);

void UpdatingMethod()
{
try
{
SendMessage(control.Handle, Win32.WM_SETREDRAW, 0,
IntPtr.Zero);
// Perform your updates here
...
}
finally
{
SendMessage(control.Handle, Win32.WM_SETREDRAW, 1,
IntPtr.Zero);
}
}
 
A

Alhambra Eidos Kiquenet

What about window form designer code ?? This code has method like
SuspendLayout and others , how can I do updates of control with my custom
control ?

any sample, please ?

Thanks.
 
P

Pavel Minaev

What about window form designer code ??

What about it? Flicker typically occurs when you're updating a large
number of controls on the form; whether they were created in the
designer or by hand is entirely irrelevant. You can get the handle of
the entire form, or of a specific panel with controls, by using its
Handle property; and then just do the trick I've described above.
any sample, please ?

Since we have no idea what exactly you're doing that's causing the
flicker - since you haven't posted any code - there isn't much that
can be added.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top