Can Delphi dragging be "promoted" to docking?

Posted by mghie on Stack Overflow See other posts from Stack Overflow or by mghie
Published on 2010-04-08T15:14:25Z Indexed on 2010/04/10 16:33 UTC
Read the original article Hit count: 282

Filed under:
|
|

I have a TPageControl whose pages are all various forms that are attached using ManualDock(). The user should be able to rearrange the tabs by dragging them, which works already. It should however also be possible to undock the docked forms.

For now I have the following code:

procedure TMainForm.PageControlMouseDown(Sender: TObject; Button: TMouseButton;
  Shift: TShiftState; X, Y: Integer);
begin
  if (Button = mbLeft) and (Shift * [ssShift, ssCtrl] = [])
    and PageControl.DockSite
  then begin
    PageControl.BeginDrag(False, 32);
  end;
end;

If either the Shift or the Ctrl key are held down, then a docking operation will be started, otherwise the tabs can be rearranged by dragging them.

Using the keys as modifiers is awkward though. Is there any way to cancel the active drag operation when the mouse cursor is outside of the tab area of the page control, and start docking the child form? This is with Delphi 2009.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about drag-and-drop