Solved

component count in TCustomPanel

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now