请注意两个关键字 一 "悬浮"不是"停靠" ,二"竖直".
解决方案 »
- sendto引发的sendto函数引发0xC0000005: Access Violation.
- CHtmlView 中检索网页文字过程中 get_outerHTML() 访问冲突,why ?
- 江湖救急!!directshow支持不支持跨平台啊
- 真心求大家分析下下面我2通宵没看懂的代码中的结构和消息循环!感谢一辈子
- 关于注册表创建 建 的问题,在建不存在的时候,创建不成功
- 如何在VC++6.0中重载DLL的DllMain函数?
- qq 的理论问题 udp 对连 好像要过firewall 牛人入
- CDialog::Create是不是一定需要Destroy?会不会有内存泄露?
- 小问题,谢谢
- 怎样更改快捷键,在vc下
- VC6.0环境,Button上双击鼠标,打开的是Button的属性页
- 求一份介绍磁盘各分区的第一个扇区数据内容的资料
我试过了,用FloatControlBar只能改变浮动位置,但是不能改变工具条的按钮图标的排列方向。
用DockControlBar只能使工具条停靠在左侧。但一浮动,工具条的按钮图标的排列方向还是会复原。
也许用DialogBar来自己管理工具条是条路。不过我也希望看到默认工具条能够支持这个方式。
对CToolBarCtrl也不熟,不清楚其中的一些函数都能够达到什么目的。
这篇文章没有仔细看。不知道是不是解决这个问题的,或者可以借鉴。
has the desired row count. if the count is too small to
be set, then return the row count used.Parameters:
pToolbar - Pointer to the MFC tool bar
object to be manipulatednRows - Requested number of rowsbLarger - Tells whether to use more rows or fewer rows
if the toolbar cannot be resized to the
requested number of rows.
(for details see CToolBarCtrl::SetRows in the MSDN
documentation) pClient - Pointer to a CPoint object for the position int
client coordinates for the toolbar to appear
floated. If this Parameter is NULL, the default
upper left corner of "this" window will be used
Returns: The value of the function CToolBarCtrl->GetRows
after the resizing has occured. A simple experiment
shows,but this is NOT the real number of rows
displayed :(
*/
int CMainFrame::FloatToolbarSetRows(
CToolBar *pToolbar, int nRows, BOOL bLarger,
CPoint *pClientPos)
{
// default upper left corner
// of the floating toolbar
// is upper left corner of main wnd
CPoint newPos(0,0); // if other pos specified, use it
if (pClientPos)
newPos = *pClientPos; // functions use screen coords
ClientToScreen(&newPos);
// first, make sure our toolbar is floating
if (!pToolbar->IsFloating())
FloatControlBar(pToolbar, CPoint(0,0));
// now set the desired row count
// may result in more rows than specified
// see the MSDN docs: CToolBarCtrl::SetRows
//
// this function also calculates the new
// toolbar window size
// unfortunately this function only arranges
// the toolbar buttons, but will not update
// the size of the tool bar window ...
CRect rcNew;
pToolbar->GetToolBarCtrl().SetRows(nRows,
bLarger, &rcNew);
// we need to reset the horizontal extend
// of the toolbar before it "knows" its
// width. It will not diplay this width
// before the window is touched by us (or
// by the mouse)
pToolbar->CalcDynamicLayout(rcNew.Width(),
LM_HORZ | LM_COMMIT); // now move the window to the desired position
FloatControlBar(pToolbar, newPos,
CBRS_ALIGN_TOP | CBRS_SIZE_DYNAMIC); return pToolbar->GetToolBarCtrl().GetRows();
}
在创建工具箱后:
//浮动工具箱的位置
CRect rect;
GetWindowRect(&rect);
CPoint pt(rect.Width()/60,rect.Height()/6);
// 设置工具箱按钮排列
int nBtnCols = 2;// 列数
int nCount = m_ToolBox.GetToolBarCtrl().GetButtonCount();
for (int i = 0; i < nCount; i++)
{
UINT nStyle = m_ToolBox.GetButtonStyle(i);
BOOL bWrap = (((i+1) % nBtnCols) == 0);
if (bWrap)
nStyle |= TBBS_WRAPPED;
else
nStyle &= ~TBBS_WRAPPED;
m_ToolBox.SetButtonStyle(i, nStyle);
}
m_ToolBox.Invalidate();
RecalcLayout();
// Create the Palette. We are using hardcoded numbers for ease here
// normally the location would be read in from an ini file.
FloatControlBar(&m_ToolBox, pt);
ShowControlBar(&m_ToolBox, TRUE, FALSE);