Jump to content

BMSoft

Members
  • Content Count

    1
  • Joined

  • Last visited

Community Reputation

0 Neutral

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi, i'm new, and i suggest to overload the TPanel component like this : TPanel = class(Vcl.ExtCtrls.TPanel) private FUpdateEnabled: boolean; FChildControl: TComponent; FListeChild: TList; FUpdateVisibility: boolean; FUpdateVisibilityChilds: Boolean; function GetChildControl: TComponent; function GetListeChild: TList; function GetUpdateEnabled: Boolean; function GetUpdateVisible: Boolean; procedure SetChildControl(const Value: TComponent); procedure SetListeChild(const Value: TList); procedure SetUpdateEnabled(const Value: Boolean); procedure SetUpdateVisibility(const Value: Boolean); protected procedure CMVisibleChanged(var Message: TMessage); message CM_VISIBLECHANGED; procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED; procedure CMDNalUpdateVisibility(var Message: TMessage); message CM_CHILD_VISIBLECHANGED; public procedure AfterConstruction; override; procedure BeforeDestruction; override; constructor Create(AOwner: TComponent); override; published property ChildControl: TComponent read FChildControl write FChildControl; property ListeChild: TList read GetListeChild write SetListeChild; property UpdateEnabled: Boolean read GetUpdateEnabled write SetUpdateEnabled; property UpdateVisibility: Boolean read GetUpdateVisible write SetUpdateVisibility; property UpdateVisibilityChilds: Boolean read FUpdateVisibilityChilds write FUpdateVisibilityChilds; end; And you can just use the UpdateEnabled properties to achieve that in ListeChild, just use the event EnabledChange for your component : procedure TPanel.CMEnabledChanged(var Message: TMessage); var i: integer; begin inherited; if Self.FUpdateEnabled=false then exit; if not IsNil(Self.FChildControl) then TWinControl(Self.FChildControl).Enabled:= Self.Enabled; if (not isNil(Self.FListeChild)) and (Self.FListeChild.Count > 0) then begin for i := 0 to Self.FListeChild.Count-1 do begin if not IsNil(Self.FListeChild[i]) then TWinControl(Self.FListeChild[i]).Enabled:= Self.Enabled; end; end; end; Hops that will help u; Thanks
×