【VC开源代码栏目提醒】:文章导读:在新的一年中,各位网友都进入紧张的学习或是工作阶段。网学会员整理了VC开源代码-CustomTree.cpp的相关内容供大家参考,祝大家在新的一年里工作和学习顺利!
// CustomTree.cpp : implementation file
//
#include "stdafx.h"
#include "BmpBKTree.h"
#include "CustomTree.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CCustomTree
CCustomTree::CCustomTree()
{
m_Bitmap.LoadBitmap(IDB_BITMAP1);
}
CCustomTree::~CCustomTree()
{
}
BEGIN_MESSAGE_MAP(CCustomTree, CTreeCtrl)
//{{AFX_MSG_MAP(CCustomTree)
ON_WM_PAINT()
ON_NOTIFY_REFLECT(TVN_ITEMEXPANDING, OnItemexpanding)
ON_NOTIFY_REFLECT(TVN_ITEMEXPANDED, OnItemexpanded)
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CCustomTree message handlers
void CCustomTree::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
CRect rect;
GetClientRect(&rect);
CDC memdc;
memdc.CreateCompatibleDC(&dc);
CBitmap bitmap;
bitmap.CreateCompatibleBitmap(&dc, rect.Width(), rect.Height());
memdc.SelectObject( &bitmap );
//获取原始画布
CWnd::DefWindowProc(WM_PAINT, (WPARAM)memdc.m_hDC , 0);
//绘制背景图片
CMemDC tempDC( &dc,rect);
CBrush brush;
brush.CreatePatternBrush(&m_Bitmap);
tempDC.FillRect(rect, &brush);
//将原始图片与背景进行组合
tempDC.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(),
&memdc, rect.left, rect.top,SRCAND);
brush.DeleteObject();
// Do not call CTreeCtrl::OnPaint() for painting messages
}
void CCustomTree::OnItemexpanding(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
SetRedraw(FALSE);
*pResult = 0;
}
void CCustomTree::OnItemexpanded(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_TREEVIEW* pNMTreeView = (NM_TREEVIEW*)pNMHDR;
// TODO: Add your control notification handler code here
SetRedraw();
*pResult = 0;
}
BOOL CCustomTree::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
return TRUE;
//return CTreeCtrl::OnEraseBkgnd(pDC);
}
上一篇:
CustomToolBar.cpp
下一篇:
车智汇提醒您:开车请不要低头玩手机