diff --git a/MusicPlayer2/BaseDialog.cpp b/MusicPlayer2/BaseDialog.cpp index bda3a1208..f716e6897 100644 --- a/MusicPlayer2/BaseDialog.cpp +++ b/MusicPlayer2/BaseDialog.cpp @@ -103,8 +103,8 @@ void CBaseDialog::ReLoadLayoutResource() void CBaseDialog::SetIcon(IconMgr::IconType type, BOOL bBigIcon) { - if (bBigIcon) - CDialog::SetIcon(theApp.m_icon_mgr.GetHICON(type, IconMgr::IconStyle::IS_OutlinedDark, IconMgr::IconSize::IS_Default), TRUE); + if (bBigIcon) // 大图标需要DPI32才足够清晰? + CDialog::SetIcon(theApp.m_icon_mgr.GetHICON(type, IconMgr::IconStyle::IS_OutlinedDark, IconMgr::IconSize::IS_DPI_32), TRUE); else CDialog::SetIcon(theApp.m_icon_mgr.GetHICON(type, IconMgr::IconStyle::IS_OutlinedDark, IconMgr::IconSize::IS_DPI_16), FALSE); } diff --git a/MusicPlayer2/CTabCtrlEx.cpp b/MusicPlayer2/CTabCtrlEx.cpp index 2c75bf9a8..69fc73d1b 100644 --- a/MusicPlayer2/CTabCtrlEx.cpp +++ b/MusicPlayer2/CTabCtrlEx.cpp @@ -80,8 +80,9 @@ void CTabCtrlEx::AdjustTabWindowSize() //为每个标签添加图标 if (m_icon_list.empty()) return; + CSize icon_size = IconMgr::GetIconSize(IconMgr::IconSize::IS_DPI_16); CImageList ImageList; - ImageList.Create(theApp.DPI(16), theApp.DPI(16), ILC_COLOR32 | ILC_MASK, 2, 2); + ImageList.Create(icon_size.cx, icon_size.cy, ILC_COLOR32 | ILC_MASK, 2, 2); for (auto icon_type : m_icon_list) { HICON hIcon = theApp.m_icon_mgr.GetHICON(icon_type, IconMgr::IconStyle::IS_OutlinedDark, IconMgr::IconSize::IS_DPI_16); diff --git a/MusicPlayer2/DrawCommon.cpp b/MusicPlayer2/DrawCommon.cpp index 6ff89f755..19393ac0c 100644 --- a/MusicPlayer2/DrawCommon.cpp +++ b/MusicPlayer2/DrawCommon.cpp @@ -701,11 +701,6 @@ void CDrawCommon::ImageResize(const wstring& path_src, const wstring& path_dest, ImageResize(imSrc, path_dest, size, type); } -HICON CDrawCommon::LoadIconResource(UINT id, int width, int height) -{ - return (HICON)LoadImage(AfxGetInstanceHandle(), MAKEINTRESOURCE(id), IMAGE_ICON, width, height, 0); -} - HBITMAP CDrawCommon::CopyBitmap(HBITMAP hSourceHbitmap) { CDC sourceDC; diff --git a/MusicPlayer2/DrawCommon.h b/MusicPlayer2/DrawCommon.h index 048b17ecf..a71aef2c6 100644 --- a/MusicPlayer2/DrawCommon.h +++ b/MusicPlayer2/DrawCommon.h @@ -135,8 +135,6 @@ class CDrawCommon static void ImageResize(const CImage& img_src, const wstring& path_dest, int size, ImageType type); static void ImageResize(const wstring& path_src, const wstring& path_dest, int size, ImageType type); - static HICON LoadIconResource(UINT id, int width, int height); - //复制一个bitmap (http://wupei.j2megame.org/archives/86) //(这两个函数未测试成功,复制的图片为全黑色,原因暂时未知,后面再调查) static HBITMAP CopyBitmap(HBITMAP hSourceHbitmap); diff --git a/MusicPlayer2/FolderExploreDlg.cpp b/MusicPlayer2/FolderExploreDlg.cpp index a9e046422..c470fe50a 100644 --- a/MusicPlayer2/FolderExploreDlg.cpp +++ b/MusicPlayer2/FolderExploreDlg.cpp @@ -229,11 +229,12 @@ BOOL CFolderExploreDlg::OnInitDialog() // TODO: 在此添加额外的初始化 //为树控件设置图标 - CImageList image_list; - image_list.Create(theApp.DPI(16), theApp.DPI(16), ILC_COLOR32 | ILC_MASK, 2, 2); - image_list.Add(CDrawCommon::LoadIconResource(IDI_EXPLORE_FOLDER, theApp.DPI(16), theApp.DPI(16))); - m_folder_explore_tree.SetImageList(&image_list, TVSIL_NORMAL); - image_list.Detach(); + CSize icon_size = IconMgr::GetIconSize(IconMgr::IconSize::IS_DPI_16); + CImageList ImageList; + ImageList.Create(icon_size.cx, icon_size.cy, ILC_COLOR32 | ILC_MASK, 2, 2); + ImageList.Add(theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Folder, IconMgr::IconStyle::IS_Color, IconMgr::IconSize::IS_DPI_16)); + m_folder_explore_tree.SetImageList(&ImageList, TVSIL_NORMAL); + ImageList.Detach(); //设置行高 m_folder_explore_tree.SetItemHeight(theApp.DPI(22)); @@ -246,12 +247,6 @@ BOOL CFolderExploreDlg::OnInitDialog() //即只有当标签切换到“文件夹浏览”时才填充数据,以加载“媒体库”对话框的打开速度 //ShowFolderTree(); - //// - //CImageList image_list1; - //image_list1.Create(theApp.DPI(16), theApp.DPI(16), ILC_COLOR32 | ILC_MASK, 2, 2); - //image_list1.Add(theApp.LoadIcon(IDI_FILE_ICON)); - //m_song_list_ctrl.SetImageList(&image_list1, LVSIL_SMALL); - //初始化右侧列表 m_song_list_ctrl.SetExtendedStyle(m_song_list_ctrl.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_LABELTIP); //CRect rc_song_list; diff --git a/MusicPlayer2/IconMgr.cpp b/MusicPlayer2/IconMgr.cpp index c57356b10..02bbd1f78 100644 --- a/MusicPlayer2/IconMgr.cpp +++ b/MusicPlayer2/IconMgr.cpp @@ -59,7 +59,7 @@ CSize IconMgr::GetIconSize(IconSize size) case IS_DPI_20: case IS_DPI_20_Full_Screen: width = theApp.DPI(20); break; case IS_DPI_32: case IS_DPI_32_Full_Screen: width = theApp.DPI(32); break; case IS_ORG_512: width = 512; break; - default: width = 0; break; // 系统默认图标大小 SM_CXICON * SM_CYICON, 此时返回0 + default: width = theApp.DPI(16); break; // 系统默认小图标大小 SM_CXICON * SM_CYICON } if (size == IS_DPI_16_Full_Screen || size == IS_DPI_20_Full_Screen || size == IS_DPI_32_Full_Screen) width = static_cast(width * CONSTVAL::FULL_SCREEN_ZOOM_FACTOR); diff --git a/MusicPlayer2/IconMgr.h b/MusicPlayer2/IconMgr.h index 5e1892b75..c18d49c01 100644 --- a/MusicPlayer2/IconMgr.h +++ b/MusicPlayer2/IconMgr.h @@ -131,8 +131,7 @@ class IconMgr enum IconSize { - IS_Default, // SM_CXICON * SM_CYICON - IS_DPI_16, + IS_DPI_16, // SM_CXICON * SM_CYICON IS_DPI_16_Full_Screen, IS_DPI_20, IS_DPI_20_Full_Screen, diff --git a/MusicPlayer2/LyricEditDlg.cpp b/MusicPlayer2/LyricEditDlg.cpp index 58be22bde..5334f26bb 100644 --- a/MusicPlayer2/LyricEditDlg.cpp +++ b/MusicPlayer2/LyricEditDlg.cpp @@ -363,24 +363,23 @@ BOOL CLyricEditDlg::OnInitDialog() return -1; // fail to create } RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, 0); - int icon_size = theApp.DPI(20); - if (icon_size < 32) - icon_size = CCommon::IconSizeNormalize(icon_size); + + CSize icon_size = IconMgr::GetIconSize(IconMgr::IconSize::IS_DPI_20); CImageList ImageList; - ImageList.Create(icon_size, icon_size, ILC_COLOR32 | ILC_MASK, 2, 2); + ImageList.Create(icon_size.cx, icon_size.cy, ILC_COLOR32 | ILC_MASK, 2, 2); //通过ImageList对象加载图标作为工具栏的图标 //添加图标 - ImageList.Add(CDrawCommon::LoadIconResource(IDI_ADD_TAG, icon_size, icon_size)); - ImageList.Add(CDrawCommon::LoadIconResource(IDI_REPLACE_TAG, icon_size, icon_size)); - ImageList.Add(CDrawCommon::LoadIconResource(IDI_DELETE_TAG, icon_size, icon_size)); - ImageList.Add(CDrawCommon::LoadIconResource(IDI_SAVE, icon_size, icon_size)); - ImageList.Add(CDrawCommon::LoadIconResource(IDI_PLAY_PAUSE, icon_size, icon_size)); - ImageList.Add(CDrawCommon::LoadIconResource(IDI_REW, icon_size, icon_size)); - ImageList.Add(CDrawCommon::LoadIconResource(IDI_FF, icon_size, icon_size)); - ImageList.Add(CDrawCommon::LoadIconResource(IDI_LOCATE_D, icon_size, icon_size)); - ImageList.Add(CDrawCommon::LoadIconResource(IDI_FIND, icon_size, icon_size)); - ImageList.Add(CDrawCommon::LoadIconResource(IDI_REPLACE, icon_size, icon_size)); + ImageList.Add(theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Le_Tag_Insert, IconMgr::IconStyle::IS_Color, IconMgr::IconSize::IS_DPI_20)); + ImageList.Add(theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Le_Tag_Replace, IconMgr::IconStyle::IS_Color, IconMgr::IconSize::IS_DPI_20)); + ImageList.Add(theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Le_Tag_Delete, IconMgr::IconStyle::IS_Color, IconMgr::IconSize::IS_DPI_20)); + ImageList.Add(theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Le_Save, IconMgr::IconStyle::IS_Color, IconMgr::IconSize::IS_DPI_20)); + ImageList.Add(theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Play_Pause, IconMgr::IconStyle::IS_Filled, IconMgr::IconSize::IS_DPI_20)); + ImageList.Add(theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Rewind, IconMgr::IconStyle::IS_Filled, IconMgr::IconSize::IS_DPI_20)); + ImageList.Add(theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Fast_Forward, IconMgr::IconStyle::IS_Filled, IconMgr::IconSize::IS_DPI_20)); + ImageList.Add(theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Locate, IconMgr::IconStyle::IS_OutlinedDark, IconMgr::IconSize::IS_DPI_20)); + ImageList.Add(theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Le_Find, IconMgr::IconStyle::IS_Color, IconMgr::IconSize::IS_DPI_20)); + ImageList.Add(theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Le_Replace, IconMgr::IconStyle::IS_Color, IconMgr::IconSize::IS_DPI_20)); m_wndToolBar.GetToolBarCtrl().SetImageList(&ImageList); ImageList.Detach(); SetToolbarCmdEnable(); diff --git a/MusicPlayer2/MusicPlayer2.cpp b/MusicPlayer2/MusicPlayer2.cpp index 931c71b2c..484b7d1c5 100644 --- a/MusicPlayer2/MusicPlayer2.cpp +++ b/MusicPlayer2/MusicPlayer2.cpp @@ -510,7 +510,7 @@ void CMusicPlayerApp::LoadConfig() m_hot_key_setting_data.global_multimedia_key_enable = ini.GetBool(L"hot_key", L"global_multimedia_key_enable", false); } -void CMusicPlayerApp::LoadIconResource() +void CMusicPlayerApp::LoadImgResource() { //加载图片资源 m_image_set.default_cover_img = CCommon::GetPngImageResource(IDB_DEFAULT_ALBUM_COVER); diff --git a/MusicPlayer2/MusicPlayer2.h b/MusicPlayer2/MusicPlayer2.h index 3c830c151..b989fd3aa 100644 --- a/MusicPlayer2/MusicPlayer2.h +++ b/MusicPlayer2/MusicPlayer2.h @@ -88,7 +88,7 @@ class CMusicPlayerApp : public CWinApp void LoadConfig(); - void LoadIconResource(); + void LoadImgResource(); int DPI(int pixel); //将一个像素值进行DPI变换 int DPI(double pixel); diff --git a/MusicPlayer2/MusicPlayerDlg.cpp b/MusicPlayer2/MusicPlayerDlg.cpp index 872b84a7b..c174d75b1 100644 --- a/MusicPlayer2/MusicPlayerDlg.cpp +++ b/MusicPlayer2/MusicPlayerDlg.cpp @@ -43,7 +43,7 @@ const UINT WM_TASKBARCREATED{ ::RegisterWindowMessage(_T("TaskbarCreated")) }; CMusicPlayerDlg::CMusicPlayerDlg(wstring cmdLine, CWnd* pParent /*=NULL*/) : m_cmdLine{ cmdLine }, CMainDialogBase(IDD_MUSICPLAYER2_DIALOG, pParent) { - m_hIcon = theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_App, IconMgr::IconStyle::IS_Color, IconMgr::IconSize::IS_Default); + m_hIcon = theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_App, IconMgr::IconStyle::IS_Color, IconMgr::IconSize::IS_DPI_32); m_path_edit.SetTooltopText(theApp.m_str_table.LoadText(L"UI_TIP_BTN_RECENT_FOLDER_OR_PLAYLIST").c_str()); //初始化UI @@ -1054,7 +1054,7 @@ void CMusicPlayerDlg::UpdatePlayPauseButton() if (theApp.IsTaskbarInteractionEnabled()) { HICON hIcon_play = theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Play, IconMgr::IconStyle::IS_Filled, IconMgr::IconSize::IS_DPI_16); - HICON hIcon_pause = theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Play_Pause, IconMgr::IconStyle::IS_Filled, IconMgr::IconSize::IS_DPI_16); + HICON hIcon_pause = theApp.m_icon_mgr.GetHICON(IconMgr::IconType::IT_Pause, IconMgr::IconStyle::IS_Filled, IconMgr::IconSize::IS_DPI_16); if (CPlayer::GetInstance().IsPlaying() && !CPlayer::GetInstance().IsError()) { //更新任务栏缩略图上“播放/暂停”的图标 @@ -1993,7 +1993,7 @@ BOOL CMusicPlayerDlg::OnInitDialog() CMainDialogBase::OnInitDialog(); // 载入图标资源 - theApp.LoadIconResource(); + theApp.LoadImgResource(); // 载入字体资源 theApp.m_font_set.Init(theApp.m_str_table.GetDefaultFontName().c_str());