i am working on a custom component in Delphi -7 for which i have some published properties
private
{ Private declarations }
FFolderzip ,Fimagezip,Ftextzip,FActivatezipComp : Boolean;
FMessagebo : string;
published
{ Published declarations }
{component Properties}
{#1.Folder Zip}
property ZipFolder : Boolean read FFolderzip write FFolderzip default False;
{#2.Send imagezip ?}
property ZipImage : Boolean read Fimagezip write Fimagezip default False;
{#3.text files}
property ZipText : Boolean read Ftextzip write Ftextzip default False;
{#4.message}
property ZipMessage: String read FMessagebo write FMessagebo ;
{#5.Activate }
property ActivateZipper: Boolean read FActivatezipComp write FActivatezipComp Default false;
end;
When the user drops the component on the application, ActivateZipper properties give the use a option to activate/enable or deactivate/disable the component from executing.
The component creates a file
so in the constructor i have this, CreateATextFileProc will create the file in the application folder.So if i check in the constructor if the ActivateZipper is true or false..
i have a constructor
constructor TcomProj.Create(aOwner: TComponent);
begin
inherited;
if ActivateZipper then CreateATextFileProc;
end;
The ActivateZipper is always false even if i set it to true in the object inspector.
How can the component be disabled from doing it working with published property?
The constructor is too early. The design-time property values have not been streamed into the component yet. You need to wait until your component’s
Loaded()method is called before you can then act on the values. If you create the component dynamically at run-time, you also need a property setter since there are no DFM values and thusLoaded()will not be called.