Re: [Lazarus] Accessing components in FormCreate event
On Thu, 22 Sep 2016 09:50:06 +0100 Lukasz Sokolwrote: >[...] > From what I remember (on Turbo Delphi, but this is generally true I think) > anything that causes the form to redraw, > (as it's been indicated in responses here too - resizing, aligning, changing > colours etc) > is a really bad idea, because there may not be anything to answer the OnPaint > events yet > while FormCreate is being serviced. There is no OnPaint during OnCreate. > (Speculation because I haven't dived that deep: the visual component > hierarchy on the form > is kept in a tree-like structure, that is being walked top-down by a single > thread, > and so other components' OnCreate is called AFTER their parent is created, > and not necessarily > in order of appearance (in order of being placed on form, presumably?) The order of dropping the components on the form defines the creation order. >[...] Mattias -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org http://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Accessing components in FormCreate event
On 22/09/16 08:13, Luca Olivetti wrote: > El 22/09/16 a les 08:47, Lars ha escrit: > >> >> However these may be issues with formcreate that are not related to >> the bugs I have come across. I'm trying to remember what exactly >> was the problem that I had in FormCreate, but can't remember > > > I don't remember exactly, but the size of the component isn't the > final one (depending on align, anchors or autosize, as I said I don't > remeber the details) until the FormShow, so if you need them to > initialize other components you have to wait. > > Bye From what I remember (on Turbo Delphi, but this is generally true I think) anything that causes the form to redraw, (as it's been indicated in responses here too - resizing, aligning, changing colours etc) is a really bad idea, because there may not be anything to answer the OnPaint events yet while FormCreate is being serviced. (Speculation because I haven't dived that deep: the visual component hierarchy on the form is kept in a tree-like structure, that is being walked top-down by a single thread, and so other components' OnCreate is called AFTER their parent is created, and not necessarily in order of appearance (in order of being placed on form, presumably?) Whereas in On(First)Show of the main form you can assume the entire tree exists and has sizes and positions calculated at least once) Hope it's not overly far from truth ;) -L. -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org http://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Accessing components in FormCreate event
El 22/09/16 a les 08:47, Lars ha escrit: However these may be issues with formcreate that are not related to the bugs I have come across. I'm trying to remember what exactly was the problem that I had in FormCreate, but can't remember I don't remember exactly, but the size of the component isn't the final one (depending on align, anchors or autosize, as I said I don't remeber the details) until the FormShow, so if you need them to initialize other components you have to wait. Bye -- Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007 -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org http://lists.lazarus-ide.org/listinfo/lazarus
Re: [Lazarus] Accessing components in FormCreate event
On Thu, September 22, 2016 12:31 am, I previously wrote: > If I could just find one other person that has been haunted by accessing > components in formcreate, then I'd confirm I am not imagining things i.e. here are some issues others have come across which may be semi related to problems I have experienced, or not: Quote "However sometimes a few special things can cause problems in FormCreate, usually related to the order window handles are created, and for such special cases FormShow can also be abused for initialization. " -- Jens Grusche, (posted on another delphi list) And this: http://stackoverflow.com/questions/3261653/why-would-something-fail-in-formcreate-but-work-fine-in-formshow However these may be issues with formcreate that are not related to the bugs I have come across. I'm trying to remember what exactly was the problem that I had in FormCreate, but can't remember. I do recall having to create a FirstShow hack to do what I needed to do... I don't like using the FormShow event, even with a counter, since it is called multiple times and FormCreate is only called once. -- ___ Lazarus mailing list Lazarus@lists.lazarus-ide.org http://lists.lazarus-ide.org/listinfo/lazarus