• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipSetPenDashCap197819

Started by José Roca, July 02, 2008, 07:06:05 PM

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 the dash cap, and draws a dashed line.

C++


VOID Example_SetCustomStartCap(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a pen.
   Pen pen(Color(255, 0, 0, 255), 20);

   // Set the dash style for the pen.
   pen.SetDashStyle(DashStyleDash);

   // Set a triangular dash cap for the pen.
   pen.SetDashCap(DashCapTriangle);

   // Draw a line using the pen.
   graphics.DrawLine(&pen, 20, 20, 200, 100);
}


PowerBASIC


SUB GDIP_SetPenDashCap197819 (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, 0, 0, 255), 20, %UnitWorld, pPen)

   ' // Set the dash style for the pen.
   HStatus = GdipSetPenDashStyle(pPen, %DashStyleDash)

   ' // Set a triangular dash cap for the pen.
   hStatus = GdipSetPenDashCap197819(pPen, %DashCapTriangle)

   ' // Draw a line using the pen.
   hStatus = GdipDrawLineI(pGraphics, pPen, 20, 20, 200, 100)

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

END SUB