Use the MontiVision Smart ActiveX Control with Microsoft Visual C++ 6.0

To include the MontiVision Smart Control inside your own Visual C++ 6.0 applications, use the following steps. .

1. Step

Create your application framework with the application wizard from. Make sure that the "ActiveX Controls" support checkbox is selected.

 

2. Step

Select the "Components and Controls..." command from "Project / Add To Project" menu.

3. Step

Select the CMVSmartControl Object from the "Registered ActiveX Controls" folder and press the "Insert" button.

Confirm the class and close the "Components and Controls gallery" dialog.

4. Step

Insert the control into a dialog. The control bar from the resource editor contains a new symbol for the MV Smart Control.

Select the control within the control bar and insert it into the dialog. Set the control id and check the control properties.

5. Step

Open the class wizard and add a member variable for the MV Smart Control.

 

Insert the following import command into the dialog source file:

#pragma warning(disable: 4099) // disable the warning
#import "MVSmartControl.dll" no_namespace named_guids
...
#pragma warning(default: 4099) // enable warning

This command includes all interfaces and additional information from the control COM type library. After compilation there are two new files in the destination folder: MVSmartControl.tlh and MVSmartControl.tli. These files contains all declarations from the control type library. From now on, you can use all interfaces from the MV Smart Control in the application.

The #import statement generates smart pointer wrapper for the control interfaces. Simply add "Ptr" to the interface name to get the corresponding smart pointer. To get a control interface use following code:

IMVSCFilterGraphPtr graph;
graph = m_controlVideo.GetControlUnknown();
if(graph != NULL) // use NULL not 0L or something to aviod compiler errors!
{
    // ...
}

6. Step

Load a MontiVision Project File with the filter configuration for your application. .

HRESULT hr;
CString szPath = ".\\grabimage.mvp";
...
if(graph != NULL)
{
    hr = graph->LoadConfig(szPath.AllocSysString());
    if(SUCCEEDED(hr))
    {
        ... // some configuration stuff
        hr = graph->Start(); // start filter graph
    }
}

7. Step

The MontiVision Smart Control supports control events with the  _IMVSmartControlEvents  interface. To insert event handler open the class wizard and select the control id in the message map page.

The Messages list contains all events from the MV Smart Control. Add Functions for the events you want to handle and close the dialog with the OK button. The class wizard inserts now some code like this:

BEGIN_EVENTSINK_MAP(CImageGrabberDlg, CDialog)
//{{AFX_EVENTSINK_MAP(CImageGrabberDlg)
    ON_EVENT(CImageGrabberDlg, IDC_MVSMARTCONTROL, 1 /* Started */, OnStartedMvsmartcontrol, VTS_NONE)
    ON_EVENT(CImageGrabberDlg, IDC_MVSMARTCONTROL, 3 /* Stopped */, OnStoppedMvsmartcontrol, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CImageGrabberDlg::OnStartedMvsmartcontrol()
{
    // TODO: Add your control notification handler code here
}

void CImageGrabberDlg::OnStoppedMvsmartcontrol()
{
    // TODO: Add your control notification handler code here
}

The OnXxxMvsmartcontrol methods are called by the MV Smart Control. .

See Also