mytoolbar.cpp
来自「一个画笔的程序,可以进行直线,圆和方形等图形进行画图,并可以撤消上一步的动作」· C++ 代码 · 共 103 行
CPP
103 行
// MyToolBar.cpp : implementation file
//
#include "stdafx.h"
#include "ZCR14Paint.h"
//#include "MyPaint.h"
#include "MyToolBar.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMyToolBar
CMyToolBar::CMyToolBar()
{
m_nColumns = 2;
m_rcBorder.top = 3;
m_rcBorder.bottom = 3;
m_rcBorder.left = 9;
m_rcBorder.right = 20;
}
CMyToolBar::~CMyToolBar()
{
}
BEGIN_MESSAGE_MAP(CMyToolBar, CToolBar)
//{{AFX_MSG_MAP(CMyToolBar)
ON_WM_NCPAINT()
ON_WM_PAINT()
ON_WM_LBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMyToolBar message handlers
void CMyToolBar::SetColumns(UINT nColumns)
{
SetBorders(m_rcBorder);
m_nColumns = nColumns;
int nCount = GetToolBarCtrl().GetButtonCount();
for(int i=0;i < nCount;i++)
{
UINT nStyle = GetButtonStyle(i);
BOOL bWrap = (((i+1)%nColumns)==0);
if(bWrap)
nStyle |= TBBS_WRAPPED;
else
nStyle &= ~TBBS_WRAPPED;
SetButtonStyle(i,nStyle);
}
GetParentFrame()->RecalcLayout();
}
void CMyToolBar::OnPaint()
{
CToolBar::OnPaint();
// TODO: Add your message handler code here
CWindowDC dc(this); // device context for painting
m_Option.Draw(&dc);
// Do not call CToolBar::OnPaint() for painting messages
}
void CMyToolBar::OnNcPaint()
{
// TODO: Add your message handler code here
SetColumns(2);
CControlBar::EraseNonClient();
CRect rect;
GetClientRect( &rect );
InvalidateRect( &rect, FALSE );
// Do not call CToolBar::OnNcPaint() for painting messages
}
void CMyToolBar::SetSelType(SELTYPE type)
{
m_Option.SetOptionType(type);
Invalidate();
}
void CMyToolBar::OnLButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
point.y += m_rcBorder.left;
if ( m_Option.PointToOption(point) )
Invalidate();
CToolBar::OnLButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?