0

I have a VCL form which (in addition to all the other controls) has 20 edit boxes on it that are hidden. They are essentially there as boolean variables so I can utilise their OnChange event to trigger other things.

Even though these are enabled but not visible, will they have a noticeable impact on the form load time, particularly as I am using VCL themes as well?

This article would suggest they are not created until referenced or made visible, but since I reference them during form load then I assume they will be created then. I suppose the bulk of the 'create time' is in the painting, but I figure they are not being painted if hidden so we are saving time there, therefore is the time I am left with likely to be noticeable?

WartH0g
  • 35
  • 3
  • 7
    Yes, they will make creating the form take a bit longer. But 20 is a very small number for a modern computer. Even drawing them (which indeed would require even more time) wouldn't be anything to care much about. However, using 20 invisible edit boxes as "boolean variables" sounds very strange. Almost certainly there is a better solution to your actual problem. – Andreas Rejbrand Jan 24 '21 at 12:35
  • I agree with Andreas comment above. About the alternative of edit boxes as boolean variable because they have an OnChange, you can create properties with a setter triggering an OnChange event. If you need help about that, please ask a new specific question like "How to create a form property triggering an OnChange event". – fpiette Jan 24 '21 at 12:50
  • Thanks both...yes the use of edit boxes is more a proof of concept - each one is paired with a label and together they give the same functions as a checkbox (but visually much more pleasing) - clicking the label toggles it on/off (represent by different colours) and the edit box stores the status which can then be saved into a DB. I did try using DBEdit boxes linked directly to the DB, and I even got so far as writing a custom control to incorporate everything, but I got stuck trying to get the control to work with LiveBindings so reverted to long-winded but simpler for now. Thanks :) – WartH0g Jan 24 '21 at 13:25
  • @WartH0g a checkbox can also have the style attribute [`BS_PUSHLIKE` which makes it look like a button](https://devblogs.microsoft.com/oldnewthing/20070921-00/?p=25023) which then remains pressed (unticking = unpressing). – AmigoJack Jan 24 '21 at 13:32
  • 1
    Probably you'll never notice any performance issues, but why not do it right? – David Heffernan Jan 24 '21 at 14:59
  • @AmigoJack - thanks, did not know that. Prob aly not suitable (visually) in the application but good to know. – WartH0g Jan 24 '21 at 21:25
  • @David - yes definitely need to look into a better way of doing it. Now I know what I want the control to do I can start learning how to make a custom one (which is new to me). Thanks – WartH0g Jan 24 '21 at 21:28
  • 1
    You don't need the edit controls to track the state. You can use the TLabel.Tag for this purpose, which means you're not wasting the time and memory to create the edits that will not be seen. Never use a visual control unless it's going to be made visible - there is always a better way to do things. – Ken White Jan 25 '21 at 02:41

0 Answers0