View Issue Details

IDProjectCategoryView StatusLast Update
0036513LazarusLCLpublic2020-01-26 05:30
ReporterJohn Raycheba Assigned ToOndrej Pokorny  
Status closedResolutionfixed 
PlatformWin7x32, All?OSWindows 
Product Version2.0.4 
Summary0036513: TEdit Child Controls -- Delphi Compatability
DescriptionThe basic issue is that if a TEdit can not have child controls while it can in Delph XE2 and earlier. (I have not checked more recent Delphi versions.)


To create "light weight" edit buttons and similar controls. (Yes, I do know that Lazarus already has a TEdotButton control.)

Steps To Reproduce1. Create a new project.

2. Place a TEdit control on the main form.

3. Try to place another control, such as a TButton, on the TEdit. -- The control will overlap with the TEdit, BUT the Object Inspector shows that the Button is NOT a child of the TEdit. -- This works in Delphi.

4. For comparison place a TPanel on the form.

5. Try to place a TButton on the TPanel. -- The Object Inspector shows that the TButton IS a child of the TPanel.
Additional InformationA QUICK FIX:

In the file c:\Lazarus\LCL\includes\

Starting at line 472 change the function TCustomEdit.ChildClassAllowed from:

function TCustomEdit.ChildClassAllowed(ChildClass: TClass): boolean;
  // no children
  Result := False;
  if Widgetset.GetLCLCapability(lcAllowChildControlsInNativeControls) = LCL_CAPABILITY_YES then Result := True;


function TCustomEdit.ChildClassAllowed(ChildClass: TClass): boolean;
  // no children
  //Result := False;
    //JR: Was not able to locate where in the Widgetset the lcAllowChildControlsInNativeControls is set, so just commented out and set result to true.
  //if Widgetset.GetLCLCapability(lcAllowChildControlsInNativeControls) = LCL_CAPABILITY_YES then Result := True; //JR: Commentted out.
    Result := True; //JR: Allow TEdit to have child controls, such as buttons, etc.

I assume that the proper way to fix this is to change the value of "lcAllowChildControlsInNativeControls" as this issue MAY apply to other controls and other OSs.
Unfortunately, I was not able to locate the code that sets this variable / constant.
TagsNo tags attached.
Fixed in Revision62572
Attached Files


Bart Broersma

2020-01-04 15:26

developer   ~0120213

Since when is this?
D7 (yes, very ol) did not support that.

Ondrej Pokorny

2020-01-15 06:23

developer   ~0120453

It is possible to allow this on win32. But do we really want to do it if not all widget sets don't support it? People might be surprised that the controls are not placed in edits e.g. on Gtk2.

Btw. it's not really a good practice anyway.

Zeljan Rikalo

2020-01-15 09:21

developer   ~0120460

Under Qt/Qt5 that works, I already have my own TEdit + button controls. Gtk2 and Gtk3 are definitelly problematic and it seem that it's impossible to add child control.

Ondrej Pokorny

2020-01-16 11:15

developer   ~0120474

OK, if the LCL allows it under Qt, there is no reason to block it under win32 either.

Ondrej Pokorny

2020-01-21 17:40

developer   ~0120611

Please test and close if OK.

John Raycheba

2020-01-23 05:11

reporter   ~0120684

Testing Procedure (on Win 7 x32 with Lazarus 2.0.4 and FPC 3.0.4):

1. The file c:\Lazarus\lcl\interfaces\ was replaced with the new R62572 version.
2. The file c:\lazarus\lcl\includes\ was replaced with the original one.
3. Lazarus was re-built using "Clean Up + Build all".

Testing Results:

1. A new control descending from a TEdit and containing a child TBitBtn was successfully created programmatically. When the resulting control was placed on a form all of the TEdits and TBitBtn properties were visible in the Object Inspector. -- THIS HAS SOLVED MY ISSUE.

2. In a new project with a TEdit on the main form a TBitBtn can NOT be placed on the TEdit as a child control.

Having "2." resolved would be nice, but not necessary.

If there are no further comment in a day or two, I will close this item.

John Raycheba

2020-01-26 05:30

reporter   ~0120750

Item is closed because it has been resolved.

Issue History

Date Modified Username Field Change
2020-01-04 09:01 John Raycheba New Issue
2020-01-04 15:26 Bart Broersma Note Added: 0120213
2020-01-15 06:23 Ondrej Pokorny Note Added: 0120453
2020-01-15 09:21 Zeljan Rikalo Note Added: 0120460
2020-01-16 11:15 Ondrej Pokorny Note Added: 0120474
2020-01-21 17:40 Ondrej Pokorny Assigned To => Ondrej Pokorny
2020-01-21 17:40 Ondrej Pokorny Status new => resolved
2020-01-21 17:40 Ondrej Pokorny Resolution open => fixed
2020-01-21 17:40 Ondrej Pokorny Fixed in Revision => 62572
2020-01-21 17:40 Ondrej Pokorny LazTarget => -
2020-01-21 17:40 Ondrej Pokorny Widgetset Win32/Win64 => Win32/Win64
2020-01-21 17:40 Ondrej Pokorny Note Added: 0120611
2020-01-23 05:11 John Raycheba Note Added: 0120684
2020-01-26 05:30 John Raycheba Status resolved => closed
2020-01-26 05:30 John Raycheba Note Added: 0120750