// TODO: 在此添加额外的初始化代码
CTime time = CTime::GetTickCount();
#if 1
// 不用到字串表添加ID,省事
// 自定义控件ID
static const UINT IDS_CAPTION = 1000 + 101;
// 自定义控件ID
static const UINT IDS_DATE = 1000 + 102;
// 指示器 ID 数组
static UINT indicators[] = { IDS_CAPTION, IDS_DATE };
// 创建 CStatusBar
if (!m_statusBar.Create(this, WS_CHILD | WS_BORDER | WS_VISIBLE | CBRS_BOTTOM))
{
return FALSE;
}
// 设置指示器的 ID 和 数量
m_statusBar.SetIndicators(indicators, sizeof(indicators) / sizeof(UINT));
// 调整位置
RepositionBars(AFX_IDW_CONTROLBAR_FIRST, AFX_IDW_CONTROLBAR_LAST, IDS_CAPTION);
// 将指定的指示器窗格设置为新的 ID、样式和宽度。
for (int i = 0; i < sizeof(indicators) / sizeof(UINT); i++)
m_statusBar.SetPaneInfo(i, indicators[i], i == 0 ? SBPS_NORMAL : SBPS_STRETCH, i == 0 ? 50 : 300);
// 设置文本,第一格索引为0,以此类推
m_statusBar.SetPaneText(0, _T("当前时间"));
m_statusBar.SetPaneText(1, time.Format(_T("fucku %Y"
MFC CStatusBar类简单使用记录 MFC状态栏
最新推荐文章于 2023-06-25 11:09:05 发布