资源简介
MFC tabctrl控件重载, 实现标签加载BMP图片, 美化标签. 花了很多积分,现在免费给好学者参考,不容易啊!

代码片段和文件信息
// baseTabCtrl.cpp : implementation file
//
#include “stdafx.h“
#include “baseTabCtrl.h“
#include “.\basetabctrl.h“
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CbaseTabCtrl
CbaseTabCtrl::CbaseTabCtrl(int nType)
{
m_crBack = (COLORREF)-1; // use default color
m_nDrawType = BTC_NONE;
m_bImg=false;
m_nCstrMaxLen=18;
EnableDraw(nType);
}
CbaseTabCtrl::~CbaseTabCtrl()
{
}
BEGIN_MESSAGE_MAP(CbaseTabCtrl CTabCtrl)
//{{AFX_MSG_MAP(CbaseTabCtrl)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
// ON_WM_ERASEBKGND()
ON_WM_PAINT()
ON_WM_LBUTTONDBLCLK()
ON_WM_MOUSEMOVE()
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CbaseTabCtrl message handlers
void CbaseTabCtrl::SetBkgndColor(COLORREF color)
{
// set new color
m_crBack = color;
// redraw
if (GetSafeHwnd())
UpdateWindow();
}
void CbaseTabCtrl::Inistyle(int imgSelIDint imgIDint imgInfID)
{
Modifystyle(0 TCS_OWNERDRAWFIXED);
m_ImgSel.LoadBitmap(imgSelID);
m_Img.LoadBitmap(imgID);
m_ImgInf.LoadBitmap(imgInfID);
m_bImg=true;
m_nDrawType=2;
UpdateWindow();
}
void CbaseTabCtrl::Refash()
{
CRect rClient;
GetClientRect(rClient);
rClient.bottom=25;rClient.left=rClient.right-60;
InvalidateRect(rClientfalse);
//UpdateWindow();
}
BOOL CbaseTabCtrl::EnableDraw(int nType)
{
ASSERT (nType >= BTC_NONE && nType <= BTC_ALL);
if (nType < BTC_NONE || nType > BTC_ALL)
return FALSE;
m_nDrawType = nType;
if (GetSafeHwnd())
{
if (m_nDrawType != BTC_NONE)
Modifystyle(0 TCS_OWNERDRAWFIXED);
else
Modifystyle(TCS_OWNERDRAWFIXED 0);
UpdateWindow();
}
return TRUE;
}
void CbaseTabCtrl::DrawTabItem(CDC* pDC int ixItem const CRect& rcItemC BOOL uiFlags)
{
TC_ITEM tci; CString sText;
tci.mask =TCIF_TEXT | TCIF_IMAGE;
tci.pszText =sText.GetBuffer(128);
tci.cchTextMax=30;
GetItem(ixItem&tci);
sText.ReleaseBuffer();
BOOL bSel = uiFlags;
// BOOL bBottom=(uiFlags&8)?TRUE:FALSE;
CRect rcItem=rcItemC;
// if(bSel) rcItem.bottom -= 1;
// else rcItem.bottom += 2;
///////////////////////////////////////////////
CDC tempDC;
CBitmap *m_bitmap; BITMAP bm;
tempDC.CreateCompatibleDC(pDC);
//printf( “%d\n“ bSel );
if(bSel)
{
if(GetItemState(ixItemTCIS_HIGHLIGHTED)==TCIS_HIGHLIGHTED)
{
m_bitmap=&m_ImgInf;
//printf( “have information\n“ );
}
else
{
m_bitmap=&m_Img;
//printf( “normal\n“ );
}
}
else
{
m_bitmap=&m_ImgSel;//selected
//HighlightItem(ixItemfalse);
}
m_bitmap->GetBitmap( &bm );
tempDC.Selectobject(*m_bitmap);
pDC->StretchBlt(rcItem.leftrcItem.toprcItem.Width()rcItem.Height()&tempDC00bm.bmWidthbm.bmHeightSRCCOPY);
//////////////
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 6635 2012-05-31 16:53 tabcontrol_demo vs2010\tabcontrol_demo1\ba
文件 2231 2012-05-31 16:45 tabcontrol_demo vs2010\tabcontrol_demo1\ba
文件 7425 2002-07-01 10:32 tabcontrol_demo vs2010\tabcontrol_demo1\EnTabCtrl.cpp
文件 2089 2012-05-31 15:12 tabcontrol_demo vs2010\tabcontrol_demo1\EnTabCtrl.h
文件 3651 2001-12-01 11:03 tabcontrol_demo vs2010\tabcontrol_demo1\ReadMe.txt
文件 5494 2012-05-31 15:17 tabcontrol_demo vs2010\tabcontrol_demo1\res\bitmap_i.bmp
文件 5494 2012-05-31 15:17 tabcontrol_demo vs2010\tabcontrol_demo1\res\ss.bmp
文件 5494 2012-05-31 15:18 tabcontrol_demo vs2010\tabcontrol_demo1\res\ssSel.bmp
文件 1078 2012-05-31 15:54 tabcontrol_demo vs2010\tabcontrol_demo1\res\TabControl.ico
文件 402 2001-12-01 11:03 tabcontrol_demo vs2010\tabcontrol_demo1\res\TabControl.rc2
..A.SH. 16896 2012-05-31 15:54 tabcontrol_demo vs2010\tabcontrol_demo1\res\Thumbs.db
文件 1078 2002-07-01 10:27 tabcontrol_demo vs2010\tabcontrol_demo1\res\Toolbar.bmp
文件 1274 2012-05-31 15:54 tabcontrol_demo vs2010\tabcontrol_demo1\resource.h
文件 212 2001-12-01 11:03 tabcontrol_demo vs2010\tabcontrol_demo1\StdAfx.cpp
文件 999 2001-12-01 11:03 tabcontrol_demo vs2010\tabcontrol_demo1\StdAfx.h
文件 56280 2012-05-31 15:54 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.aps
文件 1553 2002-02-01 11:47 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.clw
文件 2086 2001-12-01 11:03 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.cpp
文件 4599 2002-07-01 10:38 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.dsp
文件 765 2002-07-01 10:38 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.dsw
文件 1368 2001-12-01 11:03 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.h
文件 6548 2012-05-31 15:54 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.rc
文件 886 2015-01-11 01:38 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.sln
..A..H. 15872 2015-01-11 01:39 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.suo
..A..H. 9216 2005-12-20 16:44 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.suo.old
文件 7933 2012-05-31 15:17 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.vcproj
文件 1427 2012-05-31 16:53 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.vcproj.T37JKQGEELZP0X9.Administrator.user
文件 8070 2015-01-11 01:37 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.vcxproj
文件 2421 2015-01-11 01:37 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.vcxproj.filters
文件 143 2015-01-11 01:37 tabcontrol_demo vs2010\tabcontrol_demo1\TabControl.vcxproj.user
............此处省略10个文件信息
相关资源
- 基于MFC的TCP调试助手源码95706
- 基于mfc的多线程文件传输
- MFC数字钟(基于VC6.0)
- VC++MFC小游戏实例教程(实例)+MFC类库
- ChartCtrl控件库(可在VS2019中使用)
- 商品库存管理系统 C++ MFC
- mfc 调用redis
- MFC视频播放器源码(支持avi/wma/mp3等格
- mfc绘图大全(画直线、矩形、椭圆)
- MFC控件重绘
- hook,捕获所有案件,查找所有窗口,
- (学习)VS2010之MFC入门到精通教程
- MFC文档_视图_框架_模板结构体系深入
- 简单员工管理系统(适合初学MFC)
- MFC五子棋游戏
- MFC UDP编程
- MFC的异步网络通讯应用程序
- C++MFC模块讲解,黑发程序员课程整理
- 一个简单而强大的基于MFC的web server源
- 基于MFC的VC++仿QQ浏览器源码(雏形)
- MFCaccess.rar
- VC++MFC课程设计的学生成绩管理系统
- MFC 日历控件 万年历 Calendar自绘
- CrystalDiskInfo-HDD/SSD硬盘信息,SMART信息
- MFC自定义界面HUI,高效简单,含详细
- 仿射密码-Affine cipher
- c++MFC车牌自动识别定位,只能定位和
- mfc+sql 酒店客房管理系统
- 基于图割的图像分割OpenCV+MFC实现
- MFC绘制Bezier曲线B样条曲线曲线拟合
评论
共有 条评论