Jose's Read Only Forum 2023

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Source Code => Graphics and Multimedia => GDI+ (GDI Plus) => Topic started by: José Roca on July 03, 2008, 01:52:18 AM

Title: GDI+: GdipSetPenDashOffset
Post by: José Roca 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++


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


(http://www.jose.it-berater.org/captures/GdipSetPenDashOffset.png)