タイトルバー(長方形)の情報取得          <TOP>


タイトルバーの表示部分(長方形)を取得します。

GetTitleBarInfo タイトルバーの情報を取得

 

左:WindowsXP    右:クラシックスタイル

 

 
'================================================================
'= タイトルバー(長方形)情報取得
'=    (GetTitleBarInfo.bas)
'================================================================
#include "Windows.bi"

#define STATE_SYSTEM_FOCUSABLE &H100000 'フォーカス可能
#define STATE_SYSTEM_INVISIBLE &H8000   '非表示
#define STATE_SYSTEM_OFFSCREEN &H10000  '非可視状態
#define STATE_SYSTEM_PRESSED &H8        '押下状態
#define STATE_SYSTEM_UNAVAILABLE &H1    '無効
#define CCHILDREN_TITLEBAR 5            '

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

Type TITLEBARINFO
    cbSize As Long
    rcTitleBar As RECT
    rgstate(CCHILDREN_TITLEBAR) As Long
End Type

' タイトルバーの表示部分(長方形)を取得
Declare Function Api_GetTitleBarInfo& Lib "user32" Alias "GetTitleBarInfo" (ByVal hWnd&, ByRef pti As TITLEBARINFO)

Var Shared Text1 As Object
Var Shared Timer1 As Object

Text1.Attach GetDlgItem("Text1") : Text1.SetFontSize 14
Timer1.Attach getDlgItem("Timer1")

'================================================================
'=
'================================================================
Declare Sub Timer1_Timer edecl ()
Sub Timer1_Timer()
    Var ti As TITLEBARINFO
    Var Ret As Long

    '構造体初期化
    ti.cbSize = Len(ti)

    'このウィンドウのタイトルバー情報を取得
    Ret = Api_GetTitleBarInfo(GethWnd, ti)

    '情報を表示
    Text1.SetWindowText "Title bar rectangle:" & Chr$(13) & "(" & Str$(ti.rcTitleBar.Left) & "," & Str$(ti.rcTitleBar.Top) & ") - (" & Str$(ti.rcTitleBar.Right) & "," & Str$(ti.rcTitleBar.Bottom) & ")"
End Sub

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