Pen::SetTransform 方法 (gdipluspen.h)

Pen::SetTransform方法會設定這個Pen物件的世界轉換。

語法

Status SetTransform(
  [in] const Matrix *matrix
);

參數

[in] matrix

類型:const矩陣*

指定世界轉換之 Matrix 物件的指標。

傳回值

類型: 狀態

如果方法成功,它會傳回 Ok,這是 Status 列舉的元素。

如果方法失敗,它會傳回 Status 列舉的其中一個其他元素。

備註

這個方法會忽略 Matrix 物件的轉譯部分。

範例

下列範例會建立縮放矩陣和 Pen 物件,然後繪製矩形。 然後程式碼會依矩陣調整手寫筆,並繪製第二個矩形。

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

   Matrix matrix(20, 0, 0, 10, 0, 0);  // scale

   // Create a pen, and use it to draw a rectangle.
   Pen pen(Color(255, 0, 0, 255), 2);
   graphics.DrawRectangle(&pen, 10, 50, 150, 100);

   // Scale the pen width by a factor of 20 in the horizontal 
   // direction and a factor of 10 in the vertical direction.
   pen.SetTransform(&matrix);

   // Draw a rectangle with the transformed pen.
   graphics.DrawRectangle(&pen, 200, 50, 150, 100);
}

需求

   
最低支援的用戶端 Windows XP、Windows 2000 Professional [僅限傳統型應用程式]
最低支援的伺服器 Windows 2000 Server [僅限傳統型應用程式]
目標平台 Windows
標頭 gdipluspen.h (包含 Gdiplus.h)
程式庫 Gdiplus.lib
Dll Gdiplus.dll

另請參閱

座標系統和轉換

矩陣

Pen::GetTransform

Pen::MultiplyTransform

Pen::ResetTransform

Pen::RotateTransform

Pen::ScaleTransform

轉換