Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/VCL/Docking    [ Add a report in this area ]  
Report #:  28614   Status: Closed
TCustomDockForm.Wrong position window-carrier (Float forms)
Project:  Delphi Build #:  Delphi2005
Version:    9.0 Submitted By:   ????????? ??????
Report Type:  Basic functionality failure Date Reported:  4/30/2006 1:49:13 PM
Severity:    Extreme corner case Last Updated: 9/5/2012 4:57:32 PM
Platform:    All platforms Internal Tracking #:   274819
Resolution: Cannot Reproduce (Resolution Comments) Resolved in Build: : None
Duplicate of:  None
Voting and Rating
Overall Rating: (6 Total Ratings)
5.00 out of 5
Total Votes: 10
Description
If any management body with property DragKind=dkDock, try to disconnect from parental component and throw in free area of the screen, that he will occupy not that position, which he was indicated by user, but that, which he has indicated the system. This reveals itself in Delphi 2005 and BDS 2006 (SP1).

Such behaviour is connected with that that in Delphi before version 7 inclusive on-default property Position was equal poDesigned (for all forms). In more late version this property became to be equal poDefaultPosOnly i.e. position of the form is defined by system. For window-carrier (TCustomDockForm) necessary that his(its) coordinates were defined software.
Steps to Reproduce:
None
Workarounds
1. Create the descendant TCustomDockForm, in constructor who assign the characteristic Position importance poDesigned. Then for each joined management body to indicate this class a window-carrier.
Panel2.FloatingDockSiteClass := TDockFormEx;

2. Change the source code of the module Forms:
constructor TCustomDockForm.Create(AOwner: TComponent);
begin
  CreateNew(AOwner);
  AutoScroll := False;
  BorderStyle := bsSizeToolWin;
  DockSite := True;
  FormStyle := fsStayOnTop;
  Position := poDesigned;  //inserted
end;
Attachment
None
Comments

Sebastian Modersohn at 7/29/2006 6:48:52 AM -
Could you please post some simple steps on how to reproduce the problem? And if possible attach some illustrating screenshots?

Sergey Roschin at 9/5/2006 2:19:53 AM -
Please click to button Button1.
Panel1.ManualFloat(Rect(500,100,600,300));

---------------------------------------------- Pas

unit Unit7;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm7 = class(TForm)
    Panel1: TPanel;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form7: TForm7;

implementation

{$R *.dfm}

procedure TForm7.Button1Click(Sender: TObject);
begin
  Panel1.ManualFloat(Rect(500,100,600,300));
end;

end.

----------------------------------------------- (dfm)

object Form7: TForm7
  Left = 0
  Top = 0
  Caption = 'Form7'
  ClientHeight = 286
  ClientWidth = 426
  Color = clBtnFace
  DockSite = True
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  PixelsPerInch = 96
  TextHeight = 13
  object Panel1: TPanel
    Left = 224
    Top = 88
    Width = 185
    Height = 41
    Caption = 'Panel1'
    DragKind = dkDock
    DragMode = dmAutomatic
    TabOrder = 0
  end
  object Button1: TButton
    Left = 112
    Top = 40
    Width = 75
    Height = 25
    Caption = 'Button1'
    TabOrder = 1
    OnClick = Button1Click
  end
end

Sergey Roschin at 4/25/2007 1:27:42 AM -
In Delphi2007 also!!!

????????? ?????? at 8/30/2009 5:41:49 AM -
Please correct this problem already! One line you want to add.

Francois GAILLARD at 4/4/2012 5:30:10 PM -
See this StackOverflow Q/A for the reason and a solution: http://stackoverflow.com/a/10017718/9842.

possible fix:
function TControl.CreateFloatingDockSite(Bounds: TRect): TWinControl;
begin
  Result := nil;
  if (FloatingDockSiteClass <> nil) and
    (FloatingDockSiteClass <> TWinControlClass(ClassType)) then
  begin
    Result := FloatingDockSiteClass.Create(Application);
    with Bounds do
    begin
      // Setting Client area can create the window handle and reset Top and Left depending on Position default
      Result.ClientWidth := Right - Left;
      Result.ClientHeight := Bottom - Top;
      // It is now safe to position the window where asked
      Result.Top := Top;
      Result.Left := Left;
    end;
  end;
end;

Tomohiro Takahashi at 5/11/2012 7:19:59 AM -
This is a comment from internal tracking system.
<<<<<<<<
We need a demo.
>>>>>>>>

Server Response from: ETNACODE01