Borland Delphi

[ City Zoo | Announcements | Aritcles | Tips & Tricks | Bug List | FAQ | Sites ]


The Delphi Bug List

Component Design


Dynamically created TComponent descendants will not paint in design-mode until the form is reloaded.

Description:

Non-visual components that are derived from TComponent and are created dynamically (e.g. not created by dropping them on the form) will not be painted on the form until it is reloaded. For example, consider that you design Component A to rely on Component B for some type of information or control. When an instance of Component A is dropped on a form, it must create Component B itself if there is not one already on the form. When Component B is created this way, it will not appear on the form until it is reloaded. Descendants of TComponent do not suffer from this problem.

Solution:

Don't derive your component from TComponent if it may be dynamically created by other components.


Real typed properties cause GPF in COMPLIB.DCL.

Description:

Adding a published property that is based on a variable of type Real causes Delphi to GPF. To illustrate the problem, install this example component and add it to a form:

unit RealBug;
interface
uses WinTypes, WinProcs, Classes, Controls, Forms;

type
  TRealBug = class(TWinControl)
  private
    FVersion: Real;
  published
    Version: Real read FVersion write FVersion;
  end;

procedure Register;

implementation

  procedure Register;
  begin
    RegisterComponents('Bugs', [TRealBug]);
  end;

end.
Solution:

From the Language Reference manual:

Furthermore, the type of a property defined in a published section must be an ordinal type, a real type (Single, Double, Extended, or Comp, but not Real), a string type, a small set type, a class type, or a method pointer type.

The solution is to use Single, Double, Extended, or Comp, whichever is most appropriate to your data. It would have been better for the compiler to generate an error when attempting to publish a real type property.


[ Home Page | What's New | About CITY ZOO | Borland Delphi | About the Authors | INDEX ]
keeper@mindspring.com
Copyright © 1995 Mark R. Johnson. This is a CITY ZOO production.
Produced in conjunction with Brad Stowers.
Last revised September 5, 1995.
Enhanced version