HRGN CreateRoundRectRgn( int LeftRect, int TopRect, int RightRect, int BottomRect, int WidthEllipse, int HeightEllipse);
Declare Function CreateRoundRectRgn Lib "gdi32" ( _
ByVal LeftRect As Long, _
ByVal TopRect As Long, _
ByVal RightRect As Long, _
ByVal BottomRect As Long, _
ByVal WidthEllipse As Long, _
ByVal HeightEllipse As Long) As Long
引数の意味は以下の通り。
| LeftRect | 長方形の左上隅座標の水平成分。 |
| TopRect | 長方形の左上隅座標の垂直成分。 |
| RightRect | 長方形の右下隅座標の水平成分。 |
| BottomRect | 長方形の右下隅座標の垂直成分。 |
| WidthEllipse | 角の丸みを表す円の幅。 |
| HeightEllipse | 角の丸みを表す円の高さ。 |
戻り値は、作成結果のリージョンのハンドルである。関数の実行に失敗した場合、NULLが返される。
'二つの角の丸い長方形からなるリージョンを描画
Private Sub Command1_Click()
Dim hRgn1 As Long
Dim hRgn2 As Long
'リージョンの作成
hRgn1 = CreateRoundRectRgn(0, 0, 100, 100, 30, 30)
hRgn2 = CreateRoundRectRgn(50, 50, 150, 150, 30, 30)
'リージョンの結合
CombineRgn hRgn1, hRgn1, hRgn2, RGN_XOR
'リージョンの描画
FillRgn Picture1.hDC, hRgn1, GetStockObject(WHITE_BRUSH)
'後処理
DeleteObject hRgn1
DeleteObject hRgn2
End Sub