Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Information on USEFORM


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 10 - Last Post: Feb 28, 2018 5:54 AM Last Post By: James Williams Threads: [ Previous | Next ]
James Williams

Posts: 14
Registered: 6/9/99
Information on USEFORM  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 27, 2018 5:17 AM
Hello,

Does anyone know what the purpose of USEFORM is as well as where the documentation is on this MACRO/Function?

Thanks
Andy Walker

Posts: 72
Registered: 1/20/01
Re: Information on USEFORM  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 27, 2018 7:21 AM   in response to: James Williams in response to: James Williams
James Williams wrote:
Hello,

Does anyone know what the purpose of USEFORM is as well as where the documentation is on this MACRO/Function?

Thanks

A quick Google search threw up this article http://www.functionx.com/cppbuilder/Lesson07.htm

functionx.com cppbuilder lesson7:

This is done by calling the USEFORM macro. Its syntax is:"

USEFORM(FileName, FormName)


This macro takes two arguments. The first is a string that specifies the source file. The second specifies the name of the form as it appears in the project."

So basically a way to tell the compiler the name of the file where the Form is defined.

Andy
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Information on USEFORM [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 27, 2018 9:04 AM   in response to: Andy Walker in response to: Andy Walker
Andy Walker wrote:

So basically a way to tell the compiler the name of the file where
the Form is defined.

Note that the USExxx() macros have been deprecated since BCB6 and are
no longer used for anything meaningful, they are maintained only for
backwards compatibility with legacy code. Everything the compiler
actually needs is stored in the project file instead. BCB6 is around
the time when Borland migrated projects away from simple makefiles to
XML-based configuration files instead (before MSBuild was introduced).

--
Remy Lebeau (TeamB)
James Williams

Posts: 14
Registered: 6/9/99
Re: Information on USEFORM [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 27, 2018 9:18 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Just a question on your comments Remy. If the USExxx are depreciated then why is C++ Builder still using them and creating them in the main cpp file of every project create? Even Toko is still putting them in there.

Remy Lebeau (TeamB) wrote:
Andy Walker wrote:

So basically a way to tell the compiler the name of the file where
the Form is defined.

Note that the USExxx() macros have been deprecated since BCB6 and are
no longer used for anything meaningful, they are maintained only for
backwards compatibility with legacy code. Everything the compiler
actually needs is stored in the project file instead. BCB6 is around
the time when Borland migrated projects away from simple makefiles to
XML-based configuration files instead (before MSBuild was introduced).

--
Remy Lebeau (TeamB)
Antonio Estevez

Posts: 665
Registered: 4/12/00
Re: Information on USEFORM [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 27, 2018 9:38 AM   in response to: James Williams in response to: James Williams
El 27/02/2018 a las 18:18, James Williams escribió:
Just a question on your comments Remy. If the USExxx are depreciated then why is C++ Builder still using them and creating them in the main cpp file of every project create? Even Toko is still putting them in there.


The USEFORM macro uses the second parameter to declare the form's class
and global variable both required when the form is auto-created

By example:

USEFORM("MyFormName.cpp", MyFormName);


is converted to:
     class DELPHICLASS TMyFormName;
     extern PACKAGE TMyFormName *MyFormName;


So the compiler does not complain about undefined symbols when the form
is auto-created:
    Application->Initialize();
    Application->CreateForm(__classid(TMyFormName), &MyFormName);
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Information on USEFORM [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 27, 2018 9:43 AM   in response to: James Williams in response to: James Williams
James Williams wrote:

Just a question on your comments Remy. If the USExxx are depreciated
then why is C++ Builder still using them and creating them in the
main cpp file of every project create? Even Toko is still putting
them in there.

Seems my recollection was a little rusty:

http://www.delphigroups.info/3/4/98859.html

All of the USExxx() macros expect USEFORM() were deprecated.
USEFORM() itself is still mostly useless, though. The FileName
parameter is ignored, since the filename is stored in the project file
instead. And the FormName parameter is simply used to make an 'extern'
declaration for a Form's global variable that gets passed to
TApplication::CreateForm() for auto-created Forms. USEFORM()
statements for Forms that are not passed to CreateForm() in WinMain()
can be safely removed from the source code without affecting anything.

--
Remy Lebeau (TeamB)
James Williams

Posts: 14
Registered: 6/9/99
Re: Information on USEFORM [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 27, 2018 10:05 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Ok, that clarifies the intention of the USEFORM, so I guess that won't help me. I have posted a similar question recently that seems to not have gotten an answer. Perhaps it is simply not possible. But, what I am trying to do is make a data module which is contained in an application bpl package visible to properties edit in the main application for forms/controls that make use of the data module. Is this possible and if so, how can this be done. Just including the header file for said data module does not make it visible in the IDE control that wants to link to it.

Thanks

Remy Lebeau (TeamB) wrote:
James Williams wrote:

Just a question on your comments Remy. If the USExxx are depreciated
then why is C++ Builder still using them and creating them in the
main cpp file of every project create? Even Toko is still putting
them in there.

Seems my recollection was a little rusty:

http://www.delphigroups.info/3/4/98859.html

All of the USExxx() macros expect USEFORM() were deprecated.
USEFORM() itself is still mostly useless, though. The FileName
parameter is ignored, since the filename is stored in the project file
instead. And the FormName parameter is simply used to make an 'extern'
declaration for a Form's global variable that gets passed to
TApplication::CreateForm() for auto-created Forms. USEFORM()
statements for Forms that are not passed to CreateForm() in WinMain()
can be safely removed from the source code without affecting anything.

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Information on USEFORM [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 27, 2018 10:19 AM   in response to: James Williams in response to: James Williams
James Williams wrote:

But, what I am trying to do is make a data module which is contained
in an application bpl package visible to properties edit in the main
application for forms/controls that make use of the data module. Is
this possible and if so, how can this be done. Just including the
header file for said data module do es not make it visible in the IDE
control that wants to link to it.

That won't work, since the main app doesn't load the BPL at
design-time, only at run-time. It is not enough to just have the
DataModule's class declaration, you need an actual object instance of
the DataModule, and you won't have that at design-time when the
DataModule is not in the main app directly. Objects displayed in the
Form Designer and Object Inspector are live objects running within the
IDE's memory address space.

--
Remy Lebeau (TeamB)
James Williams

Posts: 14
Registered: 6/9/99
Re: Information on USEFORM [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 27, 2018 10:24 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Is there a way to have it loaded for design time linking? Or is there simply no possible way to achieve this?

Remy Lebeau (TeamB) wrote:
James Williams wrote:

But, what I am trying to do is make a data module which is contained
in an application bpl package visible to properties edit in the main
application for forms/controls that make use of the data module. Is
this possible and if so, how can this be done. Just including the
header file for said data module do es not make it visible in the IDE
control that wants to link to it.

That won't work, since the main app doesn't load the BPL at
design-time, only at run-time. It is not enough to just have the
DataModule's class declaration, you need an actual object instance of
the DataModule, and you won't have that at design-time when the
DataModule is not in the main app directly. Objects displayed in the
Form Designer and Object Inspector are live objects running within the
IDE's memory address space.

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: Information on USEFORM [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 27, 2018 11:52 AM   in response to: James Williams in response to: James Williams
James Williams wrote:

Is there a way to have it loaded for design time linking?

I suppose you could try creating a design-time BPL that loads the
runtime BPL. But I still don't think this will achieve what you are
looking for.

--
Remy Lebeau (TeamB)
James Williams

Posts: 14
Registered: 6/9/99
Re: Information on USEFORM [Edit]  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Feb 28, 2018 5:54 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy,

Perhaps there is a way for you to circulate this around. I did find a way to have a data module exist in a Package and have it available to the IDE without putting it inside of a design time package. Basically, I added the source unit to the main application project, but exclude it from the build. This allows me to create the visual linkage through the IDE property editor at design time.

Thanks

James

Remy Lebeau (TeamB) wrote:
James Williams wrote:

Is there a way to have it loaded for design time linking?

I suppose you could try creating a design-time BPL that loads the
runtime BPL. But I still don't think this will achieve what you are
looking for.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02