Solved

component count in TCustomPanel

Posted on 1998-12-13
1
273 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
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…

786 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