Introduction
Wnen calculating physical fields, rather often than not, one wants to evaluate the results with a graphic plot in 3D space.
Background
Several years ago I published an article at CodeGuru.com that solves the problem of visualizing the numerical results as a surface in 3D.
Now I found that neither the article nor the reference to the author do not exsist at that site. So, here I would like to present the solution that consists of:
- ATL project - DLL, exposing ActiveX (COM) component,
- C# Windows Form application consuming that ActiveX component,
- MFC client app using the same ActiveX component,
- HTML page that embeds the same ActiveX component and uses JavaScript to control its parameters.
Using the code
As you know COM-object must register several UUIDs: (CLSID, Interfaces, Typelib). It symply can not live without these nasty 128-bit identifiers.
So ATL-project must be opened in a studio running under administrator account. Otherwise the project cannot register COM-entities in Windows registry.
The other 2 client projects may be opened in a separate instance of VS (running under usual user account). I found out that it is better to develop COM-server
and COM-client apps in such environment. While developing applications that uses COM interoperability, there are several (very nasty) pitfalls you may encounter.
- Don't forget to include IPersistStorage and IPersistStreamInit interfaces in ATL control Wizard. Otherwise you won't be able to embed ActiveX control in a Windows Form.
- Compile DLL, launch Visual Studio Native Tools Command Prompt with administator rights and use the aximp utility to generate proxies as shown below.
C:\Windows\system32>aximp D:\...your path...\ATLServer\Debug\ATLServer.dll /source /verbose
The utility must answer this:
Generated Source: C:\Windows\system32\AxATLServerLib.cs
Generated Assembly: C:\Windows\system32\ATLServerLib.dll
Generated Assembly: C:\Windows\system32\AxATLServerLib.dll
Now cut (Ctrl+X) these 3 files and bring them into your project's folders.
- In MFC client project use ClassWizard to create proxy as shown below.
Happy programming!