1 | //////////////////////////////////////////////////////////// |
---|
2 | // Copyright (C) Roman Ryltsov, 2008-2014 |
---|
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 "FilterGraphHelper.h" |
---|
13 | #include "AboutDialog.h" |
---|
14 | |
---|
15 | #pragma comment(lib, "psapi.lib") |
---|
16 | |
---|
17 | //////////////////////////////////////////////////////////// |
---|
18 | // CFilterGraphListPropertySheet |
---|
19 | |
---|
20 | class CFilterGraphListPropertySheet : |
---|
21 | public CSizablePropertySheetT<CFilterGraphListPropertySheet> |
---|
22 | { |
---|
23 | public: |
---|
24 | |
---|
25 | BEGIN_MSG_MAP_EX(CFilterGraphListPropertySheet) |
---|
26 | CHAIN_MSG_MAP(CSizablePropertySheet) |
---|
27 | MSG_WM_SYSCOMMAND(OnSysCommand) |
---|
28 | END_MSG_MAP() |
---|
29 | |
---|
30 | public: |
---|
31 | |
---|
32 | //////////////////////////////////////////////////////// |
---|
33 | // CListPropertyPage |
---|
34 | |
---|
35 | class CListPropertyPage : |
---|
36 | public CPropertyPageT<CListPropertyPage>, |
---|
37 | public CDialogResize<CListPropertyPage> |
---|
38 | { |
---|
39 | public: |
---|
40 | |
---|
41 | enum { IDD = IDD_FILTERGRAPHLIST_LIST_PROPERTYPAGE }; |
---|
42 | |
---|
43 | BEGIN_MSG_MAP_EX(CListPropertyPage) |
---|
44 | CHAIN_MSG_MAP(CPropertyPage) |
---|
45 | CHAIN_MSG_MAP(CDialogResize<CListPropertyPage>) |
---|
46 | MSG_WM_INITDIALOG(OnInitDialog) |
---|
47 | MSG_WM_DESTROY(OnDestroy) |
---|
48 | MSG_LVN_GETDISPINFO(IDC_FILTERGRAPHLIST_LIST_GRAPH, OnGraphListViewGetDispInfo) |
---|
49 | MSG_LVN_GETINFOTIP(IDC_FILTERGRAPHLIST_LIST_GRAPH, OnGraphListViewGetInfoTip) |
---|
50 | MSG_LVN_ITEMCHANGED(IDC_FILTERGRAPHLIST_LIST_GRAPH, OnGraphListViewItemChanged) |
---|
51 | MSG_LVN_DBLCLK(IDC_FILTERGRAPHLIST_LIST_GRAPH, OnGraphListViewDblClk) |
---|
52 | COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHLIST_LIST_REFRESH, OnRefresh) |
---|
53 | COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHLIST_LIST_CHECK, OnCheck) |
---|
54 | COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHLIST_LIST_COPYTOCLIPBOARD, OnCopyToClipboard) |
---|
55 | COMMAND_ID_HANDLER_EX(IDC_FILTERGRAPHLIST_LIST_PROPERTIES, OnProperties) |
---|
56 | REFLECT_NOTIFICATIONS() |
---|
57 | END_MSG_MAP() |
---|
58 | |
---|
59 | BEGIN_DLGRESIZE_MAP(CListPropertyPage) |
---|
60 | DLGRESIZE_CONTROL(IDC_FILTERGRAPHLIST_LIST_GRAPH, DLSZ_SIZE_X | DLSZ_SIZE_Y) |
---|
61 | DLGRESIZE_CONTROL(IDC_FILTERGRAPHLIST_LIST_REFRESH, DLSZ_MOVE_Y) |
---|
62 | DLGRESIZE_CONTROL(IDC_FILTERGRAPHLIST_LIST_CHECK, DLSZ_MOVE_Y) |
---|
63 | DLGRESIZE_CONTROL(IDC_FILTERGRAPHLIST_LIST_COPYTOCLIPBOARD, DLSZ_MOVE_Y) |
---|
64 | DLGRESIZE_CONTROL(IDC_FILTERGRAPHLIST_LIST_PROPERTIES, DLSZ_MOVE_Y) |
---|
65 | END_DLGRESIZE_MAP() |
---|
66 | |
---|
67 | public: |
---|
68 | |
---|
69 | //////////////////////////////////////////////////// |
---|
70 | // CItem |
---|
71 | |
---|
72 | class CItem |
---|
73 | { |
---|
74 | public: |
---|
75 | CComPtr<IMoniker> m_pMoniker; |
---|
76 | CStringW m_sDisplayName; |
---|
77 | DWORD64 m_nInstance; |
---|
78 | DWORD m_nProcessIdentifier; |
---|
79 | CPath m_sProcessImagePath; |
---|
80 | CString m_sTime; |
---|
81 | CComPtr<IUnknown> m_pFilterGraphUnknown; |
---|
82 | CComPtr<IFilterGraph> m_pFilterGraph; |
---|
83 | SIZE_T m_nFilterCount; |
---|
84 | CString m_sState; |
---|
85 | DOUBLE m_fDuration; |
---|
86 | DOUBLE m_fPosition; |
---|
87 | |
---|
88 | public: |
---|
89 | // CItem |
---|
90 | CItem() throw() : |
---|
91 | m_nFilterCount(0), |
---|
92 | m_fDuration(0), |
---|
93 | m_fPosition(0) |
---|
94 | { |
---|
95 | } |
---|
96 | CComPtr<IFilterGraph>& FilterGraphNeeded(IRunningObjectTable* pRunningObjectTable) |
---|
97 | { |
---|
98 | _A(pRunningObjectTable); |
---|
99 | if(!m_pFilterGraph && pRunningObjectTable && m_pMoniker) |
---|
100 | { |
---|
101 | _A(m_pMoniker); |
---|
102 | CComPtr<IBindCtx> pBindCtx; |
---|
103 | __C(CreateBindCtx(0, &pBindCtx)); |
---|
104 | CComPtr<IUnknown> pUnknown; |
---|
105 | __C(pRunningObjectTable->GetObject(m_pMoniker, &pUnknown)); |
---|
106 | const CComQIPtr<IFilterGraph> pFilterGraph = pUnknown; |
---|
107 | __D(pFilterGraph, E_NOINTERFACE); |
---|
108 | m_pFilterGraphUnknown = pUnknown; |
---|
109 | m_pFilterGraph = pFilterGraph; |
---|
110 | m_nFilterCount = 0; |
---|
111 | m_sState.Empty(); |
---|
112 | } |
---|
113 | return m_pFilterGraph; |
---|
114 | } |
---|
115 | BOOL Check() |
---|
116 | { |
---|
117 | _ATLTRY |
---|
118 | { |
---|
119 | _FilterGraphHelper::CFilterArray FilterArray; |
---|
120 | _FilterGraphHelper::GetGraphFilters(m_pFilterGraph, FilterArray); |
---|
121 | m_nFilterCount = FilterArray.GetCount(); |
---|
122 | #pragma region IMediaControl |
---|
123 | _ATLTRY |
---|
124 | { |
---|
125 | m_sState.Empty(); |
---|
126 | const CComQIPtr<IMediaControl> pMediaControl = m_pFilterGraph; |
---|
127 | if(pMediaControl) |
---|
128 | { |
---|
129 | OAFilterState State; |
---|
130 | if(SUCCEEDED(pMediaControl->GetState(0, &State))) |
---|
131 | { |
---|
132 | static LPCTSTR g_ppszStates[] = { _T("Stopped"), _T("Paused"), _T("Running") }; |
---|
133 | if((SIZE_T) State < DIM(g_ppszStates)) |
---|
134 | m_sState = g_ppszStates[(SIZE_T) State]; |
---|
135 | } |
---|
136 | } |
---|
137 | } |
---|
138 | _ATLCATCHALL() |
---|
139 | { |
---|
140 | _Z_EXCEPTION(); |
---|
141 | } |
---|
142 | #pragma endregion |
---|
143 | #pragma region IMediaPosition |
---|
144 | _ATLTRY |
---|
145 | { |
---|
146 | m_fDuration = 0; |
---|
147 | m_fPosition = 0; |
---|
148 | const CComQIPtr<IMediaPosition> pMediaPosition = m_pFilterGraph; |
---|
149 | if(pMediaPosition) |
---|
150 | if(SUCCEEDED(pMediaPosition->get_Duration(&m_fDuration))) |
---|
151 | pMediaPosition->get_CurrentPosition(&m_fPosition); |
---|
152 | } |
---|
153 | _ATLCATCHALL() |
---|
154 | { |
---|
155 | _Z_EXCEPTION(); |
---|
156 | } |
---|
157 | #pragma endregion |
---|
158 | // SUGG: Source and Sink Paths |
---|
159 | } |
---|
160 | _ATLCATCHALL() |
---|
161 | { |
---|
162 | _Z_EXCEPTION(); |
---|
163 | return FALSE; |
---|
164 | } |
---|
165 | return TRUE; |
---|
166 | } |
---|
167 | }; |
---|
168 | |
---|
169 | private: |
---|
170 | CFilterGraphListPropertySheet& m_PropertySheet; |
---|
171 | CRoListViewT<CItem, CRoListControlDataTraitsT> m_GraphListView; |
---|
172 | CButton m_RefreshButton; |
---|
173 | CButton m_CheckButton; |
---|
174 | CButton m_CopyToClipboardButton; |
---|
175 | CButton m_PropertiesButton; |
---|
176 | CComPtr<IRunningObjectTable> m_pRunningObjectTable; |
---|
177 | |
---|
178 | public: |
---|
179 | // CListPropertyPage |
---|
180 | CListPropertyPage(CFilterGraphListPropertySheet* pPropertySheet) throw() : |
---|
181 | m_PropertySheet(*pPropertySheet) |
---|
182 | { |
---|
183 | } |
---|
184 | VOID UpdateControls() |
---|
185 | { |
---|
186 | const UINT nSelectedCount = m_GraphListView.GetSelectedCount(); |
---|
187 | m_CopyToClipboardButton.EnableWindow(nSelectedCount > 0); |
---|
188 | m_PropertiesButton.EnableWindow(nSelectedCount == 1); |
---|
189 | } |
---|
190 | INT SortGraphListViewItems(LPARAM nItemParameter1, LPARAM nItemParameter2) |
---|
191 | { |
---|
192 | const CItem& Item1 = m_GraphListView.DataFromParameter(nItemParameter1); |
---|
193 | const CItem& Item2 = m_GraphListView.DataFromParameter(nItemParameter2); |
---|
194 | const INT nTime = _tcscmp(Item1.m_sTime, Item2.m_sTime); |
---|
195 | if(nTime) |
---|
196 | return -nTime; |
---|
197 | const INT nProcess = (INT) (Item1.m_nProcessIdentifier, Item2.m_nProcessIdentifier); |
---|
198 | if(nProcess) |
---|
199 | return -nProcess; |
---|
200 | return wcscmp(Item1.m_sDisplayName, Item2.m_sDisplayName); |
---|
201 | } |
---|
202 | static int CALLBACK SortGraphListViewItems(LPARAM nItemParameter1, LPARAM nItemParameter2, LPARAM nParameter) |
---|
203 | { |
---|
204 | return ((CListPropertyPage*) nParameter)->SortGraphListViewItems(nItemParameter1, nItemParameter2); |
---|
205 | } |
---|
206 | VOID Refresh() |
---|
207 | { |
---|
208 | CRoMapT<CStringW, CItem> ItemMap; |
---|
209 | #pragma region Enumerate |
---|
210 | _ATLTRY |
---|
211 | { |
---|
212 | if(!m_pRunningObjectTable) |
---|
213 | __C(GetRunningObjectTable(0, &m_pRunningObjectTable)); |
---|
214 | CComPtr<IEnumMoniker> pEnumMoniker; |
---|
215 | __C(m_pRunningObjectTable->EnumRunning(&pEnumMoniker)); |
---|
216 | CComPtr<IMalloc> pMalloc; |
---|
217 | __C(CoGetMalloc(1, &pMalloc)); |
---|
218 | CComPtr<IMoniker> pMoniker; |
---|
219 | while(pEnumMoniker->Next(1, &pMoniker, NULL) == S_OK) |
---|
220 | { |
---|
221 | _ATLTRY |
---|
222 | { |
---|
223 | CComPtr<IBindCtx> pBindCtx; |
---|
224 | __C(CreateBindCtx(0, &pBindCtx)); |
---|
225 | LPOLESTR pszDisplayName = NULL; |
---|
226 | __C(pMoniker->GetDisplayName(pBindCtx, NULL, &pszDisplayName)); |
---|
227 | const CStringW sDisplayName = pszDisplayName; |
---|
228 | _Z4(atlTraceGeneral, 4, _T("sDisplayName %ls\n"), sDisplayName); |
---|
229 | pMalloc->Free(pszDisplayName); |
---|
230 | static CRoStaticReW g_Expression(L"^\\!FilterGraph {[0-9A-F]+} pid {[0-9A-F]+}(; process\\: {.+?}, time\\: {[0-9]+\\-[0-9]+\\-[0-9]+})?", FALSE); |
---|
231 | CRoReMatchContext MatchContext; |
---|
232 | if(g_Expression.Match(sDisplayName, &MatchContext)) |
---|
233 | { |
---|
234 | CItem Item; |
---|
235 | Item.m_pMoniker = pMoniker; |
---|
236 | Item.m_sDisplayName = sDisplayName; |
---|
237 | _W(StrToInt64ExW(CStringW(L"0x") + MatchContext.GetMatchString(0), STIF_SUPPORT_HEX, &reinterpret_cast<LONGLONG&>(Item.m_nInstance))); |
---|
238 | _W(StrToIntExW(CStringW(L"0x") + MatchContext.GetMatchString(1), STIF_SUPPORT_HEX, &reinterpret_cast<INT&>(Item.m_nProcessIdentifier))); |
---|
239 | Item.m_sTime = CString(MatchContext.GetMatchString(3)); |
---|
240 | Item.m_sTime.Replace(_T("-"), _T(":")); |
---|
241 | _W(ItemMap.SetAt(sDisplayName, Item) >= 0); |
---|
242 | } |
---|
243 | } |
---|
244 | _ATLCATCHALL() |
---|
245 | { |
---|
246 | _Z_EXCEPTION(); |
---|
247 | } |
---|
248 | pMoniker.Release(); |
---|
249 | } |
---|
250 | } |
---|
251 | _ATLCATCHALL() |
---|
252 | { |
---|
253 | _Z_EXCEPTION(); |
---|
254 | } |
---|
255 | #pragma endregion |
---|
256 | CWindowRedraw GraphListViewRedraw(m_GraphListView); |
---|
257 | BOOL bSortNeeded = FALSE; |
---|
258 | #pragma region Remove |
---|
259 | for(INT nItem = m_GraphListView.GetItemCount() - 1; nItem >= 0; nItem--) |
---|
260 | { |
---|
261 | const POSITION Position = ItemMap.Lookup(m_GraphListView.GetItemData(nItem).m_sDisplayName); |
---|
262 | if(Position) |
---|
263 | ItemMap.RemoveAtPos(Position); |
---|
264 | else |
---|
265 | _W(m_GraphListView.DeleteItem(nItem)); |
---|
266 | } |
---|
267 | #pragma endregion |
---|
268 | #pragma region Add |
---|
269 | INT nItemIndex = m_GraphListView.GetItemCount(); |
---|
270 | for(POSITION Position = ItemMap.GetStartPosition(); Position; ItemMap.GetNext(Position)) |
---|
271 | { |
---|
272 | CItem& Item = ItemMap.GetValueAt(Position); |
---|
273 | _ATLTRY |
---|
274 | { |
---|
275 | CHandle Process; |
---|
276 | //Process.Attach(OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, Item.m_nProcessIdentifier)); |
---|
277 | Process.Attach(OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, Item.m_nProcessIdentifier)); |
---|
278 | __E(Process); |
---|
279 | TCHAR pszPath[MAX_PATH] = { 0 }; |
---|
280 | //_W(GetProcessImageFileName(Process, pszPath, DIM(pszPath))); |
---|
281 | _W(GetModuleFileNameEx(Process, NULL, pszPath, DIM(pszPath))); |
---|
282 | Item.m_sProcessImagePath = pszPath; |
---|
283 | } |
---|
284 | _ATLCATCHALL() |
---|
285 | { |
---|
286 | _Z_EXCEPTION(); |
---|
287 | } |
---|
288 | const INT nItem = m_GraphListView.InsertItem(nItemIndex++, Item); |
---|
289 | _A(nItem >= 0); |
---|
290 | bSortNeeded = TRUE; |
---|
291 | } |
---|
292 | #pragma endregion |
---|
293 | if(bSortNeeded) |
---|
294 | m_GraphListView.SortItems(&CListPropertyPage::SortGraphListViewItems, (LPARAM) this); |
---|
295 | } |
---|
296 | CString GetText() |
---|
297 | { |
---|
298 | CRoArrayT<CString> GraphArray; |
---|
299 | for(INT nItem = m_GraphListView.GetNextItem(-1, LVNI_SELECTED); nItem >= 0; nItem = m_GraphListView.GetNextItem(nItem, LVNI_SELECTED)) |
---|
300 | { |
---|
301 | CItem& Item = m_GraphListView.GetItemData(nItem); |
---|
302 | _ATLTRY |
---|
303 | { |
---|
304 | if(Item.FilterGraphNeeded(m_pRunningObjectTable)) |
---|
305 | { |
---|
306 | Item.Check(); |
---|
307 | m_GraphListView.RedrawItems(nItem, nItem); |
---|
308 | CFilterGraphHelper::CProcessData ProcessData; |
---|
309 | ProcessData.m_sDisplayName = Item.m_sDisplayName; |
---|
310 | ProcessData.m_nIdentifier = Item.m_nProcessIdentifier; |
---|
311 | ProcessData.m_sImagePath = Item.m_sProcessImagePath; |
---|
312 | GraphArray.Add(CFilterGraphHelper::GetText(Item.m_pFilterGraph, &ProcessData)); |
---|
313 | } |
---|
314 | } |
---|
315 | _ATLCATCHALL() |
---|
316 | { |
---|
317 | _Z_EXCEPTION(); |
---|
318 | } |
---|
319 | } |
---|
320 | return _StringHelper::Join(GraphArray, _T("\r\n") _T("---") _T("\r\n") _T("\r\n")); |
---|
321 | } |
---|
322 | |
---|
323 | // Window Message Handler |
---|
324 | LRESULT OnInitDialog(HWND, LPARAM) |
---|
325 | { |
---|
326 | _ATLTRY |
---|
327 | { |
---|
328 | CWaitCursor WaitCursor; |
---|
329 | m_GraphListView.Initialize(GetDlgItem(IDC_FILTERGRAPHLIST_LIST_GRAPH)); |
---|
330 | CToolTipCtrl ToolTip = m_GraphListView.GetToolTips(); |
---|
331 | ToolTip.SetDelayTime(TTDT_AUTOPOP, 30 * 1000); // 30 seconds |
---|
332 | ToolTip.SetMaxTipWidth(max(GetSystemMetrics(SM_CXSCREEN) * 5 / 8, 600)); |
---|
333 | m_RefreshButton = GetDlgItem(IDC_FILTERGRAPHLIST_LIST_REFRESH); |
---|
334 | m_CheckButton = GetDlgItem(IDC_FILTERGRAPHLIST_LIST_CHECK); |
---|
335 | m_CopyToClipboardButton = GetDlgItem(IDC_FILTERGRAPHLIST_LIST_COPYTOCLIPBOARD); |
---|
336 | m_PropertiesButton = GetDlgItem(IDC_FILTERGRAPHLIST_LIST_PROPERTIES); |
---|
337 | DlgResize_Init(FALSE, FALSE); |
---|
338 | Refresh(); |
---|
339 | #if _DEVELOPMENT |
---|
340 | m_GraphListView.SetItemState(0, LVIS_FOCUSED | LVIS_SELECTED, LVIS_FOCUSED | LVIS_SELECTED); |
---|
341 | #endif // _DEVELOPMENT |
---|
342 | UpdateControls(); |
---|
343 | #pragma region Default Property Sheet Size |
---|
344 | CRect Position; |
---|
345 | _W(m_PropertySheet.GetWindowRect(Position)); |
---|
346 | Position.InflateRect(6 * Position.Width() / 8, 1 * Position.Height() / 8); |
---|
347 | CSize ScreenExtent(GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); |
---|
348 | ScreenExtent.cx -= ScreenExtent.cx / 8; |
---|
349 | ScreenExtent.cy -= ScreenExtent.cy / 8; |
---|
350 | if(Position.Width() > ScreenExtent.cx) |
---|
351 | Position.right = Position.left + ScreenExtent.cx; |
---|
352 | if(Position.Height() > ScreenExtent.cy) |
---|
353 | Position.bottom = Position.top + ScreenExtent.cy; |
---|
354 | _W(m_PropertySheet.MoveWindow(Position)); |
---|
355 | _W(m_PropertySheet.CenterWindow()); |
---|
356 | #pragma endregion |
---|
357 | CancelToClose(); |
---|
358 | } |
---|
359 | _ATLCATCHALL() |
---|
360 | { |
---|
361 | for(CWindow Window = GetWindow(GW_CHILD); Window.IsWindow(); Window = Window.GetWindow(GW_HWNDNEXT)) |
---|
362 | Window.EnableWindow(FALSE); |
---|
363 | _ATLRETHROW; |
---|
364 | } |
---|
365 | return TRUE; |
---|
366 | } |
---|
367 | LRESULT OnDestroy() |
---|
368 | { |
---|
369 | return 0; |
---|
370 | } |
---|
371 | LRESULT OnGraphListViewGetDispInfo(NMLVDISPINFO* pHeader) |
---|
372 | { |
---|
373 | const CItem& Item = m_GraphListView.DataFromParameter(pHeader->item.lParam); |
---|
374 | if(pHeader->item.mask & LVIF_TEXT) |
---|
375 | { |
---|
376 | CString& sTextBuffer = m_GraphListView.GetTextBufferString(TRUE); |
---|
377 | switch(pHeader->item.iSubItem) |
---|
378 | { |
---|
379 | case 1: // Process Name |
---|
380 | sTextBuffer = PathFindFileName(Item.m_sProcessImagePath); |
---|
381 | break; |
---|
382 | case 2: // Creation Time |
---|
383 | sTextBuffer = Item.m_sTime; |
---|
384 | break; |
---|
385 | case 3: // Filter Count |
---|
386 | if(Item.m_pFilterGraph) |
---|
387 | sTextBuffer = AtlFormatString(_T("%d"), Item.m_nFilterCount); |
---|
388 | break; |
---|
389 | case 4: // State |
---|
390 | if(Item.m_pFilterGraph) |
---|
391 | sTextBuffer = Item.m_sState; |
---|
392 | break; |
---|
393 | case 5: // Process Image Directory |
---|
394 | sTextBuffer = (LPCTSTR) GetPathDirectory(Item.m_sProcessImagePath); |
---|
395 | break; |
---|
396 | default: // Process, Instance |
---|
397 | sTextBuffer = AtlFormatString(_T("%d - 0x%p"), Item.m_nProcessIdentifier, Item.m_nInstance); |
---|
398 | } |
---|
399 | pHeader->item.pszText = m_GraphListView.GetTextBuffer(); |
---|
400 | } |
---|
401 | return 0; |
---|
402 | } |
---|
403 | LRESULT OnGraphListViewGetInfoTip(NMLVGETINFOTIP* pHeader) |
---|
404 | { |
---|
405 | const CItem& Item = m_GraphListView.GetItemData(pHeader->iItem); |
---|
406 | CString& sTextBuffer = m_GraphListView.GetTextBufferString(TRUE); |
---|
407 | sTextBuffer.AppendFormat(_T("Process: %d (0x%X) %s\r\n"), Item.m_nProcessIdentifier, Item.m_nProcessIdentifier, CString(FindFileName(Item.m_sProcessImagePath))); |
---|
408 | if(!Item.m_sTime.IsEmpty()) |
---|
409 | sTextBuffer.AppendFormat(_T("CreationTime: %s\r\n"), Item.m_sTime); |
---|
410 | if(Item.m_pFilterGraph) |
---|
411 | { |
---|
412 | sTextBuffer.AppendFormat(_T("Filter Count: %d\r\n"), Item.m_nFilterCount); |
---|
413 | if(!Item.m_sState.IsEmpty()) |
---|
414 | sTextBuffer.AppendFormat(_T("State: %s\r\n"), Item.m_sState); |
---|
415 | if(Item.m_fDuration > 0) |
---|
416 | { |
---|
417 | sTextBuffer.AppendFormat(_T("Duration: %s seconds\r\n"), _StringHelper::FormatNumber(Item.m_fDuration, 3)); |
---|
418 | sTextBuffer.AppendFormat(_T("Position: %s seconds\r\n"), _StringHelper::FormatNumber(Item.m_fPosition, 3)); |
---|
419 | } |
---|
420 | } |
---|
421 | sTextBuffer.AppendFormat(_T("Display Name: %ls\r\n"), Item.m_sDisplayName); |
---|
422 | sTextBuffer.AppendFormat(_T("Instance: 0x%p\r\n"), Item.m_nInstance); |
---|
423 | const CString sDirectory = (LPCTSTR) GetPathDirectory(Item.m_sProcessImagePath); |
---|
424 | if(!sDirectory.IsEmpty()) |
---|
425 | sTextBuffer.AppendFormat(_T("Process Directory: %s\r\n"), sDirectory); |
---|
426 | sTextBuffer.TrimRight(_T("\t\n\r .")); |
---|
427 | #pragma region Clipboard Copy |
---|
428 | if(GetKeyState(VK_CONTROL) < 0 && GetKeyState(VK_SHIFT) < 0) |
---|
429 | _ATLTRY |
---|
430 | { |
---|
431 | SetClipboardText(m_hWnd, sTextBuffer); |
---|
432 | MessageBeep(MB_OK); |
---|
433 | } |
---|
434 | _ATLCATCHALL() |
---|
435 | { |
---|
436 | _Z_EXCEPTION(); |
---|
437 | MessageBeep(MB_ICONERROR); |
---|
438 | } |
---|
439 | #pragma endregion |
---|
440 | _tcsncpy_s(pHeader->pszText, pHeader->cchTextMax, m_GraphListView.GetTextBuffer(), _TRUNCATE); |
---|
441 | return 0; |
---|
442 | } |
---|
443 | LRESULT OnGraphListViewItemChanged(NMLISTVIEW* pHeader) |
---|
444 | { |
---|
445 | UpdateControls(); |
---|
446 | return 0; |
---|
447 | } |
---|
448 | LRESULT OnGraphListViewDblClk(NMITEMACTIVATE* pHeader) |
---|
449 | { |
---|
450 | //m_CheckButton.Click(); |
---|
451 | m_PropertiesButton.Click(); |
---|
452 | return 0; |
---|
453 | } |
---|
454 | LRESULT OnRefresh(UINT, INT, HWND) |
---|
455 | { |
---|
456 | CWaitCursor WaitCursor; |
---|
457 | Refresh(); |
---|
458 | UpdateControls(); |
---|
459 | return 0; |
---|
460 | } |
---|
461 | LRESULT OnCheck(UINT, INT, HWND) |
---|
462 | { |
---|
463 | CWaitCursor WaitCursor; |
---|
464 | for(INT nItem = m_GraphListView.GetNextItem(-1, LVNI_SELECTED); nItem >= 0; nItem = m_GraphListView.GetNextItem(nItem, LVNI_SELECTED)) |
---|
465 | { |
---|
466 | CItem& Item = m_GraphListView.GetItemData(nItem); |
---|
467 | if(Item.FilterGraphNeeded(m_pRunningObjectTable)) |
---|
468 | if(Item.Check()) |
---|
469 | m_GraphListView.RedrawItems(nItem, nItem); |
---|
470 | } |
---|
471 | return 0; |
---|
472 | } |
---|
473 | LRESULT OnCopyToClipboard(UINT, INT, HWND) |
---|
474 | { |
---|
475 | CWaitCursor WaitCursor; |
---|
476 | const CString sText = GetText(); |
---|
477 | if(sText.IsEmpty()) |
---|
478 | return 0; |
---|
479 | SetClipboardText(m_hWnd, sText); |
---|
480 | MessageBeep(MB_OK); |
---|
481 | return 0; |
---|
482 | } |
---|
483 | LRESULT OnProperties(UINT, INT, HWND) |
---|
484 | { |
---|
485 | const INT nItem = m_GraphListView.GetNextItem(-1, LVNI_SELECTED); |
---|
486 | if(nItem < 0) |
---|
487 | return 0; |
---|
488 | CItem& Item = m_GraphListView.GetItemData(nItem); |
---|
489 | if(!Item.FilterGraphNeeded(m_pRunningObjectTable)) |
---|
490 | return 0; |
---|
491 | Item.Check(); |
---|
492 | CLocalObjectPtr<CFilterGraphHelper> pFilterGraphHelper; |
---|
493 | pFilterGraphHelper->SetFilterGraph(Item.m_pFilterGraph); |
---|
494 | _V(pFilterGraphHelper->DoPropertyFrameModal((LONG) (LONG_PTR) m_hWnd)); |
---|
495 | return 0; |
---|
496 | } |
---|
497 | }; |
---|
498 | |
---|
499 | private: |
---|
500 | CListPropertyPage m_ListPropertyPage; |
---|
501 | |
---|
502 | public: |
---|
503 | // CFilterGraphListPropertySheet |
---|
504 | CFilterGraphListPropertySheet() : |
---|
505 | CSizablePropertySheetT<CFilterGraphListPropertySheet>(IDS_FILTERGRAPHLIST_LIST_PROPERTYSHEETCAPTION), |
---|
506 | m_ListPropertyPage(this) |
---|
507 | { |
---|
508 | AddPage(m_ListPropertyPage); |
---|
509 | } |
---|
510 | BOOL SetInitialPosition() |
---|
511 | { |
---|
512 | if(!__super::SetInitialPosition()) |
---|
513 | return FALSE; |
---|
514 | SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)), TRUE); |
---|
515 | SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)), FALSE); |
---|
516 | #pragma region Bitness Indication |
---|
517 | CString sCaption; |
---|
518 | _W(GetWindowText(sCaption)); |
---|
519 | #if defined(_WIN64) |
---|
520 | sCaption.Append(_T(" (64-bit)")); |
---|
521 | #else |
---|
522 | if(SafeIsWow64Process()) |
---|
523 | sCaption.Append(_T(" (32-bit)")); |
---|
524 | #endif // defined(_WIN64) |
---|
525 | _W(SetWindowText(sCaption)); |
---|
526 | #pragma endregion |
---|
527 | #pragma region System Menu |
---|
528 | CMenuHandle Menu = GetSystemMenu(FALSE); |
---|
529 | _W(Menu.AppendMenu(MF_SEPARATOR)); |
---|
530 | _W(Menu.AppendMenu(MF_STRING, ID_APP_ABOUT, _T("&About..."))); |
---|
531 | #pragma endregion |
---|
532 | return TRUE; |
---|
533 | } |
---|
534 | |
---|
535 | // Window message handelrs |
---|
536 | LRESULT OnSysCommand(UINT nCommand, CPoint) |
---|
537 | { |
---|
538 | switch(nCommand) |
---|
539 | { |
---|
540 | case ID_APP_ABOUT: |
---|
541 | { |
---|
542 | CAboutDialog Dialog; |
---|
543 | Dialog.DoModal(m_hWnd); |
---|
544 | } |
---|
545 | break; |
---|
546 | default: |
---|
547 | SetMsgHandled(FALSE); |
---|
548 | } |
---|
549 | return 0; |
---|
550 | } |
---|
551 | }; |
---|
552 | |
---|