1 #pragma once 2 #include "LyricDownloadCommon.h" 3 #include "Lyric.h" 4 #include "ListCtrlEx.h" 5 #include "SongInfo.h" 6 #include "BaseDialog.h" 7 8 9 // CLyricDownloadDlg 对话框 10 11 class CLyricDownloadDlg : public CBaseDialog 12 { 13 DECLARE_DYNAMIC(CLyricDownloadDlg) 14 15 public: 16 CLyricDownloadDlg(CWnd* pParent = NULL); // 标准构造函数 17 virtual ~CLyricDownloadDlg(); 18 19 // 对话框数据 20 #ifdef AFX_DESIGN_TIME 21 enum { IDD = IDD_LYRIC_DOWNLOAD_DIALOG }; 22 #endif 23 24 #define WM_SEARCH_COMPLATE (WM_USER+101) //歌曲搜索完成消息 25 #define WM_DOWNLOAD_COMPLATE (WM_USER+102) //歌词下载完成消息 26 27 //用于向歌词搜索线程传递数据的结构体 28 struct SearchThreadInfo 29 { 30 wstring url; 31 wstring result; 32 int rtn; 33 HWND hwnd; 34 //bool exit; 35 }; 36 //歌词搜索线程函数 37 static UINT LyricSearchThreadFunc(LPVOID lpParam); 38 39 //用于向歌词下载线程传递数据的结构体 40 struct DownloadThreadInfo 41 { 42 wstring song_id; 43 wstring result; 44 bool success; 45 bool download_translate; 46 bool save_as; //下载完成后是弹出“另存为”对话框还是直接保存 47 HWND hwnd; 48 //bool exit; 49 }; 50 //歌词下载线程函数 51 static UINT LyricDownloadThreadFunc(LPVOID lpParam); 52 53 SearchThreadInfo m_search_thread_info; 54 DownloadThreadInfo m_download_thread_info; 55 56 protected: 57 SongInfo m_song; //要查找歌词的歌曲 58 wstring m_lyric_name; //保存的歌词文件的文件名(不含扩展名) 59 wstring m_lyric_dir; //当前要保存的歌词文件的目录 60 wstring m_search_result; //查找结果字符串 61 wstring m_lyric_str; //下载的歌词 62 vector<CInternetCommon::ItemInfo> m_down_list; //搜索结果的列表 63 64 int m_item_selected{ -1 }; //搜索结果列表中选中的项目 65 bool m_download_translate{ false }; 66 bool m_save_to_song_folder{ true }; //是否保存到歌曲所在目录 67 CodeType m_save_code{}; //保存的编码格式 68 int m_search_max_item{ 30 }; //查找歌曲时返回的最大数量 69 70 CListCtrlEx m_down_list_ctrl; 71 CButton m_download_translate_chk; 72 CComboBox m_save_code_combo; 73 //CToolTipCtrl m_tool_tip; //鼠标指向时的工具提示 74 CLinkCtrl m_unassciate_lnk; 75 76 CWinThread* m_pSearchThread; //搜索歌词的线程 77 CWinThread* m_pDownThread; //下载歌词的线程 78 79 void ShowDownloadList(); //将搜索结果显示出来 80 bool SaveLyric(const wchar_t* path, CodeType code_type); //保存歌词 81 void SetID(wstring id); // 保存指定id到媒体库内m_song.file_path对应条目 82 83 void SaveConfig() const; 84 void LoadConfig(); 85 86 wstring GetSavedDir(); 87 wstring GetSavedPath(); 88 89 virtual CString GetDialogName() const override; 90 virtual bool InitializeControls() override; 91 92 virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持 93 94 DECLARE_MESSAGE_MAP() 95 96 private: 97 bool IsItemSelectedValid() const; 98 99 public: 100 virtual BOOL OnInitDialog(); 101 afx_msg void OnBnClickedSearchButton2(); 102 afx_msg void OnEnChangeTitleEdit1(); 103 afx_msg void OnEnChangeArtistEdit1(); 104 afx_msg void OnNMClickLyricDownList1(NMHDR *pNMHDR, LRESULT *pResult); 105 afx_msg void OnNMRClickLyricDownList1(NMHDR *pNMHDR, LRESULT *pResult); 106 afx_msg void OnBnClickedDownloadSelected(); 107 afx_msg void OnBnClickedDownloadTranslateCheck1(); 108 afx_msg void OnDestroy(); 109 protected: 110 afx_msg LRESULT OnSearchComplate(WPARAM wParam, LPARAM lParam); 111 virtual void OnCancel(); 112 virtual void OnOK(); 113 afx_msg LRESULT OnDownloadComplate(WPARAM wParam, LPARAM lParam); 114 public: 115 afx_msg void OnBnClickedSaveToSongFolder1(); 116 afx_msg void OnBnClickedSaveToLyricFolder1(); 117 afx_msg void OnBnClickedSelectedSaveAs(); 118 afx_msg void OnCbnSelchangeCombo2(); 119 afx_msg void OnLdLyricDownload(); 120 afx_msg void OnLdLyricSaveas(); 121 afx_msg void OnLdCopyTitle(); 122 afx_msg void OnLdCopyArtist(); 123 afx_msg void OnLdCopyAlbum(); 124 afx_msg void OnLdCopyId(); 125 afx_msg void OnLdViewOnline(); 126 afx_msg void OnNMDblclkLyricDownList1(NMHDR *pNMHDR, LRESULT *pResult); 127 virtual BOOL PreTranslateMessage(MSG* pMsg); 128 afx_msg void OnNMClickUnassociateLink(NMHDR *pNMHDR, LRESULT *pResult); 129 afx_msg void OnLdPreview(); 130 afx_msg void OnLdRelate(); 131 }; 132