[This is preliminary documentation and subject to change.]
To receive event notifications from WebTV for Windows, your application must first implement the ITVControl interface. Then, when your application runs, it must obtain a reference to WebTV for Windows, as described in Getting a Pointer to WebTV for Windows. After obtaining this reference, your application then registers its implementation of ITVControl as a notification sink.
Note Currently, WebTV for Windows only sends notifications to applications running in the same process as WebTV for Windows. An example of such an application is a Microsoft® ActiveX® control or component called from an enhancement page that is currently being displayed by WebTV for Windows.
This process is demonstrated in the following example. Note that m_xTVControl
is a member variable implementation of ITVControl.
IUnknown *punk = NULL;
ITVViewer *ptvx = NULL;
HRESULT hr;
LPCONNECTIONPOINTCONTAINER pcpc = NULL;
//Get the ITVViewer interface
GetActiveObject(CLSID_TVViewer, NULL, &punk);
//If the interface is not found, return VARIANT_FALSE
if (punk == NULL)
return VARIANT_FALSE;
punk->QueryInterface(IID_ITVViewer, (void **)&pvtx);
punk->Release();
//Get the IID_TVControl connection point
ptvx->QueryInterface(IID_IConnectionPointContainer, (void**)&pcpc);
if (pcpc == NULL)
{
ptvx->Release();
ptvx = NULL;
return VARIANT_FALSE;
}
pcpc->FindConnectionPoint(IID_ITVControl, &pcpTVControl);
pcpc->Release();
if (pcpTVControl == NULL)
{
ptvx->Release();
ptvx = NULL;
return VARIANT_FALSE;
}
//Ask the connection point to advise on m_xTVControl
hr = pcpTVControl->Advise(&m_xTVControl, &dwTVControl);
if (FAILED(hr))
{
pcpTVControl->Release();
pcpTVControl = NULL;
ptvx->Release();
ptvx = NULL;
return VARIANT_FALSE;
}
ptvx->Release();
return VARIANT_TRUE;