Zakaria 0 Posted September 17 Method 'SetText' not found in base class interface Uses VCL.ExtCtrls,VCL.Controls; Type TPanel1 = class(TPanel) private Procedure SetEnabled(Value: Boolean); override; Procedure SetText(const Value: TCaption); override; public End; implementation { TPanel1 } procedure TPanel1.SetEnabled(Value: Boolean); begin inherited; end; procedure TPanel1.SetText(const Value: TCaption); begin inherited; end; Share this post Link to post
Anders Melander 1783 Posted September 17 SetText is declared private in the TControl base class so you don't have access to it. SetText is not declared virtual so you cannot override it. My guess is that you instead need to handle the WM_SETTEXT message. Share this post Link to post
PeterBelow 238 Posted September 17 3 hours ago, Zakaria said: how to correct Well, what do you want to achieve here? Look at the source code for TControl, from which TPanel inherits the Caption property and its SetText and GetText accessor methods. procedure TControl.SetTextBuf(Buffer: PChar); begin Perform(WM_SETTEXT, 0, Buffer); Perform(CM_TEXTCHANGED, 0, 0); end; Setting a control's Caption or Text properties ends up sending messages to the control. WM_SETTEXT stores the passed string and CM_TEXTCHANGED is a notification for the control that the caption or content has changed, which typically makes the control redraw itself. TCustomPanel, the immediate ancestor of TPanel, has a private message handler procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED; that just calls Invalidate to redraw the panel. If you want to react to a change of the panel Caption you have to add a handler for this message to your modified TPanel class. You cannot override the parent method since it is not virtual or dynamic and also private. But you can call the inherited message handler inside your handler using the inherited keyword. If you just want a panel that does not show the Caption: it has a ShowCaption property that you can set to false to achieve that. You could set that in an overridden Loaded method. Share this post Link to post
Anders Melander 1783 Posted September 17 7 hours ago, Zakaria said: how to correct There seems to be a pretty big gap between your knowledge and your ambitions and you shouldn't really be trying to make custom components (or whatever it was you did) if you haven't learned about things like polymorphism and scope. I suggest you start with something more basic. 2 Share this post Link to post