在CTabCtrl中我可以在运行时更改选项卡的图标吗? [英] In CTabCtrl can I change tab's icon during runtime?
问题描述
In CTabCtrl可以在运行时更改选项卡的图标吗?
我已将imagelist设置为ctabctrl。
我只想在运行时将图像索引更改为特定选项卡?有可能吗?
是的,你可以。
假设您将这样的图像添加到CMFCTabCtrl{
UINT uiBmpId = IDB_TAB_IMAGE_SET_1;
CBitmap bmp;
bmp.LoadBitmap(uiBmpId);
BITMAP bmpObj;
bmp.GetBitmap(& bmpObj);
UINT nFlags = ILC_MASK | ILC_COLOR24;
m_imgList.Create(16,bmpObj.bmHeight,nFlags,0,0);
m_imgList.Add(& bmp,RGB(255,0,0));
m_wndTabs.SetImageList(m_imgList);
}
现在,当您想要更改图像时,只需删除旧图像列表并替换为一组新图像:
< pre class ="prettyprint"> {
m_imgList.DeleteImageList();
UINT uiBmpId = IDB_FILE_VIEW_24_1;
CBitmap bmp;
bmp.LoadBitmap(uiBmpId;
BITMAP bmpObj;
bmp.GetBitmap(& bmpObj);
UINT nFlags = ILC_MASK | ILC_COLOR24;
m_imgList.Create(16,bmpObj.bmHeight,nFlags,0,0);
m_imgList.Add(& bmp,RGB(255,0,0));
m_wndTabs.SetImageList(m_imgList);
m_wndTabs.RedrawWindow();
}
-Seetharam
Hi,
In CTabCtrl can I change tab's icon during runtime?
I have set imagelist to ctabctrl.
I just want to change image index to particular tab during runtime? Is it possible?
Yes you can.
Let's say you add images like this to your CMFCTabCtrl{ UINT uiBmpId = IDB_TAB_IMAGE_SET_1; CBitmap bmp; bmp.LoadBitmap(uiBmpId); BITMAP bmpObj; bmp.GetBitmap(&bmpObj); UINT nFlags = ILC_MASK|ILC_COLOR24; m_imgList.Create(16, bmpObj.bmHeight, nFlags, 0, 0); m_imgList.Add(&bmp, RGB(255, 0, 0)); m_wndTabs.SetImageList(m_imgList); }Now when you want to change the images, just delete the old imagelist and replace with a new set of images like this:
{ m_imgList.DeleteImageList(); UINT uiBmpId = IDB_FILE_VIEW_24_1; CBitmap bmp; bmp.LoadBitmap(uiBmpId; BITMAP bmpObj; bmp.GetBitmap(&bmpObj); UINT nFlags = ILC_MASK|ILC_COLOR24; m_imgList.Create(16, bmpObj.bmHeight, nFlags, 0, 0); m_imgList.Add(&bmp, RGB(255, 0, 0)); m_wndTabs.SetImageList(m_imgList); m_wndTabs.RedrawWindow(); }-Seetharam
这篇关于在CTabCtrl中我可以在运行时更改选项卡的图标吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!