我是安裝 BCB6, DX9 及 DSPack234, 參考了 BCB6\Playcap 程式,
編譯過後的結果都 OK, 執行也正常, 但我想加入更改 resolution 的 menu item,
所以嘗試叫出 PropertyPage 來選擇 resolution.
可是現在只能顯示出 ppDefault PropertyPage, 無法顯示其他的 prooerty page,
請問各位大大, 是否我有遺漏什麼程序?
//---------------------------------------------------------------------------
#include
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma link "DSPack"
#pragma resource "*.dfm" TForm1 *Form1;
TSysDevEnum *SysDev;
ICaptureGraphBuilder2 *Graph = NULL;
IBaseFilter *SourceFilter = NULL;
IBaseFilter *VideoFilter = NULL; //---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
} //--------------------------------------------------------------------------- void __fastcall TForm1::FormCloseQuery(TObject *Sender, bool &CanClose)
{
Graph->Release();
VideoFilter->Release();
SourceFilter->Release();
}
//--------------------------------------------------------------------------- void __fastcall TForm1::FormCreate(TObject *Sender)
{
SysDev = new TSysDevEnum(AM_KSCATEGORY_CAPTURE); //CLSID_VideoInputDeviceCategory if (SysDev->CountFilters > 0)
{
TMenuItem *Device;
for(int i=0; iCountFilters; i )
{
Device = new TMenuItem(Devices);
Device->Caption = SysDev->Filters[i].FriendlyName;
Device->Tag = i;
Device->OnClick = Devices1Click;
ShowMessage(SysDev->Filters[i].FriendlyName);
Devices1->Add(Device);
}
}
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Devices1Click(TObject *Sender)
{
FilterGraph->ClearGraph();
FilterGraph->Active = false;
Filter->BaseFilter->Moniker = SysDev->GetMoniker(((TMenuItem *)Sender)->Tag);
Filter->BaseFilter->Moniker->BindToObject(NULL, NULL, IID_IBaseFilter, (void **)&SourceFilter);
FilterGraph->Active = true; CheckDSError(FilterGraph->QueryInterface(IID_ICaptureGraphBuilder2, &Graph));
CheckDSError(VideoWindow->QueryInterface(IID_IBaseFilter, &VideoFilter));
CheckDSError(Filter->QueryInterface(IID_IBaseFilter, &SourceFilter)); Graph->RenderStream(&PIN_CATEGORY_CAPTURE, &MEDIATYPE_Video, SourceFilter, NULL, VideoFilter);//PIN_CATEGORY_CAPTURE FilterGraph->Play();
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (HaveFilterPropertyPage(SourceFilter, ppDefault)) ShowMessage("have ppDefault");
if (HaveFilterPropertyPage(SourceFilter, ppVFWCapFormat)) ShowMessage("have ppVFWCapFormat");
if (HaveFilterPropertyPage(SourceFilter, ppVFWCapSource)) ShowMessage("have ppVFWCapSource");
if (HaveFilterPropertyPage(SourceFilter, ppVFWCapDisplay)) ShowMessage("have ppVFWCapDisplay");
if (HaveFilterPropertyPage(SourceFilter, ppVFWCompConfig)) ShowMessage("have ppVFWCompConfig");
if (HaveFilterPropertyPage(SourceFilter, ppVFWCompAbout)) ShowMessage("have ppVFWCompAbout");
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button2Click(TObject *Sender)
{
HRESULT hr;
IAMCrossbar *pXBar1=NULL; hr=Graph->FindInterface(&LOOK_UPSTREAM_ONLY, NULL, SourceFilter, IID_IAMCrossbar, (VOID **)&pXBar1); if (SUCCEEDED(hr))
{
ShowMessage("have IID_IAMCrossbar interface");
// DisplayCrossbarInfo(pXBar1);
pXBar1->Release();
}
else ShowMessage("non IID_IAMCrossbar interface");
}
//--------------------------------------------------------------------------- void __fastcall TForm1::Button3Click(TObject *Sender)
{
IAMVfwCaptureDialogs *pVfw=NULL;
HRESULT hr; hr=SourceFilter->QueryInterface(IID_IAMVfwCaptureDialogs, (void **)&pVfw); if (SUCCEEDED(hr))
{
ShowMessage("have IID_IAMVfwCaptureDialogs interface");
ShowFilterPropertyPage((unsigned int)Form1->Handle, SourceFilter, ppVFWCapFormat); if (S_OK==pVfw->HasDialog(VfwCaptureDialog_Source))
{
ShowMessage("have VfwCaptureDialog_Source");
}
else ShowMessage("non VfwCaptureDialog_Source");
}
else ShowMessage("non IID_IAMVfwCaptureDialogs interface");
}
//---------------------------------------------------------------------------
在 Button1Click 裡, 是用來判斷是否有 PropertyPage.
在 Button2Click, Button3Click 裡, 原本是想參考
http://delphi.ktop.com.tw/topic.php?topic_id=35690 討論,
但在 Graph->FindInterface 都回傳 fail. 我嘗試了 CLSID_VideoInputDeviceCategory Filter 及
AM_KSCATEGORY_CAPTURE Filter 都是相同的結果