Recent

Author Topic: class derived from TForm not in object inspector  (Read 8862 times)

watte

  • New Member
  • *
  • Posts: 13
class derived from TForm not in object inspector
« on: August 04, 2010, 09:21:32 am »
hello!

Sorry my english is not good, but I hope you can understand me...  ;D

I programmed a new Form (TMySpecialForm) derived form TForm with additional published properties. But the object inspector will not show this.
It seems, that the ide (on loading the unit) allways creates TForm?.

what could be wrong?  :'(
« Last Edit: August 04, 2010, 10:27:21 am by watte »

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2565
Re: class derived from TForm not in object inspector
« Reply #1 on: August 04, 2010, 11:54:29 pm »
The IDE only can do RTTI on components installed into the IDE. IT needs the compiled form RTTI info to show the propereties.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

watte

  • New Member
  • *
  • Posts: 13
Re: class derived from TForm not in object inspector
« Reply #2 on: August 05, 2010, 07:41:00 am »
RTTI?! - What can I do? My form is in a package. Is there a special way to register my form?



I did Register a new FileDescriptor with RegisterProjectFileDescriptor. Than I got a new Option in the menu "New...". When I klick this new Form, I got a new unit with my TMySpecialForm and the objectinspector show my additional properties too.  8) work fine!

But after saving and load the project, lazarus tell me property "X" do not exist... and so on. And the object inspector shows just the TForm-properties :(

So I had debug the lazarus-project on loading my project. -> The IDE do seeing that my Form is a TMySpecialForm
Quote
  ( JITForms ) -> ( function TJITComponentList.DoCreateJITComponent )
Instance:=TComponent(FCurReadClass.NewInstance);

...but creates always a TForm

Quote
  ( JITForms ) -> ( function TJITComponentList.DoCreateJITComponent )
Instance.Create(nil);
-> jump to "TForm.Create(..."

is it a bug? or have I to register something more?
« Last Edit: August 05, 2010, 10:55:29 am by watte »

Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2565
Re: class derived from TForm not in object inspector
« Reply #3 on: August 05, 2010, 11:10:57 am »
RTTI?! - What can I do? My form is in a package. Is there a special way to register my form?

that wasn't clear from your first post. Indeed, the IDE should now know your form.

Quote
I did Register a new FileDescriptor with RegisterProjectFileDescriptor. Than I got a new Option in the menu "New...". When I klick this new Form, I got a new unit with my TMySpecialForm and the objectinspector show my additional properties too.  8) work fine!

Thats good.

Quote
But after saving and load the project, lazarus tell me property "X" do not exist... and so on. And the object inspector shows just the TForm-properties :(

So I had debug the lazarus-project on loading my project. -> The IDE do seeing that my Form is a TMySpecialForm
Quote
  ( JITForms ) -> ( function TJITComponentList.DoCreateJITComponent )
Instance:=TComponent(FCurReadClass.NewInstance);

What is FCurReadClass.NewInstance calling ? And what is Instance ?

Quote
...but creates always a TForm

Quote
  ( JITForms ) -> ( function TJITComponentList.DoCreateJITComponent )
Instance.Create(nil);
-> jump to "TForm.Create(..."

Do you have a virtual overridden TMySpecialForm.Create() ? If not then TForm.Create is called.
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

watte

  • New Member
  • *
  • Posts: 13
Re: class derived from TForm not in object inspector
« Reply #4 on: August 05, 2010, 12:38:29 pm »
Thanks for your answer!

Quote
What is FCurReadClass.NewInstance calling ? And what is Instance ?

( lazarus/designer/jitforms.pp )

FCurReadClass is a class of TMySpecialForm1 (the name of the class in my project. unit1 -> TMySpecialForm1 = class(TMySpecialForm)... )
FCurReadClass.NewInstance jump to class function TLCLComponent.NewInstance: TObject;
Instance is a TComponent

Quote
Do you have a virtual overridden TMySpecialForm.Create() ? If not then TForm.Create is called.
Yes I have a overridden Create in my class, but the IDE jumps just to TForm.Create

Quote
..Indeed, the IDE should now know your form.
In my package, all components are registert by RegisterComponent. But not my forms (because it is no component). Maybe that is the reason...
I don't know how to register a form. Is there a special function?






Marc

  • Administrator
  • Hero Member
  • *
  • Posts: 2565
Re: class derived from TForm not in object inspector
« Reply #5 on: August 06, 2010, 12:26:29 am »
FCurReadClass is a class of TMySpecialForm1 (the name of the class in my project. unit1 -> TMySpecialForm1 = class(TMySpecialForm)... )

How did you check if it contains a class of TMySpecialForm1 ? Since if this is the case then your create should have been called.

Marc
//--
{$I stdsig.inc}
//-I still can't read someones mind
//-Bugs reported here will be forgotten. Use the bug tracker

watte

  • New Member
  • *
  • Posts: 13
Re: class derived from TForm not in object inspector
« Reply #6 on: August 06, 2010, 11:01:14 am »
when I run my project, the create of my class will be call. but when the IDE load my project and my unit with my class, the IDE is just call the TForm.Create...  :(

Never mind!
I give it up. - I will create a component that will have the features and properties of my special form. And on create of the component's owner, it will be install this features in the (TForm). - at runtime...


thank you very much for help!

 

TinyPortal © 2005-2018