please make some procedures virtual; suggestion for a new tForm event/procedure lazarus / 7-LCL ---------------------------------------------------------------------- Martin V · 2010-01-31 22:43 Hi, I am a Lazarus beginner and have got only a few modifications for the LCL/FPC yet. Later, I will get part of the development community, but at the moment, I would prefer that someone takes a look at my proposals and makes the changes. forms.pas declaration of class tForm:     procedure Close; -> should be virtual to enable overriding     procedure Show;  -> should be virtual to enable overriding     controls.pas declaration of class tControl     move from private to protected:       procedure SetFont(Value: TFont) -> should be virtual to enable overriding     classesh.inc (fpc rtl) declaration of class tList:     procedure Delete -> should be virtual to enable overriding     -------------------------- proposal for a new tForm event: In WDsibyl, there's a useful Form procedure / Form event which is not part of Lazarus and Delphi: SetupShow/OnSetupShow The SetupShow has to be executed the first time when the Form is shown. boolean "IsFirstShow" has to be set to true in Create. procedure tSibylForm.Show;   begin     if IsFirstShow then SetupShow;     IsFirstShow := false;     inherited Show;   end;   This would be a useful feature for lots of Lazarus (Delphi) users, because when overriding the Create constructor, a lot of stuff (e.g. Window handles) is not initialized yet and a lot of initialization stuff fails there. Lots of programmers have to override Show and need to write this simple code again and again... In WDsibyl, there's also a SetupComponent procedure and an OnSetupComponent event which is more handy than overriding the constructor. Would be nice to have, but the OnSetupComponent is nearly the same as OnCreate. Martin V. (Munich, Germany) ---------------------------------------------------------------------- theo · 2010-01-31 23:13 Quote from: Martin V on January 31, 2010, 11:43:04 pm    procedure Close; -> should be virtual to enable overriding     procedure Show;  -> should be virtual to enable overriding     I don't know exactly what you need, but are you aware that you can override DoClose and DoShow? Quote from: Martin V on January 31, 2010, 11:43:04 pm    move from private to protected:       procedure SetFont(Value: TFont) -> should be virtual to enable overriding     Again, not sure about the purpose. There is an event TFont.OnChange where you can get notified about changes.     Quote from: Martin V on January 31, 2010, 11:43:04 pmclassesh.inc (fpc rtl) declaration of class tList:     procedure Delete -> should be virtual to enable overriding         This is one for the Freepascal Mailinglist: http://www.freepascal.org/maillist.var Quote from: Martin V on January 31, 2010, 11:43:04 pmSetupShow/OnSetupShow         Good idea imho. ---------------------------------------------------------------------- Ñuño_Martínez · 2010-02-01 09:33 Completely agree with Theo. But I must add: Why do you use the word should? I think it's a big word. May be you should use may, shouldn't you? As for the TList modification: Quote from: Martin Vclassesh.inc (fpc rtl) declaration of class tList:     procedure Delete -> should be virtual to enable overriding Why? ---------------------------------------------------------------------- Martin V · 2010-02-01 14:47 Quote from: theo on February 01, 2010, 12:13:06 am   I don't know exactly what you need, but are you aware that you can override DoClose and DoShow? >procedure SetFont(Value: TFont) -> should be virtual to enable overriding Again, not sure about the purpose. There is an event TFont.OnChange where you can get notified about changes. Thanks for your response. I indeed did not notice DoShow and DoClose, this should fit my purpose. I thaught that the only purpose of On... Events is to use it in the object inspector for forms which are a visual resource. Can I overwrite On... in Lazarus when overriding a class?     Quote from: Martin V on January 31, 2010, 11:43:04 pmclassesh.inc (fpc rtl) declaration of class tList:     procedure Delete -> should be virtual to enable overriding I have got a list of pointers pointing to heap objects. If the list item gets deleted, the pointer has to be freed. So I need to have a "FreeItem (Item : pointer)" where I can place my code to free the heap. But perhaps there's another way without modifying the RTL ?         Martin V. (Munich, Germany) ---------------------------------------------------------------------- theo · 2010-02-01 14:57 Quote from: Martin V on February 01, 2010, 03:47:32 pmI thaught that the only purpose of On... Events is to use it in the object inspector for forms which are a visual resource. Can I overwrite On... in Lazarus when overriding a class? You can use On.. in your code like: MyObj.OnShow:=@Eventhandler; Or you have something like DoShow which actually triggers OnShow if assigned and which you can override.     Quote from: Martin V on January 31, 2010, 11:43:04 pmBut perhaps there's another way without modifying the RTL ? Maybe TObjectList. It has a property OwnsObjects. See http://www.freepascal.org/docs-html/fcl/contnrs/tobjectlist.html ---------------------------------------------------------------------- Ñuño_Martínez · 2010-02-01 15:12 Quote from: Martin V on February 01, 2010, 03:47:32 pmI have got a list of pointers pointing to heap objects. If the list item gets deleted, the pointer has to be freed. So I need to have a "FreeItem (Item : pointer)" where I can place my code to free the heap. But perhaps there's another way without modifying the RTL ? If you need a list of Objects then use TObjectList or TFPObjectList instead. They're very similar than TList but they destroy the objects by default.