Visual studio 2005

G

Guest

Hi All
when I am trying to discover visual studio 2005, I got a strange behavior
when I am trying to put about 50 button on the form and run the application
it makes some flicking in the startup
I tried to avoid flicking by using DoubleBuffered, see this
class InheritedButton:Button
{
public InheritedButton()
{
this.DoubleBuffered = true;
}
}
and I had used InheritedButton instead of button also makes the Form itself
support the DoubleBuffered
and still flickers!!!!!!!!!!!!!!?
 
G

Guest

well no matter how much you buffer 50 buttons, its all dependant on your
system's resources. this then brings up the question of why you have 50
buttons on a single form to begin with....maybe you should rethink your UI
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,

Well with 50 buttons (and possible some other controls as well) you may have
some issues showing the form, especially if y our computer is not powerful
enough.


--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation


"Just close your eyes and see"
 
G

GhostInAK

Hello Just close your eyes and see,

Double buffering applies to a control's graphics painting. Applying double
buffering to the form will not affect the flicker from creating a butt-load
of button controls; The buttons are not part of the form's paint routine.

Before the buttons become visible call the Win32 function LockWindowUpdate,
then release the lock once the layout is done.

-Boo
 
G

Guest

Many thx Boo for your response , I think your answer tends to be the solution
but I still have problems see this code
//////////////////////////////////////////////////////////////////
public class myBut : Button
{
[DllImport("user32.dll")]
static extern bool LockWindowUpdate(IntPtr hWndLock);
public myBut()
{
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
}
protected override void OnPaint(PaintEventArgs pevent)
{
LockWindowUpdate(this.Handle);
base.OnPaint(pevent);
LockWindowUpdate(IntPtr.Zero);
}
}
//////////////////////////////////////////////////////////
I had used this code on my form and still got the problem , even I added
this code to the constructor of the form
///////////////////////////////////////////////////////
public Form1()
{
LockWindowUpdate(this.Handle);
InitializeComponent();
LockWindowUpdate(IntPtr.Zero);
}
/////////////////////////////////////////////////////////
?????????????????????
 

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