mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-10-31 22:29:37 +01: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); |   Exclude(FFLags, dfHasSized); | ||||||
|   SetCaptureControl(nil); |   SetCaptureControl(nil); | ||||||
|   DesignSender := GetDesignControl(Sender); |   DesignSender := GetDesignControl(Sender); | ||||||
|   ParentForm := GetParentForm(DesignSender); |   ParentForm := GetDesignerForm(DesignSender); | ||||||
|   //DebugLn(['TDesigner.MouseDownOnControl DesignSender=',dbgsName(DesignSender),' ParentForm=',dbgsName(ParentForm)]); |   //DebugLn(['TDesigner.MouseDownOnControl DesignSender=',dbgsName(DesignSender),' ParentForm=',dbgsName(ParentForm)]); | ||||||
|   if (ParentForm = nil) then exit; |   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 |   // check if the message is for the designed form and there was a mouse down before | ||||||
|   DesignSender:=GetDesignControl(Sender); |   DesignSender:=GetDesignControl(Sender); | ||||||
|   SenderParentForm:=GetParentForm(DesignSender); |   SenderParentForm:=GetDesignerForm(DesignSender); | ||||||
|   //DebugLn(['TDesigner.MouseUpOnControl DesignSender=',dbgsName(DesignSender),' SenderParentForm=',dbgsName(SenderParentForm),' ',TheMessage.XPos,',',TheMessage.YPos]); |   //DebugLn(['TDesigner.MouseUpOnControl DesignSender=',dbgsName(DesignSender),' SenderParentForm=',dbgsName(SenderParentForm),' ',TheMessage.XPos,',',TheMessage.YPos]); | ||||||
|   if (MouseDownComponent=nil) or (SenderParentForm=nil) |   if (MouseDownComponent=nil) or (SenderParentForm=nil) | ||||||
|   or (SenderParentForm<>Form) |   or (SenderParentForm<>Form) | ||||||
| @ -2562,7 +2562,7 @@ begin | |||||||
| 
 | 
 | ||||||
|   DesignSender := GetDesignControl(Sender); |   DesignSender := GetDesignControl(Sender); | ||||||
|   //DebugLn('TDesigner.MouseMoveOnControl Sender=',dbgsName(Sender),' ',dbgsName(DesignSender)); |   //DebugLn('TDesigner.MouseMoveOnControl Sender=',dbgsName(Sender),' ',dbgsName(DesignSender)); | ||||||
|   SenderParentForm := GetParentForm(DesignSender); |   SenderParentForm := GetDesignerForm(DesignSender); | ||||||
|   if (SenderParentForm = nil) or (SenderParentForm <> Form) then Exit; |   if (SenderParentForm = nil) or (SenderParentForm <> Form) then Exit; | ||||||
| 
 | 
 | ||||||
|   OldMouseMovePos := LastMouseMovePos; |   OldMouseMovePos := LastMouseMovePos; | ||||||
|  | |||||||
| @ -130,7 +130,7 @@ var | |||||||
| begin | begin | ||||||
|   if Component is TControl then |   if Component is TControl then | ||||||
|   begin |   begin | ||||||
|     ParentForm := GetParentForm(TControl(Component)); |     ParentForm := GetDesignerForm(TControl(Component)); | ||||||
|     Parent := TControl(Component).Parent; |     Parent := TControl(Component).Parent; | ||||||
|     if (Parent = nil) or (ParentForm = nil) then |     if (Parent = nil) or (ParentForm = nil) then | ||||||
|     begin |     begin | ||||||
| @ -150,7 +150,7 @@ begin | |||||||
|     if Component.Owner is TWinControl then |     if Component.Owner is TWinControl then | ||||||
|     begin |     begin | ||||||
|       Parent:=TWinControl(Component.Owner); |       Parent:=TWinControl(Component.Owner); | ||||||
|       ParentForm := GetParentForm(Parent); |       ParentForm := GetDesignerForm(Parent); | ||||||
|       if (ParentForm<>nil) and (ParentForm<>Parent) then |       if (ParentForm<>nil) and (ParentForm<>Parent) then | ||||||
|       begin |       begin | ||||||
|         p:=Parent.ClientOrigin; |         p:=Parent.ClientOrigin; | ||||||
| @ -180,7 +180,7 @@ var | |||||||
| begin | begin | ||||||
|   if Component is TControl then |   if Component is TControl then | ||||||
|   begin |   begin | ||||||
|     ParentForm := GetParentForm(TControl(Component)); |     ParentForm := GetDesignerForm(TControl(Component)); | ||||||
|     if ParentForm = nil then |     if ParentForm = nil then | ||||||
|       Result := Point(0, 0) |       Result := Point(0, 0) | ||||||
|     else |     else | ||||||
| @ -205,7 +205,7 @@ var | |||||||
| begin | begin | ||||||
|   if Component is TControl then |   if Component is TControl then | ||||||
|   begin |   begin | ||||||
|     ParentForm := GetParentForm(TControl(Component)); |     ParentForm := GetDesignerForm(TControl(Component)); | ||||||
|     Parent := TControl(Component).Parent; |     Parent := TControl(Component).Parent; | ||||||
|     if (Parent = nil) or (ParentForm = nil) then |     if (Parent = nil) or (ParentForm = nil) then | ||||||
|       Result := Point(0, 0) |       Result := Point(0, 0) | ||||||
|  | |||||||
							
								
								
									
										15
									
								
								lcl/forms.pp
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								lcl/forms.pp
									
									
									
									
									
								
							| @ -1747,6 +1747,7 @@ var | |||||||
|   IsFormDesign: TIsFormDesignFunction = nil; |   IsFormDesign: TIsFormDesignFunction = nil; | ||||||
| 
 | 
 | ||||||
| function GetParentForm(Control: TControl; TopForm: Boolean = True): TCustomForm; | function GetParentForm(Control: TControl; TopForm: Boolean = True): TCustomForm; | ||||||
|  | function GetDesignerForm(Control: TControl): TCustomForm; | ||||||
| function GetFirstParentForm(Control:TControl): TCustomForm; | function GetFirstParentForm(Control:TControl): TCustomForm; | ||||||
| function ValidParentForm(Control: TControl; TopForm: Boolean = True): TCustomForm; | function ValidParentForm(Control: TControl; TopForm: Boolean = True): TCustomForm; | ||||||
| function GetDesignerForm(APersistent: TPersistent): TCustomForm; | function GetDesignerForm(APersistent: TPersistent): TCustomForm; | ||||||
| @ -1938,6 +1939,20 @@ begin | |||||||
|     Result := nil; |     Result := nil; | ||||||
| end; | 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; | function ValidParentForm(Control: TControl; TopForm: Boolean): TCustomForm; | ||||||
| begin | begin | ||||||
|  | |||||||
| @ -2033,7 +2033,7 @@ begin | |||||||
|   if (csDesigning in ComponentState) then |   if (csDesigning in ComponentState) then | ||||||
|   begin |   begin | ||||||
|     // redirect messages to designer
 |     // redirect messages to designer
 | ||||||
|     Form := GetParentForm(Self); |     Form := GetDesignerForm(Self); | ||||||
|     //debugln(['TControl.WndProc ',dbgsname(Self)]);
 |     //debugln(['TControl.WndProc ',dbgsname(Self)]);
 | ||||||
|     if Assigned(Form) and Assigned(Form.Designer) and Form.Designer.IsDesignMsg(Self, TheMessage) then |     if Assigned(Form) and Assigned(Form.Designer) and Form.Designer.IsDesignMsg(Self, TheMessage) then | ||||||
|       Exit; |       Exit; | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 ondrej
						ondrej