This is a migrated thread and some comments may be shown as answers.

Floating Window with no-border and RadTitleBar

1 Answer 160 Views
Dock
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 13 Dec 2012, 12:15 PM
Hello,
I'm adding a RadTitleBar to floating windows using the RadDock FloatingWindowCreatedEvent and then removing the floating window border through the FormBorderStyle property. However, everything I have tried so far results in a RadTitleBar that doesn't allow me to drag on it to move the window (although the buttons work correctly). Is it possible to get the RadTitleBar working with floating windows in this way, and if so, how?

Thanks!

1 Answer, 1 is accepted

Sort by
0
Julian Benkov
Telerik team
answered on 18 Dec 2012, 11:57 AM
Hello Jonh,

You can use the DragDropService to achieve this functionality. Here is a example with ToolWindows. The second ToolWindow supports drag & drop operations from the content area of window:
using System;
using System.Drawing;
using System.Windows.Forms;
using Telerik.WinControls.UI.Docking;
 
namespace Lab.Dock
{
    public partial class DockNotFrameFloatingForm : Form
    {
        private RadDock radDock = new RadDock();
 
        public DockNotFrameFloatingForm()
        {
            InitializeComponent();
 
            radDock.Dock = DockStyle.Fill;
            radDock.Parent = this;
            radDock.BringToFront();
 
            radDock.FloatingWindowCreated += radDock_FloatingWindowCreated;
        }
 
        void radDock_FloatingWindowCreated(object sender, FloatingWindowEventArgs e)
        {
            e.Window.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
        }
 
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
 
            ToolWindow tool = new ToolWindow("Tool1");
            radDock.DockWindow(tool, DockPosition.Left);
 
            tool = new ToolWindow("Tool2");
            tool.MouseMove += tool_MouseMove;
            tool.MouseDown += tool_MouseDown;
            tool.MouseUp += tool_MouseUp;
            radDock.DockWindow(tool, DockPosition.Left);
 
            tool = new ToolWindow("Tool3");
            radDock.DockWindow(tool, DockPosition.Left);
        }
 
        void tool_MouseUp(object sender, MouseEventArgs e)
        {
            beginDrag = false;
            radDock.GetService<DragDropService>().Stop(true);
        }
 
        private Point captionDragStart;
        private bool beginDrag = false;
 
        void tool_MouseDown(object sender, MouseEventArgs e)
        {
            captionDragStart = Control.MousePosition;
            beginDrag = true;
        }
 
        void tool_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button == System.Windows.Forms.MouseButtons.Left && ((DockWindow)sender).DockState == DockState.Floating && beginDrag && DockHelper.ShouldBeginDrag(Control.MousePosition, this.captionDragStart))
            {
                radDock.GetService<DragDropService>().Start(sender, Control.MousePosition);
            }
        }
    }
}

I hope this helps.

All the best,
Julian Benkov
the Telerik team
Q3’12 of RadControls for WinForms is available for download (see what's new). Get it today.
Tags
Dock
Asked by
John
Top achievements
Rank 1
Answers by
Julian Benkov
Telerik team
Share this question
or