2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 // RegFilterChooserDlg.cpp : implementation file
28 #include "RegFilterChooserDlg.h"
30 #include "..\..\DSUtil\DSUtil.h"
33 // CRegFilterChooserDlg dialog
35 //IMPLEMENT_DYNAMIC(CRegFilterChooserDlg, CResizableDialog)
36 CRegFilterChooserDlg::CRegFilterChooserDlg(CWnd
* pParent
/*=NULL*/)
37 : CResizableDialog(CRegFilterChooserDlg::IDD
, pParent
)
41 CRegFilterChooserDlg::~CRegFilterChooserDlg()
43 POSITION pos
= m_filters
.GetHeadPosition();
44 while(pos
) delete m_filters
.GetNext(pos
);
47 void CRegFilterChooserDlg::DoDataExchange(CDataExchange
* pDX
)
49 __super::DoDataExchange(pDX
);
50 DDX_Control(pDX
, IDC_LIST2
, m_list
);
53 void CRegFilterChooserDlg::AddToList(IMoniker
* pMoniker
)
55 CComPtr
<IPropertyBag
> pPB
;
56 if(SUCCEEDED(pMoniker
->BindToStorage(0, 0, IID_IPropertyBag
, (void**)&pPB
)))
59 if(SUCCEEDED(pPB
->Read(CComBSTR(_T("FriendlyName")), &var
, NULL
)))
62 m_list
.InsertItem(-1, CString(CStringW(var
.bstrVal
))),
63 (DWORD_PTR
)m_monikers
.AddTail(pMoniker
));
70 BEGIN_MESSAGE_MAP(CRegFilterChooserDlg
, CResizableDialog
)
71 ON_LBN_DBLCLK(IDC_LIST1
, OnLbnDblclkList1
)
72 ON_UPDATE_COMMAND_UI(IDOK
, OnUpdateOK
)
73 ON_BN_CLICKED(IDOK
, OnBnClickedOk
)
74 ON_BN_CLICKED(IDC_BUTTON1
, OnBnClickedButton1
)
75 ON_NOTIFY(NM_DBLCLK
, IDC_LIST2
, OnNMDblclkList2
)
79 // CRegFilterChooserDlg message handlers
81 BOOL
CRegFilterChooserDlg::OnInitDialog()
83 __super::OnInitDialog();
85 BeginEnumSysDev(CLSID_LegacyAmFilterCategory
, pMoniker
)
91 BeginEnumSysDev(DMOCATEGORY_VIDEO_EFFECT
, pMoniker
)
97 BeginEnumSysDev(DMOCATEGORY_AUDIO_EFFECT
, pMoniker
)
103 AddAnchor(IDC_LIST2
, TOP_LEFT
, BOTTOM_RIGHT
);
104 AddAnchor(IDC_BUTTON1
, BOTTOM_LEFT
);
105 AddAnchor(IDOK
, BOTTOM_RIGHT
);
106 AddAnchor(IDCANCEL
, BOTTOM_RIGHT
);
108 SetMinTrackSize(CSize(300,100));
110 return TRUE
; // return TRUE unless you set the focus to a control
111 // EXCEPTION: OCX Property Pages should return FALSE
114 void CRegFilterChooserDlg::OnLbnDblclkList1()
116 SendMessage(WM_COMMAND
, IDOK
);
119 void CRegFilterChooserDlg::OnUpdateOK(CCmdUI
* pCmdUI
)
121 pCmdUI
->Enable(!!m_list
.GetFirstSelectedItemPosition());
124 void CRegFilterChooserDlg::OnBnClickedOk()
126 CComPtr
<IMoniker
> pMoniker
;
128 POSITION pos
= m_list
.GetFirstSelectedItemPosition();
129 if(pos
) pos
= (POSITION
)m_list
.GetItemData(m_list
.GetNextSelectedItem(pos
));
130 if(pos
) pMoniker
= m_monikers
.GetAt(pos
);
133 CFGFilterRegistry
fgf(pMoniker
);
134 FilterOverride
* f
= new FilterOverride
;
135 f
->fDisabled
= false;
136 f
->type
= FilterOverride::REGISTERED
;
137 f
->name
= fgf
.GetName();
138 f
->dispname
= fgf
.GetDisplayName();
139 f
->guids
.AddTailList(&fgf
.GetTypes());
140 f
->backup
.AddTailList(&fgf
.GetTypes());
141 f
->dwMerit
= fgf
.GetMeritForDirectShow();
142 f
->iLoadType
= FilterOverride::MERIT
;
143 m_filters
.AddTail(f
);
149 void CRegFilterChooserDlg::OnBnClickedButton1()
151 CFileDialog
dlg(TRUE
, NULL
, NULL
,
152 OFN_EXPLORER
|OFN_ENABLESIZING
|OFN_HIDEREADONLY
,
153 _T("DirectShow Filters (*.dll,*.ax)|*.dll;*.ax|"), this, 0);
155 if(dlg
.DoModal() == IDOK
)
157 CFilterMapper2
fm2(false);
158 fm2
.Register(dlg
.GetPathName());
159 m_filters
.AddTail(&fm2
.m_filters
);
160 fm2
.m_filters
.RemoveAll();
166 void CRegFilterChooserDlg::OnNMDblclkList2(NMHDR
*pNMHDR
, LRESULT
*pResult
)
168 if(m_list
.GetFirstSelectedItemPosition())