Author Topic: GDI+: GdipSetPenDashOffset  (Read 3045 times)

0 Members and 1 Guest are viewing this topic.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
GDI+: GdipSetPenDashOffset
« on: July 03, 2008, 01:52:18 AM »

The following example creates a Pen object, sets the dash style, and draws a line. The code then sets the pen's offset value and draws a second line.

C++

Code: [Select]
VOID Example_SetDashOffset(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a Pen object, set the dash style, and draw a line.
   Pen pen(Color(255, 0, 0, 255), 15);
   pen.SetDashStyle(DashStyleDash);
   graphics.DrawLine(&pen, 0, 50, 400, 50);

   // Set the dash offset value for the pen, and draw a second line.
   pen.SetDashOffset(10);
   graphics.DrawLine(&pen, 0, 80, 400, 80);
}

PowerBASIC

Code: [Select]
SUB GDIP_SetPenDashOffset (BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pPen AS DWORD

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create a Pen object, set the dash style, and draw a line.
   hStatus = GdipCreatePen1(GDIP_ARGB(255, 0, 0, 255), 15, %UnitWorld, pPen)
   hStatus = GdipSetPenDashStyle(pPen, %DashStyleDash)
   hStatus = GdipDrawLineI(pGraphics, pPen, 0, 50, 400, 50)

   ' // Set the dash offset value for the pen, and draw a second line.
   hStatus = GdipSetPenDashOffset(pPen, 10)
   hStatus = GdipDrawLineI(pGraphics, pPen, 0, 80, 400, 80)

   ' // Cleanup
   IF pPen THEN GdipDeletePen(pPen)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB


« Last Edit: August 07, 2011, 09:11:32 PM by José Roca »