void SetAppPos() { new Thread(new ThreadStart(() => { Rectangle pos = new Rectangle(); AppBarData taskbarInfo = new AppBarData(); while (true) { API.GetWindowRect(hTaskList, out var rcBar); API.SHAppBarMessage(0x00000005, ref taskbarInfo); this.Invoke(new Action(() => { this.Width = labPrice.Width; })); switch (taskbarInfo.uEdge) { case 2: pos.X = 0; pos.Y = rcBar.Bottom - rcBar.Top - this.Height; pos.Width = rcBar.Right - rcBar.Left; pos.Height = this.Height; break; case 3: //任务栏在下边 pos.X = rcBar.Right - rcBar.Left - this.Width; pos.Y = 0; pos.Width = this.Width; pos.Height = rcBar.Bottom - rcBar.Top; break; default: break; } this.Invoke(new Action(() => { API.MoveWindow(this.Handle, pos.X, pos.Y, pos.Width, pos.Height, true); })); Thread.Sleep(100); } })) { IsBackground = true }
public static extern uint SHAppBarMessage(int dwMessage, ref AppBarData pData);