designer: correctly calculate non-visual component offsets for the designer form

git-svn-id: trunk@22815 -
This commit is contained in:
paul 2009-11-27 02:36:03 +00:00
parent 3058df5224
commit b255bc1884

View File

@ -139,13 +139,24 @@ begin
end;
end else
begin
ParentForm := GetDesignerForm(Component);
Result.X := LeftFromDesignInfo(Component.DesignInfo);
Result.Y := TopFromDesignInfo(Component.DesignInfo);
while Component.Owner <> ParentForm do
begin
Component := Component.Owner;
if Component is TControl then
begin
inc(Result.X, TControl(Component).Left);
inc(Result.Y, TControl(Component).Top);
end;
end;
end;
end;
function GetParentFormRelativeBounds(Component: TComponent): TRect;
var CTopLeft: TPoint;
var
CTopLeft: TPoint;
begin
CTopLeft := GetParentFormRelativeTopLeft(Component);
Result.Left := CTopLeft.X;
@ -184,19 +195,35 @@ var
ParentForm: TCustomForm;
Parent: TWinControl;
begin
if Component is TControl then begin
if Component is TControl then
begin
ParentForm := GetParentForm(TControl(Component));
Parent := TControl(Component).Parent;
if (Parent=nil) or (ParentForm=nil) then begin
Result:=Point(0,0);
end else begin
if (Parent = nil) or (ParentForm = nil) then
Result := Point(0, 0)
else
begin
ParentOrigin := Parent.ClientOrigin;
FormOrigin := ParentForm.ClientOrigin;
Result.X := ParentOrigin.X - FormOrigin.X;
Result.Y := ParentOrigin.Y - FormOrigin.Y;
end;
end else begin
end
else
begin
Result := Point(0, 0);
ParentForm := GetDesignerForm(Component);
if ParentForm = nil then
Exit;
while Component.Owner <> ParentForm do
begin
Component := Component.Owner;
if Component is TControl then
begin
inc(Result.X, TControl(Component).Left);
inc(Result.Y, TControl(Component).Top);
end;
end;
end;
end;