The C++/CLI thread

The C++/CLI thread

Postby Cuchulainn » Mon May 25, 2009 5:58 pm

Here: we start up Word and Excel to show interoperability.
Attachments
ComComponent.cpp
(1005 Bytes) Downloaded 761 times
User avatar
Cuchulainn
 
Posts: 669
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

books

Postby Cuchulainn » Mon Aug 17, 2009 11:02 am

R.G. Fraser Pro Visual C++/CLI and the .net 2.0 Platform, apress

A. Nathan .NET and COM, the complete Interoperability Guide SAMS
User avatar
Cuchulainn
 
Posts: 669
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands

Postby Cuchulainn » Wed Aug 19, 2009 9:29 am

Summary and Rationale



In some cases we have created a C++ program but we wish to use functionality that is not in C++ (for example, WindowsForms in C# or a payoff parser in F#) then it is possible to interface to C# and F# via a small CLI code snippet.

We use the .NET charts and Datasim Excel interface in C++.





Extended Option Example



This example shows the integration of a C++ program with a C# GUI. It asks the parameters for an option and calculates various values (e.g. Value, Gamma, Delta) and displays it in a chart. Optionally, the output is send to Excel (Excel 2007 needed).



The user interface is written as a C# library .dll. It contains a form class for the input and a form class for the result.

The C++ program refers to the C# .dll and consists mainly of native C++ with a little bit of C++/CLI to create the input and output C# form classes and to pass/retrieve the data. Because it uses C++/CLI it must be compiled as a C++/CLI project.





What?s taking place?



- The C++ program creates an instance of the C# input form class.

- It sets the starting option values in the form and displays the form. The form checks the input.

- When the form is closed, the C++ program reads the option parameters from the form and put them in the option object.

- The option object is calculated for various value types (value, gamma, delta) (all native C++)

- The C++ program creates an instance of the C# results form class.

- The result of the calculation is converted to a .NET array and passed to the results form.

- The results form is shown.





Remark: In the output, one value in the Gamma is INF; Excel displays it but Chart sees this and ignores it.



Edited 20 August 2009: New version of the "Exented Option Example". Outputs the numerical data also in a grid.
Attachments
ExtendedOptionSetup.zip
The "Extended Option Example" setup file.
(2.3 MiB) Downloaded 764 times
User avatar
Cuchulainn
 
Posts: 669
Joined: Mon Dec 18, 2006 2:48 pm
Location: Amsterdam, the Netherlands


Return to C++

Who is online

Users browsing this forum: No registered users and 1 guest

cron