public Taskbar()
{
IntPtr taskbarHandle = User32.FindWindow(ClassName, null);
APPBARDATA data = new APPBARDATA
{
cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA)),
hWnd = taskbarHandle
};
IntPtr result = Shell32.SHAppBarMessage(AppBarMessage.GetTaskbarPos, ref data);
if (result == IntPtr.Zero)
{
throw new InvalidOperationException();
}
this.Position = (TaskbarPosition)data.uEdge;
this.Bounds = Rectangle.FromLTRB(data.rc.left, data.rc.top, data.rc.right, data.rc.bottom);
data.cbSize = (uint)Marshal.SizeOf(typeof(APPBARDATA));
result = Shell32.SHAppBarMessage(AppBarMessage.GetState, ref data);
int state = result.ToInt32();
this.AlwaysOnTop = (state & AppBarState.AlwaysOnTop) == AppBarState.AlwaysOnTop;
this.AutoHide = (state & AppBarState.Autohide) == AppBarState.Autohide;
}