Solved

component count in TCustomPanel

Posted on 1998-12-13
1
283 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Title # Comments Views Activity
SUM 2 INTEGER ARRAYS INTO 1 10 119
Dynamically Created Query 3 81
Get weeknumber and year from date 4 57
Error when I try to post by IdHttp, error 500 - Help 2 25
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…
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 …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

710 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