Creates an instance of a data module and registers with the global screen object.
constructor CreateNew(AOwner: TComponent; Dummy: Integer = 0); virtual;
Use CreateNew instead of Create to create a data module without using the associated .form file to initialize it.
The first argument, AOwner, is the owner of the data module (usually the application). The second argument, Dummy, defaults to 0 and is not used by this constructor. The system passes 0 by default if this constructor is passed only the first argument, AOwner.
CreateNew bypasses the streaming in of the previously associated form file. Therefore, you must stream in an external form file to bind the visual components with their classes. You can stream in the previously associated form file by calling InitInheritedComponent. To stream in a different form file, bracket the call to CreateNew with calls to WriteComponentResFile and ReadComponentResFile. The following code sequence
WriteComponentResFile('Temp.xfm', DataModule1); ...
DataModule2 := TDataModule.CreateNew(Application);
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!