public static extern uint SHAppBarMessage(int dwMessage, ref APPBARDATA pData);
private static RECT AdjustWorkingAreaForAutoHide(IntPtr monitorContainingApplication, RECT area) { // maybe we can use ReBarWindow32 isntead Shell_TrayWnd IntPtr hwnd = NativeMethods.FindWindow("Shell_TrayWnd", null); IntPtr monitorWithTaskbarOnIt = NativeMethods.MonitorFromWindow(hwnd, (uint)MonitorOptions.MONITOR_DEFAULTTONEAREST); var abd = new APPBARDATA(); abd.cbSize = Marshal.SizeOf(abd); abd.hWnd = hwnd; NativeMethods.SHAppBarMessage((int)ABMsg.ABM_GETTASKBARPOS, ref abd); bool autoHide = Convert.ToBoolean(NativeMethods.SHAppBarMessage((int)ABMsg.ABM_GETSTATE, ref abd)); if (!autoHide || !Equals(monitorContainingApplication, monitorWithTaskbarOnIt)) { return area; } switch (abd.uEdge) { case (int)ABEdge.ABE_LEFT: area.Left += 2; break; case (int)ABEdge.ABE_RIGHT: area.Right -= 2; break; case (int)ABEdge.ABE_TOP: area.Top += 2; break; case (int)ABEdge.ABE_BOTTOM: area.Bottom -= 2; break; default: return area; } return area; }
public static extern uint SHAppBarMessage(int dwMessage, ref APPBARDATA pData);