Solved

Grouping Objects

Posted on 1998-09-09
6
145 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 1

Author Comment

by:bozo7
Comment Utility
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
Comment Utility
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
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now