Interrupting the component load/draw sequence to initialize a visual component. lazarus / 31-LCL ---------------------------------------------------------------------- Curt Carpenter · 2011-08-20 19:23 I have a visual component derived from TCustomControl that I need to initialize at run time after it has been loaded with its .lfm properties, but before it is drawn for the first time on my form.   Can anyone tell me how to accomplish this? I'm using Windows XP and Lazarus 0.9.30.  The component works fine at design time, but is misdrawn at runtime,   It's a conversion from Delphi, where it works fine at both design- and run time. Thanks for suggestions. ---------------------------------------------------------------------- Arbee · 2011-08-20 19:28 I have to admit I'm saying this without solid evidence .... My guess would be the onPaint of the form or panel that the control is part of. ---------------------------------------------------------------------- Curt Carpenter · 2011-08-20 20:05 Thank you for the suggestion Arbee.  I'm looking for something that I can insert into my component code itself though, so the initialization is transparent to the user (he doesn't have to write any code in his unit at all).  I'll see if maybe that can be accomplished by using the component's OnPaint though -- thanks again for the suggestion. ---------------------------------------------------------------------- User137 · 2011-08-20 20:49 Isn't the component initialized in its Create constructor? Or if its .lfm properties would cause need for additional code, you can use read and write function for properties. They can do much of initialization things. ---------------------------------------------------------------------- Martin_fr · 2011-08-20 21:20 There is a method/procedure "Loaded" which you can override. (see synedit gutter) However it is ONLY called if data was loaded. If you create the component in designer, or directly fromn your code, then it does not trigger. You can check in the constructor Create, if there is a parent and if the parent has csLoading in component flags. If so, loaded will be triggered, otherwise initialize in Create. ---------------------------------------------------------------------- Curt Carpenter · 2011-08-21 01:45 Thank you User137 and Martin_fr for sharing your knowledge. I'm pretty sure the read/write function approach would work to solve my problem, but as it happens Martin_fr's Loaded override was exactly what I needed.  I had trouble making it work until I noted that instead of writing "procedure Loaded; override: I was writing "procedure loaded: override" (with a colon instead of a semicolon ).  Took me forever to find -that- mistake, but when I did, everything started to work fine! Many thanks to Arbee, User137 and Martin_fr for your help.  I'm still in my first week with Lazarus, and there's a lot to learn. Cheers!