lcl, designer: add and use GetDesignerForm

git-svn-id: trunk@51133 -
This commit is contained in:
ondrej 2016-01-02 18:20:54 +00:00
parent 9b43183ae9
commit 0ba709770d
4 changed files with 23 additions and 8 deletions

View File

@ -2008,7 +2008,7 @@ begin
Exclude(FFLags, dfHasSized);
SetCaptureControl(nil);
DesignSender := GetDesignControl(Sender);
ParentForm := GetParentForm(DesignSender);
ParentForm := GetDesignerForm(DesignSender);
//DebugLn(['TDesigner.MouseDownOnControl DesignSender=',dbgsName(DesignSender),' ParentForm=',dbgsName(ParentForm)]);
if (ParentForm = nil) then exit;
@ -2390,7 +2390,7 @@ begin
// check if the message is for the designed form and there was a mouse down before
DesignSender:=GetDesignControl(Sender);
SenderParentForm:=GetParentForm(DesignSender);
SenderParentForm:=GetDesignerForm(DesignSender);
//DebugLn(['TDesigner.MouseUpOnControl DesignSender=',dbgsName(DesignSender),' SenderParentForm=',dbgsName(SenderParentForm),' ',TheMessage.XPos,',',TheMessage.YPos]);
if (MouseDownComponent=nil) or (SenderParentForm=nil)
or (SenderParentForm<>Form)
@ -2562,7 +2562,7 @@ begin
DesignSender := GetDesignControl(Sender);
//DebugLn('TDesigner.MouseMoveOnControl Sender=',dbgsName(Sender),' ',dbgsName(DesignSender));
SenderParentForm := GetParentForm(DesignSender);
SenderParentForm := GetDesignerForm(DesignSender);
if (SenderParentForm = nil) or (SenderParentForm <> Form) then Exit;
OldMouseMovePos := LastMouseMovePos;

View File

@ -130,7 +130,7 @@ var
begin
if Component is TControl then
begin
ParentForm := GetParentForm(TControl(Component));
ParentForm := GetDesignerForm(TControl(Component));
Parent := TControl(Component).Parent;
if (Parent = nil) or (ParentForm = nil) then
begin
@ -150,7 +150,7 @@ begin
if Component.Owner is TWinControl then
begin
Parent:=TWinControl(Component.Owner);
ParentForm := GetParentForm(Parent);
ParentForm := GetDesignerForm(Parent);
if (ParentForm<>nil) and (ParentForm<>Parent) then
begin
p:=Parent.ClientOrigin;
@ -180,7 +180,7 @@ var
begin
if Component is TControl then
begin
ParentForm := GetParentForm(TControl(Component));
ParentForm := GetDesignerForm(TControl(Component));
if ParentForm = nil then
Result := Point(0, 0)
else
@ -205,7 +205,7 @@ var
begin
if Component is TControl then
begin
ParentForm := GetParentForm(TControl(Component));
ParentForm := GetDesignerForm(TControl(Component));
Parent := TControl(Component).Parent;
if (Parent = nil) or (ParentForm = nil) then
Result := Point(0, 0)

View File

@ -1747,6 +1747,7 @@ var
IsFormDesign: TIsFormDesignFunction = nil;
function GetParentForm(Control: TControl; TopForm: Boolean = True): TCustomForm;
function GetDesignerForm(Control: TControl): TCustomForm;
function GetFirstParentForm(Control:TControl): TCustomForm;
function ValidParentForm(Control: TControl; TopForm: Boolean = True): TCustomForm;
function GetDesignerForm(APersistent: TPersistent): TCustomForm;
@ -1938,6 +1939,20 @@ begin
Result := nil;
end;
//------------------------------------------------------------------------------
function GetDesignerForm(Control: TControl): TCustomForm;
begin
// find the topmost parent form with designer
Result := nil;
while Control<>nil do
begin
if (Control is TCustomForm) and (TCustomForm(Control).Designer<>nil) then
Result := TCustomForm(Control);
Control := Control.Parent;
end;
end;
//------------------------------------------------------------------------------
function ValidParentForm(Control: TControl; TopForm: Boolean): TCustomForm;
begin

View File

@ -2033,7 +2033,7 @@ begin
if (csDesigning in ComponentState) then
begin
// redirect messages to designer
Form := GetParentForm(Self);
Form := GetDesignerForm(Self);
//debugln(['TControl.WndProc ',dbgsname(Self)]);
if Assigned(Form) and Assigned(Form.Designer) and Form.Designer.IsDesignMsg(Self, TheMessage) then
Exit;