原创 How to build 16*16 icon with CButton::SetIcon under vc

2010-5-14 11:09 1992 5 5 分类: 消费电子

The IDE of VC use the default size 32*32 to build icon for Cbutton. It is different with the SetIcon() of application. e.g, we can find this statement "SetIcon(pDlg->m_hIcon, FALSE);" for whole applcation, which can set the small icon for our application while we do minizine. But if we try this statement as follow: "GetDlgItem(IDC_BUTTON_PLAY)->SetIcon(hIcon_play, FALSE);", we will find it cannot set the small icon for our button... so, check the reference: http://lizheng0201.blog.163.com/blog/static/35264020100285236133/, we can solve this trouble.

STEPS:
(1) Check "Icon" checkbox of our button under "Styles" tab of resource editor.
(2) Add new icon into resource, named "IDI_ICON_OURS".
(3) Load this icon to cbutton:
 HICON hIcon_demo = AfxGetApp()->LoadIcon(IDI_ICON_OURS);
 m_buttonOurs.SetIcon(hIcon_demo);
(4) There are two ways to add 16*16 size icon:
(a) If we have drawed 16*16 and 32*32 two images for this icon. Then use "Image->Delete Device Image" to erase the 32*32 image. The drawback of this method we expericed was, the IDE will enlarge this small icon auto.
(b) copy the small 16*16 image to 32*32 image. Then drag it to the center of 32*32 canvas` now, enjoy the correct icon size of our Cbutton. ;P 

Allen
GV-TECH

文章评论0条评论)

登录后参与讨论
我要评论
0
5
关闭 站长推荐上一条 /2 下一条