custom double buffering [modified]
-
public void tab_Paint(object sender, PaintEventArgs e) { TabPage tab = (TabPage)sender; BufferedGraphicsContext context; BufferedGraphics buffer; // context = BufferedGraphicsManager.Current; /// Dedicated context /// used when highly animated graphics context = new BufferedGraphicsContext(); Graphics grfx = e.Graphics; buffer = context.Allocate(grfx, tab.ClientRectangle); // draw to the buffer drawSurfaceToBuffer(buffer.Graphics); // draw the buffer to the screen buffer.Render(grfx); buffer.Dispose(); grfx.Dispose(); } public void drawSurfaceToBuffer(Graphics bufferGrfx) { /// some processing that used the buffer grfxs }
this code i understand it from MSDN and write it to reduce Graphics Flicker but it does not make any thing at all also it make my background of tabpage black and the original is white is there any suggestions please Generator -- modified at 10:59 Tuesday 1st May, 2007 -
public void tab_Paint(object sender, PaintEventArgs e) { TabPage tab = (TabPage)sender; BufferedGraphicsContext context; BufferedGraphics buffer; // context = BufferedGraphicsManager.Current; /// Dedicated context /// used when highly animated graphics context = new BufferedGraphicsContext(); Graphics grfx = e.Graphics; buffer = context.Allocate(grfx, tab.ClientRectangle); // draw to the buffer drawSurfaceToBuffer(buffer.Graphics); // draw the buffer to the screen buffer.Render(grfx); buffer.Dispose(); grfx.Dispose(); } public void drawSurfaceToBuffer(Graphics bufferGrfx) { /// some processing that used the buffer grfxs }
this code i understand it from MSDN and write it to reduce Graphics Flicker but it does not make any thing at all also it make my background of tabpage black and the original is white is there any suggestions please Generator -- modified at 10:59 Tuesday 1st May, 2007I think this code is meant to reduce flicker for user-painted graphics. If you're just putting controls onto the tabpage and seeing flickering whenever you move/resize, this code won't help you at all, and might actually slow you down. You might just have too many controls, which leads to too much layout logic. I would suggest trying to limit the number of controls and nested containers. For instance, putting panels inside panels inside panels, each with their own anchors, docks, and layout engines, will really slow you down whenever you resize.
-
public void tab_Paint(object sender, PaintEventArgs e) { TabPage tab = (TabPage)sender; BufferedGraphicsContext context; BufferedGraphics buffer; // context = BufferedGraphicsManager.Current; /// Dedicated context /// used when highly animated graphics context = new BufferedGraphicsContext(); Graphics grfx = e.Graphics; buffer = context.Allocate(grfx, tab.ClientRectangle); // draw to the buffer drawSurfaceToBuffer(buffer.Graphics); // draw the buffer to the screen buffer.Render(grfx); buffer.Dispose(); grfx.Dispose(); } public void drawSurfaceToBuffer(Graphics bufferGrfx) { /// some processing that used the buffer grfxs }
this code i understand it from MSDN and write it to reduce Graphics Flicker but it does not make any thing at all also it make my background of tabpage black and the original is white is there any suggestions please Generator -- modified at 10:59 Tuesday 1st May, 2007In the 2.0 Framework there was a lot of work incorporating Double Buffering into the framework. For the form that holds the flickering control, try adding this at initialization time:
this.SetStyle( ControlStyles.OptimizedDoubleBuffer ); this.SetStyle( ControlStyles.AllPaintingInWmPaint );
These two settings go hand-in-hand. Also when loading controls on the tab,
this.TabControl.SuspendLayout(); LoadControl(TabControl); this.TabControl.ResumeLayout();
-
In the 2.0 Framework there was a lot of work incorporating Double Buffering into the framework. For the form that holds the flickering control, try adding this at initialization time:
this.SetStyle( ControlStyles.OptimizedDoubleBuffer ); this.SetStyle( ControlStyles.AllPaintingInWmPaint );
These two settings go hand-in-hand. Also when loading controls on the tab,
this.TabControl.SuspendLayout(); LoadControl(TabControl); this.TabControl.ResumeLayout();
hi , i can not find a method called LoadControl() thanx Generator
-
hi , i can not find a method called LoadControl() thanx Generator
:laugh: That was just shorthand in the example. :laugh: That is where you are loading the controls into the new tab. Basically you suspend layout, load the controls, resumelayout and then the TabControl displays the controls all at once. Did you ever look at the Window Generated code for a form??? Look at it. This is what is standard code when a design-time-generated form is populated. Look at the code as an example and follow it. :cool:
-
:laugh: That was just shorthand in the example. :laugh: That is where you are loading the controls into the new tab. Basically you suspend layout, load the controls, resumelayout and then the TabControl displays the controls all at once. Did you ever look at the Window Generated code for a form??? Look at it. This is what is standard code when a design-time-generated form is populated. Look at the code as an example and follow it. :cool:
hi , ok i looked at the generated code but i use setstyle before and no change on tab just change on form so what can i do explain please "Iam sorry but i didnot get the point" Generator -- modified at 3:35 Saturday 5th May, 2007 Generator
-
hi , ok i looked at the generated code but i use setstyle before and no change on tab just change on form so what can i do explain please "Iam sorry but i didnot get the point" Generator -- modified at 3:35 Saturday 5th May, 2007 Generator
hi all, first thanx for ur help second a friend to me solve our problem of double buffered as follows class customTabPage : TabPage { customTabPage():base() { this.DoubleBuffered = true; } } Generator