Solved

Grouping Objects

Posted on 1998-09-09
6
150 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

685 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