|
'変数の明示的な宣言を強制します。
Option Explicit
'API関数 ExcludeClipRect の使用を宣言します。
Private Declare Function ExcludeClipRect Lib "gdi32"
_
(ByVal hdc As Long, _
ByVal X1 As Long, _
ByVal Y1 As Long, _
ByVal X2 As Long, _
ByVal Y2 As Long) As Long
'第1引数:デバイスコンテキストのハンドル
'第2引数:対象とする矩形の左上のX座標
'第3引数:同Y座標
'第4引数:対象とする矩形の右下のX座標
'第5引数:同Y座標
Private Sub Command1_Click()
Dim ret As Long
'フォーム上の領域(20,20)-(60,60)をクリッピング領域から除きます。
ret = ExcludeClipRect(Me.hdc, 20, 20, 60, 60)
Command1.Enabled = False
Command2.Enabled = True
End Sub
Private Sub Command2_Click()
'フォームの背景色を変更します。
Form1.BackColor = vbRed
MsgBox "クリッピング領域から取り除かれた領域が一目瞭然!", _
vbInformation, Me.Caption
End Sub
Private Sub Form_Load()
Form1.Caption = "API関数ExcludeClipRectの使用例"
Command1.Caption = "関数実行"
Command2.Caption = "背景色変更"
Command2.Enabled = False
End Sub
|