1 // SupportedFormatDlg.cpp: 实现文件 2 // 3 4 #include "stdafx.h" 5 #include "MusicPlayer2.h" 6 #include "SupportedFormatDlg.h" 7 #include "AudioCommon.h" 8 9 10 // CSupportedFormatDlg 对话框 11 12 IMPLEMENT_DYNAMIC(CSupportedFormatDlg, CBaseDialog) 13 14 CSupportedFormatDlg::CSupportedFormatDlg(CWnd* pParent /*=nullptr*/) 15 : CBaseDialog(IDD_SUPPORT_FORMAT_DIALOG, pParent) 16 { 17 18 } 19 20 CSupportedFormatDlg::~CSupportedFormatDlg() 21 { 22 } 23 24 CString CSupportedFormatDlg::GetDialogName() const 25 { 26 return _T("SupportedFormatDlg"); 27 } 28 29 bool CSupportedFormatDlg::InitializeControls() 30 { 31 SetWindowTextW(theApp.m_str_table.LoadText(L"TITLE_SUPPORTED_FORMAT").c_str()); 32 // IDC_INFO_STATIC 33 // IDC_FORMAT_LIST 34 // IDOK 35 36 RepositionTextBasedControls({ 37 { CtrlTextInfo::R1, IDOK, CtrlTextInfo::W32 } 38 }); 39 return true; 40 } 41 42 void CSupportedFormatDlg::DoDataExchange(CDataExchange* pDX) 43 { 44 CBaseDialog::DoDataExchange(pDX); 45 DDX_Control(pDX, IDC_FORMAT_LIST, m_format_list); 46 } 47 48 49 BEGIN_MESSAGE_MAP(CSupportedFormatDlg, CBaseDialog) 50 ON_WM_GETMINMAXINFO() 51 END_MESSAGE_MAP() 52 53 54 // CSupportedFormatDlg 消息处理程序 55 56 57 BOOL CSupportedFormatDlg::OnInitDialog() 58 { 59 CBaseDialog::OnInitDialog(); 60 61 // TODO: 在此添加额外的初始化 62 63 SetIcon(IconMgr::IconType::IT_App, FALSE); // 设置小图标 64 if (theApp.m_play_setting_data.use_ffmpeg) 65 SetDlgItemTextW(IDC_INFO_STATIC, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_CORE_INFO_FFMPEG").c_str()); 66 else if (theApp.m_play_setting_data.use_mci) 67 SetDlgItemTextW(IDC_INFO_STATIC, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_CORE_INFO_MCI").c_str()); 68 else 69 SetDlgItemTextW(IDC_INFO_STATIC, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_CORE_INFO_BASS").c_str()); 70 71 //初始化列表 72 //m_format_list.SetColor(theApp.m_app_setting_data.theme_color); 73 CRect rect; 74 m_format_list.GetWindowRect(rect); 75 int width0, width1, width2; 76 m_format_list.SetExtendedStyle(m_format_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_LABELTIP); 77 78 bool is_bass = !theApp.m_play_setting_data.use_ffmpeg && !theApp.m_play_setting_data.use_mci; 79 if (is_bass) 80 { 81 width0 = theApp.DPI(100); 82 width1 = rect.Width() / 3; 83 width2 = rect.Width() - width1 - width0 - theApp.DPI(20) - 1; 84 85 m_format_list.InsertColumn(0, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_PLUGIN_FILE_NAME").c_str(), LVCFMT_LEFT, width0); 86 m_format_list.InsertColumn(1, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_PLUGIN_FORMAT_PROVIDED").c_str(), LVCFMT_LEFT, width1); 87 m_format_list.InsertColumn(2, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_PLUGIN_FILE_EXTENSION").c_str(), LVCFMT_LEFT, width2); 88 } 89 else 90 { 91 width0 = rect.Width() / 2; 92 width1 = rect.Width() - width0 - theApp.DPI(20) - 1; 93 m_format_list.InsertColumn(0, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_PLUGIN_FORMAT_PROVIDED").c_str(), LVCFMT_LEFT, width0); 94 m_format_list.InsertColumn(1, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_PLUGIN_FILE_EXTENSION").c_str(), LVCFMT_LEFT, width1); 95 } 96 97 int index = 0; 98 for (const auto support_format : CAudioCommon::m_surpported_format) 99 { 100 if (is_bass) 101 { 102 m_format_list.InsertItem(index, support_format.file_name.c_str()); 103 m_format_list.SetItemText(index, 1, support_format.description.c_str()); 104 m_format_list.SetItemText(index, 2, support_format.extensions_list.c_str()); 105 } 106 else 107 { 108 m_format_list.InsertItem(index, support_format.description.c_str()); 109 m_format_list.SetItemText(index, 1, support_format.extensions_list.c_str()); 110 } 111 index++; 112 } 113 114 return TRUE; // return TRUE unless you set the focus to a control 115 // 异常: OCX 属性页应返回 FALSE 116 } 117