The Graphics Object

I l @ ve RuBoard

The root of all GDI+ graphics capabilities for .NET is the Graphics object. This is analogous to the Win32 DC and can be obtained explicitly from a window handle or is passed to your application from, say, the OnPaint event. To obtain a Graphics object in Managed C++, for example, you would write the following code:

 HDC dc; PAINTSTRUCT ps; Graphics *pGraphics; Dc=BeginPaint(hWnd,&ps) pGraphics=new Graphics(dc); // use the Graphics... EndPaint(hWnd,&ps); 

For the purposes of this chapter, we'll assume that GDI+ operations will take place in the context of a Windows Forms application and that the Graphics object is handed to you in an event delegate. For example, we see the Graphics object that's supplied in the PaintEventArgs in the following:

 public void OnPaint(object sender, PaintEventArgs e) {    // use e.Graphics.SomeMethod(...) here 
I l @ ve RuBoard


C# and the .NET Framework. The C++ Perspective
C# and the .NET Framework
ISBN: 067232153X
EAN: 2147483647
Year: 2001
Pages: 204

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net