()
+ };
+
+ // Locate the taskbar.
+ if (SHAppBarMessage(ABM_GETTASKBARPOS, ref data) == 0)
+ return new TaskbarInfo(TaskbarPosition.Bottom, 0, false); // failsafe
+
+ var autoHide = (SHAppBarMessage(ABM_GETSTATE, ref data) & ABS_AUTOHIDE) != 0;
+
+ // Use uEdge instead of guessing from the RECT.
+ var pos = data.uEdge switch
+ {
+ ABE_LEFT => TaskbarPosition.Left,
+ ABE_TOP => TaskbarPosition.Top,
+ ABE_RIGHT => TaskbarPosition.Right,
+ _ => TaskbarPosition.Bottom, // ABE_BOTTOM or anything unexpected
+ };
+
+ // Thickness (gap) = shorter side of the rect.
+ var gap = (pos == TaskbarPosition.Left || pos == TaskbarPosition.Right)
+ ? data.rc.right - data.rc.left // width
+ : data.rc.bottom - data.rc.top; // height
+
+ return new TaskbarInfo(pos, gap, autoHide);
+ }
+
+ // ------------- P/Invoke plumbing -------------
+ private const uint ABM_GETTASKBARPOS = 0x0005;
+ private const uint ABM_GETSTATE = 0x0004;
+ private const int ABS_AUTOHIDE = 0x0001;
+
+ private const int ABE_LEFT = 0; // values returned in APPBARDATA.uEdge
+ private const int ABE_TOP = 1;
+ private const int ABE_RIGHT = 2;
+ private const int ABE_BOTTOM = 3;
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct APPBARDATA
+ {
+ public uint cbSize;
+ public IntPtr hWnd;
+ public uint uCallbackMessage;
+ public uint uEdge; // contains ABE_* value
+ public RECT rc;
+ public int lParam;
+ }
+
+ [StructLayout(LayoutKind.Sequential)]
+ private struct RECT
+ {
+ public int left, top, right, bottom;
+ }
+
+ [DllImport("shell32.dll", CharSet = CharSet.Auto)]
+ private static extern uint SHAppBarMessage(uint dwMessage, ref APPBARDATA pData);
}
pFad - Phonifier reborn
Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.
Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.
Alternative Proxies:
Alternative Proxy
pFad Proxy
pFad v3 Proxy
pFad v4 Proxy