Tip: removing a property from the Object Inspector

The wonders you find just by browsing Delphi’s included source code! Basically, the issue I blogged about a couple of days ago can be fixed to an extent by simply calling the UnlistPublishedProperty procedure of DesignIntf.  While the hidden property will still be surfaced at run-time, you may still find it a ‘good enough’ solution nonetheless. Example:

unit CCR.RichEdit.Reg;

interface

procedure Register;

implementation

uses Classes, DesignIntf, CCR.RichEdit;

procedure Register;
begin
  RegisterComponents('CCR RichEdit', [TRichEditEx]);
  UnlistPublishedProperty(TRichEditExRuler, 'Margins');
end;

end.

So, what this code does (apart from registering the TRichEditEx class) is to remove the Margins property from the object inspector for any instance of TRichEditExRuler or a class descending from TRichEditExRuler.  Note that when you use DesignIntf, designide must be added to the DPR’s requires clause — do this by right clicking on the DPR in the project manager and selecting View Source, from which you can make the change manually:

package dclCCRRichEdit;

//a load of untouched compiler settings snipped...

requires
 designide, //added
 rtl,

//etc., as before
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s