在CTabCtrl中我可以在运行时更改选项卡的图标吗? [英] In CTabCtrl can I change tab's icon during runtime?

查看:165
本文介绍了在CTabCtrl中我可以在运行时更改选项卡的图标吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆