/// <summary> /// Returns information for the Windows taskbar (type, location, size) /// </summary> public static Rectangle GetTaskbar(out AppBarLocation location) { var data = new APPBARDATA(); var res = SHAppBarMessage(ABM_GETTASKBARPOS, ref data); location = data.uEdge; return Rectangle.FromLTRB(data.rc.left, data.rc.top, data.rc.right, data.rc.bottom); }
/// <summary> /// Returns information for the Windows taskbar (type, location, size) /// </summary> public static Rectangle GetTaskbar(out AppBarLocation location) { var data = new APPBARDATA(); var res = SHAppBarMessage(ABM_GETTASKBARPOS, ref data); location = data.uEdge; return(Rectangle.FromLTRB(data.rc.left, data.rc.top, data.rc.right, data.rc.bottom)); }
public void ABSetPos(IntPtr hadle, AppBarLocation appbarlocation, int realwidth, int realheight, int viewwidth, int viewheight) { if (IsBarRegistered) { var abd = new APPBARDATA(); abd.cbSize = Marshal.SizeOf(abd); abd.hWnd = hadle; abd.uEdge = (int)appbarlocation; switch (appbarlocation) { case AppBarLocation.Left: { abd.rc.left = 0; abd.rc.top = 0; abd.rc.right = (int)(viewwidth * ScreenResolution.RealScale); abd.rc.bottom = realheight; break; } case AppBarLocation.Right: { abd.rc.left = realwidth - (int)(viewwidth * ScreenResolution.RealScale); abd.rc.top = 0; abd.rc.right = realwidth; abd.rc.bottom = realheight; break; } case AppBarLocation.Top: { abd.rc.left = 0; abd.rc.top = 0; abd.rc.right = realwidth; abd.rc.bottom = (int)(viewheight * ScreenResolution.RealScale); break; } case AppBarLocation.Bottom: { abd.rc.left = 0; abd.rc.top = realheight - (int)(viewheight * ScreenResolution.RealScale); abd.rc.right = realwidth; abd.rc.bottom = realheight; break; } default: break; } SHAppBarMessage(ABM_QUERYPOS, ref abd); SHAppBarMessage(ABM_SETPOS, ref abd); var left = abd.rc.left; MoveWindow(abd.hWnd, left, abd.rc.top, abd.rc.right - abd.rc.left, abd.rc.bottom - abd.rc.top, false); } }
public void RegisterBar(IntPtr handle, AppBarLocation appbarlocation, int realwidth, int realheight, int viewwidth, int viewheight) { if (!IsBarRegistered) { var abd = new APPBARDATA(); abd.cbSize = Marshal.SizeOf(abd); abd.hWnd = handle; this.WndProcCallBack = RegisterWindowMessage("AppBarMessage"); abd.uCallbackMessage = this.WndProcCallBack; uint ret = SHAppBarMessage(ABM_NEW, ref abd); IsBarRegistered = true; ABSetPos(handle, appbarlocation, realwidth, realheight, viewwidth, viewheight); } }
public AppBarWindow(AppBarLocation appbarlocation) : this() { this.AppBarLocation = appbarlocation; }