• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipSetAdjustableArrowCapMiddleInset

Started by José Roca, June 22, 2008, 10:25:37 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example creates an AdjustableArrowCap, pMyArrowCap, and sets the middle inset of the cap to 5 pixels. The code then creates a Pen and assigns pMyArrowCap as the ending line cap for this Pen. Next, the code draws a capped line.

C++


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

   // Create an AdjustableArrowCap, and set the middle inset to 5.
   AdjustableArrowCap myArrow(10, 10, true);
   myArrow.SetMiddleInset(5.0f);

   // Create a Pen, and assign myArrow as the end cap.
   Pen arrowPen(Color(255, 0, 0, 0));
   arrowPen.SetCustomEndCap(&myArrow);

   // Draw a line using arrowPen.
   graphics.DrawLine(&arrowPen, Point(0, 0), Point(100, 100));
}


PowerBASIC


SUB GDIP_SetMiddleInset(BYVAL hdc AS DWORD)

   LOCAL hStatus AS LONG
   LOCAL pGraphics AS DWORD
   LOCAL pArrowPen AS DWORD
   LOCAL pMyArrowCap AS DWORD

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create an AdjustableArrowCap, and set the middle inset to 5.
   hStatus = GdipCreateAdjustableArrowCap(10, 10, %TRUE, pMyArrowCap)
   hStatus = GdipSetAdjustableArrowCapMiddleInset(pMyArrowCap, 5.0!)

   ' // Create a Pen, and assign pMyArrowCap as the end cap.
   hStatus = GdipCreatePen1(GDIP_ARGB(255, 0, 0, 0), 1.0!, %UnitWorld, pArrowPen)
   hStatus = GdipSetPenCustomEndCap(pArrowPen, pMyArrowCap)

   ' // Draw a line using pArrowPen.
   hStatus = GdipDrawLineI(pGraphics, pArrowPen, 0, 0, 100, 100)

   ' // Cleanup
   IF pMyArrowCap THEN GdipDeleteCustomLineCap(pMyArrowCap)
   IF pArrowPen THEN GdipDeletePen(pArrowPen)
   IF pGraphics THEN GdipDeleteGraphics(pGraphics)

END SUB