{"id":77,"date":"2007-05-12T13:41:11","date_gmt":"2007-05-12T11:41:11","guid":{"rendered":" http:\/\/www.nsonic.de\/blog\/2007\/05\/override-enabled-property-in-own-components\/"},"modified":"2007-05-12T13:41:12","modified_gmt":"2007-05-12T11:41:12","slug":"override-enabled-property-in-own-components","status":"publish","type":"post","link":"https:\/\/www.nsonic.de\/blog\/2007\/05\/override-enabled-property-in-own-components\/","title":{"rendered":"Override &#8220;Enabled&#8221;-property in own components"},"content":{"rendered":"<p>It&#8217;s my guess that your problem is in the SetEnabled method.  You<br \/>\nmust&#8217;ve re-defined FEnabled in your derived component otherwise you<br \/>\nwould be getting a compiler error since FEnabled is part of the private<br \/>\nsection of TControl.  Without knowing exactly what you did, here&#8217;s what<br \/>\nyou should do to properly implement SetEnabled:<\/p>\n<p>[code lang=&#8221;delphi&#8221;]TMyGroupBox = class(TGroupBox)<br \/>\nprotected<br \/>\n  procedure SetEnabled(Value: Boolean); override;<br \/>\nend;<\/p>\n<p>procedure TMyGroupBox.SetEnabled(Value: Boolean);<br \/>\nbegin<br \/>\n  If Value <> Enabled Then<br \/>\n    Invalidate;<br \/>\n  Inherited;<br \/>\nend;<br \/>\n[\/code]<\/p>\n<p>**HOWEVER**<br \/>\nYou should not even have to do that.  The control should invalidate<br \/>\nitself anytime Enabled is changed.  This is done via the<br \/>\nCMEnabledChanged message and handler.<\/p>\n<p>Doing what you did below probably &#8220;disabled&#8221; (pardon the pun) the entire<br \/>\nEnabled property mechanism, which is why your text wouldn&#8217;t draw<br \/>\ncorrectly.  (The component was never actually disabled.)<\/p>\n<p>&#8211; Just a guess <span class=\"wp-smiley emoji emoji-smile\" title=\":-)\">smile<\/span> <\/p>\n<p>Mike<\/p>\n<p>[tags]Delphi, Components[\/tags]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s my guess that your problem is in the SetEnabled method. You must&#8217;ve re-defined FEnabled in your derived component otherwise you would be&hellip;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":""},"categories":[11],"tags":[90,75],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p71Tml-1f","_links":{"self":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/77"}],"collection":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":0,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/posts\/77\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/media?parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/categories?post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.nsonic.de\/blog\/wp-json\/wp\/v2\/tags?post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}