- Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathbufferingexamples.cpp
76 lines (66 loc) · 2.16 KB
/
bufferingexamples.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#using <System.Drawing.dll>
#using <System.Windows.Forms.dll>
#using <System.dll>
usingnamespaceSystem;
usingnamespaceSystem::ComponentModel;
usingnamespaceSystem::Drawing;
usingnamespaceSystem::Windows::Forms;
usingnamespaceSystem::Security::Permissions;
public ref classBufferingExamples: publicForm
{
private:
BufferedGraphicsContext^ appDomainBufferedGraphicsContext;
BufferedGraphics^ grafx;
public:
[SecurityPermission(SecurityAction::Demand, Flags=SecurityPermissionFlag::UnmanagedCode)]
BufferingExamples() : Form()
{
//<Snippet1>
// Retrieves the BufferedGraphicsContext for the
// current application domain.
BufferedGraphicsContext^ appDomainGraphicsContext =
BufferedGraphicsManager::Current;
//</Snippet1>
appDomainGraphicsContext->MaximumBuffer = System::Drawing::Size( 400, 400 );
appDomainBufferedGraphicsContext = BufferedGraphicsManager::Current;
//<Snippet2>
// Sets the maximum size for the graphics buffer
// of the buffered graphics context. Any allocation
// requests for a buffer larger than this will create
// a temporary buffered graphics context to host
// the graphics buffer.
appDomainBufferedGraphicsContext->MaximumBuffer = System::Drawing::Size( 400, 400 );
//</Snippet2>
//<Snippet3>
// Allocates a graphics buffer using the pixel format
// of the specified Graphics object.
grafx = appDomainBufferedGraphicsContext->Allocate( this->CreateGraphics(),
Rectangle( 0, 0, 400, 400 ) );
//</Snippet3>
//<Snippet4>
// Allocates a graphics buffer using the pixel format
// of the specified handle to a device context.
grafx = appDomainBufferedGraphicsContext->Allocate( this->Handle,
Rectangle( 0, 0, 400, 400 ) );
//</Snippet4>
}
//<Snippet5>
private:
voidRenderToGraphics( Graphics^ g )
{
grafx->Render( g );
}
//</Snippet5>
//<Snippet6>
private:
voidRenderToDeviceContextHandle( IntPtr hDC )
{
grafx->Render( hDC );
}
//</Snippet6>
};
[STAThread]
intmain()
{
Application::Run( gcnew BufferingExamples );
}