请选择 进入手机版 | 继续访问电脑版
MSIPO技术圈 首页 IT技术 查看内容

MFC 将工具栏的两项中加入空白按钮

2023-07-13

先视为普通按钮赋ID
ImageList中Add的图为资源视图新建的CBitmap 是个空图
SetButtonText对应的按钮文本也为空格
然后m_toolbar.GetToolBarCtrl().EnableButton(ID_BUTTONS, FALSE);将对应的按钮禁用即可
ID_BUTTONS是第一个按钮的ID值

UINT nArray[21];
for (int i = 0; i < 21; i++) {
	nArray[i] = ID_BUTTONS + i;
}
CBitmap bmp;
bmp.LoadBitmap(IDB_BITMAP1);
m_imageList.Add(&bmp, RGB(255,255,255));
m_imageList.Add(&bmp, RGB(255,255,255));
m_imageList.Add(&bmp, RGB(255,255,255));
m_imageList.Add(&bmp, RGB(255,255,255));
m_imageList.Add(&bmp, RGB(255,255,255));
m_imageList.Add(&bmp, RGB(255,255,255));
m_imageList.Add(&bmp, RGB(255,255,255));
bmp.DeleteObject();
m_toolbar.SetButtons(nArray, 21);
m_toolbar.SetButtonText(0,"1");
m_toolbar.SetButtonText(0," ");
m_toolbar.SetButtonText(0," ");
m_toolbar.SetButtonText(0," ");
m_toolbar.SetButtonText(0," ");
m_toolbar.SetButtonText(0," ");
m_toolbar.SetButtonText(0,"2");
m_toolbar.GetToolBarCtrl().EnableButton(ID_BUTTONS+1, FALSE);
m_toolbar.GetToolBarCtrl().EnableButton(ID_BUTTONS+2, FALSE);
m_toolbar.GetToolBarCtrl().EnableButton(ID_BUTTONS+3, FALSE);
m_toolbar.GetToolBarCtrl().EnableButton(ID_BUTTONS+4, FALSE);
m_toolbar.GetToolBarCtrl().EnableButton(ID_BUTTONS+5, FALSE);
m_toolbar.GetToolBarCtrl().EnableButton(ID_BUTTONS+6, FALSE);
m_toolbar.GetToolBarCtrl().EnableButton(ID_BUTTONS+7, FALSE);

在这里插入图片描述
实现这种效果
唯一的效果是被顶到后面去的按钮会闪烁(未解决)

相关阅读

手机版|MSIPO技术圈 皖ICP备19022944号-2

Copyright © 2024, msipo.com

返回顶部