Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Component Writing

How to keep certain code from executing when my component is in design-time? by djjd47130
Posted: 13 Feb 13

There are many scenarios where you do not want certain things to happen when your components is in design-time. These are things which of course should only be performed when the actual product is being run. There's a simple solution to this, but first the background.

The Delphi TComponent is the primary class for any and all components and controls which can be published into the IDE's palette. With that being said, The Delphi language provides ways of doing such checks built-in to the component's base class. Every component has an enumerated set which you can read to detect its current state. This property is called ComponentState.

In System.Classes we find...


TComponentState = set of (csLoading, csReading, csWriting, csDestroying,
    csDesigning, csAncestor, csUpdating, csFixups, csFreeNotification,
    csInline, csDesignInstance); 

As you can see, this property provides a number of flags to inform you of certain states of your component. One of those is csDesigning. This is the flag you want to check for when identifying if your component is in design-time.


if not csDesigning in ComponentState then begin

Back to Embarcadero: Delphi FAQ Index
Back to Embarcadero: Delphi Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close