source: trunk/DirectShowSpy/FilterGraphList.h @ 193

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

Cosmetic, moved binaries, added graph list and clipboard copy property sheet

File size: 35.5 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("`majortype`: %s") _T("\r\n"), I(_FilterGraphHelper::FormatMajorType(pMediaType->majortype)));
500                                                        if(pMediaType->subtype != MEDIASUBTYPE_NULL)
501                                                                sText += AtlFormatString(_T(" * ") _T("`subtype`: %s") _T("\r\n"), I(_FilterGraphHelper::FormatSubtype(pMediaType->subtype)));
502                                                        K1(bFixedSizeSamples);
503                                                        K1(bTemporalCompression);
504                                                        K1(lSampleSize);
505                                                        if(pMediaType->formattype != GUID_NULL)
506                                                                sText += AtlFormatString(_T(" * ") _T("`formattype`: %s") _T("\r\n"), I(_FilterGraphHelper::FormatFormatType(pMediaType->formattype)));
507                                                        if(pMediaType->pUnk)
508                                                                sText += AtlFormatString(_T(" * ") _T("`pUnk`: %s") _T("\r\n"), I(AtlFormatString(_T("0x%p"), pMediaType->pUnk)));
509                                                        if(pMediaType->cbFormat)
510                                                        {
511                                                                K1(cbFormat);
512                                                                if(pMediaType->pbFormat)
513                                                                {
514                                                                        CString sFormat = AtlFormatData(pMediaType->pbFormat, pMediaType->cbFormat).TrimRight();
515                                                                        sFormat.Replace(_T(" "), _T("` `"));
516                                                                        sFormat.Insert(0, _T("`"));
517                                                                        sFormat.Append(_T("`"));
518                                                                        sText += AtlFormatString(_T(" * ") _T("`pbFormat`: %s") _T("\r\n"), sFormat);
519                                                                }
520                                                        }
521                                                        #undef J
522                                                        #undef K1
523                                                        #pragma endregion
524                                                        const BYTE* pnExtraData = NULL;
525                                                        SIZE_T nExtraDataSize = 0;
526                                                        #pragma region FORMAT_VideoInfo
527                                                        if(pMediaType->formattype == FORMAT_VideoInfo)
528                                                        {
529                                                                sText += AtlFormatString(_T(" * ") _T("As `VIDEOINFOHEADER`:") _T("\r\n"));
530                                                                const VIDEOINFOHEADER* pVideoInfoHeader = (const VIDEOINFOHEADER*) pMediaType->pbFormat;
531                                                                #define J(x) I(pVideoInfoHeader->x)
532                                                                #define K1(x) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
533                                                                sText += AtlFormatString(_T("  * ") _T("`rcSource`: (%s, %s) - (%s, %s)") _T("\r\n"), J(rcSource.left), J(rcSource.top), J(rcSource.right), J(rcSource.bottom));
534                                                                sText += AtlFormatString(_T("  * ") _T("`rcTarget`: (%s, %s) - (%s, %s)") _T("\r\n"), J(rcTarget.left), J(rcTarget.top), J(rcTarget.right), J(rcTarget.bottom));
535                                                                K1(dwBitRate);
536                                                                K1(dwBitErrorRate);
537                                                                sText += AtlFormatString(_T("  * ") _T("`AvgTimePerFrame`: %s units") _T("\r\n"), I(_FilterGraphHelper::FormatReferenceTime(pVideoInfoHeader->AvgTimePerFrame)));
538                                                                K1(bmiHeader.biSize);
539                                                                K1(bmiHeader.biWidth);
540                                                                K1(bmiHeader.biHeight);
541                                                                K1(bmiHeader.biPlanes);
542                                                                K1(bmiHeader.biBitCount);
543                                                                sText += AtlFormatString(_T("  * ") _T("`bmiHeader.biCompression`: %s") _T("\r\n"), I(_FilterGraphHelper::GetFourccCodeString(pVideoInfoHeader->bmiHeader.biCompression)));
544                                                                K1(bmiHeader.biSizeImage);
545                                                                K1(bmiHeader.biXPelsPerMeter);
546                                                                K1(bmiHeader.biYPelsPerMeter);
547                                                                K1(bmiHeader.biClrUsed);
548                                                                K1(bmiHeader.biClrImportant);
549                                                                #undef J
550                                                                #undef K1
551                                                                nExtraDataSize = pMediaType->cbFormat - sizeof *pVideoInfoHeader;
552                                                        } else
553                                                        #pragma endregion
554                                                        #pragma region FORMAT_VideoInfo2
555                                                        if(pMediaType->formattype == FORMAT_VideoInfo2)
556                                                        {
557                                                                sText += AtlFormatString(_T(" * ") _T("As `VIDEOINFOHEADER2`:") _T("\r\n"));
558                                                                const VIDEOINFOHEADER2* pVideoInfoHeader2 = (const VIDEOINFOHEADER2*) pMediaType->pbFormat;
559                                                                #define J(x) I(pVideoInfoHeader2->x)
560                                                                #define K1(x) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
561                                                                #define K2(x, y) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), I(pVideoInfoHeader2->x, y))
562                                                                sText += AtlFormatString(_T("  * ") _T("rcSource: (%s, %s) - (%s, %s)") _T("\r\n"), J(rcSource.left), J(rcSource.top), J(rcSource.right), J(rcSource.bottom));
563                                                                sText += AtlFormatString(_T("  * ") _T("rcTarget: (%s, %s) - (%s, %s)") _T("\r\n"), J(rcTarget.left), J(rcTarget.top), J(rcTarget.right), J(rcTarget.bottom));
564                                                                K1(dwBitRate);
565                                                                K1(dwBitErrorRate);
566                                                                sText += AtlFormatString(_T("  * ") _T("`AvgTimePerFrame`: %s units") _T("\r\n"), I(_FilterGraphHelper::FormatReferenceTime(pVideoInfoHeader2->AvgTimePerFrame)));
567                                                                K2(dwInterlaceFlags, _T("0x%X"));
568                                                                K2(dwCopyProtectFlags, _T("0x%X"));
569                                                                K1(dwPictAspectRatioX);
570                                                                K1(dwPictAspectRatioY);
571                                                                K2(dwControlFlags, _T("0x%X"));
572                                                                K1(bmiHeader.biSize);
573                                                                K1(bmiHeader.biWidth);
574                                                                K1(bmiHeader.biHeight);
575                                                                K1(bmiHeader.biPlanes);
576                                                                K1(bmiHeader.biBitCount);
577                                                                sText += AtlFormatString(_T("  * ") _T("`bmiHeader.biCompression`: %s") _T("\r\n"), I(_FilterGraphHelper::GetFourccCodeString(pVideoInfoHeader2->bmiHeader.biCompression)));
578                                                                K1(bmiHeader.biSizeImage);
579                                                                K1(bmiHeader.biXPelsPerMeter);
580                                                                K1(bmiHeader.biYPelsPerMeter);
581                                                                K1(bmiHeader.biClrUsed);
582                                                                K1(bmiHeader.biClrImportant);
583                                                                #undef J
584                                                                #undef K1
585                                                                #undef K2
586                                                                nExtraDataSize = pMediaType->cbFormat - sizeof *pVideoInfoHeader2;
587                                                                if(nExtraDataSize)
588                                                                {
589                                                                        sText += AtlFormatString(_T("  * ") _T("Extra Data: (%d bytes)") _T("\r\n"), nExtraDataSize);
590                                                                        nExtraDataSize = 0;
591                                                                }
592                                                        } else
593                                                        #pragma endregion
594                                                        #pragma region FORMAT_MPEG2Video
595                                                        if(pMediaType->formattype == FORMAT_MPEG2Video)
596                                                        {
597                                                                sText += AtlFormatString(_T(" * ") _T("As `MPEG2VIDEOINFO`:") _T("\r\n"));
598                                                                const MPEG2VIDEOINFO* pMpeg2VideoInfo = (const MPEG2VIDEOINFO*) pMediaType->pbFormat;
599                                                                #define J(x) I(pMpeg2VideoInfo->x)
600                                                                #define K1(x) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
601                                                                #define K2(x, y) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), I(pMpeg2VideoInfo->x, y))
602                                                                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));
603                                                                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));
604                                                                K1(hdr.dwBitRate);
605                                                                K1(hdr.dwBitErrorRate);
606                                                                sText += AtlFormatString(_T("  * ") _T("`hdr.AvgTimePerFrame`: %s") _T("\r\n"), I(_FilterGraphHelper::FormatReferenceTime(pMpeg2VideoInfo->hdr.AvgTimePerFrame)));
607                                                                K2(hdr.dwInterlaceFlags, _T("0x%X"));
608                                                                K2(hdr.dwCopyProtectFlags, _T("0x%X"));
609                                                                K1(hdr.dwPictAspectRatioX);
610                                                                K1(hdr.dwPictAspectRatioY);
611                                                                K2(hdr.dwControlFlags, _T("0x%X"));
612                                                                K1(hdr.bmiHeader.biSize);
613                                                                K1(hdr.bmiHeader.biWidth);
614                                                                K1(hdr.bmiHeader.biHeight);
615                                                                K1(hdr.bmiHeader.biPlanes);
616                                                                K1(hdr.bmiHeader.biBitCount);
617                                                                sText += AtlFormatString(_T("  * ") _T("`hdr.bmiHeader.biCompression`: %s") _T("\r\n"), I(_FilterGraphHelper::GetFourccCodeString(pMpeg2VideoInfo->hdr.bmiHeader.biCompression)));
618                                                                K1(hdr.bmiHeader.biSizeImage);
619                                                                K1(hdr.bmiHeader.biXPelsPerMeter);
620                                                                K1(hdr.bmiHeader.biYPelsPerMeter);
621                                                                K1(hdr.bmiHeader.biClrUsed);
622                                                                K1(hdr.bmiHeader.biClrImportant);
623                                                                K2(dwStartTimeCode, _T("0x%08X"));
624                                                                K1(cbSequenceHeader);
625                                                                K1(dwProfile);
626                                                                K1(dwLevel);
627                                                                K2(dwFlags, _T("0x%08X"));
628                                                                #undef J
629                                                                #undef K1
630                                                                #undef K2
631                                                                #undef J
632                                                                nExtraDataSize = pMediaType->cbFormat - (sizeof *pMpeg2VideoInfo - sizeof pMpeg2VideoInfo->dwSequenceHeader);
633                                                        } else
634                                                        #pragma endregion
635                                                        #pragma region FORMAT_WaveFormatEx
636                                                        if(pMediaType->formattype == FORMAT_WaveFormatEx)
637                                                        {
638                                                                const WAVEFORMATEX* pWaveFormatEx = (const WAVEFORMATEX*) pMediaType->pbFormat;
639                                                                if(pWaveFormatEx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)
640                                                                {
641                                                                        const WAVEFORMATEXTENSIBLE* pWaveFormatExtensible = (const WAVEFORMATEXTENSIBLE*) pMediaType->pbFormat;
642                                                                        #define J(x) I(pWaveFormatExtensible->x)
643                                                                        #define K1(x) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
644                                                                        #define K2(x, y) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), I(pWaveFormatExtensible->x, y))
645                                                                        sText += AtlFormatString(_T(" * ") _T("As `WAVEFORMATEXTENSIBLE`:") _T("\r\n"));
646                                                                        K2(Format.wFormatTag, _T("0x%02X"));
647                                                                        K1(Format.nChannels);
648                                                                        K1(Format.nSamplesPerSec);
649                                                                        K1(Format.nAvgBytesPerSec);
650                                                                        K1(Format.nBlockAlign);
651                                                                        K1(Format.wBitsPerSample);
652                                                                        K1(Format.cbSize);
653                                                                        K1(Samples.wValidBitsPerSample);
654                                                                        K2(dwChannelMask, _T("0x%02X"));
655                                                                        sText += AtlFormatString(_T("  * ") _T("`SubFormat`: %s") _T("\r\n"), I(_PersistHelper::StringFromIdentifier(pWaveFormatExtensible->SubFormat)));
656                                                                        #undef J
657                                                                        #undef K1
658                                                                        #undef K2
659                                                                        nExtraDataSize = pWaveFormatEx->cbSize - (sizeof *pWaveFormatExtensible - sizeof *pWaveFormatEx);
660                                                                } else
661                                                                {
662                                                                        #define J(x) I(pWaveFormatEx->x)
663                                                                        #define K1(x) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), J(x))
664                                                                        #define K2(x, y) sText += AtlFormatString(_T("  * `") _T(#x) _T("`: %s") _T("\r\n"), I(pWaveFormatEx->x, y))
665                                                                        K2(wFormatTag, _T("0x%02X"));
666                                                                        K1(nChannels);
667                                                                        K1(nSamplesPerSec);
668                                                                        K1(nAvgBytesPerSec);
669                                                                        K1(nBlockAlign);
670                                                                        K1(wBitsPerSample);
671                                                                        K1(cbSize);
672                                                                        #undef J
673                                                                        #undef K1
674                                                                        #undef K2
675                                                                        nExtraDataSize = pWaveFormatEx->cbSize;
676                                                                }
677                                                        }
678                                                        #pragma endregion
679                                                        #pragma region Extra Data
680                                                        if(nExtraDataSize)
681                                                        {
682                                                                if(!pnExtraData)
683                                                                        pnExtraData = pMediaType->pbFormat + pMediaType->cbFormat - nExtraDataSize;
684                                                                CString sFormat = AtlFormatData(pnExtraData, nExtraDataSize).TrimRight();
685                                                                sFormat.Replace(_T(" "), _T("` `"));
686                                                                sFormat.Insert(0, _T("`"));
687                                                                sFormat.Append(_T("`"));
688                                                                sText += AtlFormatString(_T("  * ") _T("Extra Data: %s") _T("\r\n"), sFormat);
689                                                        }
690                                                        #pragma endregion
691                                                }
692                                                _ATLCATCHALL()
693                                                {
694                                                        _Z_EXCEPTION();
695                                                }
696                                        }
697                                }
698                                sText += _T("\r\n");
699                                #pragma endregion
700                        }
701                        #pragma endregion
702                        return sText;
703                }
704                #undef I
705                CString GetText()
706                {
707                        CRoArrayT<CString> GraphArray;
708                        for(INT nItem = m_GraphListView.GetNextItem(-1, LVNI_SELECTED); nItem >= 0; nItem = m_GraphListView.GetNextItem(nItem, LVNI_SELECTED))
709                        {
710                                CItem& Item = m_GraphListView.GetItemData(nItem);
711                                _ATLTRY
712                                {
713                                        if(Item.FilterGraphNeeded(m_pRunningObjectTable))
714                                        {
715                                                Item.Check();
716                                                m_GraphListView.RedrawItems(nItem, nItem);
717                                                GraphArray.Add(GetText(Item));
718                                        }
719                                }
720                                _ATLCATCHALL()
721                                {
722                                        _Z_EXCEPTION();
723                                }
724                        }
725                        return _StringHelper::Join(GraphArray, _T("\r\n") _T("---") _T("\r\n") _T("\r\n"));
726                }
727
728        // Window Message Handler
729                LRESULT OnInitDialog(HWND, LPARAM)
730                {
731                        _ATLTRY
732                        {
733                                CWaitCursor WaitCursor;
734                                m_GraphListView.Initialize(GetDlgItem(IDC_FILTERGRAPHLIST_LIST_GRAPH));
735                                CToolTipCtrl ToolTip = m_GraphListView.GetToolTips();
736                                ToolTip.SetDelayTime(TTDT_AUTOPOP, 30 * 1000); // 30 seconds
737                                ToolTip.SetMaxTipWidth(max(GetSystemMetrics(SM_CXSCREEN) * 5 / 8, 600));
738                                m_RefreshButton = GetDlgItem(IDC_FILTERGRAPHLIST_LIST_REFRESH);
739                                m_CheckButton = GetDlgItem(IDC_FILTERGRAPHLIST_LIST_CHECK);
740                                m_CopyToClipboardButton = GetDlgItem(IDC_FILTERGRAPHLIST_LIST_COPYTOCLIPBOARD);
741                                DlgResize_Init(FALSE, FALSE);
742                                Refresh();
743                                #if _DEVELOPMENT
744                                        m_GraphListView.SetItemState(0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED);
745                                #endif // _DEVELOPMENT
746                                UpdateControls();
747                                #pragma region Default Property Sheet Size
748                                CRect Position;
749                                _W(m_PropertySheet.GetWindowRect(Position));
750                                Position.InflateRect(6 * Position.Width() / 8, 1 * Position.Height() / 8);
751                                CSize ScreenExtent(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN));
752                                ScreenExtent.cx -= ScreenExtent.cx / 8;
753                                ScreenExtent.cy -= ScreenExtent.cy / 8;
754                                if(Position.Width() > ScreenExtent.cx)
755                                        Position.right = Position.left + ScreenExtent.cx;
756                                if(Position.Height() > ScreenExtent.cy)
757                                        Position.bottom = Position.top + ScreenExtent.cy;
758                                _W(m_PropertySheet.MoveWindow(Position));
759                                _W(m_PropertySheet.CenterWindow());
760                                #pragma endregion
761                                CancelToClose();
762                        }
763                        _ATLCATCHALL()
764                        {
765                                for(CWindow Window = GetWindow(GW_CHILD); Window.IsWindow(); Window = Window.GetWindow(GW_HWNDNEXT))
766                                        Window.EnableWindow(FALSE);
767                                _ATLRETHROW;
768                        }
769                        return TRUE;
770                }
771                LRESULT OnDestroy()
772                {
773                        return 0;
774                }
775                LRESULT OnGraphListViewGetDispInfo(NMLVDISPINFO* pHeader)
776                {
777                        const CItem& Item = m_GraphListView.DataFromParameter(pHeader->item.lParam);
778                        if(pHeader->item.mask & LVIF_TEXT)
779                        {
780                                CString& sTextBuffer = m_GraphListView.GetTextBufferString(TRUE);
781                                switch(pHeader->item.iSubItem)
782                                {
783                                case 1: // Process Name
784                                        sTextBuffer = PathFindFileName(Item.m_sProcessImagePath);
785                                        break;
786                                case 2: // Creation Time
787                                        sTextBuffer = Item.m_sTime;
788                                        break;
789                                case 3: // Filter Count
790                                        if(Item.m_pFilterGraph)
791                                                sTextBuffer = AtlFormatString(_T("%d"), Item.m_nFilterCount);
792                                        break;
793                                case 4: // State
794                                        if(Item.m_pFilterGraph)
795                                                sTextBuffer = Item.m_sState;
796                                        break;
797                                case 5: // Process Image Directory
798                                        sTextBuffer = (LPCTSTR) GetPathDirectory(Item.m_sProcessImagePath);
799                                        break;
800                                default: // Process, Instance
801                                        sTextBuffer = AtlFormatString(_T("%d - 0x%p"), Item.m_nProcessIdentifier, Item.m_nInstance);
802                                }
803                                pHeader->item.pszText = m_GraphListView.GetTextBuffer();
804                        }
805                        return 0;
806                }
807                LRESULT OnGraphListViewGetInfoTip(NMLVGETINFOTIP* pHeader)
808                {
809                        const CItem& Item = m_GraphListView.GetItemData(pHeader->iItem);
810                        CString& sTextBuffer = m_GraphListView.GetTextBufferString(TRUE);
811                        sTextBuffer.AppendFormat(_T("Process: %d (0x%X) %s\r\n"), Item.m_nProcessIdentifier, Item.m_nProcessIdentifier, CString(FindFileName(Item.m_sProcessImagePath)));
812                        if(!Item.m_sTime.IsEmpty())
813                                sTextBuffer.AppendFormat(_T("CreationTime: %s\r\n"), Item.m_sTime);
814                        if(Item.m_pFilterGraph)
815                        {
816                                sTextBuffer.AppendFormat(_T("Filter Count: %d\r\n"), Item.m_nFilterCount);
817                                if(!Item.m_sState.IsEmpty())
818                                        sTextBuffer.AppendFormat(_T("State: %s\r\n"), Item.m_sState);
819                                if(Item.m_fDuration > 0)
820                                {
821                                        sTextBuffer.AppendFormat(_T("Duration: %s seconds\r\n"), _StringHelper::FormatNumber(Item.m_fDuration, 3));
822                                        sTextBuffer.AppendFormat(_T("Position: %s seconds\r\n"), _StringHelper::FormatNumber(Item.m_fPosition, 3));
823                                }
824                        }
825                        sTextBuffer.AppendFormat(_T("Display Name: %ls\r\n"), Item.m_sDisplayName);
826                        sTextBuffer.AppendFormat(_T("Instance: 0x%p\r\n"), Item.m_nInstance);
827                        sTextBuffer.TrimRight(_T("\t\n\r ."));
828                        const CString sDirectory = (LPCTSTR) GetPathDirectory(Item.m_sProcessImagePath);
829                        if(!sDirectory.IsEmpty())
830                                sTextBuffer.AppendFormat(_T("Process Directory: %s\r\n"), sDirectory);
831                        #pragma region Clipboard Copy
832                        if(GetKeyState(VK_CONTROL) < 0 && GetKeyState(VK_SHIFT) < 0)
833                                _ATLTRY
834                                {
835                                        SetClipboardText(m_hWnd, sTextBuffer);
836                                        MessageBeep(MB_OK);
837                                }
838                                _ATLCATCHALL()
839                                {
840                                        _Z_EXCEPTION();
841                                        MessageBeep(MB_ICONERROR);
842                                }
843                        #pragma endregion
844                        _tcsncpy_s(pHeader->pszText, pHeader->cchTextMax, m_GraphListView.GetTextBuffer(), _TRUNCATE);
845                        return 0;
846                }
847                LRESULT OnGraphListViewItemChanged(NMLISTVIEW* pHeader)
848                {
849                        UpdateControls();
850                        return 0;
851                }
852                LRESULT OnGraphListViewDblClk(NMITEMACTIVATE* pHeader)
853                {
854                        m_CheckButton.Click();
855                        return 0;
856                }
857                LRESULT OnRefresh(UINT, INT, HWND)
858                {
859                        CWaitCursor WaitCursor;
860                        Refresh();
861                        UpdateControls();
862                        return 0;
863                }
864                LRESULT OnCheck(UINT, INT, HWND)
865                {
866                        CWaitCursor WaitCursor;
867                        for(INT nItem = m_GraphListView.GetNextItem(-1, LVNI_SELECTED); nItem >= 0; nItem = m_GraphListView.GetNextItem(nItem, LVNI_SELECTED))
868                        {
869                                CItem& Item = m_GraphListView.GetItemData(nItem);
870                                if(Item.FilterGraphNeeded(m_pRunningObjectTable))
871                                        if(Item.Check())
872                                                m_GraphListView.RedrawItems(nItem, nItem);
873                        }
874                        return 0;
875                }
876                LRESULT OnCopyToClipboard(UINT, INT, HWND)
877                {
878                        CWaitCursor WaitCursor;
879                        const CString sText = GetText();
880                        if(sText.IsEmpty())
881                                return 0;
882                        SetClipboardText(m_hWnd, sText);
883                        MessageBeep(MB_OK);
884                        return 0;
885                }
886        };
887
888private:
889        CListPropertyPage m_ListPropertyPage;
890
891public:
892// CFilterGraphListPropertySheet
893        CFilterGraphListPropertySheet() :
894                CSizablePropertySheetT<CFilterGraphListPropertySheet>(IDS_FILTERGRAPHLIST_LIST_PROPERTYSHEETCAPTION),
895                m_ListPropertyPage(this)
896        {
897                AddPage(m_ListPropertyPage);
898        }
899        BOOL SetInitialPosition()
900        {
901                if(!__super::SetInitialPosition())
902                        return FALSE;
903                SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)), TRUE);
904                SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)), FALSE);
905                #pragma region Bitness Indication
906                CString sCaption;
907                _W(GetWindowText(sCaption));
908                #if defined(_WIN64)
909                        sCaption.Append(_T(" (64-bit)"));
910                #else
911                        if(SafeIsWow64Process())
912                                sCaption.Append(_T(" (32-bit)"));
913                #endif // defined(_WIN64)
914                _W(SetWindowText(sCaption));
915                #pragma endregion
916                #pragma region System Menu
917                CMenuHandle Menu = GetSystemMenu(FALSE);
918                _W(Menu.AppendMenu(MF_SEPARATOR));
919                _W(Menu.AppendMenu(MF_STRING, ID_APP_ABOUT, _T("&About...")));
920                #pragma endregion
921                return TRUE;
922        }
923
924// Window message handelrs
925        LRESULT OnSysCommand(UINT nCommand, CPoint)
926        {
927                switch(nCommand)
928                {
929                case ID_APP_ABOUT:
930                        {
931                                CAboutDialog Dialog;
932                                Dialog.DoModal(m_hWnd);
933                        }
934                        break;
935                default:
936                        SetMsgHandled(FALSE);
937                }
938                return 0;
939        }
940};
941
Note: See TracBrowser for help on using the repository browser.