New components TMyLabel inheriting TLabel class, in the hope that the effect of TMyLabel generate a Label attached to the Panel, could you tell me how to achieve?
CodePudding user response:
Such demand, suggest you don't from TLabel class inheritance, from TCustomControl inheritance is better,
CodePudding user response:
reference 1st floor ccrun response: such demand, suggest you don't from TLabel class inheritance, from TCustomControl inheritance is better, The demon elder brother excuse me, specific how to implement? CodePudding user response:
reference 1st floor ccrun response: such demand, suggest you don't from TLabel class inheritance, from TCustomControl inheritance is better, Demon elder brother, I try to use TCustomControl inheritance, that the constructor again, how should I generate TPanel class attributes of the parent assignment? CodePudding user response:
TLabeledEdit should be the same as you want to achieve, reference the VCL Delphi source code is best, //-- -- -- -- -- -- -- -- -- -- -- -- As you say, inherit TPanel better TPanel is a Handle, and there is no Label, after many times need to be Handle, subsequent to do, TLabeledEdit itself is TEdit is given priority to, the Label as attached, CodePudding user response:
TMyLabel inheritance TPanel... Then declared a TLabel TMyLabel variables... And establish TLabel in TMyLabel dynamic... TLabel Parent attribute set for this... If you want to set at the beginning of the Text of TLabel... Remember that in TMyLabel: CreateWnd... About the Windows UI... CodePudding user response:
reference 5 floor start8588 reply: TMyLabel inheritance TPanel... Then declared a TLabel TMyLabel variables... And establish TLabel in TMyLabel dynamic... TLabel Parent attribute set for this... If you want to set at the beginning of the Text of TLabel... Remember that in TMyLabel: CreateWnd... About the Windows UI... I hope TMyLabel components generated after changing the size of the Panel of its corresponding Label size change, how to set? CodePudding user response:
I hope TMyLabel components generated after changing the size of the Panel of its corresponding Label size change, how to set? Actually I don't think you should want to define such TMyLabel the function of the components to meet your hope, Because the Label does not know that they will be placed on the Panel or the Form above or on the Frame, in other words, the Label only know oneself level under the situation, and is not clear at the next higher level, According to the need of you, instead, you should define a TMyPanel component, then traverse a Panel when change size and all the Label, in order to achieve what you want,