Solved

component count in TCustomPanel

Posted on 1998-12-13
1
276 Views
Last Modified: 2010-08-05
Im busy writing a component and i want to know how many components is in the component(TCustomPanel) at desine time

Here is the program

unit test;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, ExtCtrls,DB, DBTables;

type
  TRPPage = class(TCustomPanel)
  private
    { Private declarations }
  protected
    { Protected declarations }
    procedure Paint; override;
  public
    { Public declarations }
  published
    { Published declarations }
  end;

var
  NComp:integer;

procedure Register;

implementation

procedure Register;
begin
  RegisterComponents('Test', [TRPPage]);
end;

procedure TRPPage.Paint;
var
  Rect: TRect;
  i:integer;
 begin
  Rect := GetClientRect;
  with Canvas do
  begin
    Brush.Color := RGB(255,255,255);
    FillRect(Rect);
    Rectangle(0, 0, Width, Height);
    {Componentcount don't work here}
    canvas.textout(50,50,inttostr(ComponentCount));
  end;
 end;


end.

0
Comment
Question by:delpro
1 Comment
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 50 total points
ID: 1350901
Use ControlCount instead of component count. ControlCount  is the count of child components (ie: component who list this one as their parent. ComponentCount is the count of components owned by the component - in this instance form will own all the components and so component count will be 0.

Cheers,

Raymond.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

809 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