このコードは、私がthis post on CodeGuruから拝借した情報に基づき作成されたものです。コメント欄の修正案がx64でこのコードを実行できるようにしたVisual Vincentに感謝します。
準備:共有の定数、変数、関数:
Const ABS_AUTOHIDE As Int32 = 1
Const ABS_ONTOP As Int32 = 2
Const ABM_NEW As Int32 = 0
Const ABM_REMOVE As Int32 = 1
Const ABM_QUERYPOS As Int32 = 2
Const ABM_SETPOS As Int32 = 3
Const ABM_GETSTATE As Int32 = 4
Const ABM_GETTASKBARPOS As Int32 = 5
Const ABM_ACTIVATE As Int32 = 6
Const ABM_GETAUTOHIDEBAR As Int32 = 7
Const ABM_SETAUTOHIDEBAR As Int32 = 8
Const ABM_WINDOWPOSCHANGED As Int32 = 9
Const TB_POS_BOTTOM As Integer = 1
Const TB_POS_TOP As Integer = 2
Const TB_POS_LEFT As Integer = 3
Const TB_POS_RIGHT As Integer = 4
Private Declare Function apiSHAppBarMessage Lib "shell32" Alias "SHAppBarMessage" (ByVal dwMessage As UInt32, ByRef pData As APPBARDATA) As UIntPtr
Private Structure RECT
Public rLeft, rTop, rRight, rBottom As Int32
End Structure
Private Structure APPBARDATA
Public cbSize As UInt32, hwnd As IntPtr, uCallbackMessage, uEdge As UInt32, rc As RECT, lParam As IntPtr
End Structure
Dim ABD As New APPBARDATA
Dim Autohide_State As Int32
Dim taskbar_left, taskbar_right, taskbar_top, taskbar_bottom, taskbar_edge, taskbar_thickness As Integer
第1 & 2:以下のサブタスクバーの上、下、左と右のエッジの位置と画面のエッジを見つけるために使用することができますそれが存在する。
Private Sub GetTaskBarEdge_and_Coordinates()
apiSHAppBarMessage(ABM_GETTASKBARPOS, ABD)
taskbar_left = ABD.rc.rLeft
taskbar_right = ABD.rc.rRight
taskbar_top = ABD.rc.rTop
taskbar_bottom = ABD.rc.rBottom
'Figure out if it's located on the buttom, top, left or right edge of screen
If (taskbar_left < 5) And (taskbar_top > 5) Then
taskbar_edge = TB_POS_BOTTOM
ElseIf (taskbar_left < 5) And (taskbar_top < 5) And (taskbar_right > taskbar_bottom) Then
taskbar_edge = TB_POS_TOP
ElseIf (taskbar_left < 5) And (taskbar_top < 5) And (taskbar_right < taskbar_bottom) Then
taskbar_edge = TB_POS_LEFT
ElseIf (taskbar_left > 5) And (taskbar_top < 5) Then
taskbar_edge = TB_POS_RIGHT
Else
MsgBox("Something went wrong while I was trying to find the taskbar edge. Please contact the develloper. Defaulting Edge to bottom.")
taskbar_edge = TB_POS_BOTTOM
End If
End Sub
第3部:機能の下に、自動隠し状態の整数値が表示されます。パート1のIセットアップ
0 Means AH is off, Always on top is off.
1 means AH is on and Always on Top is off.
2 means AH is off and AoT is on.
3 means AH and AoT are on.
注定数:ABS_AUTOHIDE = 1、ABS_ONTOP = 2
Private Function GetTaskBarAHState() As Integer
Return CInt(apiSHAppBarMessage(ABM_GETSTATE, Nothing))
End Function
パート4:タスクバー厚みがtaskbar_bottomから計算することができる - taskbar_top OR taskbar_right - taskbar_leftは(に応じどのタスクバーの端にあるか)。
Private Sub GetTaskBar_Thickness()
GetTaskBarEdge_and_Coordinates()
Select Case taskbar_edge
Case TB_POS_BOTTOM
taskbar_thickness = Math.Abs(taskbar_bottom - taskbar_top)
Case TB_POS_TOP
taskbar_thickness = Math.Abs(taskbar_bottom - taskbar_top)
Case Case TB_POS_LEFT
taskbar_thickness = Math.Abs(taskbar_right - taskbar_left)
Case TB_POS_RIGHT
taskbar_thickness = Math.Abs(taskbar_right - taskbar_left)
Case Else
MsgBox("Something went wrong while I tried to find Taskbar thickness. Please contact the develloper. Default to taskbar thickness of 39 [4]")
taskbar_thickness = 39
End Select
End Sub
「APPBARDATA」構造体のフィールドは正しいタイプではありません。 'cbSize'は' UInt32'、 'hWnd'は' IntPtr'、 'uCallbackMessage'と' uEdge'は 'UInt32'、' lParam'は 'IntPtr'でなければなりません。 –
また、 'apiSHAppBarMessage'関数の' dwMessage'パラメータは 'UInt32'でなければならず、関数の戻り値は' UIntPtr'でなければなりません。 –
Vincentありがとう、もう一度読んで、あなたが提案している変更を適用します。 – thebunnyrules