指定領域に長方形を描画・反転描画          <TOP>


指定領域に長方形を描画(Rectangle)・反転描画(InvertRect)します。

Rectangle 長方形の描画

InvertRect 長方形内の色を反転描画

 

 

'================================================================
'= 指定領域に長方形を描画・反転描画
'=    (InvertRect.bas)
'================================================================
#include "Windows.bi"

Type RECT
    Left As Long
    Top As Long
    Right As Long
    Bottom As Long
End Type

' 長方形の描画
Declare Function Api_Rectangle& Lib "gdi32" Alias "Rectangle" (ByVal hDC&, ByVal X1&, ByVal Y1&, ByVal X2&, ByVal Y2&)

' 長方形内の色を反転描画
Declare Function Api_InvertRect& Lib "user32" Alias "InvertRect" (ByVal hDC&, lpRect As RECT)

' 指定されたウィンドウのクライアント領域または画面全体を表すディスプレイデバイスコンテキストのハンドルを取得
Declare Function Api_GetDC& Lib "user32" Alias "GetDC" (ByVal hWnd&)

' デバイスコンテキストを解放
Declare Function Api_ReleaseDC& Lib "user32" Alias "ReleaseDC" (ByVal hWnd&, ByVal hDC&)

'================================================================
'=
'================================================================
Declare Sub MainForm_Start edecl ()
Sub MainForm_Start()
    Var R As RECT
    Var hDC As Long
    Var Ret As Long

    hDC = Api_GetDC(GethWnd)

    R.Left = 35
    R.Right = 105
    R.Top = 30
    R.Bottom = 80

    'Rectangle
    Ret = Api_Rectangle(hDC, R.Left, R.Top, R.Right, R.Bottom)

    R.Left = 130
    R.Right = 200

    'Invert Rectangle(InvertRect)
    Ret = Api_InvertRect(hDC, R)

    Ret = Api_ReleaseDC(GethWnd, hDC)
End Sub

'================================================================
'=
'================================================================
While 1
    WaitEvent
Wend
Stop
End