CGpGraphics.GetPageUnitmethod
Gets the unit of measure currently set for this **Graphics** object.
Syntax
FUNCTION GetPageUnit () AS GpUnit
Description
Gets the unit of measure currently set for this Graphics object.
Example
' ======================================================================================== ' The following example creates a Graphics object and sets its unit of measure to UnitPixel. ' Then the code draws a square that is 100 pixels on each side. The call to Graphics.GetPageUnit ' demonstrates how to obtain the unit of measure (which is already known in this case) for ' the Graphics object. The code determines whether the unit of measure is UnitPixel and if ' so, changes the unit of measure to UnitInch. Then the code draws a square that is 1 inch ' on each side. ' ======================================================================================== SUB Example_GetPageUnit (BYVAL hdc AS HDC)
' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc ' // Get the DPI scaling ratio DIM rxRatio AS SINGLE = graphics.GetDpiX / 96
DIM blackPen AS CGpPen = CGpPen(ARGB_BLACk, 0) DIM redPen AS CGpPen = CGpPen(ARGB_RED, 0)
graphics.SetPageUnit(UnitPixel) graphics.DrawRectangle(@blackPen, 0, 0, 100 * rxRatio, 100 * rxRatio)
' // Get the page unit. DIM pageUnit AS GpUnit pageUnit = graphics.GetPageUnit
IF pageUnit = UnitPixel THEN
graphics.SetPageUnit(UnitInch)
END IF
graphics.DrawRectangle(@redPen, 2, 0, 1, 1)
END SUB ' ========================================================================================
Reference
- Include file
CGpGraphics.inc - Defined in AfxNova/CGpGraphics.inc:363
- Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
- Topic: CGpGraphics Class