Pen.Clone 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
會建立一個完全相同的複製品。Pen
public:
virtual System::Object ^ Clone();
public object Clone();
abstract member Clone : unit -> obj
override this.Clone : unit -> obj
Public Function Clone () As Object
傳回
實作
範例
以下程式碼範例是為 Windows Forms 設計的,並需要 PaintEventArgse,這是 Paint 事件處理程序的參數。 此程式碼會執行下列動作:
建立 Pen。
複製了那支筆。
用筆的複製品在螢幕上畫線。
public:
void Clone_Example( PaintEventArgs^ e )
{
// Create a Pen object.
Pen^ myPen = gcnew Pen( Color::Black,5.0f );
// Clone myPen.
Pen^ clonePen = dynamic_cast<Pen^>(myPen->Clone());
// Draw a line with clonePen.
e->Graphics->DrawLine( clonePen, 0, 0, 100, 100 );
}
public void Clone_Example(PaintEventArgs e)
{
// Create a Pen object.
Pen myPen = new Pen(Color.Black, 5);
// Clone myPen.
Pen clonePen = (Pen)myPen.Clone();
// Draw a line with clonePen.
e.Graphics.DrawLine(clonePen, 0, 0, 100, 100);
}
Public Sub Clone_Example(ByVal e As PaintEventArgs)
' Create a Pen object.
Dim myPen As New Pen(Color.Black, 5)
' Clone myPen.
Dim clonePen As Pen = CType(myPen.Clone(), Pen)
' Draw a line with clonePen.
e.Graphics.DrawLine(clonePen, 0, 0, 100, 100)
End Sub