As I understand it, graphics is an intermediary between device context and your drawing conetent. It stores the relevant properties of the device context, as well as the properties of the drawing content. In this way, it can "map" drawing content to device content in its own way.
The drawing work in GDI is done directly on device context. In gdi-+, you need to create a graphics on the device context, and then call the graphics related methods to complete the drawing work.
The graphics class has four constructors:
Static graphics* FROMHDC (in hdc hdc) { return new Graphics (HDC); } Static graphics* FROMHDC (in HDC hdc, in HANDLE hdevice) { return new Graphics (HDC, hdevice); } Static graphics* Fromhwnd (in HWND hwnd, in BOOL ICM = FALSE) { return new Graphics (HWND, ICM); } static graphics* fromimage (in Image *image) { return new Graphics (image); }
Constructor 1 creates a graphics class from the Image object. This method allows you to manipulate a bitmap by using the Grapgics method after opening a sheet or creating a bitmap.
Constructor 2 Gets a graphics object from a traditional hdc and takes over the traditional operations done in HDC.
Constructor 3 allows you to create an instance of a graphics class that is bound to a particular device.
Constructor 4 allows you to directly get a graphics class instance directly from a specific window hwnd.
Reprint Address: http://www.cppblog.com/dingding/archive/2008/06/27/54795.html