Gets the handle to the device context associated with this System.Drawing.Graphics.
Handle to the device context associated with this System.Drawing.Graphics.
The device context is a Windows structure based on ndptecgdi that defines a set of graphical objects and their associated attributes, as well as the graphical modes that affect output. This method returns that device context with the exception of a font. Because a font is not selected, calls to the Font.FromHdc(IntPtr) method using a handle returned from the Graphics.GetHdc method will fail.
Calls to the Graphics.GetHdc and erload:System.Drawing.Graphics.ReleaseHdc methods must appear in pairs. During the scope of a Graphics.GetHdc and erload:System.Drawing.Graphics.ReleaseHdc method pair, you usually make only calls to ndptecgdi functions. Calls in that scope made to ndptecgdiplus methods of the System.Drawing.Graphics that produced the hdc parameter fail with an ObjectBusy error. Also, ndptecgdiplus ignores any state changes made to the System.Drawing.Graphics of the hdc parameter in subsequent operations.