Changing the window title
This page shows you how to change the window title using the IVideoWindow interface. Please note that error handling codes are omitted to keep the sample code simple.
Sample code
The following sample code shows how to chage the video window title. It is quite easy.
#include <stdio.h>
#include <dshow.h>
// change here
#define FILENAME L"c:\\DXSDK\\Samples\\Media\\butterfly.mpg"
int
main()
{
IGraphBuilder *pGraphBuilder;
IMediaControl *pMediaControl;
IMediaEvent *pMediaEvent;
long eventCode;
IVideoWindow *pVideoWindow;
CoInitialize(NULL);
CoCreateInstance(CLSID_FilterGraph,
NULL,
CLSCTX_INPROC,
IID_IGraphBuilder,
(LPVOID *)&pGraphBuilder);
pGraphBuilder->QueryInterface(IID_IMediaControl,
(LPVOID *)&pMediaControl);
pGraphBuilder->QueryInterface(IID_IMediaEvent,
(LPVOID *)&pMediaEvent);
pMediaControl->RenderFile(FILENAME);
pGraphBuilder->QueryInterface(IID_IVideoWindow,
(LPVOID *)&pVideoWindow);
// Will fail if this is before RenderFile()
pVideoWindow->put_Caption(L"THIS IS A TEST");
pMediaControl->Run();
pMediaEvent->WaitForCompletion(-1, &eventCode);
pMediaEvent->Release();
pMediaControl->Release();
pGraphBuilder->Release();
CoUninitialize();
return 0;
}
Please note that you must use put_Caption after doing RenderFile. This is because the video window (VideoRenderer) is prepared when RenderFile is called.