The following example creates a
Pen object and sets the compound array for the pen. The code then draws a line using the
Pen object.
C++
VOID Example_SetCompoundArray(HDC hdc)
{
Graphics graphics(hdc);
// Create an array of real numbers and a Pen object.
REAL compVals[6] = {0.0f, 0.2f, 0.5f, 0.7f, 0.9f, 1.0f};
Pen pen(Color(255, 0, 0, 255), 30);
// Set the compound array of the pen.
pen.SetCompoundArray(compVals, 6);
// Draw a line with the pen.
graphics.DrawLine(&pen, 5, 20, 405, 200);
}
PowerBASIC
SUB GDIP_SetPenCompoundArray (BYVAL hdc AS DWORD)
LOCAL hStatus AS LONG
LOCAL pGraphics AS DWORD
LOCAL pPen AS DWORD
hStatus = GdipCreateFromHDC(hdc, pGraphics)
' // Create an array of real numbers and a Pen object.
DIM compVals(5) AS SINGLE
ARRAY ASSIGN compVals() = 0.0!, 0.2!, 0.5!, 0.7!, 0.9!, 1.0!
hStatus = GdipCreatePen1(GDIP_ARGB(255, 0, 0, 255), 30, %UnitWorld, pPen)
' // Set the compound array of the pen.
hStatus = GdipSetPenCompoundArray(pPen, compVals(0), 6)
' // Draw a line with the pen.
hStatus = GdipDrawLineI(pGraphics, pPen, 5, 20, 405, 200)
' // Cleanup
IF pPen THEN GdipDeletePen(pPen)
IF pGraphics THEN GdipDeleteGraphics(pGraphics)
END SUB
The following illustration shows the output of the preceding code.
(http://www.jose.it-berater.org/captures/GdipSetPenCompoundArray.png)