Solved

Conditional compile

Posted on 1998-07-08
4
212 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
ID: 1357360
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
ID: 1357361
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
ID: 1357362
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
ID: 1357363
What would you do if you wanted to make multi language application with lot of Labels on a Form?
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

821 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