Skip to content

Latest commit

 

History

History
144 lines (100 loc) · 4.73 KB

nf-gdipluspen-pen-setdashpattern.md

File metadata and controls

144 lines (100 loc) · 4.73 KB
UID title description helpviewer_keywords old-location tech.root ms.assetid ms.date ms.keywords req.header req.include-header req.target-type req.target-min-winverclnt req.target-min-winversvr req.kmdf-ver req.umdf-ver req.ddi-compliance req.unicode-ansi req.idl req.max-support req.namespace req.assembly req.type-library req.lib req.dll req.irql targetos req.typenames req.redist req.product ms.custom f1_keywords dev_langs topic_type api_type api_location api_name
NF:gdipluspen.Pen.SetDashPattern
Pen::SetDashPattern (gdipluspen.h)
The Pen::SetDashPattern method sets an array of custom dashes and spaces for this Pen object.
Pen class [GDI+]
SetDashPattern method
Pen.SetDashPattern
Pen::SetDashPattern
SetDashPattern
SetDashPattern method [GDI+]
SetDashPattern method [GDI+]
Pen class
_gdiplus_CLASS_Pen_SetDashPattern_dashArray_count_
gdiplus._gdiplus_CLASS_Pen_SetDashPattern_dashArray_count_
gdiplus\_gdiplus_CLASS_Pen_SetDashPattern_dashArray_count_.htm
gdiplus
VS|gdicpp|~\gdiplus\gdiplusreference\classes\penclass\penmethods\setdashpattern.htm
12/05/2018
Pen class [GDI+],SetDashPattern method, Pen.SetDashPattern, Pen::SetDashPattern, SetDashPattern, SetDashPattern method [GDI+], SetDashPattern method [GDI+],Pen class, _gdiplus_CLASS_Pen_SetDashPattern_dashArray_count_, gdiplus._gdiplus_CLASS_Pen_SetDashPattern_dashArray_count_
gdipluspen.h
Gdiplus.h
Windows
Windows XP, Windows 2000 Professional [desktop apps only]
Windows 2000 Server [desktop apps only]
Gdiplus.lib
Gdiplus.dll
Windows
GDI+ 1.0
19H1
Pen::SetDashPattern
gdipluspen/Pen::SetDashPattern
c++
APIRef
kbSyntax
COM
Gdiplus.dll
Pen.SetDashPattern

Pen::SetDashPattern

-description

The Pen::SetDashPattern method sets an array of custom dashes and spaces for this Pen object.

-parameters

-param dashArray [in]

Type: const REAL*

Pointer to an array of real numbers that specifies the length of the custom dashes and spaces. All elements in the array must be positive real numbers.

-param count [in]

Type: INT

Integer that specifies the number of elements in the dashArray array. The integer must be greater than 0 and not greater than the total number of elements in the array.

-returns

Type: Status

If the method succeeds, it returns Ok, which is an element of the Status enumeration.

If the method fails, it returns one of the other elements of the Status enumeration.

-remarks

This method will set the DashStyle enumeration for this Pen object to DashStyleCustom.

The elements in the dashArray array set the length of each dash and space in the dash pattern. The first element sets the length of a dash, the second element sets the length of a space, the third element sets the length of a dash, and so forth.

The length of each dash and space in the dash pattern is the product of the element value in the array and the width of the Pen object.

Examples

The following example creates an array of real numbers. The code then creates a Pen object, sets the dash pattern based on the array, and then draws the custom dashed line.

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

   // Create and set an array of real numbers.
   REAL dashVals[4] = {
      5.0f,   // dash length 5
      2.0f,   // space length 2
      15.0f,  // dash length 15
      4.0f};  // space length 4

   // Create a Pen object.
   Pen pen(Color(255, 0, 0, 0), 5);

   // Set the dash pattern for the custom dashed line.
   pen.SetDashPattern(dashVals, 4);

   // Draw the custom dashed line.
   graphics.DrawLine(&pen, 5, 20, 405, 200); 
}

-see-also

Drawing a Custom Dashed Line

Pen

Pen::GetDashPattern

Pen::GetDashPatternCount

Pens, Lines, and Rectangles