/// <summary> /// Callback for making this control thread safe /// </summary> /// <param name="size"></param> private void SetSizeCallback(int size) { switch (this.captionAlign) { case DirectionStyle.Down: int tempY = this.Height - size; //set the new location of the panel Win32Wrapper.SetWindowPos(this.Handle, IntPtr.Zero, this.Location.X, this.Location.Y + tempY, this.Width, size, Win32Wrapper.FlagsSetWindowPos.SWP_NOZORDER | Win32Wrapper.FlagsSetWindowPos.SWP_SHOWWINDOW); break; case DirectionStyle.Up: this.Height = size; break; case DirectionStyle.Right: int tempX = this.Width - size; Win32Wrapper.SetWindowPos(this.Handle, IntPtr.Zero, this.Location.X + tempX, this.Location.Y, size, this.Height, Win32Wrapper.FlagsSetWindowPos.SWP_NOZORDER | Win32Wrapper.FlagsSetWindowPos.SWP_SHOWWINDOW); break; case DirectionStyle.Left: this.Width = size; if (this.Width < this.captionCtrl.Width) { this.Width = this.captionCtrl.Width; } break; } }
/// <summary> /// Method called in order to have this control accessed in a thread safe way /// </summary> private void AnimationFinished() { //check to see if Anchoring needs special treatment if (this.captionAlign == DirectionStyle.Right || this.captionAlign == DirectionStyle.Down) { this.Anchor = backupAnchor; } if (captionAlign == DirectionStyle.Down) { //set caption location (no redrawing) and hiding Win32Wrapper.SetWindowPos(this.captionCtrl.Handle, IntPtr.Zero, 0, this.Height - this.captionCtrl.Height, 0, 0, Win32Wrapper.FlagsSetWindowPos.SWP_NOREDRAW | Win32Wrapper.FlagsSetWindowPos.SWP_NOZORDER | Win32Wrapper.FlagsSetWindowPos.SWP_NOSIZE | Win32Wrapper.FlagsSetWindowPos.SWP_HIDEWINDOW); //set back the parent this.captionCtrl.Parent = this; this.captionCtrl.Visible = true; //set back the moveable property; during collapsing the movement is not allowed moveable = backupMoveable; } else { if (captionAlign == DirectionStyle.Right) { //set caption location (no redrawing) and hiding Win32Wrapper.SetWindowPos(this.captionCtrl.Handle, IntPtr.Zero, this.Width - this.captionCtrl.Width, 0, 0, 0, Win32Wrapper.FlagsSetWindowPos.SWP_NOREDRAW | Win32Wrapper.FlagsSetWindowPos.SWP_NOZORDER | Win32Wrapper.FlagsSetWindowPos.SWP_NOSIZE | Win32Wrapper.FlagsSetWindowPos.SWP_HIDEWINDOW); //set back the parent this.captionCtrl.Parent = this; this.captionCtrl.Visible = true; //set back the moveable property; during collapsing the movement is not allowed moveable = backupMoveable; } } //set the state of the object expanded/collapsed SetState(); ShowControls(); }
/// <summary> /// This method will take the caption control out of the controls of this panel /// </summary> private void ChangeCaptionParent() { //take the caption out of the panel beacause of the flickering this.captionCtrl.Parent = this.Parent; this.captionCtrl.Location = new Point(this.Location.X + this.Width - this.captionCtrl.Width, this.Location.Y + this.Height - this.captionCtrl.Height); Win32Wrapper.SetWindowPos(this.Handle, this.captionCtrl.Handle, 0, 0, 0, 0, Win32Wrapper.FlagsSetWindowPos.SWP_NOMOVE | Win32Wrapper.FlagsSetWindowPos.SWP_NOSIZE | Win32Wrapper.FlagsSetWindowPos.SWP_NOREDRAW); //disable moving backupMoveable = moveable; moveable = false; }
protected override void WndProc(ref Message m) { if (!DesignMode && firstTimeVisible && m.Msg == 0x18) { firstTimeVisible = false; backupHeight = Height; backupWidth = Width; switch (captionAlign) { case DirectionStyle.Down: //set the new location of the panel Win32Wrapper.SetWindowPos(Handle, IntPtr.Zero, Location.X, Location.Y + captionCtrl.Location.Y, Width, captionCtrl.Height, Win32Wrapper.FlagsSetWindowPos.SWP_NOZORDER); captionCtrl.SetDirectionStyle(DirectionStyle.Up); break; case DirectionStyle.Up: Height = captionCtrl.Height; captionCtrl.SetDirectionStyle(DirectionStyle.Down); break; case DirectionStyle.Right: //int tempX = this.Width - size; Win32Wrapper.SetWindowPos(Handle, IntPtr.Zero, Location.X + Width - captionCtrl.Location.X, Location.Y, captionCtrl.Width, Height, Win32Wrapper.FlagsSetWindowPos.SWP_NOZORDER); captionCtrl.SetDirectionStyle(DirectionStyle.Left); break; case DirectionStyle.Left: Width = captionCtrl.Width; captionCtrl.SetDirectionStyle(DirectionStyle.Right); break; } captionCtrl.Location = new Point(0, 0); //set the state of the object expanded/collapsed ShowControls(); } base.WndProc(ref m); }