Jump to content
kokoslolos

Properties and design time code

Recommended Posts

Hi,

 

First of all, I'm not an expert in writing design time code, but this what I'm trying to achieve.

 

I have my own custom TAction descendant, lets call it TXAction, with extra published properties (like ActionCode, ActionID, ActionName, ActionDescription ...), in design time time package that is installed in the IDE.

Then I have a base form with some default TXAction components with some default properties set like ActionDescription with a place holder i.e "Export [fn] to xls" where the "[fn]" will be replaced in design time with the Form Name.

 

In the TXAction Loaded overridden method, I have this code:

 

procedure TXAction.Loaded;
var
  aIXRBaseForm : IXRBaseForm;
begin
  inherited;

  if (csDesigning in ComponentState) and (Owner<>nil) then
  begin
    if Supports(Owner, IXRBaseForm, aIXRBaseForm) then
    begin
      if ActionCode = ('.' + IntToStr(ActionID)) then
         ActionCode := aIXRBaseForm.FormCode + ActionCode;

      if (AnsiPos('[fn]', ActionDescription) > 0) and (aIXRBaseForm.FormName <> '') then
        ActionDescription := StringReplace(ActionDescription, '[fn]', aIXRBaseForm.FormName, [rfReplaceAll]);
    end;
  end;
end;

The code above works as expected, I have several descendant forms that inherit from this base form, and when I open them in the IDE,

these inherited TXActions instead of the placeholder "[fn]" in the description, they are replaced with the Form's name.

 

My problem is that the Save All button in the IDE is not activated for the form to indicated there was a change, like it does when a property is changed in the object inspector,

so that the user can save it and store these changes in the .dfm.

Although, if the Save button which is always enabled is clicked, the changes are saved!

 

This leads me to thinking if I'm indeed doing this right, is this the correct way to change properties in design time?

How can I make the Save All button enabled?

 

Thank you.

 

 

 

 

 

Share this post


Link to post

I was planning to write this but I forgot, I use Delphi 2007.

Does this solution work for this version of delphi?

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×