Using the MontiVision Smart ActiveX Control with Visual
C++ 2002-2005
To include the MontiVision Smart Control in your
own Visual C++ application, use the following steps.
1. Step
Create your application framework with the
application wizard form. Make sure that the "ActiveX Controls"
checkbox is selected.
2. Step
Select the "Customize Toolbox
.." command from the "Tools" menu.
3. Step
Enable the "CMVSmartControl" ActiveX Control and press OK.
4. Step
Select the MVSmartControl from
the Toolbox Window and draw the control into the dialog
resource.
5. Step
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 "C:\\WINNT\\System32\\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 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 "Add Event
Handler" Dialog.
The Message type list contains
all available Events from the MV Smart Control. Add Functions for
the events you want to handle and pres the "Add and Edit" button.
The dialog inserts some code like this:
BEGIN_EVENTSINK_MAP(CImageGrabberDlg,
CDialog)
ON_EVENT(CImageGrabberDlg, IDC_MVSMARTCONTROL, 1
, StartedMvsmartcontrol, VTS_NONE)
ON_EVENT(CImageGrabberDlg, IDC_MVSMARTCONTROL, 3
, StoppedMvsmartcontrol, VTS_NONE)
END_EVENTSINK_MAP()
void CImageGrabberDlg::StartedMvsmartcontrol()
{
// TODO: Add your message handler code
here
}
void CImageGrabberDlg::StoppedMvsmartcontrol()
{
// TODO: Add your message handler code
here
}
The XxxMvsmartcontrol methods
were called by the MV Smart Control.
See Also
|