delphi - Disable/de-activate a custom component with published property -
i working on custom component in delphi -7
have 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 user drops component on application, activatezipper
properties give use option activate/enable or deactivate/disable component executing. component creates file in constructor have this, createatextfileproc
create file in application folder.so if check in constructor if activatezipper
true or false..
i have constructor
constructor tcomproj.create(aowner: tcomponent); begin inherited; if activatezipper createatextfileproc; end;
the activatezipper
false if set true in object inspector. how can component disabled doing working published property?
the constructor early. design-time property values have not been streamed component yet. need wait until component's loaded()
method called before can act on values. if create component dynamically @ run-time, need property setter since there no dfm values , loaded()
not called.
type tcomproj = class(tcomponent) private ... procedure setactivatezipper(value: boolean); protected procedure loaded; override; published property activatezipper: boolean read factivatezipcomp write setactivatezipper; end; procedure tcomproj.setactivatezipper(value: boolean); begin if factivatezipcomp <> value begin factivatezipcomp := value; if activatezipper , ((componentstate * [csdesigning, csloading, csloading]) = []) createatextfileproc; end; end; procedure tcomproj.loaded; begin inherited; if activatezipper createatextfileproc; end;
Comments
Post a Comment