图标栏有2行或2列 [英] icon bar with 2 lines or 2 columns

查看:77
本文介绍了图标栏有2行或2列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好

我想知道是否有办法将我的CMFCToolBar与定义的行数或列?

I would like to know if there is a way to dock my CMFCToolBar with a defined number of lines or columns ?

一些用户个性化图标工具栏 有很多图标,想把它放在2行(或列)上。

some users personalizes icon tool bar  with lot of icons and want to put it on 2 lines (or columns).

有人已经这样做了吗?

谢谢

推荐答案

Hi Yan,

Hi Yan,

感谢您在此发帖。

因为您使用  CMFCToolBar类, 您可以尝试使用   CMFCToolBar :: AdjustLayout    CMFCToolBar :: CalcFixedLayout  方法
调整布局。

Since you are using the CMFCToolBar class,  You can try to use  the CMFCToolBar::AdjustLayout and CMFCToolBar::CalcFixedLayout methods to adjust layout.

如果你有空闲时间,下面是关于设置CToolBar布局

If you have free time, the below is about setting  CToolBar layout

您可以使用
CalcDynamicLayout
功能设置CToolBar布局。

You can use the CalcDynamicLayout function to set the CToolBar layout.

您需要从CToolBar派生一个类,您创建一个样式为

You need to derive a class from CToolBar, You create a toolbar with the style

CBRS_SIZE_DYNAMIC的工具栏。

CBRS_SIZE_DYNAMIC.

在派生类中,您需要覆盖虚函数CalcDynamicLayout()。当需要知道工具栏大小时,MFC将调用此函数。

In your derived class, you need to override the virtual function CalcDynamicLayout(). This function is called by MFC when it needs to know the toolbar size.

当工具栏大小应反映到主框架窗口的顶部或底部时,标志nMode将包含LM_HORZDOCK。

The flag nMode will contain LM_HORZDOCK when the toolbar size should reflect docking to the top or bottom of the main frame window.

同样,当对接到主框架的左侧或右侧时,nMode包含LM_VERTDOCK。 

Similarly, nMode contains LM_VERTDOCK when docking to the left or right of the main frame. 

如果你想设置固定布局,你需要覆盖函数:

if you want to set the fixed layout, you need to override the function:

CSize CToolBarEMRL::CalcDynamicLayout (int nLength, DWORD nMode)
{
   if (m_bKeepSizeWhenDocked && (nMode & LM_VERTDOCK)) {
      return CToolBar::CalcDynamicLayout(nLength,
                            (nMode & ~LM_VERTDOCK) | (LM_MRUWIDTH));
   }
   else
   {
      return CToolBar::CalcDynamicLayout(nLength, nMode);
   }
}




如果您的工具栏只保留其"浮动"状态,当它们停靠在主框架窗口的

If your toolbars only keep their "floating" size when they are docked to the left or right side of

的左侧或右侧时的大小。如果工具栏停靠在顶部或底部,则工具栏将变为单行。

the main frame window. The toolbar becomes a single row if it is docked to the top or bottom.

如果您希望工具栏在任何一侧保持其大小,您只需更改上面的"if"

If you want a toolbar to keep its size on any side, you just need to change the above 'if'

声明:

if (m_bKeepSizeWhenDocked && ((nMode & LM_VERTDOCK) ||
                              (nMode & LM_HORZDOCK))) 
{
    return CToolBar::CalcDynamicLayout(nLength,
                            (nMode & ~(LM_VERTDOCK | LM_HORZDOCK)) |
                            (LM_MRUWIDTH));
}

最佳 此致,

Best  Regards,

Hart


这篇关于图标栏有2行或2列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆