Graphics.DrawLine(const Pen*, const PointF, const PointF) method

Applies to: desktop apps only

The Graphics::DrawLine method draws a line that connects two points.

Syntax

Status DrawLine(
  [in]       const Pen *pen,
  [in, ref]  const PointF &pt1,
  [in, ref]  const PointF &pt2
);

Parameters

pen [in]

Type: const Pen*

Pointer to a pen that is used to draw the line.

pt1 [in, ref]

Type: const PointF

Reference to a PointF object that specifies the start of the line.

pt2 [in, ref]

Type: const PointF

Reference to a PointF object that specifies the end of the line.

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 a line.



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

   // Create a Pen object.
   Pen blackPen(Color(255, 0, 0, 0), 3);

   // Create two PointF objects that define the line.
   PointF point1(100.0f, 100.0f);
   PointF point2(500.0f, 100.0f);

   // Draw the line.
   graphics.DrawLine(&blackPen, point1, point2);

}


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
DrawLines Methods
PointF
Using a Pen to Draw Lines and Rectangles
Pens, Lines, and Rectangles

 

 

Send comments about this topic to Microsoft

Build date: 3/6/2012

Community Additions

ADD
Show: