Please remember this is a work in progress. Home » crosstalk » ctpmgr

Topics in CrossTalk Project Manager

    Articles in CrossTalk Project Manager

     

    CrossTalk Project Manager

    Using CrossTalk in a Project

    CrossTalk Projects are not special Delphi projects. In fact a CrossTalk Project refers to the CTP file used to generate the .pas files used by your Delphi application(s).

    Generally each Delphi project that uses CrossTalk will also have an accompanying CTP file. However a singleDelphi project could have multiple CTP files, and a single CTP file could be shared among several Delphi project.

    Create a Delphi Project

    Create a VCL Forms Delphi project and save it.

    Creating a CTP file

    To create a CTP file, run the CrossTalk Project Manager. It can be accessed from the CrossTalk program group, or in \Program Files\CrossTalk\. The executable name is CTClassgen.exe.

    Select "Create a new CrossTalk Project". A Save As dialog will appear. Browse to the directory where you saved the Delphi project. Select a name for your CTP file. It can be named anything. For example Test.ctp.

    Next the editor form will appear.

    This form allows the selection of .NET assemblies, and then classes that we want to use in our Delphi project. The Add GAC button allows addition ofassemblies that are in the GAC, and the Add User button allows non GAC assemblies to be added. Click the Add GAC button. The Add GAC Assembly form will appear.

    Assemblies can be browsed or filtered. For this example lets add mscorlib, where much of the System namespace exists. To do this type "mscor" in the search text field.

    Now select mscorlib. The form will display the version and culture. This isuseful as assemblies with duplicate names can exist in the GAC, but with different versions and/or cultures.

    Now click OK. The main edit form will reappear with mscorlib added to the assembly list.

    Now we will add a class from mscrolib. Select mscorlib in the Assembly References list.

    Click the Add button to the right of the Types list, and an Add Type form will appear.

    Available Types lists the types that are available in mscorlib for use. A search text field also exists. Type 'stringbu' into the search text field.

    Select System.Text.StringBuilder.

    Click OK.

    In this example we have added one assembly reference, and selected one class. More can be added but we will continue with only one for simplicity. The CTP file can be edited again at a later date to add more types or assembly references.

    Click Save, and then close the CTP Manager. Go to the Delphi project directory and you will see your Delphi project files, and your newly created CTP file.

    Double click on Test.ctp to run the CTP manager again. This time we run the CTP manager to generate the necessary .pas files.

    Click "Generate ..."

    Close this window. The .pas files are ready and have been generated in our project directory.

    Switch back to Delphi and test compile the application.

    Using StringBuilder

    Open the .pas file for the form in the Delphi project and add CTmscorlib to the uses clause.

    Now we can use StringBuilder. Add a button to the form and create a Click event. Add the following code.

    Now run the project and press the button.

    You have just successfully created a native VCL Forms application that calls a .NET class! This sample was designed to be simplistic to reduce the possiblities for errors. However now you should understand how to add more classes including your own custom .NET classes and use them from Delphi. CrossTalk can use System.XML, .NET DataSet classes, and much more.

     

    Terms of Use | Privacy Statement © 2002 - 2018 Atozed Software