Help Center

CGpGraphics.GetDpiYmethod

Gets the vertical resolution, in dots per inch, of the display device associated with this **Graphics** object.

GraphicsmethodCGpGraphics.incdocumented

Syntax

FUNCTION GetDpiY () AS SINGLE

Return value

This method returns the vertical resolution, in dots per inch, of the display device associated with this Graphics object.

Description

Gets the vertical resolution, in dots per inch, of the display device associated with this Graphics object.

Example

' ======================================================================================== ' The following example gets the vertical resolution, in dots per inch, of the display ' device and uses that value to convert pixels to inches. Then the code draws two rectangles ' that have the same height: one measured in inches and one measured in pixels. ' ======================================================================================== SUB Example_GetDpiY (BYVAL hdc AS HDC)

' // Create a graphics object from the window device context DIM graphics AS CGpGraphics = hdc

' // Get the vertical resolution, in dots per inch, of the display device DIM dpiY AS SINGLE = graphics.GetDpiY

' // Set the unit of measure for graphics to inches graphics.SetPageUnit(UnitInch) graphics.SetPageScale(dpiY / 96)

' // Use dpiY to convert pixels to inches, and draw a ' // rectangle that has a width of 100 pixels DIM side AS SINGLE = 100.0 / dpiY DIM bluePen AS CGpPen = CGpPen(ARGB_BLUE, 0) graphics.DrawRectangle(@bluePen, 0.0, 0.0, side, side)

' // Set the unit of measure for graphics to pixels graphics.SetPageUnit(UnitPixel) graphics.SetPageScale(dpiY / 96)

' // Draw a 100-pixel square. DIM redPen AS CGpPen = CGpPen(ARGB_RED, 1) graphics.DrawRectangle(@redPen, 120, 0, 100, 100)

END SUB ' ========================================================================================

Reference

  • Include file CGpGraphics.inc
  • Defined in AfxNova/CGpGraphics.inc:396
  • Documented in Graphics/GdiPlus Classes/CGpGraphics Classes.md
  • Topic: CGpGraphics Class