如何减少CMFCToolBar上2个按钮之间的空间? [英] How to reduce space between 2 buttons on a CMFCToolBar?
问题描述
工具栏是使用CreatEx()函数创建的CMFCToolBar。我想减少工具栏上2个按钮之间的空间,以便工具栏可以缩短以适应屏幕。你能告诉我如何减少工具栏按钮之间的空间吗?
提前谢谢。
我认为没有一种简单的方法可以做到这一点。查看源代码,按钮大小设置如下:
BOOL CMFCToolBar :: LoadToolBarEx(UINT uiToolbarResID,CMFCToolBarInfo& params ,BOOL bLocked)
{
[...]
CSize sizeImage(pData-> wWidth,pData-> wHeight);
CSize sizeButton(pData-> wWidth + AFX_TOOLBAR_BUTTON_MARGIN,pData-> wHeight + AFX_TOOLBAR_BUTTON_MARGIN);
[...]
SetSizes(sizeButton,sizeImage);
[...]
}AFX_TOOLBAR_BUTTON_MARGIN在C:\Program Files(x86)\ Microsoft Visual Studio中定义14.0\VC\atlmfc\src\mfc\afxtoolbar.cpp,如下所示:
$
#define AFX_TOOLBAR_BUTTON_MARGIN 6
所以你唯一的选择是覆盖虚函数CMFCToolBar :: LoadToolBarEx(),并从MFC复制代码并调整"sizeButton"的值 使用比AFX_TOOLBAR_BUTTON_MARGIN更小的值 。$
-Seetharam
The toolbars are CMFCToolBar created with CreatEx() function. I want to reduce the space between 2 buttons on the toolbars so that the toolbars can be shorter to fit on the screen. Could you please let me know how to reduce the space between toolbar buttons?
Thanks in advance.
I don't think there is an easy way to do this. Looking at the source code, the button sizes are set like this:
BOOL CMFCToolBar::LoadToolBarEx(UINT uiToolbarResID, CMFCToolBarInfo& params, BOOL bLocked) { [...] CSize sizeImage(pData->wWidth, pData->wHeight); CSize sizeButton(pData->wWidth + AFX_TOOLBAR_BUTTON_MARGIN, pData->wHeight + AFX_TOOLBAR_BUTTON_MARGIN); [...] SetSizes(sizeButton, sizeImage); [...] }AFX_TOOLBAR_BUTTON_MARGIN is defined in C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\atlmfc\src\mfc\afxtoolbar.cpp, like this:
#define AFX_TOOLBAR_BUTTON_MARGIN 6So your only option is to override the virtual function CMFCToolBar::LoadToolBarEx(), and copy the code from MFC and tweak the value of "sizeButton" by using a smaller value than AFX_TOOLBAR_BUTTON_MARGIN .
-Seetharam
这篇关于如何减少CMFCToolBar上2个按钮之间的空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!