Conditional compile

Posted on 1998-07-08
Last Modified: 2010-04-04

Is it possible to use conditional compiling in DFM files (somehow, sice {$IFDEF} doesn't work)?

I need to disable some components like this:
(this is: "View form as a text" source of DFM)

{$ifdef DEMO}
  object Timer1: TTimer
    Interval = 100
    OnTimer = Timer1Timer
    Top = 528
Question by:yuhoo
LVL 10

Expert Comment

Comment Utility
Not possible according to me.

You can disable it programmatically.

Or you can make two forms and make your uses claus contitional:
LVL 10

Accepted Solution

Lischke earned 50 total points
Comment Utility
This is not possible at all. What you can do is to specify something like:

{$ifdef ver100}
  {$r D3.dfm}
  {$r D2.dfm

and it will compile, but this way you cannot open the formular in the IDE.

So the answer is no.

Ciao, Mike

Expert Comment

Comment Utility
You can't do this in the dfm...but why do you need to...

you can do this in the pas file...and create it dynamically...

{$ifdef DEMO}
  Timer1 := TTimer.Create(self);
  with Timer1 do
    Interval := 100;
    OnTimer := Form1Timer;
    Top := 528;

remember to wrap calls to Timer1 in nil checks...i.e. if Assigned(Timer1) then or if Timer1 <> nil then...


Author Comment

Comment Utility
What would you do if you wanted to make multi language application with lot of Labels on a Form?

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now