• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipSetPenDashOffset

Started by José Roca, July 03, 2008, 01:52:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



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++


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


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