• Welcome to Jose's Read Only Forum 2023.
 

GDI+: GdipGetAdjustableArrowCapMiddleInset

Started by José Roca, June 22, 2008, 11:34:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example creates an AdjustableArrowCap object, pMyArrowCap, with middle inset set to zero (default value). The code then creates a Pen object, assigns pMyArrowCap as the ending line cap for this Pen object, and draws a capped line. Next, the code gets the middle inset, increments it, and draws another capped line.

C++


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

   // Create an AdjustableArrowCap with width and height set to 10.
   // Middle inset defaults to 0 pixels.
   AdjustableArrowCap myArrow(10, 10, true);

   // 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, 10), Point(100, 10));

   // Get the inset of the arrow.
   REAL inset = myArrow.GetMiddleInset();

   // Increase inset by 5 pixels and draw another line.
   myArrow.SetMiddleInset(inset + 5);
   arrowPen.SetCustomEndCap(&myArrow);
   graphics.DrawLine(&arrowPen, Point(0, 40), Point(100, 40));
}


PowerBASIC


SUB GDIP_GetMiddleInset(BYVAL hdc AS DWORD)

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

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create an AdjustableArrowCap with width and height set to 10.
   ' // Middle inset defaults to 0 pixels.
   hStatus = GdipCreateAdjustableArrowCap(10, 10, %TRUE, pMyArrowCap)

   ' // 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 arrowPen.
   hStatus = GdipDrawLineI(pGraphics, pArrowPen, 0, 0, 100, 100)

   ' // Get the inset of the arrow.
   hStatus = GdipSetAdjustableArrowCapMiddleInset(pMyArrowCap, inset)

   ' // Increase inset by 5 pixels and draw another line.
   hStatus = GdipSetAdjustableArrowCapMiddleInset(pMyArrowCap, inset + 5)
   hStatus = GdipSetPenCustomEndCap(pArrowPen, pMyArrowCap)
   hStatus = GdipDrawLineI(pGraphics, pArrowPen, 0, 40, 100, 40)

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

END SUB