Display VFW Capture Dialog Boxes
[The feature associated with this page, DirectShow, is a legacy feature. It has been superseded by MediaPlayer, IMFMediaEngine, and Audio/Video Capture in Media Foundation. Those features have been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer, IMFMediaEngine and Audio/Video Capture in Media Foundation instead of DirectShow, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]
A capture device that still uses a Video for Windows (VFW) driver can support any of the following three dialog boxes, which are used to configure the device.
Dialog box | Description |
---|---|
Video Source | Used to select the video input and to adjust device settings, such as picture brightness or contrast. |
Video Format | Used to select the image dimensions and bit depth. |
Video Display | Used to control the appearance of the rendered video. |
To show one of these dialog boxes, do the following:
- Stop the filter graph.
- Query the capture filter for the IAMVfwCaptureDialogs interface. If QueryInterface succeeds, it means the capture device is a VFW device.
- Call IAMVfwCaptureDialogs::HasDialog to check if the driver supports the dialog box that you wish to display. The VfwCaptureDialogs enumeration defines flags for each of the VFW dialog boxes. HasDialog returns S_OK if the dialog box is supported. It returns S_FALSE otherwise, so check for the value S_OK directly, rather than using the SUCCEEDED macro.
- If the dialog box is supported, call IAMVfwCaptureDialogs::ShowDialog to display the dialog box.
- Restart the graph.
The following code shows these steps for the Video Source dialog box:
pControl->Stop(); // Stop the graph.
// Query the capture filter for the IAMVfwCaptureDialogs interface.
IAMVfwCaptureDialogs *pVfw = 0;
hr = pCap->QueryInterface(IID_IAMVfwCaptureDialogs, (void**)&pVfw);
if (SUCCEEDED(hr))
{
// Check if the device supports this dialog box.
if (S_OK == pVfw->HasDialog(VfwCaptureDialog_Source))
{
// Show the dialog box.
hr = pVfw->ShowDialog(VfwCaptureDialog_Source, hwndParent);
}
}
pControl->Run();
Related topics