|
|
|
|
// HeaderCtrlCl.cpp : ʵ<><CAB5><EFBFBD>ļ<EFBFBD>
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
// #include "DemoList.h"
|
|
|
|
|
#include "HeaderCtrlCl.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CHeaderCtrlCl
|
|
|
|
|
|
|
|
|
|
IMPLEMENT_DYNAMIC(CHeaderCtrlCl, CHeaderCtrl)
|
|
|
|
|
|
|
|
|
|
CHeaderCtrlCl::CHeaderCtrlCl()
|
|
|
|
|
: m_R(171)
|
|
|
|
|
, m_G(199)
|
|
|
|
|
, m_B(235)
|
|
|
|
|
, m_Gradient(8)
|
|
|
|
|
{
|
|
|
|
|
m_Format = "";
|
|
|
|
|
m_Height = 1;
|
|
|
|
|
m_fontHeight = 15;
|
|
|
|
|
m_fontWith = 0;
|
|
|
|
|
m_color = RGB(0,0,0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CHeaderCtrlCl::~CHeaderCtrlCl()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CHeaderCtrlCl, CHeaderCtrl)
|
|
|
|
|
ON_WM_PAINT()
|
|
|
|
|
ON_MESSAGE(HDM_LAYOUT, OnLayout)
|
|
|
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// CHeaderCtrlCl <20><>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void CHeaderCtrlCl::OnPaint()
|
|
|
|
|
{
|
|
|
|
|
CPaintDC dc(this); // device context for painting
|
|
|
|
|
// TODO: <20>ڴ˴<DAB4><CBB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
// <20><>Ϊ<EFBFBD><CEAA>ͼ<EFBFBD><CDBC>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD> CHeaderCtrl::OnPaint()
|
|
|
|
|
int nItem;
|
|
|
|
|
nItem = GetItemCount();//<2F>õ<EFBFBD><C3B5>м<EFBFBD><D0BC><EFBFBD><EFBFBD><EFBFBD>Ԫ
|
|
|
|
|
for(int i = 0; i<nItem;i ++)
|
|
|
|
|
{
|
|
|
|
|
CRect tRect;
|
|
|
|
|
GetItemRect(i,&tRect);//<2F>õ<EFBFBD>Item<65>ijߴ<C4B3>
|
|
|
|
|
int R = m_R,G = m_G,B = m_B;
|
|
|
|
|
CRect nRect(tRect);//<2F><><EFBFBD><EFBFBD><EFBFBD>ߴ絽<DFB4>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
nRect.left++;//<2F><><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>ߵĵط<C4B5>
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>屳<EFBFBD><E5B1B3>
|
|
|
|
|
for(int j = tRect.top;j<=tRect.bottom;j++)
|
|
|
|
|
{
|
|
|
|
|
nRect.bottom = nRect.top+1;
|
|
|
|
|
CBrush _brush;
|
|
|
|
|
_brush.CreateSolidBrush(RGB(R,G,B));//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ
|
|
|
|
|
dc.FillRect(&nRect,&_brush); //<2F><><EFBFBD>䱳<EFBFBD><E4B1B3>
|
|
|
|
|
_brush.DeleteObject(); //<2F>ͷŻ<CDB7>ˢ
|
|
|
|
|
R-=m_Gradient;G-=m_Gradient;B-=m_Gradient;
|
|
|
|
|
if (R<0)R = 0;
|
|
|
|
|
if (G<0)G = 0;
|
|
|
|
|
if (B<0)B= 0;
|
|
|
|
|
nRect.top = nRect.bottom;
|
|
|
|
|
}
|
|
|
|
|
dc.SetBkMode(TRANSPARENT);
|
|
|
|
|
CFont nFont ,* nOldFont;
|
|
|
|
|
//dc.SetTextColor(RGB(250,50,50));
|
|
|
|
|
dc.SetTextColor(m_color);
|
|
|
|
|
nFont.CreateFont(m_fontHeight,m_fontWith,0,0,0,FALSE,FALSE,0,0,0,0,0,0,_TEXT("<EFBFBD><EFBFBD><EFBFBD><EFBFBD>"));//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
nOldFont = dc.SelectObject(&nFont);
|
|
|
|
|
|
|
|
|
|
UINT nFormat = 1;
|
|
|
|
|
if (m_Format[i]=='0')
|
|
|
|
|
{
|
|
|
|
|
nFormat = DT_LEFT;
|
|
|
|
|
tRect.left+=3;
|
|
|
|
|
}
|
|
|
|
|
else if (m_Format[i]=='1')
|
|
|
|
|
{
|
|
|
|
|
nFormat = DT_CENTER;
|
|
|
|
|
}
|
|
|
|
|
else if (m_Format[i]=='2')
|
|
|
|
|
{
|
|
|
|
|
nFormat = DT_RIGHT;
|
|
|
|
|
tRect.right-=3;
|
|
|
|
|
}
|
|
|
|
|
TEXTMETRIC metric;
|
|
|
|
|
dc.GetTextMetrics(&metric);
|
|
|
|
|
int ofst = 0;
|
|
|
|
|
ofst = tRect.Height() - metric.tmHeight;
|
|
|
|
|
tRect.OffsetRect(0,ofst/2);
|
|
|
|
|
dc.DrawText(m_HChar[i],&tRect,nFormat);
|
|
|
|
|
dc.SelectObject(nOldFont);
|
|
|
|
|
nFont.DeleteObject(); //<2F>ͷ<EFBFBD><CDB7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
//<2F><>ͷ<EFBFBD><CDB7>ʣ<EFBFBD>ಿ<EFBFBD><E0B2BF>
|
|
|
|
|
CRect rtRect;
|
|
|
|
|
CRect clientRect;
|
|
|
|
|
GetItemRect(nItem - 1,rtRect);
|
|
|
|
|
GetClientRect(clientRect);
|
|
|
|
|
rtRect.left = rtRect.right+1;
|
|
|
|
|
rtRect.right = clientRect.right;
|
|
|
|
|
int R = m_R,G = m_G,B = m_B;
|
|
|
|
|
CRect nRect(rtRect);
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>屳<EFBFBD><E5B1B3>
|
|
|
|
|
for(int j = rtRect.top;j<=rtRect.bottom;j++)
|
|
|
|
|
{
|
|
|
|
|
nRect.bottom = nRect.top+1;
|
|
|
|
|
CBrush _brush;
|
|
|
|
|
_brush.CreateSolidBrush(RGB(R,G,B));//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ
|
|
|
|
|
dc.FillRect(&nRect,&_brush); //<2F><><EFBFBD>䱳<EFBFBD><E4B1B3>
|
|
|
|
|
_brush.DeleteObject(); //<2F>ͷŻ<CDB7>ˢ
|
|
|
|
|
R-=m_Gradient;G-=m_Gradient;B-=m_Gradient;
|
|
|
|
|
if (R<0)R = 0;
|
|
|
|
|
if (G<0)G = 0;
|
|
|
|
|
if (B<0)B= 0;
|
|
|
|
|
nRect.top = nRect.bottom;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
LRESULT CHeaderCtrlCl::OnLayout( WPARAM wParam, LPARAM lParam )
|
|
|
|
|
{
|
|
|
|
|
LRESULT lResult = CHeaderCtrl::DefWindowProc(HDM_LAYOUT, 0, lParam);
|
|
|
|
|
HD_LAYOUT &hdl = *( HD_LAYOUT * ) lParam;
|
|
|
|
|
RECT *prc = hdl.prc;
|
|
|
|
|
WINDOWPOS *pwpos = hdl.pwpos;
|
|
|
|
|
|
|
|
|
|
//<2F><>ͷ<EFBFBD>߶<EFBFBD>Ϊԭ<CEAA><D4AD>1.5<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD>̬<EFBFBD>ı<EFBFBD>ͷ<EFBFBD>߶ȵĻ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>1.5<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>ȫ<EFBFBD>ֱ<EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int nHeight = (int)(pwpos->cy * m_Height);
|
|
|
|
|
pwpos->cy = nHeight;
|
|
|
|
|
prc->top = nHeight;
|
|
|
|
|
return lResult;
|
|
|
|
|
}
|