private void SizeAppBar() { ShellApi.ShellApi.RECT rt = new ShellApi.ShellApi.RECT(); if ((m_Edge == AppBarEdges.Left) || (m_Edge == AppBarEdges.Right)) { rt.top = 0; rt.bottom = SystemInformation.PrimaryMonitorSize.Height; if (m_Edge == AppBarEdges.Left) { rt.right = m_PrevSize.Width; } else { rt.right = SystemInformation.PrimaryMonitorSize.Width; rt.left = rt.right - m_PrevSize.Width; } } else { rt.left = 0; rt.right = SystemInformation.PrimaryMonitorSize.Width; if (m_Edge == AppBarEdges.Top) { rt.bottom = m_PrevSize.Height; } else { rt.bottom = SystemInformation.PrimaryMonitorSize.Height; rt.top = rt.bottom - m_PrevSize.Height; } } AppbarQueryPos(ref rt); switch (m_Edge) { case AppBarEdges.Left: rt.right = rt.left + m_PrevSize.Width; break; case AppBarEdges.Right: rt.left = rt.right - m_PrevSize.Width; break; case AppBarEdges.Top: rt.bottom = rt.top + m_PrevSize.Height; break; case AppBarEdges.Bottom: rt.top = rt.bottom - m_PrevSize.Height; break; } AppbarSetPos(ref rt); Location = new Point(rt.left, rt.top); Size = new Size(rt.right - rt.left, rt.bottom - rt.top); }
private void AppbarGetTaskbarPos(out ShellApi.ShellApi.RECT taskRect) { // prepare data structure of message ShellApi.ShellApi.APPBARDATA msgData = new ShellApi.ShellApi.APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); // get taskbar position ShellApi.ShellApi.SHAppBarMessage((UInt32)AppBarMessages.GetTaskBarPos, ref msgData); taskRect = msgData.rc; }
private void AppbarSetPos(ref ShellApi.ShellApi.RECT appRect) { // prepare data structure of message ShellApi.ShellApi.APPBARDATA msgData = new ShellApi.ShellApi.APPBARDATA(); msgData.cbSize = (UInt32)Marshal.SizeOf(msgData); msgData.hWnd = Handle; msgData.uEdge = (UInt32)m_Edge; msgData.rc = appRect; // set postion for the appbar ShellApi.ShellApi.SHAppBarMessage((UInt32)AppBarMessages.SetPos, ref msgData); appRect = msgData.rc; }
private void SizeAppBar() { ShellApi.ShellApi.RECT rt = new ShellApi.ShellApi.RECT(); if ((m_Edge == AppBarEdges.Left) || (m_Edge == AppBarEdges.Right)) { rt.top = 0; rt.bottom = SystemInformation.PrimaryMonitorSize.Height; if (m_Edge == AppBarEdges.Left) { rt.right = m_PrevSize.Width; } else { rt.right = SystemInformation.PrimaryMonitorSize.Width; rt.left = rt.right - m_PrevSize.Width; } } else { rt.left = 0; rt.right = SystemInformation.PrimaryMonitorSize.Width; if (m_Edge == AppBarEdges.Top) { rt.bottom = m_PrevSize.Height; } else { rt.bottom = SystemInformation.PrimaryMonitorSize.Height; rt.top = rt.bottom - m_PrevSize.Height; } } AppbarQueryPos(ref rt); switch (m_Edge) { case AppBarEdges.Left: rt.right = rt.left + m_PrevSize.Width; break; case AppBarEdges.Right: rt.left = rt.right - m_PrevSize.Width; break; case AppBarEdges.Top: rt.bottom = rt.top + m_PrevSize.Height; break; case AppBarEdges.Bottom: rt.top = rt.bottom - m_PrevSize.Height; break; } AppbarSetPos(ref rt); Location = new Point(rt.left, rt.top); Size = new Size(rt.right - rt.left, rt.bottom - rt.top); }