Graphics.DrawLine(const Pen*, INT, INT, INT, INT) 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]  INT x1,
  [in]  INT y1,
  [in]  INT x2,
  [in]  INT y2
);

Parameters

pen [in]

Type: const Pen*

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

x1 [in]

Type: INT

Integer that specifies the x-coordinate of the starting point of the line.

y1 [in]

Type: INT

Integer that specifies the y-coordinate of the starting point of the line.

x2 [in]

Type: INT

Integer that specifies the x-coordinate of the ending point of the line.

y2 [in]

Type: INT

Integer that specifies the y-coordinate of the ending point 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_DrawLine3(HDC hdc

{

   Graphics graphics(hdc);



   // Create a Pen object.

   Pen blackPen(Color(255, 0, 0, 0), 3);



   // Initialize the coordinates of the points that define the line.

   int x1 = 100;

   int y1 = 100;

   int x2 = 500;

   int y2 = 100;



   // Draw the line.

   graphics.DrawLine(&blackPen, x1, y1, x2, y2);

}

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
Point
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: