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

📄 mytoolbar.cpp

📁 简单的画笔程序 完全由自己编写的
💻 CPP
字号:
// MyToolBar.cpp : implementation file
//

#include "stdafx.h"
#include "LY16paint.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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -