Form's subclass lazarus / 31-LCL ---------------------------------------------------------------------- luca · 2018-10-24 08:16 Hi. I've a Form (TFrmMain) with a button (Btn1) on it. I created an OnClick event procedure for Btn1 (FrmMainBtn1_OnClick). Then I created two forms TFrmForm1 and TFrmForm2 both subclasses of TFrmMain. I inserted a button in TFrmForm1, named it Btn1 (as on TFrmMain) and create a OnClick event procedure (Form1Btn1_OnClick). When I compiled and error occurred: Duplicate Name: A component named "Btn1" already exists. I've to remove Btn1 to compile the program. If I run the program the Btn1 appears on TfrmForm1. When I clicked on this button the Form1Btn1_OnClick procedure is executed (instead of FrmMainBtn1_OnClick) Is it a normal behaviour? In any case I found it really usefull to create a hierarchy of Forms and to manage the logic to show button at top level having different procedure linked to same buttons. Regards Luca ---------------------------------------------------------------------- Thaddy · 2018-10-24 11:59 Such things can be remedied by using only one form per unit. ---------------------------------------------------------------------- HeavyUser · 2018-11-04 10:57 Quote from: luca on October 24, 2018, 10:16:26 amHi. I've a Form (TFrmMain) with a button (Btn1) on it. I created an OnClick event procedure for Btn1 (FrmMainBtn1_OnClick). Then I created two forms TFrmForm1 and TFrmForm2 both subclasses of TFrmMain. How? how did you subclassed form1 and form2 from the frmMain? Quote from: luca on October 24, 2018, 10:16:26 amI inserted a button in TFrmForm1, named it Btn1 (as on TFrmMain) and create a OnClick event procedure (Form1Btn1_OnClick). if you have properly subclasses frmMain you should be able to see the button you placed on frmMain on form1 and form2 you will not need to add it again. Quote from: luca on October 24, 2018, 10:16:26 amWhen I compiled and error occurred: Duplicate Name: A component named "Btn1" already exists. ofcourse it exists you already said you have a button with the same name on the parent form. Quote from: luca on October 24, 2018, 10:16:26 amI've to remove Btn1 to compile the program. you could also rename it to a non existing name. Quote from: luca on October 24, 2018, 10:16:26 amIf I run the program the Btn1 appears on TfrmForm1. When I clicked on this button the Form1Btn1_OnClick procedure is executed (instead of FrmMainBtn1_OnClick) Is it a normal behaviour? Yes it is normal to be able to override the click event on a child form. Quote from: luca on October 24, 2018, 10:16:26 am In any case I found it really usefull to create a hierarchy of Forms and to manage the logic to show button at top level having different procedure linked to same buttons. Do it properly then don't short circuit the IDE. Select the menu File\New on the tree on the left select inherited project component and on the list on the right select your form to inherit from and press ok. ---------------------------------------------------------------------- jamie · 2018-11-04 16:00 Maybe he should be looking into TFRAMES or something ? ---------------------------------------------------------------------- lucamar · 2018-11-04 16:15 Quote from: jamie on November 04, 2018, 05:00:53 pmMaybe he should be looking into TFRAMES or something ? IMHO, frames are a different concept. To better understand what the OP is, I think, looking for think about the relationship between TFindDialog and TReplaceDialog.