xref: /MusicPlayer2/MusicPlayer2/CoverDownloadDlg.h (revision 6ff78c2af22a2540d4da0cd487a360b3fffc6e91)
1 #pragma once
2 #include "CoverDownloadCommon.h"
3 #include "ListCtrlEx.h"
4 #include "SongInfo.h"
5 #include "BaseDialog.h"
6 
7 // CCoverDownloadDlg 对话框
8 
9 class CCoverDownloadDlg : public CBaseDialog
10 {
11     DECLARE_DYNAMIC(CCoverDownloadDlg)
12 
13 public:
14     CCoverDownloadDlg(CWnd* pParent = nullptr);   // 标准构造函数
15     virtual ~CCoverDownloadDlg();
16 
17 // 对话框数据
18 #ifdef AFX_DESIGN_TIME
19     enum { IDD = IDD_COVER_DOWNLOAD_DIALOG };
20 #endif
21 
22 #define WM_SEARCH_COMPLATE (WM_USER+101)        //歌曲搜索完成消息
23 #define WM_DOWNLOAD_COMPLATE (WM_USER+102)      //专辑封面下载完成消息
24 
25     //歌曲搜索线程函数
26     static UINT SongSearchThreadFunc(LPVOID lpParam);
27 
28     //专辑封面下载线程函数
29     static UINT CoverDownloadThreadFunc(LPVOID lpParam);
30 
31 protected:
32     CListCtrlEx m_down_list_ctrl;
33     CLinkCtrl m_unassciate_lnk;
34 
35     SongInfo m_song;        // 此次下载封面的歌曲,窗口初始化时写入,之后不应再从播放实例获取
36     wstring m_org_album_cover_path; // 歌曲原封面,初始化时写入,在CoverDownloadThreadFunc中应读取这里,不从播放实例获取
37     wstring m_title;        //要查找歌词的歌曲的标题
38     wstring m_artist;       //要查找歌词的歌曲的艺术家
39     wstring m_album;        //要查找歌词的歌曲的唱片集
40     wstring m_file_name;    //要查找歌词的歌曲的文件名
41 
42     bool m_save_to_song_folder;     // 是否将下载到的封面存储到歌曲目录
43 
44     vector<CInternetCommon::ItemInfo> m_down_list;  //搜索结果的列表
45     int m_item_selected{ -1 };      //搜索结果列表中选中的项目
46 
47     wstring m_search_url;
48     int m_search_rtn;
49     wstring m_search_result;
50 
51     CWinThread* m_pSearchThread;        //搜索歌词的线程
52     CWinThread* m_pDownThread;          //下载歌词的线程
53 
54     void SaveConfig() const;
55     void LoadConfig();
56 
57     void SetID(wstring id);     // 保存指定id到媒体库内m_song.file_path对应条目
58 
59     wstring GetSavedDir();
60 
61     virtual SongInfo GetSongInfo() const;
62     virtual CString GetDialogName() const override;
63     virtual bool InitializeControls() override;
64 
65     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持
66     void ShowDownloadList();        //将搜索结果显示出来
67 
68     DECLARE_MESSAGE_MAP()
69 public:
70     virtual BOOL OnInitDialog();
71     afx_msg void OnBnClickedSearchButton();
72 protected:
73     afx_msg LRESULT OnSearchComplate(WPARAM wParam, LPARAM lParam);
74 public:
75     afx_msg virtual void OnBnClickedDownloadSelected();
76     afx_msg void OnNMClickCoverDownList(NMHDR *pNMHDR, LRESULT *pResult);
77     afx_msg void OnNMDblclkCoverDownList(NMHDR *pNMHDR, LRESULT *pResult);
78     afx_msg void OnNMRClickCoverDownList(NMHDR *pNMHDR, LRESULT *pResult);
79     virtual void OnOK();
80     virtual void OnCancel();
81     afx_msg void OnDestroy();
82 protected:
83     afx_msg LRESULT OnDownloadComplate(WPARAM wParam, LPARAM lParam);
84 public:
85     afx_msg void OnEnChangeTitleEdit();
86     afx_msg void OnEnChangeArtistEdit();
87     afx_msg void OnNMClickUnassociateLink(NMHDR *pNMHDR, LRESULT *pResult);
88     afx_msg void OnBnClickedSaveToSongFolder2();
89     afx_msg void OnBnClickedSaveToAlbumFolder2();
90 };
91