- 任意の形状を GraphicsPathに指定
- GraphicsPathをFormのRegionに指定
- パスの形状を表す任意の座標集合を配列に格納
- GraphicsPath::AddClosedCurveメソッドにより座標集合を指定
以下の例は、AddEllipseメソッドを利用して、楕円形のパスを入手し、フォームを表示した例です。
//ボーダーをなくす(そのほうがベスト)
this->FormBorderStyle=System::Windows::Forms::FormBorderStyle::None;
//FormのGraphicsオブジェクトの作成
Graphics^ g = this->CreateGraphics();
//Graphicパス変数の宣言
System::Drawing::Drawing2D::GraphicsPath^ path = gcnew System::Drawing::Drawing2D::GraphicsPath();
//GraphicPathに楕円の領域を指定追加
path->AddEllipse(g->VisibleClipBounds);
//フォームのRegionにpathを設定
this->Region = gcnew System::Drawing::Region(path); 上記の例では、FormのボーダースタイルをNONEにしています。ただ、この方法を採用すると、マウス操作によるフォームの操作ができませんから、そこは別途実装してもらうことになります。