CTrueColorToolBar

本文介绍如何使用MFC框架创建并配置工具栏和状态栏,包括左右两侧工具栏的设置、加载按钮资源及状态栏指标设定等。文章还展示了如何启用停靠功能并实现工具栏的动态调整。
protected:  // control bar embedded members
	CStatusBar  m_wndStatusBar;
	CToolBar    m_wndToolBar;
	CTrueColorToolBar    m_ToolBarDrawLeft;
	CTrueColorToolBar    m_ToolBarDrawRight;
/////////////////////////////////////////////////
	m_ToolBarDrawLeft.SetBorders(1, 1, 1, 1);
	if (!m_ToolBarDrawLeft.Create(this, WS_CHILD | WS_VISIBLE | CBRS_LEFT
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_ToolBarDrawLeft.LoadToolBar(IDR_TOOLBAR_DRAW))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
	m_ToolBarDrawLeft.ModifyStyle(0, TBSTYLE_FLAT);

	m_ToolBarDrawLeft.LoadTrueColorToolBar(TOOLBAR_DRAW_BUTTON_WIDTH,
									   IDB_TOOLBAR_DRAW,
		                               IDB_TOOLBAR_DRAW_HOT,
									   IDB_TOOLBAR_DRAW_DISABLED);

	m_ToolBarDrawRight.SetBorders(1, 1, 1, 1);
	if (!m_ToolBarDrawRight.Create(this, WS_CHILD | WS_VISIBLE | CBRS_RIGHT
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_ToolBarDrawRight.LoadToolBar(IDR_TOOLBAR_DRAW))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
	m_ToolBarDrawRight.ModifyStyle(0, TBSTYLE_FLAT);

	m_ToolBarDrawRight.LoadTrueColorToolBar(TOOLBAR_DRAW_BUTTON_WIDTH,
									   IDB_TOOLBAR_DRAW,
		                               IDB_TOOLBAR_DRAW_HOT);

	if (!m_wndStatusBar.Create(this) ||
		!m_wndStatusBar.SetIndicators(indicators,
		  sizeof(indicators)/sizeof(UINT)))
	{
		TRACE0("Failed to create status bar\n");
		return -1;      // fail to create
	}

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	m_ToolBarDrawLeft.EnableDocking(CBRS_ALIGN_ANY);
	m_ToolBarDrawRight.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);
	DockControlBar(&m_ToolBarDrawLeft);
	DockControlBar(&m_ToolBarDrawRight);

	return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值