SetWindowRgn

機能
指定の領域をウィンドウ領域として設定する
Declare Function SetWindowRgn lib "user32.dll" _
(ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Declare Function SetWindowRgn lib "user32.dll" _
(ByVal hWnd As Integer, ByVal hRgn As Integer, ByVal bRedraw As Boolean) As Integer

int SetWindowRgn(
HWND hWnd,
HRGN hRgn,
BOOL bRedraw
);
引数
hWnd

ウィンドウのハンドル
hRgn
ウィンドウ領域に設定する既存の領域のハンドル
bRedraw
領域作成後に再描画するとき       1
再描画しないとき                 0
戻り値
成功したとき            0以外
失敗したとき            0
サンプル
ダウンロード(SetWindowRgn.lzh 1.24KB)

'指定の領域をウィンドウ領域として設定する
Private Declare Function SetWindowRgn Lib "user32.dll" _
    (ByVal hWnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Type RECT
    Left As Long            '矩形の左上隅のX座標
    Top As Long             '同、Y座標
    Right As Long           '矩形の右下隅のX座標
    Bottom As Long          '同、Y座標
End Type

'円形・楕円形の領域をRECT構造体に基づいて作成する
Private Declare Function CreateEllipticRgnIndirect Lib "gdi32.dll" _
    (lprc As RECT) As Long

Private Sub Command1_Click() MsgBox "丸いフォームになりましたか?" End End Sub
Private Sub Form_Load() Dim lpRect As RECT, hRgn As Long Me.Caption = "SetWindowRgn()関数の実験" With lpRect .Left = 0 .Top = 0 .Right = Me.ScaleWidth .Bottom = Me.ScaleHeight End With hRgn = CreateEllipticRgnIndirect(lpRect) Call SetWindowRgn(Me.hWnd, hRgn, True) End Sub