What is GDI ?
GDI is an acronym for Graphics Device Interface. The GDI allows you to draw on your windows. It is a device independent output model in the sense that the graphics code that you write for drawing will work on any video output which has a Windows driver.
In order to avoid one window interfering with another while drawing output on the screen GDI uses a mechanism called as device context to avoid this conflict. So when a window draws on a screen, printer or any other output device, it doesn’t output pixels directly on the device. Instead it draws to a logical surface represented by a “device context” (DC). A DC is a data structure that has all information that GDI needs to know. Before a Windows program draws anything on the screen it acquires a DC handle from the GDI and then passes this handle back to the GDI each time it calls the GDI output function. In MFC a DC encapsulates the GDI functions that a program uses to generate output. MFC’s CDC class wraps a Windows device context and the GDI functions into one package. CPaintDC and CClientDC are subclasses of CDC and represent the different types of device contexts that windows applications use.
E.g.
CDC* pDC = GetDC();
//do some drawing
Release (pDC);
