00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "stdafx.h"
00026 #include "mplayerc.h"
00027 #include <dmo.h>
00028 #include "RegFilterChooserDlg.h"
00029 #include "GraphBuilder.h"
00030 #include "..\..\DSUtil\DSUtil.h"
00031
00032
00033
00034
00035
00036 CRegFilterChooserDlg::CRegFilterChooserDlg(CWnd* pParent )
00037 : CResizableDialog(CRegFilterChooserDlg::IDD, pParent)
00038 {
00039 }
00040
00041 CRegFilterChooserDlg::~CRegFilterChooserDlg()
00042 {
00043 POSITION pos = m_filters.GetHeadPosition();
00044 while(pos) delete m_filters.GetNext(pos);
00045 }
00046
00047 void CRegFilterChooserDlg::DoDataExchange(CDataExchange* pDX)
00048 {
00049 __super::DoDataExchange(pDX);
00050 DDX_Control(pDX, IDC_LIST2, m_list);
00051 }
00052
00053 void CRegFilterChooserDlg::AddToList(IMoniker* pMoniker)
00054 {
00055 CComPtr<IPropertyBag> pPB;
00056 if(SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
00057 {
00058 CComVariant var;
00059 if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
00060 {
00061 m_list.SetItemData(
00062 m_list.InsertItem(-1, CString(CStringW(var.bstrVal))),
00063 (DWORD_PTR)m_monikers.AddTail(pMoniker));
00064 }
00065 }
00066
00067 }
00068
00069
00070 BEGIN_MESSAGE_MAP(CRegFilterChooserDlg, CResizableDialog)
00071 ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkList1)
00072 ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
00073 ON_BN_CLICKED(IDOK, OnBnClickedOk)
00074 ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
00075 ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnNMDblclkList2)
00076 END_MESSAGE_MAP()
00077
00078
00079
00080
00081 BOOL CRegFilterChooserDlg::OnInitDialog()
00082 {
00083 __super::OnInitDialog();
00084
00085 BeginEnumSysDev(CLSID_LegacyAmFilterCategory, pMoniker)
00086 {
00087 AddToList(pMoniker);
00088 }
00089 EndEnumSysDev
00090
00091 BeginEnumSysDev(DMOCATEGORY_VIDEO_EFFECT, pMoniker)
00092 {
00093 AddToList(pMoniker);
00094 }
00095 EndEnumSysDev
00096
00097 BeginEnumSysDev(DMOCATEGORY_AUDIO_EFFECT, pMoniker)
00098 {
00099 AddToList(pMoniker);
00100 }
00101 EndEnumSysDev
00102
00103 AddAnchor(IDC_LIST2, TOP_LEFT, BOTTOM_RIGHT);
00104 AddAnchor(IDC_BUTTON1, BOTTOM_LEFT);
00105 AddAnchor(IDOK, BOTTOM_RIGHT);
00106 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
00107
00108 SetMinTrackSize(CSize(300,100));
00109
00110 return TRUE;
00111
00112 }
00113
00114 void CRegFilterChooserDlg::OnLbnDblclkList1()
00115 {
00116 SendMessage(WM_COMMAND, IDOK);
00117 }
00118
00119 void CRegFilterChooserDlg::OnUpdateOK(CCmdUI* pCmdUI)
00120 {
00121 pCmdUI->Enable(!!m_list.GetFirstSelectedItemPosition());
00122 }
00123
00124 void CRegFilterChooserDlg::OnBnClickedOk()
00125 {
00126 CComPtr<IMoniker> pMoniker;
00127
00128 POSITION pos = m_list.GetFirstSelectedItemPosition();
00129 if(pos) pos = (POSITION)m_list.GetItemData(m_list.GetNextSelectedItem(pos));
00130 if(pos) pMoniker = m_monikers.GetAt(pos);
00131 if(pMoniker)
00132 {
00133 CGraphRegFilter gf(pMoniker);
00134 Filter* f = new Filter;
00135 f->fDisabled = false;
00136 f->type = Filter::REGISTERED;
00137 f->name = gf.GetName();
00138 f->dispname = gf.GetDispName();
00139 gf.GetGUIDs(f->guids);
00140 gf.GetGUIDs(f->backup);
00141 f->dwMerit = gf.GetDWORDMerit();
00142 f->iLoadType = Filter::MERIT;
00143 m_filters.AddTail(f);
00144 }
00145
00146 __super::OnOK();
00147 }
00148
00149 void CRegFilterChooserDlg::OnBnClickedButton1()
00150 {
00151 CFileDialog dlg(TRUE, NULL, NULL,
00152 OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
00153 _T("DirectShow Filters (*.dll,*.ax)|*.dll;*.ax|"), this, 0);
00154
00155 if(dlg.DoModal() == IDOK)
00156 {
00157 CFilterMapper2 fm2(false);
00158 fm2.Register(dlg.GetPathName());
00159 m_filters.AddTail(&fm2.m_filters);
00160 fm2.m_filters.RemoveAll();
00161
00162 __super::OnOK();
00163 }
00164 }
00165
00166 void CRegFilterChooserDlg::OnNMDblclkList2(NMHDR *pNMHDR, LRESULT *pResult)
00167 {
00168 if(m_list.GetFirstSelectedItemPosition())
00169 {
00170 OnBnClickedOk();
00171 }
00172
00173 *pResult = 0;
00174 }