⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 texttoolbar.cpp

📁 这是本人两年前兼职为某个公司做的石油钻进设计软件
💻 CPP
字号:
// TextToolBar.cpp: implementation of the CTextToolBar class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "cvenus.h"
#include "TextToolBar.h"

#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTextToolBar::CTextToolBar()
{

}

CTextToolBar::~CTextToolBar()
{

}

BOOL CTextToolBar::LoadToolBar(const int lpszResourceName)
{
	BOOL bReturn = CToolBar::LoadToolBar(lpszResourceName);

	// Check if we loaded the toolbar.
	if (bReturn == FALSE)
		return bReturn;

	// Make it flat.
	ModifyStyle(0, GetStyle()|TBSTYLE_FLAT);

	// Set the text for each button
	CToolBarCtrl& bar = GetToolBarCtrl();


	// Remove the string map in case we are loading another toolbar into this control
	if (m_pStringMap)
	{
		delete m_pStringMap;
		m_pStringMap = NULL;
	}

	int		nIndex = 0;
	TBBUTTON	tb;

	for (nIndex = bar.GetButtonCount() - 1; nIndex >= 0; nIndex--)
	{
		ZeroMemory(&tb, sizeof(TBBUTTON));
		bar.GetButton(nIndex, &tb);

		// Do we have a separator?
		if ((tb.fsStyle & TBSTYLE_SEP) ==  TBSTYLE_SEP)
			continue;

		// Have we got a valid command id?
		if (tb.idCommand == 0)
			continue;

		// Get the resource string if there is one.
		CString strText;
		LPCTSTR lpszButtonText = NULL;
		CString	strButtonText(_T(""));
		_TCHAR	seps[] = _T("\n");

		strText.LoadString(tb.idCommand);

		if (!strText.IsEmpty())
		{
			lpszButtonText = _tcstok((LPTSTR)(LPCTSTR)strText, seps);

			while(lpszButtonText)
			{
				strButtonText = lpszButtonText;
				lpszButtonText = _tcstok(NULL, seps);
			}
		}

		if (!strButtonText.IsEmpty())
			SetButtonText(nIndex, strButtonText);
	}

	// Resize the buttons so that the text will fit.
	CRect rc(0, 0, 0, 0);
	CSize sizeMax(0, 0);

	for (nIndex = bar.GetButtonCount() - 1; nIndex >= 0; nIndex--)
	{
		bar.GetItemRect(nIndex, rc);

		rc.NormalizeRect();
		sizeMax.cx = __max(rc.Size().cx, sizeMax.cx);
		sizeMax.cy = __max(rc.Size().cy, sizeMax.cy);
	}
	SetSizes(sizeMax, CSize(16,16));

	return bReturn;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -