Graphics.DrawLine(const Pen*, REAL, REAL, REAL, REAL) 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] REAL x1,
[in] REAL y1,
[in] REAL x2,
[in] REAL y2
);
Parameters
pen [in]
Type: const Pen*Pointer to a pen that is used to draw the line.
x1 [in]
Type: REALReal number that specifies the x-coordinate of the starting point of the line.
y1 [in]
Type: REALReal number that specifies the y-coordinate of the starting point of the line.
x2 [in]
Type: REALReal number that specifies the x-coordinate of the ending point of the line.
y2 [in]
Type: REALReal number 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_DrawLine4(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.
REAL x1 = 100.0f;
REAL y1 = 100.0f;
REAL x2 = 500.0f;
REAL y2 = 100.0f;
// 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
Using a Pen to Draw Lines and Rectangles
Send comments about this topic to Microsoft
Build date: 3/6/2012