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