この Graphics オブジェクトのクリッピング領域を指定した Graphics オブジェクトの Clip プロパティに設定します。
Overloads Public Sub SetClip( _
ByVal g As Graphics _)
[C#]
public void SetClip(Graphicsg);
[C++]
public: void SetClip(Graphics* g);
[JScript]
public function SetClip(
g : Graphics);
パラメータ
- g
新しいクリップ領域の取得元となる Graphics オブジェクト。
戻り値
このメソッドは値を返しません。
使用例
[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e と、 Form オブジェクトの例である thisForm が必要です。このコードは次のアクションを実行します。
- サンプルの thisForm Form オブジェクトから一時 Graphics オブジェクトを作成します。
- 一時 Graphics オブジェクトのクリッピング領域を小さな正方形に設定します。
- フォームのグラフィックス オブジェクトのクリッピング領域を一時 Graphics オブジェクトに更新します。
- 黒いソリッド ブラシで大きな四角形を塗りつぶします。
[Visual Basic, C#] 黒で塗りつぶされた小さな正方形が生成されます。
Public Sub SetClipGraphics(e As PaintEventArgs)
' Create temporary graphics object and set its clipping region.
Dim newGraphics As Graphics = thisForm.CreateGraphics()
newGraphics.SetClip(New Rectangle(0, 0, 100, 100))
' Update clipping region of graphics to clipping region of new
' graphics.
e.Graphics.SetClip(newGraphics)
' Fill rectangle to demonstrate clip region.
e.Graphics.FillRectangle(New SolidBrush(Color.Black), 0, 0, _
500, 300)
' Release new graphics.
newGraphics.Dispose()
End Sub
[C#]
public void SetClipGraphics(PaintEventArgs e)
{
// Create temporary Graphics object and set its clipping region.
Graphics newGraphics = thisForm.CreateGraphics();
newGraphics.SetClip(new Rectangle(0, 0, 100, 100));
// Update clipping region of graphics to clipping region of new graphics.
e.Graphics.SetClip(newGraphics);
// Fill rectangle to demonstrate clip region.
e.Graphics.FillRectangle(new SolidBrush(Color.Black), 0, 0, 500, 300);
// Release new graphics.
newGraphics.Dispose();
}
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン
をクリックします。
必要条件
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
参照
Graphics クラス | Graphics メンバ | System.Drawing 名前空間 | Graphics.SetClip オーバーロードの一覧