Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
BufferedGraphicsContext Class

Provides methods for creating graphics buffers that can be used for double buffering.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)
Visual Basic (Declaration)
Public NotInheritable Class BufferedGraphicsContext _
    Implements IDisposable
Visual Basic (Usage)
Dim instance As BufferedGraphicsContext
C#
public sealed class BufferedGraphicsContext : IDisposable
Visual C++
public ref class BufferedGraphicsContext sealed : IDisposable
JScript
public final class BufferedGraphicsContext implements IDisposable

The BufferedGraphicsContext class allows you to implement custom double buffering for your graphics. Graphics that use double buffering can reduce or eliminate flicker that is caused by redrawing a display surface.

NoteNote:

The simplest way to use double buffering is to set the OptimizedDoubleBuffer control style flag on a control using the SetStyle method. Setting the OptimizedDoubleBuffer control styles flag for a control redirects all painting for the control through a default graphics buffer, without requiring any additional code. This flag is set to true by default.

The BufferedGraphicsContext class provides methods for creating and configuring a graphics buffer. The Allocate method creates a BufferedGraphics, which is a wrapper for a graphics buffer that also provides methods you can use to write to the buffer and render its contents to an output device.

You can retrieve the BufferedGraphicsContext for the current application domain from the static BufferedGraphicsManager..::.Current property. For graphically intensive applications such as animation, you can create a dedicated BufferedGraphicsContext using the constructor, but for most applications the BufferedGraphicsManager..::.Current property will be sufficient.

For more information on drawing buffered graphics and custom buffering implementations, see Double Buffered Graphics and How to: Manually Manage Buffered Graphics.

The following code example demonstrates how to acquire the BufferedGraphicsContext for the current application domain. This code is part of a larger example provided for the BufferedGraphics class.

Visual Basic
' Retrieves the BufferedGraphicsContext for the 
' current application domain.
Dim appDomainGraphicsContext As BufferedGraphicsContext = BufferedGraphicsManager.Current

C#
// Retrieves the BufferedGraphicsContext for the 
// current application domain.
BufferedGraphicsContext appDomainGraphicsContext = 
     BufferedGraphicsManager.Current;

Visual C++
// Retrieves the BufferedGraphicsContext for the 
// current application domain.
BufferedGraphicsContext^ appDomainGraphicsContext =
   BufferedGraphicsManager::Current;

System..::.Object
  System.Drawing..::.BufferedGraphicsContext
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker