资源描述:
《重载listctrl列头,列头皮肤》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、重载listctrl头,可惜换列头皮肤#pragmaonce#include"RSHeaderCtrl.h"//CRSListCtrlclassCRSListCtrl:publicCListCtrl{DECLARE_DYNAMIC(CRSListCtrl)public:CRSListCtrl();virtual~CRSListCtrl();protected:CFontm_fontText;CRSHeaderCtrlm_wndHeaderCtrl;protected:DECLARE_MESSAGE_MAP()voidInitHeader();voidRSRecta
2、ngle(HDChDC,intleft,inttop,intright,intbottom);virtualBOOLPreCreateWindow(CREATESTRUCT&cs);public:afx_msgvoidOnPaint();afx_msgBOOLOnEraseBkgnd(CDCpDC);afx_msgvoidDrawItem(LPDRAWITEMSTRUCTlpDrawItemStruct);afx_msgvoidMeasureItem(LPMEASUREITEMSTRUCTlpMeasureItemStruct);afx_msgintOnCreat
3、e(LPCREATESTRUCTlpCreateStruct);afx_msgvoidOnDestroy();afx_msgLRESULTOnInsertColumn(WPARAMwParam,LPARAMlParam);};//RSListCtrl.cpp:实现文件//#include"stdafx.h"#include"Rising.h"#include"RSListCtrl.h"#include".rslistctrl.h"//CRSListCtrlIMPLEMENT_DYNAMIC(CRSListCtrl,CListCtrl)CRSListCtrl::C
4、RSListCtrl(){}CRSListCtrl::~CRSListCtrl(){}BEGIN_MESSAGE_MAP(CRSListCtrl,CListCtrl)ON_WM_PAINT()ON_WM_ERASEBKGND()ON_WM_DRAWITEM_REFLECT()ON_WM_MEASUREITEM_REFLECT()ON_WM_CREATE()ON_WM_DESTROY()ON_MESSAGE(LVM_INSERTCOLUMN,OnInsertColumn)END_MESSAGE_MAP()//CRSListCtrl消息处理程序BOOLCRSListC
5、trl::PreCreateWindow(CREATESTRUCT&cs){cs.style=LVS_OWNERDRAWFIXED;returnCListCtrl::PreCreateWindow(cs);}voidCRSListCtrl::RSRectangle(HDChDC,intleft,inttop,intright,intbottom){POINTptOrg,ptTmp;right=max(0,right-1);bottom=max(0,bottom-1);二MoveToEx(hDC,left,top,&ptOrg);二LineTo(hDC,left,b
6、ottom);二MoveToEx(hDC,left,bottom,&ptTmp);二LineTo(hDC,right,bottom);二MoveToEx(hDC,right,bottom,&ptTmp);::LineTo(hDC,right,top);二MoveToEx(hDC,right,top,&ptTmp);二LineTo(hDC,left,top);二MoveToEx(hDC,ptOrg.x,ptOrg.y,&ptTmp);}voidCRSListCtrl::OnPaint(){PAINTSTRUCTps;HDChDC=NULL;HDChDCMem=NUL
7、L;HBITMAPhBMP=NULL;HBITMAPhOldBitmap=NULL;HPENhPen=NULL;HPENhOldPen=NULL;CRectrectClient;HRGNhRgn=NULL;GetClientRect(&rectClient);InitHeader();//donothing,onlyvalidatetheclipregion.hDC=::BeginPaint(m_hWnd,&ps);二EndPaint(m_hWnd,&ps);//realdrawhDC=::GetDC(m_hWnd);hDCMem=::CreateCompatib
8、leDC(