📄 standardbar.cpp
字号:
// standardBar.cpp : implementation file
//
#include "stdafx.h"
#include "HKGL.h"
#include "standardBar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CstandardBar
CstandardBar::CstandardBar()
{
}
CstandardBar::~CstandardBar()
{
}
BEGIN_MESSAGE_MAP(CstandardBar, CToolBarCtrl)
//{{AFX_MSG_MAP(CstandardBar)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CstandardBar message handlers
BOOL CstandardBar::Create(DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
BOOL bRet = CToolBarCtrl::Create(dwStyle, rect, pParentWnd, nID);//记录基类的返回值
m_nButtonCount = IDSTR_EXIT - IDSTR_SPDJ + 1;
SetBitmapSize( CSize(32,32) );
VERIFY(AddBitmap(m_nButtonCount,IDR_STANDARDBAR) != -1);//添加位图
m_pTBButtons = new TBBUTTON[m_nButtonCount];//用来加入工具栏的按钮
for (int nIndex = 0; nIndex < m_nButtonCount; nIndex++)//循环设顶按钮的属性
{
CString string;
string.LoadString(nIndex + IDSTR_SPDJ);//装载字符串资源
//为每个字符串再加一个"\0" ,用于向工具栏里加字符串
// Add second '\0'
int nStringLength = string.GetLength() + 1;
TCHAR * pString = string.GetBufferSetLength(nStringLength);
pString[nStringLength] = 0;
pString[nStringLength-1] = 0;
VERIFY((m_pTBButtons[nIndex].iString = AddStrings(pString)) != -1);//返回字符串编号
string.ReleaseBuffer();
/* m_pTBButtons[nIndex].iString =AddString(IDSTR_XSDJ);
*/ m_pTBButtons[nIndex].fsState =TBSTATE_ENABLED;
m_pTBButtons[nIndex].fsStyle =TBSTYLE_FLAT;//TBSTYLE_CHECK ;TBSTYLE_BUTTON
m_pTBButtons[nIndex].dwData = 0;
m_pTBButtons[nIndex].iBitmap = nIndex;//控制按钮的相关图片
m_pTBButtons[nIndex].idCommand = nIndex + IDSTR_SPDJ;//用于命令消息传递
}
m_pTBButtons[m_nButtonCount-1].idCommand=IDCANCEL;//用来响应退出消息
TBBUTTON sepButton;//用于分割的按钮
sepButton.idCommand = 0;
sepButton.fsStyle = TBSTYLE_SEP;
sepButton.fsState = TBSTATE_ENABLED;
sepButton.iString = 0;
sepButton.iBitmap = 0;
sepButton.dwData = 0;
for (nIndex = 0; nIndex < m_nButtonCount; nIndex++)
{
VERIFY(AddButtons(1,&m_pTBButtons[nIndex]));//添加循环按钮
if (!((nIndex +1) % 3))
{
VERIFY(AddButtons(1,&sepButton));//3个为一组
}
}
this->SetStyle(TBSTYLE_FLAT|CCS_TOP);
return bRet;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -