|
本帖最后由 cheating_plugin 于 2019-11-6 20:43 编辑
第一:CToolBar放在CMainFrame中(不是dialog)
第二:CToolBar不可能移动,就像一些软件那样,放上去了以后鼠标是不能拉动的,除非使用MoveWindow等才行,手动是移动不了的。
第三:把CToolBar放在底部,在create中,有CBRS_BOTTOM参数,CToolBar控件的确放在了文档的下面,但Combo box控件居然在文档的上面,这怎么弄啊?
第四:不管窗口如何改变,Combo box控件的位置与大小始终不变。
哪位大哥能告知一下不?
这里是代码:
if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBar1.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
!m_wndToolBar1.LoadToolBar(IDR_MAINFRAMEBOT))
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
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
}
int index = 3;// 占位符索引
#define IDC_COMBO 5001
int width = 100;// 占位符宽度
m_wndToolBar1.SetButtonInfo(index, IDC_COMBO, TBBS_SEPARATOR, width);
CRect rect;
m_wndToolBar1.GetItemRect(index, &rect);
int height = 300;// ComboBox下拉后高度,尽量长吧。
rect.bottom = rect.top + height;
m_Combo.Create(WS_CHILD | WS_VISIBLE | WS_VSCROLL | CBS_SORT | CBS_DROPDOWNLIST,
rect, this, IDC_COMBO);
m_Combo.AddString(_T("item0"));
m_Combo.AddString(_T("item1"));
m_Combo.AddString(_T("item2"));
m_Combo.SetCurSel(0);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
m_wndToolBar1.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar1);
|
上一篇: cocos和c++的关系与前景下一篇: visual studio 2013 专业版和旗舰版的区别
|