delphi3000.com - the free delphi knowledge platform
delphi3000.com - the free delphi knowledge platform
Have a look at your member-status

connecting people's knowledge


  - Recent ArticlesRSS feed for Recent Articles on delphi3000.com
  - List of All Articles
  - Top Viewed Articles
  - Articles (+Attachem.)
  - Articles Of Interest
  - Categories
  - Top Uploader
  - Search
  - Index

  - My Home
  - Submit an Article
  - My Articles
  - My Personal Data
  - My Bookmarks
  - Activities
  - Login/Logout

  - Sign Up
  - Why Sign Up
  - Newsletter

  - Press
  - Advertise

  - Contact
  - Feedback



Community
Borland
ClubeDelphi
Dr. Bob
UK-BUG
Delphi Meetings
Planeta Delphi








Share this article with friendsShare this article with friends
Rate this articleRate this article - to keep the quality of delphi3000.com !
Comment this article or read through previous comments (1)


Panel showing Enabled/Disabled in ChildrenFormat this article printer-friendly!Bookmark function is only available for registered users!
Simple Component Extension
Product:
Delphi all versions
Category:
VCL-General
Skill Level:
Scoring:
Last Update:
04/25/2005
Search Keys:
delphi delphi3000 article borland vcl code-snippet panel enabled disabled children controls tpanel childcontrols
Times Scored:
1
Visits:
3011
Uploader: Daniel Wischnewski
Company: Delphi-PRAXiS
Reference: gate(n)etwork
 
Question/Problem/Abstract:
Often you disable all Controls within a Panel by simply setting the Enabled Property of the Panel. It works, however the user does not get any visual feedback.
Answer:



The following component code simply extends the Delphi Panel to properly show the Enabled State (True/False) within its children.

Extending the control is very simple. All  we need to do is to override and extend the default SetEnabled procedure. The new procedure will first call the original version and then rotate through all children and copy the state.

There is one drawback although, if there is a disabled control (XYZ) on the panel, you then disable the panel and enbale it again, the control (XYZ) will be enabled, too.

Anyway, often it is very useful. Here you go:

unit uRealPanel;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ExtCtrls;

type
  TRealPanel = class(TPanel)
  private
  protected
    procedure SetEnabled(Value: Boolean); override;
  end;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('gate(n)etwork', [TRealPanel]);
end;

{ TRealPanel }

procedure TRealPanel.SetEnabled(Value: Boolean);
var
  I: Integer;
begin
  inherited;
  if csDesigning in ComponentState then
    Exit;
  for I := 0 to Pred(ControlCount) do
    if Controls[I] is TWinControl then
      (Controls[I] as TWinControl).Enabled := Value;
end;

end.


Have fun,
Daniel, ContentAce.com





Please rate this article!
Skill level:
BeginnerExpert

Useful:
No!Very!

Overall rating:
PoorExcellent



Comments to this article
Write a new comment
TControl
    Kacper Kwapisz (Feb 14 2007 8:39PM)

Better if there will be TControl instead TWinControl, becouse for example TLabel has Enabled property and it's TControl, not TWinControl.
Respond














 
Sign up to consume product discounts for Bronze memberships !

read more


   


  Community Ad of
M. Shkolnik
 
   














 







     
  Copyright © 2000 - 2007 delphi3000.com - All rights reserved. Terms of use. || Privacy
delphi3000.com is a service by bluestep.com IT-Services GmbH (Vienna)