xref: /MusicPlayer2/MusicPlayer2/SupportedFormatDlg.cpp (revision 9c4ef8a8f2876557772f84b85d0eb04ab8fa8c61)
14c2ce8a1SZhong Yang // SupportedFormatDlg.cpp: 实现文件
24c2ce8a1SZhong Yang //
34c2ce8a1SZhong Yang 
44c2ce8a1SZhong Yang #include "stdafx.h"
54c2ce8a1SZhong Yang #include "MusicPlayer2.h"
64c2ce8a1SZhong Yang #include "SupportedFormatDlg.h"
74c2ce8a1SZhong Yang #include "AudioCommon.h"
84c2ce8a1SZhong Yang 
94c2ce8a1SZhong Yang 
104c2ce8a1SZhong Yang // CSupportedFormatDlg 对话框
114c2ce8a1SZhong Yang 
IMPLEMENT_DYNAMIC(CSupportedFormatDlg,CBaseDialog)12d5347edbSZhong Yang IMPLEMENT_DYNAMIC(CSupportedFormatDlg, CBaseDialog)
134c2ce8a1SZhong Yang 
144c2ce8a1SZhong Yang CSupportedFormatDlg::CSupportedFormatDlg(CWnd* pParent /*=nullptr*/)
15d5347edbSZhong Yang     : CBaseDialog(IDD_SUPPORT_FORMAT_DIALOG, pParent)
164c2ce8a1SZhong Yang {
174c2ce8a1SZhong Yang 
184c2ce8a1SZhong Yang }
194c2ce8a1SZhong Yang 
~CSupportedFormatDlg()204c2ce8a1SZhong Yang CSupportedFormatDlg::~CSupportedFormatDlg()
214c2ce8a1SZhong Yang {
224c2ce8a1SZhong Yang }
234c2ce8a1SZhong Yang 
GetDialogName() const24d5347edbSZhong Yang CString CSupportedFormatDlg::GetDialogName() const
25d5347edbSZhong Yang {
26d5347edbSZhong Yang     return _T("SupportedFormatDlg");
27d5347edbSZhong Yang }
28d5347edbSZhong Yang 
InitializeControls()296ff78c2aSlrisora bool CSupportedFormatDlg::InitializeControls()
306ff78c2aSlrisora {
31*9c4ef8a8Slrisora     SetWindowTextW(theApp.m_str_table.LoadText(L"TITLE_SUPPORTED_FORMAT").c_str());
326ff78c2aSlrisora     // IDC_INFO_STATIC
336ff78c2aSlrisora     // IDC_FORMAT_LIST
346ff78c2aSlrisora     // IDOK
356ff78c2aSlrisora 
366ff78c2aSlrisora     RepositionTextBasedControls({
376ff78c2aSlrisora         { CtrlTextInfo::R1, IDOK, CtrlTextInfo::W32 }
386ff78c2aSlrisora         });
396ff78c2aSlrisora     return true;
406ff78c2aSlrisora }
416ff78c2aSlrisora 
DoDataExchange(CDataExchange * pDX)424c2ce8a1SZhong Yang void CSupportedFormatDlg::DoDataExchange(CDataExchange* pDX)
434c2ce8a1SZhong Yang {
44d5347edbSZhong Yang     CBaseDialog::DoDataExchange(pDX);
454c2ce8a1SZhong Yang     DDX_Control(pDX, IDC_FORMAT_LIST, m_format_list);
464c2ce8a1SZhong Yang }
474c2ce8a1SZhong Yang 
484c2ce8a1SZhong Yang 
BEGIN_MESSAGE_MAP(CSupportedFormatDlg,CBaseDialog)49d5347edbSZhong Yang BEGIN_MESSAGE_MAP(CSupportedFormatDlg, CBaseDialog)
504c2ce8a1SZhong Yang     ON_WM_GETMINMAXINFO()
514c2ce8a1SZhong Yang END_MESSAGE_MAP()
524c2ce8a1SZhong Yang 
534c2ce8a1SZhong Yang 
544c2ce8a1SZhong Yang // CSupportedFormatDlg 消息处理程序
554c2ce8a1SZhong Yang 
564c2ce8a1SZhong Yang 
574c2ce8a1SZhong Yang BOOL CSupportedFormatDlg::OnInitDialog()
584c2ce8a1SZhong Yang {
59d5347edbSZhong Yang     CBaseDialog::OnInitDialog();
604c2ce8a1SZhong Yang 
614c2ce8a1SZhong Yang     // TODO:  在此添加额外的初始化
624c2ce8a1SZhong Yang 
63a87de172Slrisora     SetIcon(IconMgr::IconType::IT_App, FALSE);       // 设置小图标
6486e2c9c2Slrisora     if (theApp.m_play_setting_data.use_ffmpeg)
65*9c4ef8a8Slrisora         SetDlgItemTextW(IDC_INFO_STATIC, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_CORE_INFO_FFMPEG").c_str());
6686e2c9c2Slrisora     else if (theApp.m_play_setting_data.use_mci)
67*9c4ef8a8Slrisora         SetDlgItemTextW(IDC_INFO_STATIC, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_CORE_INFO_MCI").c_str());
6886e2c9c2Slrisora     else
69*9c4ef8a8Slrisora         SetDlgItemTextW(IDC_INFO_STATIC, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_CORE_INFO_BASS").c_str());
704c2ce8a1SZhong Yang 
714c2ce8a1SZhong Yang     //初始化列表
72df1c5ec5Szhongyang     //m_format_list.SetColor(theApp.m_app_setting_data.theme_color);
73d5347edbSZhong Yang     CRect rect;
742bed31d4SZhong Yang     m_format_list.GetWindowRect(rect);
754c2ce8a1SZhong Yang     int width0, width1, width2;
7681af536cSZhong Yang     m_format_list.SetExtendedStyle(m_format_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_LABELTIP);
7781af536cSZhong Yang 
789c045b76Slrisora     bool is_bass = !theApp.m_play_setting_data.use_ffmpeg && !theApp.m_play_setting_data.use_mci;
799c045b76Slrisora     if (is_bass)
8081af536cSZhong Yang     {
814c2ce8a1SZhong Yang         width0 = theApp.DPI(100);
824c2ce8a1SZhong Yang         width1 = rect.Width() / 3;
832bed31d4SZhong Yang         width2 = rect.Width() - width1 - width0 - theApp.DPI(20) - 1;
844c2ce8a1SZhong Yang 
85*9c4ef8a8Slrisora         m_format_list.InsertColumn(0, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_PLUGIN_FILE_NAME").c_str(), LVCFMT_LEFT, width0);
86*9c4ef8a8Slrisora         m_format_list.InsertColumn(1, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_PLUGIN_FORMAT_PROVIDED").c_str(), LVCFMT_LEFT, width1);
87*9c4ef8a8Slrisora         m_format_list.InsertColumn(2, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_PLUGIN_FILE_EXTENSION").c_str(), LVCFMT_LEFT, width2);
8881af536cSZhong Yang     }
8981af536cSZhong Yang     else
9081af536cSZhong Yang     {
9181af536cSZhong Yang         width0 = rect.Width() / 2;
9281af536cSZhong Yang         width1 = rect.Width() - width0 - theApp.DPI(20) - 1;
93*9c4ef8a8Slrisora         m_format_list.InsertColumn(0, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_PLUGIN_FORMAT_PROVIDED").c_str(), LVCFMT_LEFT, width0);
94*9c4ef8a8Slrisora         m_format_list.InsertColumn(1, theApp.m_str_table.LoadText(L"TXT_SUPPORTED_FORMAT_PLUGIN_FILE_EXTENSION").c_str(), LVCFMT_LEFT, width1);
9581af536cSZhong Yang     }
964c2ce8a1SZhong Yang 
974c2ce8a1SZhong Yang     int index = 0;
984c2ce8a1SZhong Yang     for (const auto support_format : CAudioCommon::m_surpported_format)
994c2ce8a1SZhong Yang     {
1009c045b76Slrisora         if (is_bass)
1014c2ce8a1SZhong Yang         {
1024c2ce8a1SZhong Yang             m_format_list.InsertItem(index, support_format.file_name.c_str());
1034c2ce8a1SZhong Yang             m_format_list.SetItemText(index, 1, support_format.description.c_str());
1044c2ce8a1SZhong Yang             m_format_list.SetItemText(index, 2, support_format.extensions_list.c_str());
1054c2ce8a1SZhong Yang         }
10681af536cSZhong Yang         else
10781af536cSZhong Yang         {
10881af536cSZhong Yang             m_format_list.InsertItem(index, support_format.description.c_str());
10981af536cSZhong Yang             m_format_list.SetItemText(index, 1, support_format.extensions_list.c_str());
11081af536cSZhong Yang         }
11181af536cSZhong Yang         index++;
1124c2ce8a1SZhong Yang     }
1134c2ce8a1SZhong Yang 
1144c2ce8a1SZhong Yang     return TRUE;  // return TRUE unless you set the focus to a control
1154c2ce8a1SZhong Yang                   // 异常: OCX 属性页应返回 FALSE
1164c2ce8a1SZhong Yang }
117