Graphics.SetPageUnit method

Applies to: desktop apps only

The Graphics::SetPageUnit method sets the unit of measure for this Graphics object. The page unit belongs to the page transformation, which converts page coordinates to device coordinates.

Syntax

Status SetPageUnit(
  [in]  Unit unit
);

Parameters

unit [in]

Type: Unit

Element of the Unit enumeration that specifies the unit of measure for this Graphics object.

Return value

Type:

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

Examples

The following example draws two rectangles: one measured in pixels and one measured in inches.


VOID Example_SetPageUnit(HDC hdc)
{
   Graphics graphics(hdc);

   // Set the page units to pixels, and draw a rectangle.
   graphics.SetPageUnit(UnitPixel);
   Pen blackPen(Color(255, 0, 0, 0), 0.0f);
   graphics.DrawRectangle(&blackPen, 0, 0, 100, 100);

   // Set the page units to inches, and draw a rectangle.
   graphics.SetPageUnit(UnitInch);
   Pen bluePen(Color(255, 0, 0, 255), 0.0f);
   graphics.DrawRectangle(&bluePen, 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::GetPageUnit
Graphics::SetPageScale
Unit
Types of Coordinate Systems

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Show: