Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to Enable or Disable showing Children in Panels Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
28-May-03
Category
VCL-General
Language
Delphi All Versions
Views
101
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Daniel Wischnewski

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: 

1   unit uRealPanel;
2   
3   interface
4   
5   uses
6     Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
7     ExtCtrls;
8   
9   type
10    TRealPanel = class(TPanel)
11    private
12    protected
13      procedure SetEnabled(Value: Boolean); override;
14    end;
15  
16  procedure register;
17  
18  implementation
19  
20  procedure register;
21  begin
22    RegisterComponents('gate(n)etwork', [TRealPanel]);
23  end;
24  
25  { TRealPanel }
26  
27  procedure TRealPanel.SetEnabled(Value: Boolean);
28  var
29    I: Integer;
30  begin
31    inherited;
32    if csDesigning in ComponentState then
33      Exit;
34    for I := 0 to Pred(ControlCount) do
35      if Controls[I] is TWinControl then
36        (Controls[I] as TWinControl).Enabled := Value;
37  end;
38  
39  end.


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC