kokoslolos 1 Posted Wednesday at 03:52 PM 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
msohn 29 Posted Wednesday at 04:11 PM A quick google search brought up this: https://stackoverflow.com/questions/31740385/vcl-events-handles-designer-modified So you can set Designer.Modified via the parent form - but checks for csDesigning and Designer <> nil are required. Also you should obviously set Modified only if you've actually modified something. Share this post Link to post
kokoslolos 1 Posted Wednesday at 04:29 PM 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
kokoslolos 1 Posted 7 hours ago Another question, In case cases is the TForm Designer property nil? I'm trying to use this to notify designer that something us modified but it's always nil. Does it have to be run from an installed design package? Thanks! Share this post Link to post
msohn 29 Posted 7 hours ago 1 minute ago, kokoslolos said: I'm trying to use this to notify designer that something us modified but it's always nil. How did you verify this? Of course if you just run the code in an application of yours it will be nil. After you modified the code, you need to recompile the package which contains the code for the component and you need to make sure the IDE is actually using that modified version. If everything else fails, you need to debug the package by running a second instance of the IDE under the debugger. Share this post Link to post