The advent of Delphi will be a large number of programmers into the visual programming under Windows, for some c&c++ of the best friend programmer envy, sigh. Until C++builder the appearance of these programer just use the dream of programming tools, also will some reluctantly "defected" to Delphi under the programmer and pull back to C + + arms. She is really merging the visual programming and Object-oriented programming languages of Windows. However, because the C++builder market time is relatively short solid and the available control is not many, and the use of controls only for a certain version, mutual interoperability is not good, unless you have sourcecode; for the Delphi is not to mention, C++builder can not use, Of course, if you have sourcecode then you can turn it into a c++builder control, but you have to go through the step&go of n times complie...m.
Delphi has a powerful control group, how to use these controls has been plagued by our c++builder followers, I learned some of the project through the practice of how to use the Delphi control in the C++builder method.
My method of making C++builder use the DELPHIVCL class library is based on a more general way of using DLLs in Windows. In practical application, the VCL control is found to be converted to DLL library, and DLL is called dynamically in C++builder. This method applies to Non-visual VCL controls.
False order in Delphi has a sample control, has attributes actived, Pro1, Pro2, want to transfer this control to c++builder use.
One: Delphi in the production of DLLs
1. In Delphi new DLL Project Sampledll, when create a new class in this project Tttempcomp base class for Tcomponent is also a control, in which add a constructorCreate1, but do not make any action;
2. Add the function (actived, Pro1, Pro2) &create, destroy frame of the property to be exported in the DLL, add the exported function, exports name in the procdure;
3. Create1 the Ttempcomp instance Temp1 in the main process of the DLL, save the export and set the Exitproc;
4. Add Hwctrl:=sample1.create (TEMP1) to the Opensample function to instantiate the sample, add the corresponding statement to closesample and other attributes;
II: Use of DLLs in C++builder
1. The DLL generated in Delphi with Implib to generate LIB file to join the C++builder project documents;
2. Add in header file
extern "C" __declspec(dllimport) bool _stdcall OpenSample(void);
extern "C" __declspec(dllimport) void _stdcall CloseSample(void);
extern "C" __declspec(dllimport) bool _stdcall Actived(void);
extern "C" __declspec(dllimport) int _stdcall Pro1(void);
extern "C" __declspec(dllimport) int _stdcall Pro2(void);
3.在OpenSample后你就可以使用Delphi中的属性Actived、Pro1、Pro2