public bool PreFilterMessage(ref Message m)
 {
     if (m.Msg == WM_KEYDOWN)
     {
         Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode;
         if (keyCode == Keys.ControlKey)
         {
             if (!ctrlDown && dragged != null && IsDocked(dragged))
             {
                 ToolBarDockArea docked = GetDockedArea(dragged);
                 docked.SuspendLayout();
                 dragged.Parent             = dragged.FloatForm;
                 dragged.Location           = new Point(0, 0);
                 dragged.DockStyle          = DockStyle.None;
                 dragged.FloatForm.Visible  = true;
                 dragged.FloatForm.Location = new Point(Control.MousePosition.X - ptOffset.X, Control.MousePosition.Y - 8);
                 dragged.FloatForm.Size     = dragged.Size;
                 docked.ResumeLayout();
                 docked.PerformLayout();
             }
             ctrlDown = true;
         }
     }
     else if (m.Msg == WM_KEYUP)
     {
         Keys keyCode = (Keys)(int)m.WParam & Keys.KeyCode;
         if (keyCode == Keys.ControlKey)
         {
             if (ctrlDown && dragged != null && !IsDocked(dragged))
             {
                 ToolBarDockArea closest = GetClosestArea(Control.MousePosition, dragged.PreferredDockedArea);
                 if (closest != null)
                 {
                     closest.SuspendLayout();
                     Point newLoc = closest.PointToClient(Control.MousePosition);
                     dragged.DockStyle = closest.Dock;
                     dragged.Parent    = closest;
                     dragged.PreferredDockedLocation = newLoc;
                     dragged.FloatForm.Visible       = false;
                     dragged.PreferredDockedArea     = closest;
                     closest.ResumeLayout();
                     closest.PerformLayout();
                 }
             }
             ctrlDown = false;
         }
     }
     return(false);
 }
        private void ToolBarMouseMove(object sender, MouseEventArgs e)
        {
            Point ptPos = new Point(e.X, e.Y);

            if (dragged != null)
            {
                Point ptDelta = new Point(ptStart.X - Control.MousePosition.X, ptStart.Y - Control.MousePosition.Y);

                Point newLoc = dragged.PointToScreen(new Point(0, 0));
                newLoc = new Point(newLoc.X - ptDelta.X, newLoc.Y - ptDelta.Y);
                ToolBarDockArea closest = GetClosestArea(Control.MousePosition, dragged.PreferredDockedArea);
                // Added by mav
                if (closest != null && !dragged.IsAllowed(closest.Dock))
                {
                    closest = null;
                }

                ToolBarDockArea docked = GetDockedArea(dragged);

                if (ctrlDown)
                {
                    closest = null;
                }

                if (docked != null)
                {
                    if (closest == null)
                    {
                        docked.SuspendLayout();
                        dragged.Parent             = dragged.FloatForm;
                        dragged.Location           = new Point(0, 0);
                        dragged.DockStyle          = DockStyle.None;
                        dragged.FloatForm.Visible  = true;
                        dragged.FloatForm.Location = new Point(Control.MousePosition.X - ptOffset.X, Control.MousePosition.Y - 8);
                        dragged.FloatForm.Size     = dragged.Size;
                        docked.ResumeLayout();
                        docked.PerformLayout();
                    }
                    else if (closest != docked)
                    {
                        closest.SuspendLayout();
                        newLoc            = closest.PointToClient(Control.MousePosition);
                        dragged.DockStyle = closest.Dock;
                        dragged.Parent    = closest;
                        dragged.PreferredDockedLocation = newLoc;
                        dragged.FloatForm.Visible       = false;
                        dragged.PreferredDockedArea     = closest;
                        closest.ResumeLayout();
                        closest.PerformLayout();
                    }
                    else
                    {
                        closest.SuspendLayout();
                        newLoc = closest.PointToClient(Control.MousePosition);
                        //						if(closest.Horizontal)
                        //							newLoc = new Point(newLoc.X - 4, newLoc.Y - dragged.Height/2);
                        //						else
                        //							newLoc = new Point(newLoc.X - dragged.Width/2, newLoc.Y - 4);
                        dragged.PreferredDockedLocation = newLoc;
                        closest.ResumeLayout();
                        closest.PerformLayout();
                    }
                }
                else
                {
                    if (closest == null)
                    {
                        dragged.FloatForm.Location = newLoc;
                    }
                    else
                    {
                        closest.SuspendLayout();
                        newLoc            = closest.PointToClient(Control.MousePosition);
                        dragged.DockStyle = closest.Dock;
                        dragged.Parent    = closest;
                        dragged.PreferredDockedLocation = newLoc;
                        dragged.FloatForm.Visible       = false;
                        dragged.PreferredDockedArea     = closest;
                        closest.ResumeLayout();
                        closest.PerformLayout();
                    }
                }
                ptStart = Control.MousePosition;
            }
        }