• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

GDI+: GdipGetPenLineJoin

Started by José Roca, October 04, 2008, 12:38:13 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 line join style, and draws a rectangle. The code then gets the line join style, creates a second pen based on the first pen, and draws a second rectangle.

C++


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

   // Create a pen with a round line join, and use
   // that pen to draw a rectangle.
   Pen pen(Color(255, 255, 0, 0), 15);
   pen.SetLineJoin(LineJoinRound);
   graphics.DrawRectangle(&pen, 20, 20, 200, 100);

   // Get the line join for the pen.
   LineJoin lineJoin = pen.GetLineJoin();

   // Create another pen, and use the same line join.
   Pen pen2(Color(255, 0, 255, 0), 15);
   pen2.SetLineJoin(lineJoin);

   // Draw a second rectangle.
   graphics.DrawRectangle(&pen2, 250, 20, 200, 100);
}


PowerBASIC


SUB GDIP_GetPenLineJoin (BYVAL hdc AS DWORD)

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

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create a pen with a round line join, and use
   ' // that pen to draw a rectangle.
   hStatus = GdipCreatePen1(GDIP_ARGB(255, 255, 0, 0), 15, %UnitWorld, pPen)
   hStatus = GdipSetPenLineJoin(pPen, %LineJoinRound)
   hStatus = GdipDrawRectangleI(pGraphics, pPen, 20, 20, 200, 100)

   ' // Get the line join for the pen.
   LOCAL lineJoin AS LONG
   hStatus = GdipGetPenLineJoin(pPen, lineJoin)

   ' // Create another pen, and use the same line join.
   hStatus = GdipCreatePen1(GDIP_ARGB(255, 0, 255, 0), 15, %UnitWorld, pPen2)
   hStatus = GdipSetPenLineJoin(pPen2, lineJoin)

   ' // Draw a second rectangle.
   hStatus = GdipDrawRectangleI(pGraphics, pPen2, 250, 20, 200, 100)

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

END SUB