The following example draws a line.
C++
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);
}
PowerBASIC
SUB GDIP_DrawLine (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pPen AS DWORD
hStatus = GdipCreateFromHDC(hdc, pGraphics)
' // Create a Pen
hStatus = GdipCreatePen1(GDIP_ARGB(255, 255, 0, 0), 1, %UnitPixel, pPen)
' // Draw the line
GdipDrawLineI pGraphics, pPen, 0, 0, 200, 100
' // Cleanup
IF pPen THEN GdipDeletePen(pPen)
IF pGraphics THEN GdipDeleteGraphics(pGraphics)
END SUB
(http://www.jose.it-berater.org/captures/GdipDrawLine.png)