Board index » delphi » TCustomForm.CreateNew problem

TCustomForm.CreateNew problem

Hi,

in one of the examples in the helpfiles I read that you can create a
non-TForm component that is derived from TCustomForm by using the CreateNew
method in combination with ReadComponentResFile. I can't however get this to
work.

Here's my code:

  AForm := TXSummaryPrintForm.CreateNew(nil);
  // The DFM file originally belonged to the class of AForm. Only it is no
longer a descendant of TForm, but only of TCustomForm. It's a Text DFM.
  AForm2 :=
ReadComponentResFile('d:\usr\jeroen\saba\printcomponents\tmp\SummaryPrintFm.
dfm', AForm) as TXSummaryPrintForm;

At the last line I get the message:
  EInvalid Image with message 'Invalid stream format'

What am I doing wrong. And what does the helpfile precisely mean with that
CreateNew must be bracketed by WriteComponentResFile and
ReadComponentResFile.

Thanks, Jeroen

 

Re:TCustomForm.CreateNew problem


Quote
In article <8qd219$c...@bornews.borland.com>, Jeroen Moolhuijsen wrote:
> in one of the examples in the helpfiles I read that you can create a
> non-TForm component that is derived from TCustomForm by using the CreateNew
> method in combination with ReadComponentResFile. I can't however get this to
> work.

ReadComponentResFile only works with *binary* DFM files, so if you are using
the default D5 text DFMs you run into the wall here.

Peter Below (TeamB)  100113.1...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Other Threads