Solved

Conditional compile

Posted on 1998-07-08
4
209 Views
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
  end
{$ENDIF}
0
Comment
Question by:yuhoo
4 Comments
 
LVL 10

Expert Comment

by:Jacco
Comment Utility
Not possible according to me.

You can disable it programmatically.

Or you can make two forms and make your uses claus contitional:
uses
{$IFDEF DEMO}
  unit1,
{$ELSE}
  unit2,
{$ENDIF}
0
 
LVL 10

Accepted Solution

by:
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}
{$else}
  {$r D2.dfm
{$endif}

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

So the answer is no.

Ciao, Mike
0
 
LVL 3

Expert Comment

by:rickpet
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
  begin
    Interval := 100;
    OnTimer := Form1Timer;
    Top := 528;
  end;
{$ENDIF}

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

Rick
0
 

Author Comment

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

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