Link to home
Start Free TrialLog in
Avatar of bogieman_
bogieman_

asked on

Don't Execute code in design time

I have made a TComponent decendent, and I want it to skip a certain block of code if it is still in design time in delphi (on the form in delphi, in other words) .  At first, I thought I could just look for delphi's TAppbuilder using FindWindow to see if it is running, but then it will never execute the code when delphi is running at the same time.  Is there some compiler directive?  I've seen alot of {if ...}'s and I don't know if there is one that applies to this.  Any help?
ASKER CERTIFIED SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of PeterLarsen
PeterLarsen

Try this :

if csDesigning in YourComponent.ComponentState then
begin
 //Enter designtime code here
end
else
begin
 //Enter runtimecode here
end;

Regards
Peter
Well, to slow i see :-)
Avatar of bogieman_

ASKER

Hmmm...accept kretzschmar  or PeterLarsen - you will both have to prove to me that you are worthy of points...
Just give the points to Meikl, he was there first - and he need it :-)
I'm sure it works so here are the stinking points.