3

I'm using TFrame as base class for a compound component which is registered in the IDE. When I pick the component from the palette and I add it into a form/frame, everything seems to works good. The next time I open the form/frame, the frame component appears as a common frame, like if the component is unregistered from the IDE, I mean that:

  • All custom published properties are no more visible in the Object Inspector.
  • Only published properties inherited from TFrame are still visible in the Object Inspector.
  • Subcomponents can be clicked and moved inside the frame. enter image description here

Furthermore, if the property had a value, I get the following error:

Error reading MyComponent1.MyProperty: Property MyProperty does not exists. Ignore the error and continue? NOTE: Ignoring the error may cause components to be deleted or property values to be lost.

Step by step example:

  • I've created and compiled a "Designtime and Runtime" package. (Note that, using Delphi 2007, I've obtained the TFrameModule class as explained in this Ondrej Kelle's post).

Code:

  TMyComponent = class(TFrame)
  private
    FMyCaption : TCaption;
    { Private declarations }
  public
    { Public declarations }
  published
    property MyCaption : TCaption read FMyCaption write FMyCaption;
  end;

....

procedure Register;
var
  delphivclide: THandle;
  TFrameModule: TCustomModuleClass;
begin
  RegisterComponents('MyComponents', [TMyComponent]);

  //registering custom module for TMyComponent
  delphivclide := GetModuleHandle('delphivclide100.bpl');
  if delphivclide <> 0 then
  begin
    TFrameModule := GetProcAddress(delphivclide, '@Vclformcontainer@TFrameModule@');
    if Assigned(TFrameModule) then
      RegisterCustomModule(TMyComponent, TFrameModule);
  end;
end;
  • I've added the folder which contains dcu and dcp files to Tools -> Options -> Library - Win32 -> Library path

  • I've added the folder which contains the bpl file to the PATH environment variable.

  • I've installed the package in the IDE and restarted it.

  • I've created a new "Runtime" package with a form in which I've placed a component of TMyComponent class.

  • The component is appeared as expected and I've set MyCaption property to 'AAA'. enter image description here

  • Then I've saved the form and closed the IDE.

  • After that I've restarted the IDE, on reopening the same form file, I get the following error:enter image description here

  • I've also tried to follow the same steps without setting any value to the property and I've noticed that the property disappears from the Object Inspector:enter image description here

Further informations:

  • The MyCaption property appear in the Object Inspector each time the component's package is recompiled and the IDE is restarted. I can see it in the Object Inspector until the next time I close and restart the IDE, then it disappears again.

  • I've reproduced the same problem using DelphiXE7, passing 'delphivclide210.bpl' instead of 'delphivclide100.bpl' to the GetModuleHandle function in the Register procedure.

  • It doesn't seems related to the OS, I've reproduced it on Windows 10 and on Windows XP.

Fabrizio
  • 7,603
  • 6
  • 44
  • 104
  • see http://stackoverflow.com/questions/876081/registering-a-custom-frame and http://stackoverflow.com/questions/289672/showing-tframe-descendants-additional-properties-on-the-object-inspector and https://wiert.me/2009/07/16/delphi-frames-as-visual-components-dont-forget-your-sprig/ and no doubt many more topics that can be found using web search – David Heffernan May 22 '17 at 10:32
  • @DavidHeffernan: I'm using Delphi 2007, so I've tried registering custom module as shown in [Ondrej Kelle's post](https://stackoverflow.com/a/289934/4528159) but I still have the same error. Don't know if it matter, but at the moment, I only need to use my frame as a component and don't really need to add a wizard for creating child classes. Is in this case `RegisterCustomModule` required? (I've updated the question's `Register` procedure code) – Fabrizio May 22 '17 at 13:01
  • @DavidHeffernan: I've read dozens of pages about custom frames but I don't figured out what I'm doing wrong. New properties disappear after the first time I open the source file in which my component is placed.. I've also found a similar question [here](https://stackoverflow.com/questions/33683142/tframe-as-component-ide-changes-object-to-inline-on-first-use) but it has no answer. – Fabrizio May 22 '17 at 17:00

0 Answers0