如何显示浮动工具条?

wangyugood 2001-07-21 11:44:02
如何在某一位置以某种方式显示浮动工具条?
...全文
362 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
xiaoxiaohan 2001-12-19
  • 打赏
  • 举报
回复
-- 第一种方法

---- 该方法最为简单,利用VC中的工具条的系统未公布的隐含参数 TBSTYLE_FLAT,不需更改原由程序只要在程序中添加4条语句即可实现浮动效果。不过该方法只能产生简单的浮动工具条,而且没有象OFFICES中工具条右侧的拖动条gripper。而且该方法在VC50下存在严重的缺陷,当拖动工具条时,系统不能对工具条进行刷新,因此会产生移动工具条到新位置时,原处仍有工具条。主要是负责工具条的动态连接库COMCTL32.DLL的BUG。该问题在VC60中由于更新了该动态连接库而得以解决。程序员如果使用的是VC5版可以用新的版本COMCTL32.DLL (4.72版以上)替换该动态连接库来解决。

---- 具体方法如下:

int CMainFrame::OnCreate
(LPCREATESTRUCT lpCreateStruct)
{
...
m_wndToolBar.SetBarStyle
(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY |
CBRS_SIZE_DYNAMIC|TBSTYLE_FLAT);

//添加以下4句语句,产生浮动效果
LONG lStyle;
lStyle=GetWindowLong
(m_wndToolBar,GWL_STYLE);
lStyle=lStyle|TBSTYLE_FLAT;
SetWindowLong(m_wndToolBar,
GWL_STYLE,lStyle);

m_wndToolBar.EnableDocking
(CBRS_ALIGN_ANY);
...
}
第二种方法
---- 该方法是对MFC原来的CTOOLBAR类进行继承,主要是重载成员函数 OnWindowPosChanging(LPWINDOWPOS lpWndPos);OnPaint();OnNcPaint();OnNcCalcSize(); 实现浮动工具条。使用本类,只要将以下的程序代码FlatToolBar.h和FlatToolBar.Cpp 加入项目,并用INCLUDE将FlatToolBar.H包含到绘制主窗口的CMainFrame中,然后把你的原先定义工具条变量的CToolBar类变成 CFlatToolBar类,并在建立工具条后调用 SetFlatLookStyle()函数设置浮动方式。为方便以后其它使用程序,可以在该类上右击鼠标,选择Add to Gallery将CFlatToolBar类存入类库以便下次使用。
wjyasd 2001-07-21
  • 打赏
  • 举报
回复
改变属性!
CControlBar::SetBarStyle
void SetBarStyle( DWORD dwStyle );
Parameters
dwStyle
The desired styles for the control bar. Can be one or more of the following:
CBRS_ALIGN_TOP Allows the control bar to be docked to the top of the client area of a frame window.
CBRS_ALIGN_BOTTOM Allows the control bar to be docked to the bottom of the client area of a frame window.
CBRS_ALIGN_LEFT Allows the control bar to be docked to the left side of the client area of a frame window.
CBRS_ALIGN_RIGHT Allows the control bar to be docked to the right side of the client area of a frame window.
CBRS_ALIGN_ANY Allows the control bar to be docked to any side of the client area of a frame window.
CBRS_BORDER_TOP Causes a border to be drawn on the top edge of the control bar when it would be visible.
CBRS_BORDER_BOTTOM Causes a border to be drawn on the bottom edge of the control bar when it would be visible.
CBRS_BORDER_LEFT Causes a border to be drawn on the left edge of the control bar when it would be visible.
CBRS_BORDER_RIGHT Causes a border to be drawn on the right edge of the control bar when it would be visible.
CBRS_FLOAT_MULTI Allows multiple control bars to be floated in a single mini-frame window.
CBRS_TOOLTIPS Causes tool tips to be displayed for the control bar.
CBRS_FLYBY Causes message text to be updated at the same time as tool tips.
CBRS_GRIPPER Causes a gripper, similar to that used on bands in a CReBar object, to be drawn for any CControlBar-derived class.
Remarks

Call this function to set the desired CBRS_ styles for the control bar. Does not affect the WS_ (window style) settings.

jerry2 2001-07-21
  • 打赏
  • 举报
回复
The framework callsCFrameWnd::DockControlBar when the user attempts to drop the toolbar on a side of the frame window that allows docking.

wangyugood 2001-07-21
  • 打赏
  • 举报
回复
比如在窗口右侧,垂直显示。
请高手指教!
prog_st 2001-07-21
  • 打赏
  • 举报
回复
什么位置????????????????????何种方式?????????????????????????
知道上两个条件,才知如何解决!
Matrix_w 2001-07-21
  • 打赏
  • 举报
回复
还可以用
CToolBarCtrl &m_ctrBar=m_yourToolBar.GetToolBarCtrl();
然后按楼下设置各种属性
leafdown 2001-07-21
  • 打赏
  • 举报
回复
不过刚才说的仅仅是工具条
leafdown 2001-07-21
  • 打赏
  • 举报
回复
你试试CRebar类,很方便的可以实现
Matrix_w 2001-07-21
  • 打赏
  • 举报
回复
在MainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 中加入
m_yourToolBar.EnableDocking(~~~~~);
EnableDocking(~~~~~);

//其中~~~~~ 为 CBRS_ALIGN_ANY 则为随意docking
// 为 CBRS_ALIGN_TOP 则为上面
//其它形式如楼上说。。。。
DockControlBar(&m_yourToolBar);
wangyugood 2001-07-21
  • 打赏
  • 举报
回复
能再具体点么?

16,551

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧