source: trunk/DirectShowSpy/FilterGraphList.h @ 196

Last change on this file since 196 was 196, checked in by roman, 11 years ago

Cosmetic fixes, new .BAT names, UnregisterTreatAsClasses? export to force removal of TreatAs? keys

File size: 35.4 KB
Line 
1////////////////////////////////////////////////////////////
2// Copyright (C) Roman Ryltsov, 2008-2013
3// Created by Roman Ryltsov roman@alax.info
4
5#pragma once
6
7#include <psapi.h>
8#include <atlctrlx.h>
9#include <atlsplit.h>
10#include "rofiles.h"
11#include "FilterGraphSpy.h"
12#include "AboutDialog.h"
13
14#pragma comment(lib, "psapi.lib")
15
16////////////////////////////////////////////////////////////
17// CFilterGraphListPropertySheet
18
19class CFilterGraphListPropertySheet :
20        public CSizablePropertySheetT<CFilterGraphListPropertySheet>
21{
22public:
23
24BEGIN_MSG_MAP_EX(CFilterGraphListPropertySheet)
25        CHAIN_MSG_MAP(CSizablePropertySheet)
26        MSG_WM_SYSCOMMAND(OnSysCommand)
27END_MSG_MAP()
28
29public:
30
31        ////////////////////////////////////////////////////////
32        // CListPropertyPage
33
34        class CListPropertyPage :
35                public CPropertyPageT<CListPropertyPage>,
36                public CDialogResize<CListPropertyPage>
37        {
38        public:
39
40                enum { IDD = IDD_FILTERGRAPHLIST_LIST_PROPERTYPAGE };
41
42        BEGIN_MSG_MAP_EX(CListPropertyPage)
43                CHAIN_MSG_MAP(CPropertyPage)
44                CHAIN_MSG_MAP(CDialogResize<CListPropertyPage>)
45                MSG_WM_INITDIALOG(OnInitDialog)
46                MSG_WM_DESTROY(OnDestroy)
47                MSG_LVN_GETDISPINFO(IDC_FILTERGRAPHLIST_LIST_GRAPH, OnGraphListViewGetDispInfo)
48                MSG_LVN_GETINFOTIP(IDC_FILTERGRAPHLIST_LIST_GRAPH, OnGraphListViewGetInfoTip)
49                MSG_LVN_ITEMCHANGED(IDC_FILTERGRAPHLIST_LIST_GRAPH, OnGraphListViewItemChanged)
50                MSG_LVN_DBLCLK(IDC_FILTERGRAPHLIST_LIST_GRAPH, OnGraphListViewDblClk)
51                COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHLIST_LIST_REFRESH, OnRefresh)
52                COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHLIST_LIST_CHECK, OnCheck)
53                COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHLIST_LIST_COPYTOCLIPBOARD, OnCopyToClipboard)
54                REFLECT_NOTIFICATIONS()
55        END_MSG_MAP()
56
57        BEGIN_DLGRESIZE_MAP(CListPropertyPage)
58                DLGRESIZE_CONTROL(IDC_FILTERGRAPHLIST_LIST_GRAPH, DLSZ_SIZE_X | DLSZ_SIZE_Y)
59                DLGRESIZE_CONTROL(IDC_FILTERGRAPHLIST_LIST_REFRESH, DLSZ_MOVE_Y)
60                DLGRESIZE_CONTROL(IDC_FILTERGRAPHLIST_LIST_CHECK, DLSZ_MOVE_Y)
61                DLGRESIZE_CONTROL(IDC_FILTERGRAPHLIST_LIST_COPYTOCLIPBOARD, DLSZ_MOVE_Y)
62        END_DLGRESIZE_MAP()
63
64        public:
65
66                ////////////////////////////////////////////////////
67                // CItem
68
69                class CItem
70                {
71                public:
72                        CComPtr<IMoniker> m_pMoniker;
73                        CStringW m_sDisplayName;
74                        DWORD64 m_nInstance;
75                        DWORD m_nProcessIdentifier;
76                        CPath m_sProcessImagePath;
77                        CString m_sTime;
78                        CComPtr<IUnknown> m_pFilterGraphUnknown;
79                        CComPtr<IFilterGraph> m_pFilterGraph;
80                        SIZE_T m_nFilterCount;
81                        CString m_sState;
82                        DOUBLE m_fDuration;
83                        DOUBLE m_fPosition;
84
85                public:
86                // CItem
87                        CItem() throw() :
88                                m_nFilterCount(0),
89                                m_fDuration(0),
90                                m_fPosition(0)
91                        {
92                        }
93                        CComPtr<IFilterGraph>& FilterGraphNeeded(IRunningObjectTable* pRunningObjectTable)
94                        {
95                                _A(pRunningObjectTable);
96                                if(!m_pFilterGraph && pRunningObjectTable && m_pMoniker)
97                                {
98                                        _A(m_pMoniker);
99                                        CComPtr<IBindCtx> pBindCtx;
100                                        __C(CreateBindCtx(0, &pBindCtx));
101                                        CComPtr<IUnknown> pUnknown;
102                                        __C(pRunningObjectTable->GetObject(m_pMoniker, &pUnknown));
103                                        const CComQIPtr<IFilterGraph> pFilterGraph = pUnknown;
104                                        __D(pFilterGraph, E_NOINTERFACE);
105                                        m_pFilterGraphUnknown = pUnknown;
106                                        m_pFilterGraph = pFilterGraph;
107                                        m_nFilterCount = 0;
108                                        m_sState.Empty();
109                                }
110                                return m_pFilterGraph;
111                        }
112                        BOOL Check()
113                        {
114                                _ATLTRY
115                                {
116                                        _FilterGraphHelper::CFilterArray FilterArray;
117                                        _FilterGraphHelper::GetGraphFilters(m_pFilterGraph, FilterArray);
118                                        m_nFilterCount = FilterArray.GetCount();
119                                        #pragma region IMediaControl
120                                        _ATLTRY
121                                        {
122                                                m_sState.Empty();
123                                                const CComQIPtr<IMediaControl> pMediaControl = m_pFilterGraph;
124                                                if(pMediaControl)
125                                                {
126                                                        OAFilterState State;
127                                                        if(SUCCEEDED(pMediaControl->GetState(0, &State)))
128                                                        {
129                                                                static LPCTSTR g_ppszStates[] = { _T("Stopped"), _T("Paused"), _T("Running") };
130                                                                if((SIZE_T) State < DIM(g_ppszStates))
131                                                                        m_sState = g_ppszStates[(SIZE_T) State];
132                                                        }
133                                                }
134                                        }
135                                        _ATLCATCHALL()
136                                        {
137                                                _Z_EXCEPTION();
138                                        }
139                                        #pragma endregion
140                                        #pragma region IMediaPosition
141                                        _ATLTRY
142                                        {
143                                                m_fDuration = 0;
144                                                m_fPosition = 0;
145                                                const CComQIPtr<IMediaPosition> pMediaPosition = m_pFilterGraph;
146                                                if(pMediaPosition)
147                                                        if(SUCCEEDED(pMediaPosition->get_Duration(&m_fDuration)))
148                                                                pMediaPosition->get_CurrentPosition(&m_fPosition);
149                                        }
150                                        _ATLCATCHALL()
151                                        {
152                                                _Z_EXCEPTION();
153                                        }
154                                        #pragma endregion
155                                        // SUGG: Source and Sink Paths
156                                }
157                                _ATLCATCHALL()
158                                {
159                                        _Z_EXCEPTION();
160                                        return FALSE;
161                                }
162                                return TRUE;
163                        }
164                };
165
166        private:
167                CFilterGraphListPropertySheet& m_PropertySheet;
168                CRoListViewT<CItem, CRoListControlDataTraitsT> m_GraphListView;
169                CButton m_RefreshButton;
170                CButton m_CheckButton;
171                CButton m_CopyToClipboardButton;
172                CComPtr<IRunningObjectTable> m_pRunningObjectTable;
173
174        public:
175        // CListPropertyPage
176                CListPropertyPage(CFilterGraphListPropertySheet* pPropertySheet) throw() :
177                        m_PropertySheet(*pPropertySheet)
178                {
179                }
180                VOID UpdateControls()
181                {
182                        m_CopyToClipboardButton.EnableWindow(m_GraphListView.GetSelectedCount() > 0);
183                }
184                INT SortGraphListViewItems(LPARAM nItemParameter1, LPARAM nItemParameter2)
185                {
186                        const CItem& Item1 = m_GraphListView.DataFromParameter(nItemParameter1);
187                        const CItem& Item2 = m_GraphListView.DataFromParameter(nItemParameter2);
188                        const INT nTime = _tcscmp(Item1.m_sTime, Item2.m_sTime);
189                        if(nTime)
190                                return -nTime;
191                        const INT nProcess = (INT) (Item1.m_nProcessIdentifier, Item2.m_nProcessIdentifier);
192                        if(nProcess)
193                                return -nProcess;
194                        return wcscmp(Item1.m_sDisplayName, Item2.m_sDisplayName);
195                }
196                static int CALLBACK SortGraphListViewItems(LPARAM nItemParameter1, LPARAM nItemParameter2, LPARAM nParameter)
197                {
198                        return ((CListPropertyPage*) nParameter)->SortGraphListViewItems(nItemParameter1, nItemParameter2);
199                }
200                VOID Refresh()
201                {
202                        CRoMapT<CStringW, CItem> ItemMap;
203                        #pragma region Enumerate
204                        _ATLTRY
205                        {
206                                if(!m_pRunningObjectTable)
207                                        __C(GetRunningObjectTable(0, &m_pRunningObjectTable));
208                                CComPtr<IEnumMoniker> pEnumMoniker;
209                                __C(m_pRunningObjectTable->EnumRunning(&pEnumMoniker));
210                                CComPtr<IMalloc> pMalloc;
211                                __C(CoGetMalloc(1, &pMalloc));
212                                CComPtr<IMoniker> pMoniker;
213                                while(pEnumMoniker->Next(1, &pMoniker, NULL) == S_OK)
214                                {
215                                        _ATLTRY
216                                        {
217                                                CComPtr<IBindCtx> pBindCtx;
218                                                __C(CreateBindCtx(0, &pBindCtx));
219                                                LPOLESTR pszDisplayName = NULL;
220                                                __C(pMoniker->GetDisplayName(pBindCtx, NULL, &pszDisplayName));
221                                                const CStringW sDisplayName = pszDisplayName;
222                                                _Z4(atlTraceGeneral, 4, _T("sDisplayName %ls\n"), sDisplayName);
223                                                pMalloc->Free(pszDisplayName);
224                                                static CRoStaticReW g_Expression(L"^\\!FilterGraph {[0-9A-F]+} pid {[0-9A-F]+}(; process\\: {.+?}, time\\: {[0-9]+\\-[0-9]+\\-[0-9]+})?", FALSE);
225                                                CRoReMatchContext MatchContext;
226                                                if(g_Expression.Match(sDisplayName, &MatchContext))
227                                                {
228                                                        CItem Item;
229                                                        Item.m_pMoniker = pMoniker;
230                                                        Item.m_sDisplayName = sDisplayName;
231                                                        _W(StrToInt64ExW(CStringW(L"0x") + MatchContext.GetMatchString(0), STIF_SUPPORT_HEX, &reinterpret_cast<LONGLONG&>(Item.m_nInstance)));
232                                                        _W(StrToIntExW(CStringW(L"0x") + MatchContext.GetMatchString(1), STIF_SUPPORT_HEX, &reinterpret_cast<INT&>(Item.m_nProcessIdentifier)));
233                                                        Item.m_sTime = CString(MatchContext.GetMatchString(3));
234                                                        Item.m_sTime.Replace(_T("-"), _T(":"));
235                                                        _W(ItemMap.SetAt(sDisplayName, Item) >= 0);
236                                                }
237                                        }
238                                        _ATLCATCHALL()
239                                        {
240                                                _Z_EXCEPTION();
241                                        }
242                                        pMoniker.Release();
243                                }
244                        }
245                        _ATLCATCHALL()
246                        {
247                                _Z_EXCEPTION();
248                        }
249                        #pragma endregion
250                        CWindowRedraw GraphListViewRedraw(m_GraphListView);
251                        BOOL bSortNeeded = FALSE;
252                        #pragma region Remove
253                        for(INT nItem = m_GraphListView.GetItemCount() - 1; nItem >= 0; nItem--)
254                        {
255                                const POSITION Position = ItemMap.Lookup(m_GraphListView.GetItemData(nItem).m_sDisplayName);
256                                if(Position)
257                                        ItemMap.RemoveAtPos(Position);
258                                else
259                                        _W(m_GraphListView.DeleteItem(nItem));
260                        }
261                        #pragma endregion
262                        #pragma region Add
263                        INT nItemIndex = m_GraphListView.GetItemCount();
264                        for(POSITION Position = ItemMap.GetStartPosition(); Position; ItemMap.GetNext(Position))
265                        {
266                                CItem& Item = ItemMap.GetValueAt(Position);
267                                _ATLTRY
268                                {
269                                        CHandle Process;
270                                        //Process.Attach(OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, Item.m_nProcessIdentifier));
271                                        Process.Attach(OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, Item.m_nProcessIdentifier));
272                                        __E(Process);
273                                        TCHAR pszPath[MAX_PATH] = { 0 };
274                                        //_W(GetProcessImageFileName(Process, pszPath, DIM(pszPath)));
275                                        _W(GetModuleFileNameEx(Process, NULL, pszPath, DIM(pszPath)));
276                                        Item.m_sProcessImagePath = pszPath;
277                                }
278                                _ATLCATCHALL()
279                                {
280                                        _Z_EXCEPTION();
281                                }
282                                const INT nItem = m_GraphListView.InsertItem(nItemIndex++, Item);
283                                _A(nItem >= 0);
284                                bSortNeeded = TRUE;
285                        }
286                        #pragma endregion
287                        if(bSortNeeded)
288                                m_GraphListView.SortItems(&CListPropertyPage::SortGraphListViewItems, (LPARAM) this);
289                }
290                static CString FormatIdentifier(LPCSTR pszValue)
291                {
292                        CString sText;
293                        if(pszValue && *pszValue)
294                        {
295                                sText = _T("``");
296                                sText.Insert(1, CString(pszValue));
297                        }
298                        return sText;
299                }
300                static CString FormatIdentifier(LPCWSTR pszValue)
301                {
302                        CString sText;
303                        if(pszValue && *pszValue)
304                        {
305                                sText = _T("``");
306                                sText.Insert(1, CString(pszValue));
307                        }
308                        return sText;
309                }
310                static CString FormatIdentifier(LONG nValue)
311                {
312                        CString sText;
313                        sText = _T("``");
314                        sText.Insert(1, _StringHelper::FormatNumber(nValue));
315                        return sText;
316                }
317                static CString FormatIdentifier(ULONG nValue)
318                {
319                        return FormatIdentifier((LONG) nValue);
320                }
321                static CString FormatIdentifier(BOOL nValue)
322                {
323                        return FormatIdentifier((LONG) nValue);
324                }
325                static CString FormatIdentifier(LONGLONG nValue)
326                {
327                        CString sText;
328                        sText = _T("``");
329                        sText.Insert(1, _StringHelper::FormatNumber(nValue));
330                        return sText;
331                }
332                static CString FormatIdentifier(LONG nValue, LPCTSTR pszFormat)
333                {
334                        CString sText;
335                        sText = _T("``");
336                        sText.Insert(1, AtlFormatString(pszFormat, nValue));
337                        return sText;
338                }
339                #define I FormatIdentifier
340                static CString FormatPins(_FilterGraphHelper::CPinArray& PinArray)
341                {
342                        CRoArrayT<CString> Array;
343                        for(SIZE_T nIndex  = 0; nIndex < PinArray.GetCount(); nIndex++)
344                        {
345                                const CComPtr<IPin>& pPin = PinArray[nIndex];
346                                CString sText = I(_FilterGraphHelper::GetPinName(pPin));
347                                const CComPtr<IPin> pPeerPin = _FilterGraphHelper::GetPeerPin(pPin);
348                                if(pPeerPin)
349                                        sText += AtlFormatString(_T(" (%s)"), I(_FilterGraphHelper::GetPinFullName(pPeerPin)));
350                                Array.Add(sText);
351                        }
352                        return _StringHelper::Join(Array, _T(", "));
353                }
354                CString GetText(CItem& Item) const
355                {
356                        _A(Item.m_pFilterGraph);
357                        CString sText;
358                        sText += AtlFormatString(_T("# ") _T("Filter Graph") _T("\r\n") _T("\r\n"));
359                        #pragma region Graph Parameters
360                        sText += AtlFormatString(_T("* ") _T("Process: %s (%s) %s") _T("\r\n"), I(Item.m_nProcessIdentifier), I(Item.m_nProcessIdentifier, _T("0x%X")), I(FindFileName(Item.m_sProcessImagePath)));
361                        //if(!Item.m_sTime.IsEmpty())
362                        //      sText += AtlFormatString(_T("* ") _T("CreationTime: %s") _T("\r\n"), I(Item.m_sTime));
363                        if(!Item.m_sState.IsEmpty())
364                                sText += AtlFormatString(_T("* ") _T("State: %s") _T("\r\n"), I(Item.m_sState));
365                        if(Item.m_fDuration > 0)
366                        {
367                                sText += AtlFormatString(_T("* ") _T("Duration: %s seconds") _T("\r\n"), I(_StringHelper::FormatNumber(Item.m_fDuration, 3)));
368                                sText += AtlFormatString(_T("* ") _T("Position: %s seconds") _T("\r\n"), I(_StringHelper::FormatNumber(Item.m_fPosition, 3)));
369                        }
370                        sText += AtlFormatString(_T("* ") _T("Display Name: %s") _T("\r\n"), I(Item.m_sDisplayName));
371                        const CString sDirectory = (LPCTSTR) GetPathDirectory(Item.m_sProcessImagePath);
372                        if(!sDirectory.IsEmpty())
373                                sText += AtlFormatString(_T("* ") _T("Process Directory: %s") _T("\r\n"), I(sDirectory));
374                        sText += _T("\r\n");
375                        #pragma endregion
376                        #pragma region Filter
377                        _FilterGraphHelper::CFilterArray FilterArray;
378                        _FilterGraphHelper::GetGraphFilters(Item.m_pFilterGraph, FilterArray);
379                        if(!FilterArray.IsEmpty())
380                        {
381                                sText += AtlFormatString(_T("## ") _T("Filters") _T("\r\n") _T("\r\n"));
382                                for(SIZE_T nIndex = 0; nIndex < FilterArray.GetCount(); nIndex++)
383                                        _ATLTRY
384                                        {
385                                                const CComPtr<IBaseFilter>& pBaseFilter = FilterArray[nIndex];
386                                                sText += AtlFormatString(_T("%d. ") _T("%ls") _T("\r\n"), nIndex + 1, _FilterGraphHelper::GetFilterName(pBaseFilter));
387                                                const CStringW sClassIdentifierString = _FilterGraphHelper::GetFilterClassIdentifierString(pBaseFilter);
388                                                if(!sClassIdentifierString.IsEmpty())
389                                                        sText += AtlFormatString(_T(" * ") _T("Class: %s %s") _T("\r\n"), I(sClassIdentifierString), I(_FilterGraphHelper::GetFilterClassDescription(pBaseFilter)));
390                                                _FilterGraphHelper::CPinArray InputPinArray;
391                                                if(_FilterGraphHelper::GetFilterPins(pBaseFilter, PINDIR_INPUT, InputPinArray))
392                                                        sText += AtlFormatString(_T(" * ") _T("Input Pins: %s") _T("\r\n"), FormatPins(InputPinArray));
393                                                _FilterGraphHelper::CPinArray OutputPinArray;
394                                                if(_FilterGraphHelper::GetFilterPins(pBaseFilter, PINDIR_OUTPUT, OutputPinArray))
395                                                        sText += AtlFormatString(_T(" * ") _T("Output Pins: %s") _T("\r\n"), FormatPins(OutputPinArray));
396                                                #pragma region IFileSourceFilter
397                                                const CComQIPtr<IFileSourceFilter> pFileSourceFilter = pBaseFilter;
398                                                if(pFileSourceFilter)
399                                                {
400                                                        CComHeapPtr<OLECHAR> pszFileName;
401                                                        CMediaType pMediaType;
402                                                        pMediaType.Allocate(MEDIATYPE_NULL, MEDIASUBTYPE_NULL);
403                                                        const HRESULT nGetCurFileResult = pFileSourceFilter->GetCurFile(&pszFileName, pMediaType);
404                                                        _Z45_DSHRESULT(nGetCurFileResult);
405                                                        if(SUCCEEDED(nGetCurFileResult))
406                                                                sText += AtlFormatString(_T(" * ") _T("File Source: %s") _T("\r\n"), I(pszFileName));
407                                                }
408                                                #pragma endregion
409                                                #pragma region IFileSinkFilter
410                                                const CComQIPtr<IFileSinkFilter> pFileSinkFilter = pBaseFilter;
411                                                if(pFileSinkFilter)
412                                                {
413                                                        CComHeapPtr<OLECHAR> pszFileName;
414                                                        CMediaType pMediaType;
415                                                        pMediaType.Allocate(MEDIATYPE_NULL, MEDIASUBTYPE_NULL);
416                                                        const HRESULT nGetCurFileResult = pFileSinkFilter->GetCurFile(&pszFileName, pMediaType);
417                                                        _Z45_DSHRESULT(nGetCurFileResult);
418                                                        if(SUCCEEDED(nGetCurFileResult))
419                                                                sText += AtlFormatString(_T(" * ") _T("File Sink: %s") _T("\r\n"), I(pszFileName));
420                                                }
421                                                #pragma endregion
422                                        }
423                                        _ATLCATCHALL()
424                                        {
425                                                _Z_EXCEPTION();
426                                        }
427                                sText += _T("\r\n");
428                                #pragma region Connection
429                                sText += AtlFormatString(_T("## ") _T("Connections") _T("\r\n") _T("\r\n"));
430                                INT nConnectionIndex = 0;
431                                for(SIZE_T nFilterIndex = 0; nFilterIndex < FilterArray.GetCount(); nFilterIndex++)
432                                {
433                                        const CComPtr<IBaseFilter>& pBaseFilter = FilterArray[nFilterIndex];
434                                        _FilterGraphHelper::CPinArray PinArray;
435                                        _FilterGraphHelper::GetFilterPins(pBaseFilter, PINDIR_OUTPUT, PinArray);
436                                        for(SIZE_T nPinIndex  = 0; nPinIndex < PinArray.GetCount(); nPinIndex++)
437                                        {
438                                                const CComPtr<IPin>& pOutputPin = PinArray[nPinIndex];
439                                                const CComPtr<IPin> pInputPin = _FilterGraphHelper::GetPeerPin(pOutputPin);
440                                                if(!pInputPin)
441                                                        continue;
442                                                CString sConnectionText = AtlFormatString(_T("%s - %s"), I(_FilterGraphHelper::GetPinFullName(pOutputPin)), I(_FilterGraphHelper::GetPinFullName(pInputPin)));
443                                                _ATLTRY
444                                                {
445                                                        const CMediaType pMediaType = _FilterGraphHelper::GetPinMediaType(pOutputPin);
446                                                        if(pMediaType)
447                                                        {
448                                                                CStringW sMajorType = _FilterGraphHelper::FormatMajorType(pMediaType->majortype);
449                                                                CStringW sSubtype;
450                                                                if(pMediaType->subtype != MEDIASUBTYPE_NULL)
451                                                                        sSubtype = _FilterGraphHelper::FormatSubtype(pMediaType->subtype);
452                                                                sConnectionText += AtlFormatString(_T(" (%s %s)"), I(sMajorType), I(sSubtype));
453                                                        }
454                                                }
455                                                _ATLCATCHALL()
456                                                {
457                                                        _Z_EXCEPTION();
458                                                }
459                                                sText += AtlFormatString(_T("%d. ") _T("%s") _T("\r\n"), ++nConnectionIndex, sConnectionText);
460                                        }
461                                }
462                                sText += _T("\r\n");
463                                #pragma endregion
464                                #pragma region Media Type
465                                sText += AtlFormatString(_T("## ") _T("Media Types") _T("\r\n") _T("\r\n"));
466                                INT nGlobalPinIndex = 0;
467                                CRoListT<CComPtr<IPin>> PinList;
468                                for(SIZE_T nFilterIndex = 0; nFilterIndex < FilterArray.GetCount(); nFilterIndex++)
469                                {
470                                        const CComPtr<IBaseFilter>& pBaseFilter = FilterArray[nFilterIndex];
471                                        _FilterGraphHelper::CPinArray PinArray;
472                                        _FilterGraphHelper::GetFilterPins(pBaseFilter, PinArray);
473                                        for(SIZE_T nPinIndex  = 0; nPinIndex < PinArray.GetCount(); nPinIndex++)
474                                        {
475                                                const CComPtr<IPin>& pPin = PinArray[nPinIndex];
476                                                if(PinList.FindFirst(pPin))
477                                                        continue;
478                                                PinList.AddTail(pPin);
479                                                CString sPinText = AtlFormatString(_T("%s"), I(_FilterGraphHelper::GetPinFullName(pPin)));
480                                                const CComPtr<IPin> pPeerPin = _FilterGraphHelper::GetPeerPin(pPin);
481                                                if(pPeerPin)
482                                                {
483                                                        PinList.AddTail(pPeerPin);
484                                                        sPinText += AtlFormatString(_T(", %s"), I(_FilterGraphHelper::GetPinFullName(pPeerPin)));
485                                                }
486                                                sText += AtlFormatString(_T("%d. ") _T("%s") _T("\r\n"), ++nGlobalPinIndex, sPinText);
487                                                _ATLTRY
488                                                {
489                                                        CMediaType pMediaType;
490                                                        if(pPeerPin)
491                                                                pMediaType = _FilterGraphHelper::GetPinMediaType(pPin);
492                                                        else
493                                                                pMediaType = _FilterGraphHelper::EnumerateFirstPinMediaType(pPin);
494                                                        if(!pMediaType)
495                                                                continue;
496                                                        #pragma region AM_MEDIA_TYPE
497                                                        #define J(x) I(pMediaType->x)
498                                                        #define K1(x) sText += AtlFormatString(_T(" * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
499                                                        sText += AtlFormatString(_T(" * ") _T("Data: %s") _T("\r\n"), I(AtlFormatData((const BYTE*) (const AM_MEDIA_TYPE*) pMediaType, sizeof *pMediaType).TrimRight()));
500                                                        sText += AtlFormatString(_T(" * ") _T("`majortype`: %s") _T("\r\n"), I(_FilterGraphHelper::FormatMajorType(pMediaType->majortype)));
501                                                        if(pMediaType->subtype != MEDIASUBTYPE_NULL)
502                                                                sText += AtlFormatString(_T(" * ") _T("`subtype`: %s") _T("\r\n"), I(_FilterGraphHelper::FormatSubtype(pMediaType->subtype)));
503                                                        K1(bFixedSizeSamples);
504                                                        K1(bTemporalCompression);
505                                                        K1(lSampleSize);
506                                                        if(pMediaType->formattype != GUID_NULL)
507                                                                sText += AtlFormatString(_T(" * ") _T("`formattype`: %s") _T("\r\n"), I(_FilterGraphHelper::FormatFormatType(pMediaType->formattype)));
508                                                        if(pMediaType->pUnk)
509                                                                sText += AtlFormatString(_T(" * ") _T("`pUnk`: %s") _T("\r\n"), I(AtlFormatString(_T("0x%p"), pMediaType->pUnk)));
510                                                        if(pMediaType->cbFormat)
511                                                        {
512                                                                K1(cbFormat);
513                                                                if(pMediaType->pbFormat)
514                                                                        sText += AtlFormatString(_T(" * ") _T("Format Data, `pbFormat`: %s") _T("\r\n"), I(AtlFormatData(pMediaType->pbFormat, pMediaType->cbFormat).TrimRight()));
515                                                        }
516                                                        #undef J
517                                                        #undef K1
518                                                        #pragma endregion
519                                                        const BYTE* pnExtraData = NULL;
520                                                        SIZE_T nExtraDataSize = 0;
521                                                        #pragma region FORMAT_VideoInfo
522                                                        if(pMediaType->formattype == FORMAT_VideoInfo)
523                                                        {
524                                                                sText += AtlFormatString(_T(" * ") _T("As `VIDEOINFOHEADER`:") _T("\r\n"));
525                                                                const VIDEOINFOHEADER* pVideoInfoHeader = (const VIDEOINFOHEADER*) pMediaType->pbFormat;
526                                                                #define J(x) I(pVideoInfoHeader->x)
527                                                                #define K1(x) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
528                                                                sText += AtlFormatString(_T("  * ") _T("`rcSource`: (%s, %s) - (%s, %s)") _T("\r\n"), J(rcSource.left), J(rcSource.top), J(rcSource.right), J(rcSource.bottom));
529                                                                sText += AtlFormatString(_T("  * ") _T("`rcTarget`: (%s, %s) - (%s, %s)") _T("\r\n"), J(rcTarget.left), J(rcTarget.top), J(rcTarget.right), J(rcTarget.bottom));
530                                                                K1(dwBitRate);
531                                                                K1(dwBitErrorRate);
532                                                                sText += AtlFormatString(_T("  * ") _T("`AvgTimePerFrame`: %s units") _T("\r\n"), I(_FilterGraphHelper::FormatReferenceTime(pVideoInfoHeader->AvgTimePerFrame)));
533                                                                K1(bmiHeader.biSize);
534                                                                K1(bmiHeader.biWidth);
535                                                                K1(bmiHeader.biHeight);
536                                                                K1(bmiHeader.biPlanes);
537                                                                K1(bmiHeader.biBitCount);
538                                                                sText += AtlFormatString(_T("  * ") _T("`bmiHeader.biCompression`: %s") _T("\r\n"), I(_FilterGraphHelper::GetFourccCodeString(pVideoInfoHeader->bmiHeader.biCompression)));
539                                                                K1(bmiHeader.biSizeImage);
540                                                                K1(bmiHeader.biXPelsPerMeter);
541                                                                K1(bmiHeader.biYPelsPerMeter);
542                                                                K1(bmiHeader.biClrUsed);
543                                                                K1(bmiHeader.biClrImportant);
544                                                                #undef J
545                                                                #undef K1
546                                                                nExtraDataSize = pMediaType->cbFormat - sizeof *pVideoInfoHeader;
547                                                        } else
548                                                        #pragma endregion
549                                                        #pragma region FORMAT_VideoInfo2
550                                                        if(pMediaType->formattype == FORMAT_VideoInfo2)
551                                                        {
552                                                                sText += AtlFormatString(_T(" * ") _T("As `VIDEOINFOHEADER2`:") _T("\r\n"));
553                                                                const VIDEOINFOHEADER2* pVideoInfoHeader2 = (const VIDEOINFOHEADER2*) pMediaType->pbFormat;
554                                                                #define J(x) I(pVideoInfoHeader2->x)
555                                                                #define K1(x) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
556                                                                #define K2(x, y) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), I(pVideoInfoHeader2->x, y))
557                                                                sText += AtlFormatString(_T("  * ") _T("rcSource: (%s, %s) - (%s, %s)") _T("\r\n"), J(rcSource.left), J(rcSource.top), J(rcSource.right), J(rcSource.bottom));
558                                                                sText += AtlFormatString(_T("  * ") _T("rcTarget: (%s, %s) - (%s, %s)") _T("\r\n"), J(rcTarget.left), J(rcTarget.top), J(rcTarget.right), J(rcTarget.bottom));
559                                                                K1(dwBitRate);
560                                                                K1(dwBitErrorRate);
561                                                                sText += AtlFormatString(_T("  * ") _T("`AvgTimePerFrame`: %s units") _T("\r\n"), I(_FilterGraphHelper::FormatReferenceTime(pVideoInfoHeader2->AvgTimePerFrame)));
562                                                                K2(dwInterlaceFlags, _T("0x%X"));
563                                                                K2(dwCopyProtectFlags, _T("0x%X"));
564                                                                K1(dwPictAspectRatioX);
565                                                                K1(dwPictAspectRatioY);
566                                                                K2(dwControlFlags, _T("0x%X"));
567                                                                K1(bmiHeader.biSize);
568                                                                K1(bmiHeader.biWidth);
569                                                                K1(bmiHeader.biHeight);
570                                                                K1(bmiHeader.biPlanes);
571                                                                K1(bmiHeader.biBitCount);
572                                                                sText += AtlFormatString(_T("  * ") _T("`bmiHeader.biCompression`: %s") _T("\r\n"), I(_FilterGraphHelper::GetFourccCodeString(pVideoInfoHeader2->bmiHeader.biCompression)));
573                                                                K1(bmiHeader.biSizeImage);
574                                                                K1(bmiHeader.biXPelsPerMeter);
575                                                                K1(bmiHeader.biYPelsPerMeter);
576                                                                K1(bmiHeader.biClrUsed);
577                                                                K1(bmiHeader.biClrImportant);
578                                                                #undef J
579                                                                #undef K1
580                                                                #undef K2
581                                                                nExtraDataSize = pMediaType->cbFormat - sizeof *pVideoInfoHeader2;
582                                                                if(nExtraDataSize)
583                                                                {
584                                                                        sText += AtlFormatString(_T("  * ") _T("Extra Data: (%d bytes)") _T("\r\n"), nExtraDataSize);
585                                                                        nExtraDataSize = 0;
586                                                                }
587                                                        } else
588                                                        #pragma endregion
589                                                        #pragma region FORMAT_MPEG2Video
590                                                        if(pMediaType->formattype == FORMAT_MPEG2Video)
591                                                        {
592                                                                sText += AtlFormatString(_T(" * ") _T("As `MPEG2VIDEOINFO`:") _T("\r\n"));
593                                                                const MPEG2VIDEOINFO* pMpeg2VideoInfo = (const MPEG2VIDEOINFO*) pMediaType->pbFormat;
594                                                                #define J(x) I(pMpeg2VideoInfo->x)
595                                                                #define K1(x) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
596                                                                #define K2(x, y) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), I(pMpeg2VideoInfo->x, y))
597                                                                sText += AtlFormatString(_T("  * ") _T("`hdr.rcSource`: (%s, %s) - (%s, %s)") _T("\r\n"), J(hdr.rcSource.left), J(hdr.rcSource.top), J(hdr.rcSource.right), J(hdr.rcSource.bottom));
598                                                                sText += AtlFormatString(_T("  * ") _T("`hdr.rcTarget`: (%s, %s) - (%s, %s)") _T("\r\n"), J(hdr.rcTarget.left), J(hdr.rcTarget.top), J(hdr.rcTarget.right), J(hdr.rcTarget.bottom));
599                                                                K1(hdr.dwBitRate);
600                                                                K1(hdr.dwBitErrorRate);
601                                                                sText += AtlFormatString(_T("  * ") _T("`hdr.AvgTimePerFrame`: %s") _T("\r\n"), I(_FilterGraphHelper::FormatReferenceTime(pMpeg2VideoInfo->hdr.AvgTimePerFrame)));
602                                                                K2(hdr.dwInterlaceFlags, _T("0x%X"));
603                                                                K2(hdr.dwCopyProtectFlags, _T("0x%X"));
604                                                                K1(hdr.dwPictAspectRatioX);
605                                                                K1(hdr.dwPictAspectRatioY);
606                                                                K2(hdr.dwControlFlags, _T("0x%X"));
607                                                                K1(hdr.bmiHeader.biSize);
608                                                                K1(hdr.bmiHeader.biWidth);
609                                                                K1(hdr.bmiHeader.biHeight);
610                                                                K1(hdr.bmiHeader.biPlanes);
611                                                                K1(hdr.bmiHeader.biBitCount);
612                                                                sText += AtlFormatString(_T("  * ") _T("`hdr.bmiHeader.biCompression`: %s") _T("\r\n"), I(_FilterGraphHelper::GetFourccCodeString(pMpeg2VideoInfo->hdr.bmiHeader.biCompression)));
613                                                                K1(hdr.bmiHeader.biSizeImage);
614                                                                K1(hdr.bmiHeader.biXPelsPerMeter);
615                                                                K1(hdr.bmiHeader.biYPelsPerMeter);
616                                                                K1(hdr.bmiHeader.biClrUsed);
617                                                                K1(hdr.bmiHeader.biClrImportant);
618                                                                K2(dwStartTimeCode, _T("0x%08X"));
619                                                                K1(cbSequenceHeader);
620                                                                K1(dwProfile);
621                                                                K1(dwLevel);
622                                                                K2(dwFlags, _T("0x%08X"));
623                                                                #undef J
624                                                                #undef K1
625                                                                #undef K2
626                                                                #undef J
627                                                                nExtraDataSize = pMediaType->cbFormat - (sizeof *pMpeg2VideoInfo - sizeof pMpeg2VideoInfo->dwSequenceHeader);
628                                                        } else
629                                                        #pragma endregion
630                                                        #pragma region FORMAT_WaveFormatEx
631                                                        if(pMediaType->formattype == FORMAT_WaveFormatEx)
632                                                        {
633                                                                const WAVEFORMATEX* pWaveFormatEx = (const WAVEFORMATEX*) pMediaType->pbFormat;
634                                                                if(pWaveFormatEx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
635                                                                {
636                                                                        const WAVEFORMATEXTENSIBLE* pWaveFormatExtensible = (const WAVEFORMATEXTENSIBLE*) pMediaType->pbFormat;
637                                                                        #define J(x) I(pWaveFormatExtensible->x)
638                                                                        #define K1(x) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
639                                                                        #define K2(x, y) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), I(pWaveFormatExtensible->x, y))
640                                                                        sText += AtlFormatString(_T(" * ") _T("As `WAVEFORMATEXTENSIBLE`:") _T("\r\n"));
641                                                                        K2(Format.wFormatTag, _T("0x%02X"));
642                                                                        K1(Format.nChannels);
643                                                                        K1(Format.nSamplesPerSec);
644                                                                        K1(Format.nAvgBytesPerSec);
645                                                                        K1(Format.nBlockAlign);
646                                                                        K1(Format.wBitsPerSample);
647                                                                        K1(Format.cbSize);
648                                                                        K1(Samples.wValidBitsPerSample);
649                                                                        K2(dwChannelMask, _T("0x%02X"));
650                                                                        sText += AtlFormatString(_T("  * ") _T("`SubFormat`: %s") _T("\r\n"), I(_PersistHelper::StringFromIdentifier(pWaveFormatExtensible->SubFormat)));
651                                                                        #undef J
652                                                                        #undef K1
653                                                                        #undef K2
654                                                                        nExtraDataSize = pWaveFormatEx->cbSize - (sizeof *pWaveFormatExtensible - sizeof *pWaveFormatEx);
655                                                                } else
656                                                                {
657                                                                        #define J(x) I(pWaveFormatEx->x)
658                                                                        #define K1(x) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
659                                                                        #define K2(x, y) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), I(pWaveFormatEx->x, y))
660                                                                        K2(wFormatTag, _T("0x%02X"));
661                                                                        K1(nChannels);
662                                                                        K1(nSamplesPerSec);
663                                                                        K1(nAvgBytesPerSec);
664                                                                        K1(nBlockAlign);
665                                                                        K1(wBitsPerSample);
666                                                                        K1(cbSize);
667                                                                        #undef J
668                                                                        #undef K1
669                                                                        #undef K2
670                                                                        nExtraDataSize = pWaveFormatEx->cbSize;
671                                                                }
672                                                        }
673                                                        #pragma endregion
674                                                        #pragma region Extra Data
675                                                        if(nExtraDataSize)
676                                                        {
677                                                                if(!pnExtraData)
678                                                                        pnExtraData = pMediaType->pbFormat + pMediaType->cbFormat - nExtraDataSize;
679                                                                sText += AtlFormatString(_T("  * ") _T("Extra Data: %s") _T("\r\n"), I(AtlFormatData(pnExtraData, nExtraDataSize).TrimRight()));
680                                                        }
681                                                        #pragma endregion
682                                                }
683                                                _ATLCATCHALL()
684                                                {
685                                                        _Z_EXCEPTION();
686                                                }
687                                        }
688                                }
689                                sText += _T("\r\n");
690                                #pragma endregion
691                        }
692                        #pragma endregion
693                        return sText;
694                }
695                #undef I
696                CString GetText()
697                {
698                        CRoArrayT<CString> GraphArray;
699                        for(INT nItem = m_GraphListView.GetNextItem(-1, LVNI_SELECTED); nItem >= 0; nItem = m_GraphListView.GetNextItem(nItem, LVNI_SELECTED))
700                        {
701                                CItem& Item = m_GraphListView.GetItemData(nItem);
702                                _ATLTRY
703                                {
704                                        if(Item.FilterGraphNeeded(m_pRunningObjectTable))
705                                        {
706                                                Item.Check();
707                                                m_GraphListView.RedrawItems(nItem, nItem);
708                                                GraphArray.Add(GetText(Item));
709                                        }
710                                }
711                                _ATLCATCHALL()
712                                {
713                                        _Z_EXCEPTION();
714                                }
715                        }
716                        return _StringHelper::Join(GraphArray, _T("\r\n") _T("---") _T("\r\n") _T("\r\n"));
717                }
718
719        // Window Message Handler
720                LRESULT OnInitDialog(HWND, LPARAM)
721                {
722                        _ATLTRY
723                        {
724                                CWaitCursor WaitCursor;
725                                m_GraphListView.Initialize(GetDlgItem(IDC_FILTERGRAPHLIST_LIST_GRAPH));
726                                CToolTipCtrl ToolTip = m_GraphListView.GetToolTips();
727                                ToolTip.SetDelayTime(TTDT_AUTOPOP, 30 * 1000); // 30 seconds
728                                ToolTip.SetMaxTipWidth(max(GetSystemMetrics(SM_CXSCREEN) * 5 / 8, 600));
729                                m_RefreshButton = GetDlgItem(IDC_FILTERGRAPHLIST_LIST_REFRESH);
730                                m_CheckButton = GetDlgItem(IDC_FILTERGRAPHLIST_LIST_CHECK);
731                                m_CopyToClipboardButton = GetDlgItem(IDC_FILTERGRAPHLIST_LIST_COPYTOCLIPBOARD);
732                                DlgResize_Init(FALSE, FALSE);
733                                Refresh();
734                                #if _DEVELOPMENT
735                                        m_GraphListView.SetItemState(0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
736                                #endif // _DEVELOPMENT
737                                UpdateControls();
738                                #pragma region Default Property Sheet Size
739                                CRect Position;
740                                _W(m_PropertySheet.GetWindowRect(Position));
741                                Position.InflateRect(6 * Position.Width() / 8, 1 * Position.Height() / 8);
742                                CSize ScreenExtent(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
743                                ScreenExtent.cx -= ScreenExtent.cx / 8;
744                                ScreenExtent.cy -= ScreenExtent.cy / 8;
745                                if(Position.Width() > ScreenExtent.cx)
746                                        Position.right = Position.left + ScreenExtent.cx;
747                                if(Position.Height() > ScreenExtent.cy)
748                                        Position.bottom = Position.top + ScreenExtent.cy;
749                                _W(m_PropertySheet.MoveWindow(Position));
750                                _W(m_PropertySheet.CenterWindow());
751                                #pragma endregion
752                                CancelToClose();
753                        }
754                        _ATLCATCHALL()
755                        {
756                                for(CWindow Window = GetWindow(GW_CHILD); Window.IsWindow(); Window = Window.GetWindow(GW_HWNDNEXT))
757                                        Window.EnableWindow(FALSE);
758                                _ATLRETHROW;
759                        }
760                        return TRUE;
761                }
762                LRESULT OnDestroy()
763                {
764                        return 0;
765                }
766                LRESULT OnGraphListViewGetDispInfo(NMLVDISPINFO* pHeader)
767                {
768                        const CItem& Item = m_GraphListView.DataFromParameter(pHeader->item.lParam);
769                        if(pHeader->item.mask & LVIF_TEXT)
770                        {
771                                CString& sTextBuffer = m_GraphListView.GetTextBufferString(TRUE);
772                                switch(pHeader->item.iSubItem)
773                                {
774                                case 1: // Process Name
775                                        sTextBuffer = PathFindFileName(Item.m_sProcessImagePath);
776                                        break;
777                                case 2: // Creation Time
778                                        sTextBuffer = Item.m_sTime;
779                                        break;
780                                case 3: // Filter Count
781                                        if(Item.m_pFilterGraph)
782                                                sTextBuffer = AtlFormatString(_T("%d"), Item.m_nFilterCount);
783                                        break;
784                                case 4: // State
785                                        if(Item.m_pFilterGraph)
786                                                sTextBuffer = Item.m_sState;
787                                        break;
788                                case 5: // Process Image Directory
789                                        sTextBuffer = (LPCTSTR) GetPathDirectory(Item.m_sProcessImagePath);
790                                        break;
791                                default: // Process, Instance
792                                        sTextBuffer = AtlFormatString(_T("%d - 0x%p"), Item.m_nProcessIdentifier, Item.m_nInstance);
793                                }
794                                pHeader->item.pszText = m_GraphListView.GetTextBuffer();
795                        }
796                        return 0;
797                }
798                LRESULT OnGraphListViewGetInfoTip(NMLVGETINFOTIP* pHeader)
799                {
800                        const CItem& Item = m_GraphListView.GetItemData(pHeader->iItem);
801                        CString& sTextBuffer = m_GraphListView.GetTextBufferString(TRUE);
802                        sTextBuffer.AppendFormat(_T("Process: %d (0x%X) %s\r\n"), Item.m_nProcessIdentifier, Item.m_nProcessIdentifier, CString(FindFileName(Item.m_sProcessImagePath)));
803                        if(!Item.m_sTime.IsEmpty())
804                                sTextBuffer.AppendFormat(_T("CreationTime: %s\r\n"), Item.m_sTime);
805                        if(Item.m_pFilterGraph)
806                        {
807                                sTextBuffer.AppendFormat(_T("Filter Count: %d\r\n"), Item.m_nFilterCount);
808                                if(!Item.m_sState.IsEmpty())
809                                        sTextBuffer.AppendFormat(_T("State: %s\r\n"), Item.m_sState);
810                                if(Item.m_fDuration > 0)
811                                {
812                                        sTextBuffer.AppendFormat(_T("Duration: %s seconds\r\n"), _StringHelper::FormatNumber(Item.m_fDuration, 3));
813                                        sTextBuffer.AppendFormat(_T("Position: %s seconds\r\n"), _StringHelper::FormatNumber(Item.m_fPosition, 3));
814                                }
815                        }
816                        sTextBuffer.AppendFormat(_T("Display Name: %ls\r\n"), Item.m_sDisplayName);
817                        sTextBuffer.AppendFormat(_T("Instance: 0x%p\r\n"), Item.m_nInstance);
818                        sTextBuffer.TrimRight(_T("\t\n\r ."));
819                        const CString sDirectory = (LPCTSTR) GetPathDirectory(Item.m_sProcessImagePath);
820                        if(!sDirectory.IsEmpty())
821                                sTextBuffer.AppendFormat(_T("Process Directory: %s\r\n"), sDirectory);
822                        #pragma region Clipboard Copy
823                        if(GetKeyState(VK_CONTROL) < 0 && GetKeyState(VK_SHIFT) < 0)
824                                _ATLTRY
825                                {
826                                        SetClipboardText(m_hWnd, sTextBuffer);
827                                        MessageBeep(MB_OK);
828                                }
829                                _ATLCATCHALL()
830                                {
831                                        _Z_EXCEPTION();
832                                        MessageBeep(MB_ICONERROR);
833                                }
834                        #pragma endregion
835                        _tcsncpy_s(pHeader->pszText, pHeader->cchTextMax, m_GraphListView.GetTextBuffer(), _TRUNCATE);
836                        return 0;
837                }
838                LRESULT OnGraphListViewItemChanged(NMLISTVIEW* pHeader)
839                {
840                        UpdateControls();
841                        return 0;
842                }
843                LRESULT OnGraphListViewDblClk(NMITEMACTIVATE* pHeader)
844                {
845                        m_CheckButton.Click();
846                        return 0;
847                }
848                LRESULT OnRefresh(UINT, INT, HWND)
849                {
850                        CWaitCursor WaitCursor;
851                        Refresh();
852                        UpdateControls();
853                        return 0;
854                }
855                LRESULT OnCheck(UINT, INT, HWND)
856                {
857                        CWaitCursor WaitCursor;
858                        for(INT nItem = m_GraphListView.GetNextItem(-1, LVNI_SELECTED); nItem >= 0; nItem = m_GraphListView.GetNextItem(nItem, LVNI_SELECTED))
859                        {
860                                CItem& Item = m_GraphListView.GetItemData(nItem);
861                                if(Item.FilterGraphNeeded(m_pRunningObjectTable))
862                                        if(Item.Check())
863                                                m_GraphListView.RedrawItems(nItem, nItem);
864                        }
865                        return 0;
866                }
867                LRESULT OnCopyToClipboard(UINT, INT, HWND)
868                {
869                        CWaitCursor WaitCursor;
870                        const CString sText = GetText();
871                        if(sText.IsEmpty())
872                                return 0;
873                        SetClipboardText(m_hWnd, sText);
874                        MessageBeep(MB_OK);
875                        return 0;
876                }
877        };
878
879private:
880        CListPropertyPage m_ListPropertyPage;
881
882public:
883// CFilterGraphListPropertySheet
884        CFilterGraphListPropertySheet() :
885                CSizablePropertySheetT<CFilterGraphListPropertySheet>(IDS_FILTERGRAPHLIST_LIST_PROPERTYSHEETCAPTION),
886                m_ListPropertyPage(this)
887        {
888                AddPage(m_ListPropertyPage);
889        }
890        BOOL SetInitialPosition()
891        {
892                if(!__super::SetInitialPosition())
893                        return FALSE;
894                SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)), TRUE);
895                SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)), FALSE);
896                #pragma region Bitness Indication
897                CString sCaption;
898                _W(GetWindowText(sCaption));
899                #if defined(_WIN64)
900                        sCaption.Append(_T(" (64-bit)"));
901                #else
902                        if(SafeIsWow64Process())
903                                sCaption.Append(_T(" (32-bit)"));
904                #endif // defined(_WIN64)
905                _W(SetWindowText(sCaption));
906                #pragma endregion
907                #pragma region System Menu
908                CMenuHandle Menu = GetSystemMenu(FALSE);
909                _W(Menu.AppendMenu(MF_SEPARATOR));
910                _W(Menu.AppendMenu(MF_STRING, ID_APP_ABOUT, _T("&About...")));
911                #pragma endregion
912                return TRUE;
913        }
914
915// Window message handelrs
916        LRESULT OnSysCommand(UINT nCommand, CPoint)
917        {
918                switch(nCommand)
919                {
920                case ID_APP_ABOUT:
921                        {
922                                CAboutDialog Dialog;
923                                Dialog.DoModal(m_hWnd);
924                        }
925                        break;
926                default:
927                        SetMsgHandled(FALSE);
928                }
929                return 0;
930        }
931};
932
Note: See TracBrowser for help on using the repository browser.