Condividi tramite


Metodo Pen::GetPenType (gdipluspen.h)

Il metodo Pen::GetPenType ottiene il tipo attualmente impostato per questo oggetto Pen .

Sintassi

PenType GetPenType();

Valore restituito

Tipo: PenType

Questo metodo restituisce un elemento dell'enumerazione PenType che indica lo stile della penna attualmente impostato per questo oggetto Pen .

Commenti

Un oggetto Pen viene creato con un tipo di penna predefinito di PenTypeSolidColor, che è un elemento dell'enumerazione PenType .

Esempio

L'esempio seguente crea un oggetto HatchBrush e quindi passa l'indirizzo dell'oggetto HatchBrush a un costruttore Pen . Il codice usa la penna, che ha una larghezza di 15, per disegnare una linea. Il codice chiama il metodo Pen::GetPenType per determinare il tipo della penna e quindi verifica se il tipo è PenTypeHatchFill.

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

   // Create a HatchBrush object.
   HatchBrush hatchBrush(
      HatchStyleVertical,
      Color(255, 255, 0, 0),
      Color(255, 0, 0, 255));

   // Create a pen based on a hatch brush, and use that
   // pen to draw a line.
   Pen pen(&hatchBrush, 15);
   graphics.DrawLine(&pen, 20, 20, 200, 100);

   // Obtain information about the pen.
   PenType penType = pen.GetPenType();

   if(penType == PenTypeHatchFill)
   {
      // The pen will draw with a hatch pattern.
   }
}

Requisiti

   
Client minimo supportato Windows XP, Windows 2000 Professional [solo app desktop]
Server minimo supportato Windows 2000 Server [solo app desktop]
Piattaforma di destinazione Windows
Intestazione gdipluspen.h (include Gdiplus.h)
Libreria Gdiplus.lib
DLL Gdiplus.dll

Vedi anche

Penna

Pen::GetBrush

Pen::SetBrush

Penne, linee e rettangoli

Uso di una penna per disegnare linee e rettangoli