Microsoft DirectX 9.0 |
This topic applies to Windows XP only.
Note This article applies to MFC version 6.0, using Microsoft® Visual C++® version 6.0.
This article shows how to create an MFC application that hosts the Video Control. To set up the project, perform the following steps.
tuner.h
msvidctl.h
Tuner.h defines the Tuning Model interfaces, and msvidctl.h defines the Video Control interface. You must include msvidctl.h because MFC does not provide wrapper classes for certain derived classes that you will need to use.
The DLL for the Video Control, msvidctl.dll, contains two type libraries, but MFC does not create wrapper classes for all of the objects in both libraries. Therefore, you must use a combination of techniques to access and control the various Video Control and Tuning Model objects. The following code snippets illustrate these techniques.
Create an instance of an MFC-generated wrapper class
All the COM calls are hidden. Notice that the method names in the wrapper classes are slightly different from the names generated by MIDL in the original header files.
CMSVidVideoRenderer myRenderer = m_VidCtl.GetActiveRenderer();
CRect sourceRect = myRenderer.GetSourceSize();
Create an instance of a Tuning Model COM object
Since MFC does not create any wrapper classes for the Tuning Model objects, you must create and access them using the native COM methods such as CoCreateInstance and QueryInterface.
HRESULT hr;
CComPtr<ITuningSpaceContainer> pTuningSpaceContainer;
hr = CoCreateInstance(CLSID_SystemTuningSpaces,
NULL,
CLSCTX_INPROC_SERVER,
IID_ITuningSpaceContainer,
reinterpret_cast<void**> (&pTuningSpaceContainer));
if(FAILED(hr))
{
AfxMessageBox("Failed to create system tuning spaces object");
return false;
}
long count = 0;
hr = pTuningSpaceContainer->get_Count(&count);
if(FAILED(hr))
{
AfxMessageBox("Failed to get count");
return false;
}
Obtain a derived interface from a wrapper class
MFC does not create a wrapper class for some derived interfaces, such as IMSVidTuner. To get a pointer to these interfaces, to use the m_lpDispatch member of the wrapper class, which is an IDispatch pointer, to call QueryInterface.
CMSVidInputDevice inputDevice = m_VidCtl.GetInputActive();
if (inputDevice.m_lpDispatch)
{
// We have an active input.
CComPtr<IMSVidTuner> myTuner;
inputDevice.m_lpDispatch->QueryInterface(
__uuidof(IMSVidTuner),
reinterpret_cast<void**> &myTuner);
if (FAILED(hr))
{
AfxMessageBox("Failed to QI for tuner");
return;
}
// Assume pATSCTR is an IATSCTuneRequest interface pointer.
myTuner->put_Tune(pATSCTR);
}