🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.nativeapi
14 messages
14 total messages Started by Dmitry Konnov Fri, 24 Nov 2006 17:23
Application->CreateForm
#2756
Author: Dmitry Konnov
Date: Fri, 24 Nov 2006 17:23
15 lines
1328 bytes
Hi All,

  TEditCard *a_EditCard = NULL;
        Application->CreateForm(FindClass("EditCardClass"),  &a_EditCard);
  a_EditCard->Show();

In this example TEditCard is TForm descendant with single parameter
(TComponent *Owner);
Is there a possibility to create form with extra parameters in constructor
by means
Application->CreateForm ?

Thank you.

Please help.
Re: Application->CreateForm
#2757
Author: Hans Galema
Date: Fri, 24 Nov 2006 17:34
16 lines
1442 bytes
Dmitry Konnov wrote:

>   TEditCard *a_EditCard = NULL;
>         Application->CreateForm(FindClass("EditCardClass"),  &a_EditCard);
>   a_EditCard->Show();

That looks like a problem for borland.public.cppbuilder.vcl.components.using

> Is there a possibility to create form with extra parameters in constructor
> by means
> Application->CreateForm ?

Why would you? I thought that we were not supposed to use CreateForm() but
the new operator instead. Where did you place that code?

Hans.
Re: Application->CreateForm
#2758
Author: Dmitry Konnov
Date: Fri, 24 Nov 2006 18:01
15 lines
1320 bytes
Hans ,

> Why would you? I thought that we were not supposed to use CreateForm() but
> the new operator instead. Where did you place that code?

Why i use this approach?

If i registered form with RegisterClass(__classid(TMyForm))

since then i can create my forms by VCLClass name.

And this reduces dependency in code since no #include need

Dmitry
Re: Application->CreateForm
#2760
Author: Remy Lebeau (TeamB)
Date: Sat, 25 Nov 2006 01:52
23 lines
1690 bytes
"Dmitry Konnov" <dmitry@weblinedesign.biz> wrote in message
news:45672a82@newsgroups.borland.com...

>         Application->CreateForm(FindClass("EditCardClass"),  &a_EditCard);

You don't need to use FindClass().  Use __classid() instead:

    Application->CreateForm(__classid(TEditCard),  &a_EditCard);

> Is there a possibility to create form with extra parameters in
> constructor by means Application->CreateForm ?

No.  CreateForm() can only use the TComponent* constructor and no other.
For what you are asking, you will have to get rid of the CreateForm()
altogether and use the 'new' operator instead (which you should be doing
anyway):

    TEditCard *a_EditCard = new TEditCard(whatever parameters you want);
    a_EditCard->Show();


Gambit
Re: Application->CreateForm
#2759
Author: Remy Lebeau (TeamB)
Date: Sat, 25 Nov 2006 01:54
16 lines
1458 bytes
"Dmitry Konnov" <dmitry@weblinedesign.biz> wrote in message
news:4567333e@newsgroups.borland.com...

> If i registered form with RegisterClass(__classid(TMyForm))
>
> since then i can create my forms by VCLClass name.
>
> And this reduces dependency in code since no #include need

You have to use an #include anyway in order to declare and use your form
variable.  So what do you gain exactly by using Register/FindClass() and
CreateForm()?  Nothing.


Gambit
Re: Application->CreateForm
#2762
Author: Dmitry Konnov
Date: Sat, 25 Nov 2006 09:56
21 lines
1822 bytes
Remy

> You have to use an #include anyway in order to declare and use your form
> variable.  So what do you gain exactly by using Register/FindClass() and
> CreateForm()?  Nothing.

nop.
I just put RegisterClass(__classid(TMyForm)) into form constructor
and set form as auto-creatable in project options. So on application start
forms are auto-created and auto-registered.

no need for #include in any place of application.

And i noticed that reducing of includes improve compilation time immensly.
That is obvious.

If i have more than 60 forms in project with untrivial includes - i realised
that compilation because impossible or goes to eternity.

Dmitry
Re: Application->CreateForm
#2761
Author: Dmitry Konnov
Date: Sat, 25 Nov 2006 10:04
26 lines
1576 bytes
Remy

> No.  CreateForm() can only use the TComponent* constructor and no other.

That is very pitty.
In my memory Delphi allows to do this. Why Builders not supported that?


In a while i override this problem just introducing new Method to base Form
class,
Like
void __fastcall Init(...)

so i must to do for all forms

  TEditCard *a_EditCard = NULL;
        Application->CreateForm(FindClass("EditCardClass"),  &a_EditCard);
  a_EditCard->Init(...);
  a_EditCard->Show();

which is actually constructor params replacement.
but no standard.

Dmitry
http://sourceforge.net/project/showfiles.php?group_id=141030
Re: Application->CreateForm
#2764
Author: Remy Lebeau (TeamB)
Date: Sat, 25 Nov 2006 11:14
27 lines
2060 bytes
"Dmitry Konnov" <dmitry@weblinedesign.biz> wrote in message
news:4568132a@newsgroups.borland.com...

> I just put RegisterClass(__classid(TMyForm)) into form constructor
> and set form as auto-creatable in project options. So on application
> start forms are auto-created and auto-registered.

You should only auto-create the MainForm.  Use 'new' to programmably create
secondary forms when actually needed.  That reduces run-time resource usage
considerably.

> And i noticed that reducing of includes improve compilation time immensly.
> That is obvious.

Then I take it that you are not using pre-compiled headers?  That would also
greatly reduce compile times.

> If i have more than 60 forms in project with untrivial includes - i
> realised that compilation because impossible or goes to eternity.

Not true.  I have applications that have just as many forms and many more
includes in them, and there is no problem with compiling them.  Sounds like
you have not optimized your project coding properly.


Gambit
Re: Application->CreateForm
#2763
Author: Remy Lebeau (TeamB)
Date: Sat, 25 Nov 2006 11:17
31 lines
1858 bytes
"Dmitry Konnov" <dmitry@weblinedesign.biz> wrote in message
news:456814f4@newsgroups.borland.com...

> In my memory Delphi allows to do this.

No, it doesn't.  CreateForm() works exactly the same way in Delphi that it
does in C++.

> Why Builders not supported that?

CreateForm() is internally hard-coded to only use the TComponent*
constructor.  That has nothing to do with a class's ability to be created
with other constructors.  You have to call the desired constructor directly
for that.  In Delphi, you simply call the constructor by name (usually
Create()).  In C++, you use the 'new' operator instead.

> In a while i override this problem just introducing new Method to base
Form
> class,
> Like
> void __fastcall Init(...)

You are going about it all wrong.

> so i must to do for all forms

I already showed you in my earlier reply what you should be doing.


Gambit
Re: Application->CreateForm
#2765
Author: Dmitry Konnov
Date: Sat, 25 Nov 2006 18:39
14 lines
1616 bytes
Remy

> I already showed you in my earlier reply what you should be doing.

VCL gives exelent opportunity to create Forms by Name.
This is advantage when you need flexible way of upgrading your application
without
exe recompilation.
For example i can keep VCLFormName somewhere in database and create
forms in application by Name.
Forms can be supplied to application with bpls.

Dmitry
Re: Application->CreateForm
#2766
Author: Erol Fornoles
Date: Sun, 26 Nov 2006 03:50
17 lines
1928 bytes
I don't get it. How can you supply forms to an executable via .bpl
files?

- Erol

On Nov 26, 2:39 am, "Dmitry Konnov" <dmi...@weblinedesign.biz> wrote:
> Remy
>
> > I already showed you in my earlier reply what you should be doing.VCL gives exelent opportunity to create Forms by Name.
> This is advantage when you need flexible way of upgrading your application
> without
> exe recompilation.
> For example i can keep VCLFormName somewhere in database and create
> forms in application by Name.
> Forms can be supplied to application with bpls.
> 
> Dmitry
Re: Application->CreateForm
#2767
Author: Remy Lebeau (TeamB)
Date: Sun, 26 Nov 2006 05:11
18 lines
1898 bytes
"Erol Fornoles" <erol.fornoles@gmail.com> wrote in message
news:1164513031.096119.148930@l12g2000cwl.googlegroups.com...

> How can you supply forms to an executable via .bpl files?

The same way the VCL allows bpl's to provide access to custom components.
Forms are just specialized components, afterall.  If a bpl implements a
custom TForm and then registers is, the application can use that
registration to instantiate the form without actually knowing what it is.
All component registrations allow that.  Of course, the application will not
be able to access the form-specific class members without a header file for
the bpl, unless it doesn't care about the custom members, in which case it
can access the form via a generic TForm* pointer (same as with components,
via TComponent*).


Gambit
Re: Application->CreateForm
#2768
Author: Dmitry Konnov
Date: Sun, 26 Nov 2006 16:50
10 lines
1454 bytes
Yes ,
Remy correct.

You can put Form into bpl and somewhere in initialization section
call RegisterClass for that form inside bpl.
Since then it  becomes available by Name in application.
You can create base Form class to implement interface for all descendant
Forms.

Dmitry
Re: Application->CreateForm
#2794
Author: Dmitry Konnov
Date: Tue, 26 Dec 2006 16:52
6 lines
1304 bytes
Hi All,

If somebody knows how to create TDataModule by
VCLClassName in BCB, please help.

Dmitry
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads