矩形領域枠を点線で描画する          <TOP>


矩形領域枠を点線で描画します。

DrawFocusRect 指定の矩形の周囲にフォーカスを示す点線を描画する

 

左:「実行」ボタンをクリック    右:2度実行すると線は消えます。

 

点線であることの確認(Loupe使用)

 

'================================================================
'= 矩形領域枠を点線で描画する
'=    (DrawFocusRect.bas)
'================================================================
#include "Windows.bi"

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

' 指定の矩形の周囲にフォーカスを示す点線を描画する
Declare Function Api_DrawFocusRect& Lib "user32" Alias "DrawFocusRect" (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&)
 

Var Shared hDC As Long

'================================================================
'=
'================================================================
Declare Sub Button1_on edecl ()
Sub Button1_on()
    Var rct As RECT
    Var Ret As Long

    hDC = Api_GetDC(GethWnd)

    rct.Top = 10
    rct.Left = 20
    rct.Right = 200
    rct.Bottom = 65

    Ret = Api_DrawFocusRect(hDC, rct)
    Ret = Api_ReleaseDC(GethWnd, hDC)
End Sub

'================================================================
'=
'================================================================
Declare Sub MainForm_QueryClose edecl (Shift%, Mode%)
Sub MainForm_QueryClose(Shift%, Mode%)
    Var Ret As Long

    Ret = Api_ReleaseDC(GethWnd, hDC)
    End
End Sub

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