Microsoft DirectX 9.0 |
The IAMCopyCaptureFileProgress is a callback interface used by the ICaptureGraphBuilder2::CopyCaptureFile method.
Because the CopyCaptureFile method can take a long time to complete, an application can implement this interface to receive periodic notifications about the progress of the copy operation. If the application does not need to receive this information, there is no need to implement the interface.
In addition to the methods inherited from IUnknown, the IAMCopyCaptureFileProgress interface exposes the following method.
Method | Description |
Progress | Called periodically by the ICaptureGraphBuilder2::CopyCaptureFile method during capture operations. |
Remarks
To use this interface, implement a class that inherits the interface and implements all of its methods, including the methods in IUnknown. In your application, create an instance of the class and pass it to the CopyCaptureFile method. You do not have to implement COM reference counting in your class, as long as the object is guaranteed not to be deleted before the CopyCaptureFile method returns.
The following example shows a class that implements the interface:
class CProgress : public IAMCopyCaptureFileProgress
{
public:
STDMETHODIMP_(ULONG) AddRef() { return 1; }
STDMETHODIMP_(ULONG) Release() { return 0; }
STDMETHODIMP QueryInterface(REFIID iid, void **ppv)
{
if (ppv == NULL) return E_POINTER;
if (iid == __uuidof(IUnknown))
{
*ppv = static_cast<IUnknown*>(this);
return S_OK;
}
if (iid == IID_IAMCopyCaptureFileProgress)
{
*ppv = static_cast<IAMCopyCaptureFileProgress*>(this);
return S_OK;
}
return E_NOINTERFACE;
}
}
STDMETHODIMP Progress(int iPercent)
{
if (i < 0 || i > 100) return E_INVALIDARG;
TCHAR szMsg[32];
wsprintf(szMsg, TEXT("Progress: %d%%"), i);
// Assume g_hwndStatus is a valid HWND.
SetWindowText(g_hwndStatus, szMsg);
return S_OK;
};
};
The following example uses this class in the CopyCaptureFile method:
// Scope for CProgress object
{
CProgress Prog;
// Assume pBuilder is an initialized ICaptureGraphBuilder2 pointer.
hr = pBuilder->CopyCaptureFile(szCaptureFile, szDestFile, TRUE,
static_cast<IAMCopyCaptureFileProgress*>(&Prog));
}