mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-02 18:00:26 +02:00
lcl, designer: add and use GetDesignerForm
git-svn-id: trunk@51133 -
This commit is contained in:
parent
9b43183ae9
commit
0ba709770d
@ -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;
|
||||
|
@ -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)
|
||||
|
15
lcl/forms.pp
15
lcl/forms.pp
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user