• Welcome to Powerbasic Museum 2020-B.
 

GDI+: GdipSetAdjustableArrowCapFillState

Started by José Roca, June 22, 2008, 12:18:40 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example creates an AdjustableArrowCap object, pMyArrowCap, and sets the fill mode to FALSE. The code then creates a Pen object and assigns pMyArrowCap as the ending line cap for this Pen object. Next, the code draws a line.

C++


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

   // Create an AdjustableArrowCap. Fill state defaults to TRUE when
   // arrow cap is constructed.
   AdjustableArrowCap myArrow(10, 10);

   // Set fill state to FALSE.
   myArrow.SetFillState(false);

   // 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_SetFillState (BYVAL hdc AS DWORD)

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

   hStatus = GdipCreateFromHDC(hdc, pGraphics)

   ' // Create an AdjustableArrowCap with the fill state set to TRUE.
   hStatus = GdipCreateAdjustableArrowCap(10, 10, %TRUE, pMyArrowCap)

   ' // Set fill state to FALSE.
   hStatus = GdipSetAdjustableArrowCapFillState(pMyArrowCap, %FALSE)

   ' // 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