/// <summary> /// <para> /// Requests a size and screen position for an appbar. When the request is made, the message proposes a /// screen edge and a bounding rectangle for the appbar. /// </para> /// <para> /// The system adjusts the bounding rectangle so /// that the appbar does not interfere with the Windows taskbar or any other appbars. /// </para> /// </summary> public void QueryPosition(ref Position position, DockPosition dock) { //TODO: //ABM_QUERYPOS seems to do nothing on Windows 10. It gives back the exact //same dimensions, not adjusting for the start bar //When the dock is docked to the left for example, it doesn't take the //entire screen length because the start bar is there. I used ABM_QUERYPOS //to tell me how much space Windows actually assigned to to the dock //Since ABM_QUERYPOS doesn't work properly on Windows 10, I've decided //to only allow the screen to be reserved when docked to top of the screen, //with the assumption that the start bar is always on the botton of the screen //The code is being left "as is" in case I figure out the solution to it APPBARDATA msgData = new APPBARDATA(); msgData.cbSize = Marshal.SizeOf(msgData); msgData.hWnd = _handle; msgData.uEdge = (uint)dock.ToNative(); position.ToNative(ref msgData.rc); Win32AppBar.SHAppBarMessage(ABM.ABM_QUERYPOS, ref msgData); position = Position.FromNative(ref msgData.rc); }
/// <summary> /// <para> /// Sets the size and screen position of an appbar. The message specifies a /// screen edge and the bounding rectangle for the appbar. /// </para> /// <para> /// The system may adjust the bounding rectangle so that the appbar does not /// interfere with the Windows taskbar or any other appbars. /// </para> /// </summary> public void SetPosition(ref Position position, DockPosition dock) { APPBARDATA msgData = new APPBARDATA(); msgData.cbSize = Marshal.SizeOf(msgData); msgData.hWnd = _handle; msgData.uEdge = (uint)dock.ToNative(); position.ToNative(ref msgData.rc); if (dock.Selected == DockEdge.Top) { msgData.rc.bottom = msgData.rc.bottom + 8; } Win32AppBar.SHAppBarMessage(ABM.ABM_SETPOS, ref msgData); position = Position.FromNative(ref msgData.rc); }
/// <summary> /// <para> /// Sets the size and screen position of an appbar. The message specifies a /// screen edge and the bounding rectangle for the appbar. /// </para> /// <para> /// The system may adjust the bounding rectangle so that the appbar does not /// interfere with the Windows taskbar or any other appbars. /// </para> /// </summary> public void SetPosition(ref Position position, DockPosition dock) { APPBARDATA msgData = new APPBARDATA(); msgData.cbSize = Marshal.SizeOf(msgData); msgData.hWnd = _handle; msgData.uEdge = (uint)dock.ToNative(); position.ToNative(ref msgData.rc); Win32AppBar.SHAppBarMessage(ABM.ABM_SETPOS, ref msgData); position = Position.FromNative(ref msgData.rc); }