タスクバーの位置とサイズの取得          <TOP>


タスクバーの位置とサイズを取得します。

SHAppBarMessage アプリケーションバーのメッセージをシステムに送る

 

WindowsXP例                                           Windows98例

 

 


 

'================================================================
'= タスクバーの位置とサイズ
'=    (AppBarMsg.bas)
'================================================================
#include "Windows.bi"

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

Type APPBARDATA
    cbSize As Long
    hWnd   As Long
    uCallbackMessage As Long
    uEdge  As Long
    rc     As RECT
    lParam As Long
End Type

' アプリケーションバーのメッセージをシステムに送る
Declare Function Api_SHAppBarMessage& Lib "Shell32" Alias "SHAppBarMessage" (ByVal dwMessage&, pData As APPBARDATA)

#define ABM_GETTASKBARPOS &H5           'アプリケーションバーの位置とサイズを調べる

Var Shared Text1 As Object
Text1.Attach GetDlgItem("Text1") : Text1.SetFontSize 14

'================================================================
'=
'================================================================
Declare Sub MainForm_Start edecl ()
Sub MainForm_Start()
    Var AppData As APPBARDATA
    Var txt As String
    Var CrLf As String
    Var Ret As Long

    CrLf = Chr$(13,10)

    'タスクバーの位置とサイズを取得します
    Ret = Api_SHAppBarMessage(ABM_GETTASKBARPOS, AppData)

    txt =       " 縦位置(Top) : " & Format$(AppData.rc.Top,"#,###") & CrLf
    txt = txt & " 横位置(Left): " & Format$(AppData.rc.Left,"#,###") & CrLf
    txt = txt & " 幅(Width)   : " & Format$(AppData.rc.Right - AppData.rc.Left,"#,###") & CrLf
    txt = txt & " 高さ(Height): " & Format$(AppData.rc.Bottom - AppData.rc.Top,"#,###")
    Text1.SetWindowText txt
End Sub

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