■ Access VBA 実行コード
Private Const ABM_GETTASKBARPOS = &H5
'四角形の左上隅と右下隅の座標を格納する構造体
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'タスクバーのパラメーターが格納される構造体
Private Type APPBARDATA
cbSize As Long
hwnd As Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long
End Type
'ウィンドウズAPI
Private Declare Function SHAppBarMessage Lib "shell32.dll" _
(ByVal dwMessage As Long, pData As APPBARDATA)
As Long
’高さ取得プロシージャ
Public Function MyGetTaskBarHeight(lhWnd As Long) As Integer
Dim tAdb As APPBARDATA
Dim lRet As Long
tAdb.cbSize = Len(tAdb)
tAdb.hwnd = lhWnd
lRet = SHAppBarMessage(ABM_GETTASKBARPOS, tAdb)
'高さを計算し返します
MyGetTaskBarHeight = tAdb.rc.Bottom - tAdb.rc.Top
End Function
'コマンドクリックイベント
Private Sub コマンド0_Click()
Me.Caption = MyGetTaskBarHeight(Me.hwnd)
End Sub