|
Adding the control to a Visual Studio.NET project |
![]() ![]()
|
Find below required steps:
Using the control inside Microsoft Visual C++.NET with MFC
The use of ActiveX controls within projects developed using Visual C++.NET and MFC creates particular issues users must be aware of: as for Visual C++ 6.0, ActiveX controls require wrapper classes in order to be used in this environment. Usually these wrapper classes should be generated automatically by the development environment through a dedicated wizard but, due to a bug inside Visual C++.NET (2003, 2005 and 2008), wrapper classes will result incomplete when dealing with ActiveX controls that, in order to maintain backward compatibility, alternates identifiers of properties and methods. For this reason our control comes with its already generated C++ wrapper classes, installed by the setup package inside the "wrappers\cpp.net" directory (by default the complete path should be "C:\Program Files\Active Sound Editor\wrappers\cpp.net").
This issue implies to perform some manual action when creating a variable associated to the control:
Dragging the control's icon from the Toolbox, insert an instance of Active Sound Editor inside the container dialog box Copy the following wrapper files into your project directory: ActiveSoundEditor.cpp and ActiveSoundEditor.h WaveformAnalyzer.cpp and WaveformAnalyzer.h Effects.cpp and Effects.h
Add the just mentioned wrapper files to your project. Open the header file of the dialog box class (supposing that our application's name will be TestApp the header file will be named TestAppDlg.h) Insert the following includes:
#include "ActiveSoundEditor.h" #include "WaveformAnalyzer.h" #include "Effects.h"
Inside the CTestAppDlg class, declare a variable of type CActiveSoundEditor that will represent the control in your code:
CActiveSoundEditor m_editor;
Open the source file of the dialog class TestAppDlg.cpp Search the CTestAppDlg::DoDataExchange override function and insert the following code (here we assume that the development environment will assign the identifier IDC_ACTIVESOUNDEDITORCTRL1 to the control):
DDX_Control(pDX, IDC_ACTIVESOUNDEDITORCTRL1, m_editor);
Just for testing purposes, search the CTestAppDlg::OnInitDialog handler function and insert the following code:
m_editor.InitEditor ((long) GetSafeHwnd ()); m_editor.AboutBox ();
Now compile and run the project: you will see the control's about box displayed before showing the main dialog box of the application.
|