views:

126

answers:

1

Hello,

I have a Delphi component which I want to install and have it available at the component palette in Delphi but not in C++ Builder. In BDS/RAD 2006 and above I can either have it installed for both personalities or none.

I need to do so because this component uses 3rd party libraries that doesn't support C++ Builder.

I have looked at jedi.inc mentioned here but I'm not able to find the combination to be able to register the component in Delphi personalities only. The component should also work for older Delphi versions: D5, D6 and D7; but not for BCB5 and BCB6. Is this possible?

BTW: Component is written in Delphi. C++ Builder shares same packages as Delphi.

Thanks in advance.

+4  A: 

the BCB define is only set when Delphi is compiling with support for C++Builder (using the -J switches) You can use code like this to detect that someone is trying to build your package with C++ support and issue an error

{$IFDEF BCB}
{$Message Error 'This component is not usable in C++Builder'}
{$ENDIF BCB}
David Dean - Embarcadero
Thanks David. the problem with this is that this component is part of a package which contains other components which should work in C++ Builder. Only this component should not be registered.
Narcís Calvet
My experience is with getting people to /enable/ C++ Support, so I've not tried going the other way before…you could try these directives:{$J OFF}{$OBJEXPORTALL OFF}
David Dean - Embarcadero
Narcís Calvet
I understand why he said what he did, and he is correct that the code is there and should theoretically be accessible. However, whether or not the code is accessible has little relevance to whether a component will register correctly in the IDE. My experience is that it is possible to have Delphi-only components because I've had to help people who could only see their components in Delphi, but wanted to see them in both Delphi and C++.
David Dean - Embarcadero
Thanks David. I'm using code below. TComponent3 needs to be registered in Delphi only. What's wrong with that? RegisterComponents(MyPaletteMessage,[ TComponent1, TComponent2 {$IFNDEF CLX} {$IFDEF BCB} {$J OFF} {$OBJEXPORTALL OFF} ,TComponent3 {$ENDIF} {$ENDIF} ]);
Narcís Calvet
I was imagining you setting the directive in the code for TComponent3.Setting the directive there will only affect that particular source file, which means that everything is still available.If you're just trying to keep it out of that single line, something like this might work better:RegisterComponents(MyPaletteMessage,[ TComponent1, TComponent2 {$IFNDEF CLX} {$IFNDEF BCB},TComponent3 {$ENDIF} {$ENDIF} ])
David Dean - Embarcadero
The previous comment also assumes that the -J option is being passed to the compiler for the project.
David Dean - Embarcadero
@David - most people see components appear in Delphi and not C++ due to misconfigurations in the IDE/projects, not in the component packages themselves.
Remy Lebeau - TeamB
David, thanks for your help! I have been playing around with your suggestions without success. A colleague, much more seasoned in similar stuff than I, told me that -J and ObjExportAll is for generating: .lib, .ojb, .hpp, etc; files, which the C++ Builder compiler needs, when compiling packages with dcc32 compiler. However, the binary package (.bpl) will always contain the component and hence the IDE will install it on the toolbox for both personalities. When adding packages to the tool palette the IDE doesn't check if C++ Builder specific files exist for the component.
Narcís Calvet
Also a conditional directive like HPPNOEMIT exists. However, this is for not generating properties and methods in *.hpp files but that's not what we are looking for. Given all that we will try to make the 3rd party library compatible with C++ Builder.
Narcís Calvet