CPB Mailing List

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[BCB3] Multiple components in one unit



Hi,

Just received BCB3 today. I'm trying to get my components into BCB3. I've
hit one problem and have one Delphi comp question.

First the question:

I installed a couple of Delphi comps with no probs but then I noticed in the
readme.hlp (BCB3 root directory) that you should included the following in
the Delphi source:

{$ObjExportAll On}

I haven't done this (it seems to work anyway) and am wondering what problems
I might encounter if I don't include it?
If I do put it in, should it go in the implementation or interface section?

Sorry that's 2 questions.

I should add that I haven't used them in an app yet, I'm trying to get all
my components installed first.

Now the problem:

I have several components in one cpp/h unit, I've included #pragma
package(smart_init) in the cpp file just after the #include's. I've also put
a PACKAGE directive for each component class declaration in h file and one
for the Register() function in the cpp file. I have some general utility
funcs declared in the h file and defined in the cpp file. It all compiles Ok
but the components are not appearing on the palette.

Here is an example of how my unit looks (knocked up on the fly - assume
syntax Ok):

--------------------------

// ex.h file

class PACKAGE A : public TComponent {
    public:
        __fastcall A();
};

class PACKAGE B : public TComponent {
    public:
        __fastcall B();
};

void ufunc1( void );
void ufunc2( int i );
// etc.

-------------------------

// ex.cpp
...
#include "ex.h"

__fastcall A::A() : TComponent()
{
}

__fastcall B::B() : TComponent()
{
}

void ufunc1( void )
{
}

void ufunc2( int i )
{
}

namespace ex
{
    void __fastcall PACKAGE Register()
     {
          TComponentClass classes[2] = {
               __classid(A),
               __classid(B)
           };

          RegisterComponents("A palette page", classes, 1);
     }
}

Any ideas on how to get this to work would be welcome. One thing I could do
is separate the components into individual units but I don't fancy that.
Although none of the classes inherit from each other they are conceptually
related and I would like to keep them in one unit. So far I have 3 hours
experience with this so I obviously haven't cottoned on to everything yet
:-).

As an aside, the comps are overrides of standard comps (TEdit, TCheckBox,
TRadioButton ... ) 10 in all, that can be made to read and write their
values to the registry. They are used in just about all my apps and
therefore have been fairly well tested. There are one or two minor probs but
with easy workarounds. If, no, when (lets be positive), I get them working
in BCB3, if anyone's interested in them, drop me a line and I'll mail you a
copy.

TIA
    Mark.




W Komornicki's Home Page | Main Index | Thread Index