Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Grouping Objects

Posted on 1998-09-09
6
Medium Priority
?
157 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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 200 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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 anti-spam), the admin…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

885 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