Changeset 792 for trunk/Utilities/EnumerateAudioDevices/MainDialog.h
- Timestamp:
- Dec 12, 2017, 5:26:03 AM (4 years ago)
- Location:
- trunk/Utilities/EnumerateAudioDevices
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Utilities/EnumerateAudioDevices
- Property svn:ignore
-
old new 4 4 *.user 5 5 ipch 6 .vs
-
- Property svn:ignore
-
trunk/Utilities/EnumerateAudioDevices/MainDialog.h
r619 r792 6 6 7 7 #include "rodshow.h" 8 #include "romf.h" 8 9 #include <mmdeviceapi.h> 9 10 #include <mmreg.h> … … 43 44 44 45 private: 46 CDpiAwareness m_DpiAwareness; 47 CFont m_TextFont; 45 48 CRoEdit m_TextEdit; 49 CFont m_ButtonFont; 50 CButton m_CloseButton; 46 51 47 52 public: … … 64 69 return FALSE; 65 70 } 71 static VOID FormatWaveFormatEx(const WAVEFORMATEX* pWaveFormatEx, SIZE_T nWaveFormatExSize, CRoArrayT<CString>& Array) 72 { 73 _A(nWaveFormatExSize >= sizeof (WAVEFORMATEX)); 74 Array.Add(AtlFormatString(_T("wFormatTag 0x%02X"), pWaveFormatEx->wFormatTag)); 75 Array.Add(AtlFormatString(_T("nChannels %d"), pWaveFormatEx->nChannels)); 76 Array.Add(AtlFormatString(_T("nSamplesPerSec %d"), pWaveFormatEx->nSamplesPerSec)); 77 Array.Add(AtlFormatString(_T("nAvgBytesPerSec %d"), pWaveFormatEx->nAvgBytesPerSec)); 78 Array.Add(AtlFormatString(_T("nBlockAlign %d"), pWaveFormatEx->nBlockAlign)); 79 Array.Add(AtlFormatString(_T("wBitsPerSample %d"), pWaveFormatEx->wBitsPerSample)); 80 Array.Add(AtlFormatString(_T("cbSize %d"), pWaveFormatEx->cbSize)); 81 if(nWaveFormatExSize < sizeof (WAVEFORMATEXTENSIBLE) || pWaveFormatEx->wFormatTag != WAVE_FORMAT_EXTENSIBLE) 82 return; 83 const WAVEFORMATEXTENSIBLE* pWaveFormatExtensible = (const WAVEFORMATEXTENSIBLE*) pWaveFormatEx; 84 Array.Add(AtlFormatString(_T("wValidBitsPerSample %d"), pWaveFormatExtensible->Samples.wValidBitsPerSample)); 85 Array.Add(AtlFormatString(_T("dwChannelMask 0x%02X"), pWaveFormatExtensible->dwChannelMask)); 86 Array.Add(AtlFormatString(_T("SubFormat %ls"), _PersistHelper::StringFromIdentifier(pWaveFormatExtensible->SubFormat))); 87 } 66 88 67 89 // Window Message Handler 68 90 LRESULT OnInitDialog(HWND, LPARAM) 69 91 { 70 SetIcon(AtlLoadIcon(IDI_MODULE), TRUE); 92 DlgResize_Init(); 93 SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON)), TRUE); 71 94 SetIcon(AtlLoadIconImage(IDI_MODULE, LR_DEFAULTCOLOR, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON)), FALSE); 72 95 CMenuHandle Menu = GetSystemMenu(FALSE); 73 96 _W(Menu.AppendMenu(MF_SEPARATOR)); 74 97 _W(Menu.AppendMenu(MF_STRING, ID_APP_ABOUT, _T("&About..."))); 75 DlgResize_Init();76 98 CAboutDialog::UpdateCaption(*this); 99 m_TextEdit = GetDlgItem(IDC_TEXT); 100 m_TextFont = m_DpiAwareness.ScaleFont(m_TextEdit.GetFont(), 11); 101 m_TextEdit.SetFont(m_TextFont); 102 m_CloseButton = GetDlgItem(IDOK); 103 m_ButtonFont = m_DpiAwareness.ScaleFont(GetFont(), 9); 104 m_CloseButton.SetFont(m_ButtonFont); 105 #pragma region Position 106 { 107 CRect Position; 108 _W(GetWindowRect(Position)); 109 const HMONITOR hMonitor = MonitorFromPoint(Position.CenterPoint(), MONITOR_DEFAULTTONEAREST); 110 MONITORINFO Information = { sizeof Information }; 111 if(GetMonitorInfo(hMonitor, &Information)) 112 { 113 CSize DefaultExtent = reinterpret_cast<const CRect&>(Information.rcWork).Size(); 114 DefaultExtent.cx = DefaultExtent.cx * 6 / 8; 115 DefaultExtent.cy = DefaultExtent.cy * 6 / 8; 116 BOOL bUpdate = FALSE; 117 CSize ExcessExtent(DefaultExtent.cx - Position.Width(), DefaultExtent.cy - Position.Height()); 118 if(ExcessExtent.cx > 0) 119 { 120 Position.left -= ExcessExtent.cx / 2; 121 Position.right = Position.left + DefaultExtent.cx; 122 bUpdate = TRUE; 123 } 124 if(ExcessExtent.cy > 0) 125 { 126 Position.top -= ExcessExtent.cy / 2; 127 Position.bottom = Position.top + DefaultExtent.cy; 128 bUpdate = TRUE; 129 } 130 if(bUpdate) 131 _W(MoveWindow(Position, FALSE)); 132 } 133 } 77 134 _W(CenterWindow()); 135 #pragma endregion 78 136 _ATLTRY 79 137 { … … 1301 1359 if(IsWaveFormatExKey(Key) && Value.vt == VT_BLOB && Value.blob.cbSize >= sizeof (WAVEFORMATEX)) 1302 1360 { 1303 const WAVEFORMATEX* pWaveFormatEx = (const WAVEFORMATEX*) Value.blob.pBlobData;1304 1361 CRoArrayT<CString> Array; 1305 Array.Add(AtlFormatString(_T("wFormatTag 0x%02X"), pWaveFormatEx->wFormatTag)); 1306 Array.Add(AtlFormatString(_T("nChannels %d"), pWaveFormatEx->nChannels)); 1307 Array.Add(AtlFormatString(_T("nSamplesPerSec %d"), pWaveFormatEx->nSamplesPerSec)); 1308 Array.Add(AtlFormatString(_T("nAvgBytesPerSec %d"), pWaveFormatEx->nAvgBytesPerSec)); 1309 Array.Add(AtlFormatString(_T("nBlockAlign %d"), pWaveFormatEx->nBlockAlign)); 1310 Array.Add(AtlFormatString(_T("wBitsPerSample %d"), pWaveFormatEx->wBitsPerSample)); 1311 Array.Add(AtlFormatString(_T("cbSize %d"), pWaveFormatEx->cbSize)); 1312 if(Value.blob.cbSize >= sizeof (WAVEFORMATEXTENSIBLE) && pWaveFormatEx->wFormatTag == WAVE_FORMAT_EXTENSIBLE) 1313 { 1314 const WAVEFORMATEXTENSIBLE* pWaveFormatExtensible = (const WAVEFORMATEXTENSIBLE*) pWaveFormatEx; 1315 Array.Add(AtlFormatString(_T("wValidBitsPerSample %d"), pWaveFormatExtensible->Samples.wValidBitsPerSample)); 1316 Array.Add(AtlFormatString(_T("dwChannelMask 0x%02X"), pWaveFormatExtensible->dwChannelMask)); 1317 Array.Add(AtlFormatString(_T("SubFormat %ls"), _PersistHelper::StringFromIdentifier(pWaveFormatExtensible->SubFormat))); 1318 } 1362 FormatWaveFormatEx((const WAVEFORMATEX*) Value.blob.pBlobData, Value.blob.cbSize, Array); 1319 1363 sDetail = _StringHelper::Join(Array, _T("; ")); 1320 1364 } … … 1411 1455 CComPtr<IUnknown> pUnknown; 1412 1456 const HRESULT nActivateResult = pMmDevice->Activate(Item.Value, CLSCTX_ALL, NULL, (VOID**) &pUnknown); 1413 sText.AppendFormat(_T("\t") _T("\t") _T("%hs") _T("\t") _T("0x%08X") _T("\r\n"), Item.pszName, nActivateResult); 1457 CRoArrayT<CString> ArrayA; 1458 ArrayA.Add(CString(Item.pszName)); 1459 ArrayA.Add(MF::FormatResult(nActivateResult)); 1460 sText.AppendFormat(_T("\t") _T("\t") _T("%s") _T("\r\n"), _StringHelper::Join(ArrayA, _T("\t"))); 1461 if(FAILED(nActivateResult)) 1462 continue; 1463 if(Item.Value == __uuidof(IAudioClient)) 1464 { 1465 const CComPtr<IAudioClient>& pAudioClient = reinterpret_cast<const CComPtr<IAudioClient>&>(pUnknown); 1466 WAVEFORMATEX* pWaveFormatEx; 1467 if(SUCCEEDED(pAudioClient->GetMixFormat(&pWaveFormatEx))) 1468 { 1469 ArrayA.RemoveAll(); 1470 ArrayA.Add(_T("Mix Format")); 1471 CRoArrayT<CString> ArrayB; 1472 FormatWaveFormatEx(pWaveFormatEx, sizeof *pWaveFormatEx + pWaveFormatEx->cbSize, ArrayB); 1473 ArrayA.Add(_StringHelper::Join(ArrayB, _T("; "))); 1474 sText.AppendFormat(_T("\t") _T("\t") _T("\t") _T("%s") _T("\r\n"), _StringHelper::Join(ArrayA, _T("\t"))); 1475 } 1476 // SUGG: Try explicitly well known formats like mono, stereo, 5.1, 7.1 at 48000 Hz, 16-bit, 24-bit and 32-bit IEEE float 1477 } 1414 1478 } 1415 1479 #pragma endregion … … 1427 1491 } 1428 1492 #pragma endregion 1429 m_TextEdit = GetDlgItem(IDC_TEXT);1430 1493 m_TextEdit.SetValue(sText); 1431 1494 }
Note: See TracChangeset
for help on using the changeset viewer.