Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

Graphics.GetPageUnit method

Applies to: desktop apps only

The Graphics::GetPageUnit method gets the unit of measure currently set for this Graphics object.

Syntax

Unit GetPageUnit();

Parameters

This method has no parameters.

Return value

Type:

Type: Unit

This method returns an element of the Unit enumeration that indicates the unit of measure currently set for this Graphics object.

Examples

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.


VOID Example_GetPageUnit(HDC hdc)
{
   Graphics graphics(hdc);
   Pen blackPen(Color(255, 0, 0, 0), 0.0f);
   Pen redPen(Color(255, 255, 0, 0), 0.0f);

   graphics.SetPageUnit(UnitPixel);
   graphics.DrawRectangle(&blackPen, 0, 0, 100, 100);

   // Get the page unit.
   Unit pageUnit = graphics.GetPageUnit();

   // If unit is UnitPixel, set the page unit to UnitInch.
   if (pageUnit == UnitPixel)
   {
      graphics.SetPageUnit(UnitInch);
   }

   graphics.DrawRectangle(&redPen, 2, 0, 1, 1);
}

Requirements

Minimum supported client

Windows XP, Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Product

GDI+ 1.0

Header

Gdiplusgraphics.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.dll

See also

Graphics
Graphics::GetDpiX
Graphics::GetDpiY
Graphics::GetPageScale
Graphics::SetPageScale
Graphics::SetPageUnit
Unit
Types of Coordinate Systems

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show:
© 2015 Microsoft