Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Note that WM_SetRedraw = 0XB
- // Suspend drawing.
- UnsafeSharedNativeMethods.SendMessage(handle, WindowMessages.WM_SETREDRAW, IntPtr.Zero, IntPtr.Zero);
- ...
- // Resume drawing.
- UnsafeSharedNativeMethods.SendMessage(handle, WindowMessages.WM_SETREDRAW, new IntPtr(1), IntPtr.Zero);
- SetStyle(ControlStyles.OptimizedDoubleBuffer |
- ControlStyles.AllPaintingInWmPaint, true);
- BufferedGraphicsContext gfxManager;
- BufferedGraphics gfxBuffer;
- Graphics gfx;
- private void InstallGFX(bool forceInstall)
- {
- if (forceInstall || gfxManager == null)
- {
- gfxManager = BufferedGraphicsManager.Current;
- gfxBuffer = gfxManager.Allocate(this.CreateGraphics(), new Rectangle(0, 0, Width, Height));
- gfx = gfxBuffer.Graphics;
- }
- }
- protected override void OnPaint(PaintEventArgs e)
- {
- InstallGFX(false);
- // .. use gfx to draw
- gfxBuffer.Render(e.Graphics);
- }
- protected override void OnSizeChanged(EventArgs e)
- {
- base.OnSizeChanged(e);
- InstallGFX(true); // to reallocate drawing space of new size
- }
- using System;
- using System.Collections.Generic;
- using System.Text;
- using System.Windows.Forms;
- namespace myNameSpace.Forms.UserControls
- {
- public class TableLayoutPanelNoFlicker : TableLayoutPanel
- {
- public TableLayoutPanelNoFlicker()
- {
- this.DoubleBuffered = true;
- }
- }
- }
Add Comment
Please, Sign In to add comment