次の方法で共有


Graphics.SetClip メソッド (Graphics, CombineMode)

この Graphics オブジェクトのクリッピング領域を現在のクリップ領域と指定した Graphics オブジェクトの Clip プロパティとを組み合わせる指定の操作の結果に設定します。

Overloads Public Sub SetClip( _
   ByVal g As Graphics, _   ByVal combineMode As CombineMode _)
[C#]
public void SetClip(Graphicsg,CombineModecombineMode);
[C++]
public: void SetClip(Graphics* g,CombineModecombineMode);
[JScript]
public function SetClip(
   g : Graphics,combineMode : CombineMode);

パラメータ

  • g
    組み合わせるクリップ領域を指定する Graphics オブジェクト。
  • combineMode
    使用する組み合わせ操作を指定する CombineMode 列挙体のメンバ。

戻り値

このメソッドは値を返しません。

使用例

[Visual Basic, C#] 次の例は、Windows フォームでの使用を意図してデザインされており、 Paint イベント ハンドラのパラメータである PaintEventArgs e と、 Form オブジェクトの例である thisForm が必要です。このコードは次のアクションを実行します。

  • サンプルの thisForm Form オブジェクトから一時 Graphics オブジェクトを作成します。
  • 一時 Graphics オブジェクトのクリッピング領域を小さな正方形に設定します。
  • CombineMode.Replace メンバを使用して、フォームのグラフィック オブジェクトのクリッピング領域を新しい Graphics オブジェクトのクリッピング領域に更新します。
  • 黒いソリッド ブラシで大きな四角形を塗りつぶします。

[Visual Basic, C#] 黒で塗りつぶされた小さな正方形が生成されます。

 
Public Sub SetClipGraphicsCombine(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, CombineMode.Replace)
' 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 SetClipGraphicsCombine(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, CombineMode.Replace);
// 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 オーバーロードの一覧