Adding the control to a Visual Studio.NET project |
|
Find below required steps:
• | Open the project you are working on |
• | If not already visible, open the Toolbox of Visual Studio.NET. |
• | Right click the mouse button over the Toolbox surface. |
• | Select the "Add/Remove Items..." menu item (if still using Visual Studio.NET 2002 use the "Customize Toolbox..." menu item); this will open the "Customize Toolbox" dialog box. |
• | Select the "COM components" tab |
• | Between the installed COM components find the component named "Active Sound Recorder ActiveX Control" as displayed below |
• | Pressing the "OK" button will bring you again to your project working area |
• | Once the control has been inserted inside the project, the following icon should appear inside your toolbox |
• | Now you can select the control icon inside the toolbox and drag it into the dialog box under editing; the following icon will appear on the dialog box (note that this icon will be invisible at runtime) and two references to the control will be automatically added to the "References" section of the Project |
• | You can now start developing your code around the control as described inside the How to use the control in your projects section |
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 "\Program files\MultiMedia Soft\Active Sound Recorder\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 Recorder inside the container dialog box
Copy wrapper files contained inside the "\Program files\MultiMedia Soft\Active Sound Recorder\wrappers\cpp.net" into your project directory:
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 "ActiveSoundRecorder.h"
Inside the CTestAppDlg class, declare a variable of type CActiveSoundRecorder that will represent the control in your code:
CActiveSoundRecorder m_Recorder;
In case you should need using any of the available COM objects inside your code, add the related wrapper file; if for example you should need accessing the Spectrum COM object you will have to add the following line of code:
#include "Spectrum.h"
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_ACTIVESOUNDRECORDERCTRL1 to the control):
DDX_Control(pDX, IDC_ACTIVESOUNDRECORDERCTRL1, m_Recorder);
Just for testing purposes, search the CTestAppDlg::OnInitDialog handler function and insert the following code:
m_Recorder.InitRecordingSystem ((long) GetSafeHwnd ());
m_Recorder.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.