CGpGraphics.FromHDCmethod
Creates a **Graphics** object that is associated with a specified device context.
Syntax
FUNCTION FromHDC (BYVAL hdc AS HDC) AS GpStatus
FUNCTION FromHDC (BYVAL hdc AS HDC, BYVAL hDevice AS HANDLE) AS GpStatus
Parameters
| Name | Description | |
|---|---|---|
hdc | Handle to the device context that will be associated with the new Graphics object. | |
hDevice | Handle to a device that will be associated with the new Graphics object. |
Return value
If the function succeeds, it returns StatusOk, which is an element of the GpStatus enumeration.
If the function fails, it returns one of the other elements of the GpStatus enumeration.
Description
Creates a Graphics object that is associated with a specified device context.
Remarks
When you use these methods to create a Graphics object, make sure that the Graphics object is deleted before the device context is released.
Example
' ======================================================================================== ' The following example draws a rectangle. ' ======================================================================================== SUB Example_FromHDC (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Set the scale transform graphics.ScaleTransformForDpi
' // Draw the rectangle DIM redPen AS CGpPen = CGpPen(ARGB_RED, 1) graphics.DrawRectangle(@redPen, 10, 10, 200, 100)
END SUB ' ========================================================================================
Reference
- Include file
CGpGraphics.inc - Defined in AfxNova/CGpGraphics.inc:71
- Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
- Topic: CGpGraphics Class