Solved

Grouping Objects

Posted on 1998-09-09
6
148 Views
Last Modified: 2013-11-23
I am wondering if there is a way to group a bunch of objects, like labels or edit boxes, so that i can set them visible false or true in one statement not a whole bunch of statements. Please Help
0
Comment
Question by:bozo7
6 Comments
 
LVL 3

Expert Comment

by:Matvey
ID: 1339161
Well, I really doubt you can hide all of them with just one statement, however, you can make a TList of these objects, and set the properties in a FOR loop.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1339162
what you can do is make a descendant of a panel (or any other group component) which when set to invisible, automatically makes all his components invisible? What about it?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1339163
bozo7,

 come to think of it, panel already supports this offcourse! What a stupid comment I've put above...
 Put all the components in a panel and than make panel invisible. Otherwise if the components are scattered all over a form and can't be put in one panel... make a descendant of TList... (like matvey proposes)

Zif.
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 1

Author Comment

by:bozo7
ID: 1339164
I should have clarified.
I also want to enable or disable a group of objects and have the glyphs on the buttons be the disabled glyph not the enabled glyph. When I use a toolbar or panel for this the buttons are disabled but don't show the disabled glyphs.
ZifNab I am rejecting your answer not because it is wrong but because my question was not clear. Sorry
bozo
0
 
LVL 10

Accepted Solution

by:
Jacco earned 50 total points
ID: 1339165
You can derive a panel component that does the job for you.

unit GroupPanel;

interface

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

type
  TGroupPanel=class(TPanel)
  private
    FControlsVisible: Boolean;
    FControlsEnabled: Boolean;
    procedure SetControlsVisible(Value: Boolean);
    procedure SetControlsEnabled(Value: Boolean);
  public
    constructor Create(AOwner: TComponent); override;
  published
    property ControlsVisible: Boolean
      read FControlsVisible
      write SetControlsVisible default True;
    property ControlsEnabled: Boolean
      read FControlsEnabled
      write SetControlsEnabled default True;
  end;

implementation

constructor TGroupPanel.Create(AOwner: TComponent);
begin
  inherited Create(AOwner);
  FControlsVisible:=True;
  FControlsEnabled:=True;
end;

procedure TGroupPanel.SetControlsVisible(Value: Boolean);
var
  iControl: Integer;
begin
  if Value<>FControlsVisible then begin
    for iControl:=0 to ControlCount-1 do
      Controls[iControl].Visible:=Value;
    FControlsVisible:=Value;
  end;
end;

procedure TGroupPanel.SetControlsEnabled(Value: Boolean);
var
  iControl: Integer;
begin
  if Value<>FControlsEnabled then begin
    for iControl:=0 to ControlCount-1 do
      Controls[iControl].Enabled:=Value;
    FControlsEnabled:=Value;
  end;
end;

end.
0
 
LVL 1

Author Comment

by:bozo7
ID: 1339166
I had to move the SetControlsVisible and SetcontrolsEnabled to the Public section. Otherwise does exaclty what I was looking for.

I really enjoy this exchange of info

bozo
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question