Board index » cppbuilder » runtime initialization

runtime initialization


2008-06-12 04:57:11 PM
cppbuilder77
I have some BCB5 runtime code that works as expected but the conversion to
RAD 2007 is not 100% ok.
The runtime package includes the following code:
#pragma startup startproc 67
void startproc( void )
{
using namespace VideoMonitor;
RegisterClass( __classid( TVideoPanel) );
// and more....
}
In my BCB5 demo, controls are created at runtime based on text (same as what
you find in a DFM). This demo works when linked statically and dynamically.
The same demo in 2007, however, only runs when statically linked. When
dynamically linked I get an error "class TVideoPanel not found"
Has something changed in 2007 I am not aware of ?
Malcolm
 
 

Re:runtime initialization

"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
Quote
The runtime package includes the following code:
Why are you using #pragma startup for that instead of exporting a Register()
function instead? Packages should be using Register(). It is called
automatically when the package is loaded. That applies to all BCB versions.
Gambit
 

Re:runtime initialization

I know about the exported function for wizards, but I can't find information
on Register() in the help for standard runtime packages - I only came across
the #pragma options. Do you have a reference link, or search criteria for
the help file ? Or even just the required declaration ?
I'll keep looking.....
Mal
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

[snip]

Why are you using #pragma startup for that instead of exporting a
Register() function instead? Packages should be using Register(). It is
called automatically when the package is loaded. That applies to all BCB
versions.


Gambit

 

{smallsort}

Re:runtime initialization

"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
Quote
I know about the exported function for wizards, but I can't
find information on Register() in the help for standard runtime
packages - I only came across the #pragma options. Do you
have a reference link, or search criteria for the help file ? Or
even just the required declaration ?
It is the same declaration you use in design-time packages when registering
components, ie:
namespace VideoMonitor
{
void __fastcall PACKAGE Register()
{
RegisterClass(__classid(TVideoPanel));
}
}
Gambit
 

Re:runtime initialization

Now I understand. I wasn't thinking outside the square.....I thought that
Register() function was only used by the IDE.
Cheers.
Mal
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

[snip]
Quote
It is the same declaration you use in design-time packages when
registering components, ie:

namespace VideoMonitor
{
void __fastcall PACKAGE Register()
{
RegisterClass(__classid(TVideoPanel));
}
}


Gambit

 

Re:runtime initialization

Remy,
I assume the namespace has to follow the same rules - same as the unit name,
all in lowercase except for the first letter.
Mal
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

[snip]

namespace VideoMonitor
{
void __fastcall PACKAGE Register()
{
RegisterClass(__classid(TVideoPanel));
}
}


Gambit

 

Re:runtime initialization

After making the suggested change, now my BCB5 code does not run. Here is
the code, in a unit called VideoMonitor_10R_c5.cpp
namespace Videomonitor_10r_c5
{
void __fastcall PACKAGE Register()
{
RegisterClass( __classid( TVideoPanel ) );
RegisterClass( __classid( TVideoMonitor ) );
// etc
}
}
"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
Quote
Remy,

I assume the namespace has to follow the same rules - same as the unit
name, all in lowercase except for the first letter.

Mal

 

Re:runtime initialization

I worked out how to get the BCB5 code to work - the Register() function must
be defined in each unit containing the class to be registered.
Hopefully this will solve the 2007 problems....
Mal
"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
Quote
After making the suggested change, now my BCB5 code does not run. Here is
the code, in a unit called VideoMonitor_10R_c5.cpp

[snip]
 

Re:runtime initialization

Nope, back to square 1.....Remy, does the Register() function have to be
defined in each unit (where the class is implemented), or somewhere else.
Mal
"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
Quote
I worked out how to get the BCB5 code to work - the Register() function
must be defined in each unit containing the class to be registered.

Hopefully this will solve the 2007 problems....

Mal

"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...
>After making the suggested change, now my BCB5 code does not run. Here
>is the code, in a unit called VideoMonitor_10R_c5.cpp
>
[snip]


 

Re:runtime initialization

I moved the registration of the classes to the routine that performs the
object creation. From what I understand, calling the functions when the
class is already registered does nothing. This will do for now...although
I'd still love to know if Register() can be defined as discussed. I just
can't get it to work.
Mal
"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
Quote
Nope, back to square 1.....Remy, does the Register() function have to be
defined in each unit (where the class is implemented), or somewhere else.

Mal

 

Re:runtime initialization

"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
Quote
I thought that Register() function was only used by the IDE.
All exported Register() functions in a package, whether design-time or
run-time, are called by LoadPackage().
Gambit
 

Re:runtime initialization

"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
Quote
I assume the namespace has to follow the same rules - same
as the unit name, all in lowercase except for the first letter.
Yes.
 

Re:runtime initialization

"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
Quote
Nope, back to square 1.....Remy, does the Register() function have
to be defined in each unit (where the class is implemented), or somewhere
else.
Each unit has its own Register() function.
Gambit
 

Re:runtime initialization

I tried but it did not solve the problem. I've worked around it by placing
the calls in the function where the object is created. I'll play more
later.
Mal
"Remy Lebeau (TeamB)" < XXXX@XXXXX.COM >wrote in message
Quote

"Malcolm Smith" < XXXX@XXXXX.COM >wrote in message
news: XXXX@XXXXX.COM ...

[snip]

Each unit has its own Register() function.

Gambit