Author Topic: GDI+: GdipGetPenDashCap197819  (Read 2758 times)

0 Members and 1 Guest are viewing this topic.

Offline José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2481
GDI+: GdipGetPenDashCap197819
« on: July 02, 2008, 07:27:11 PM »

The following example creates a Pen object, sets the dash cap style, and draws a line. The code then gets the dash cap style of the pen and creates a second Pen object with the same dash cap style. Finally, the code draws a second line using the second pen.

C++

Code: [Select]
VOID Example_GetDashCap(HDC hdc)
{
   Graphics graphics(hdc);
   // Create a pen with a dash cap.
   Pen pen(Color(255, 0, 0, 255), 15);
   pen.SetDashStyle(DashStyleDash);
   pen.SetDashCap(DashCapRound);

   graphics.DrawLine(&pen, 50, 50, 400, 200);

   // Obtain the dash cap for the pen.
   DashCap dashCap;
   dashCap = pen.GetDashCap();

   // Create another pen, and use the same dash cap.
   Pen pen2(Color(255, 0, 255, 0), 15);
   pen2.SetDashStyle(DashStyleDash);
   pen2.SetDashCap(dashCap);

   // Draw a second line.
   graphics.DrawLine(&pen2, 50, 100, 400, 300);
}

PowerBASIC

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

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

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create a pen with a dash cap.
   hStatus = GdipCreatePen1(GDIP_ARGB(255, 0, 0, 255), 15, %UnitWorld, pPen)
   hStatus = GdipSetPenDashStyle(pPen, %DashStyleDash)
   hStatus = GdipSetPenDashCap197819(pPen, %DashCapRound)

   hStatus = GdipDrawLineI(pGraphics, pPen, 50, 50, 400, 200)

   ' // Obtain the dash cap for the pen.
   LOCAL dashCap AS LONG
   hStatus = GdipGetPenDashCap197819(pPen, dashCap)

   ' // Create another pen, and use the same dash cap.
   LOCAL pPen2 AS DWORD
   hStatus = GdipCreatePen1(GDIP_ARGB(255, 0, 255, 0), 15, %UnitWorld, pPen2)
   hStatus = GdipSetPenDashStyle(pPen2, %DashStyleDash)
   hStatus = GdipSetPenDashCap197819(pPen2, dashCap)

   ' // Draw a second line.
   hStatus = GdipDrawLineI(pGraphics, pPen2, 50, 50, 400, 300)

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

END SUB


« Last Edit: August 07, 2011, 09:12:53 PM by José Roca »