/******************************************************************************\
* file : ListCtrl.h
* created: 1997.09.22
*
* description:
* Implements a CListCtrl which can mark full rows.
\******************************************************************************/
#ifndef _CLISTCTRLH_H_
#define _CLISTCTRLH_H_
#include "TitleTip.h"
#include "HeaderCtrlEx.h"
#define LVNU_SELCHANGED 0x1000
/**
* A super CListControl.
*
features:
*
* - Title Tip item expantion
*
- full row selection
*
- notifies parent selection has changed
*
-
*
*/
class CListCtrlH : public CListCtrl
{
typedef CListCtrl inherited;
DECLARE_DYNCREATE(CListCtrlH)
// Construction
public:
CListCtrlH();
virtual ~CListCtrlH();
// Attributes
protected:
BOOL m_bFullRowSel;
BOOL m_bClientWidthSel;
bool bShowLine;
int nFontHeight;
COLORREF nTxtColor;
CHeaderCtrlEx m_header;
public:
BOOL SetFullRowSel(BOOL bFillRowSel);
BOOL GetFullRowSel();
void ShowLineBk( bool bShow )
{
bShowLine = bShow;
};
void SetTxtColor( COLORREF cr )
{
nTxtColor = cr;
}
void SetFontHeight( int nNewFontHeight )
{
nFontHeight = nNewFontHeight;
/*
CFont *pOldFont = NULL;
CFont font;
if( nFontHeight != -1 )
{
CFont* ptf = GetFont(); // 得到原来的字体
LOGFONT lf;
ptf->GetLogFont(&lf);
lf.lfHeight = nFontHeight; // 改变字体高度
CDC* pDC = GetDC();
font.CreateFontIndirect(&lf);
pOldFont = (CFont *)pDC->SelectObject(&font);
font.DeleteObject();
ReleaseDC( pDC );
}
//*/
CRect rc;
GetWindowRect( &rc );
WINDOWPOS wp;
wp.hwnd = m_hWnd;
wp.cx = rc.Width();
wp.cy = rc.Height();
wp.flags = SWP_SHOWWINDOW | SWP_NOMOVE | SWP_NOOWNERZORDER | SWP_NOZORDER;
SendMessage( WM_WINDOWPOSCHANGED, 0, (LPARAM)&wp );
};
// Overrides
protected:
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CListCtrlH)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void PreSubclassWindow();
//}}AFX_VIRTUAL
// Implementation
public:
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
void RepaintSelectedItems();
// Implementation - list view colors
COLORREF m_clrText;
COLORREF m_clrTextBk;
COLORREF m_clrBkgnd;
CTitleTip m_titletip;
afx_msg LRESULT OnSetTextColor(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetTextBkColor(WPARAM wParam, LPARAM lParam);
afx_msg LRESULT OnSetBkColor(WPARAM wParam, LPARAM lParam);
bool HitTestRowCol(CPoint& point, int& iRow, int& iColumn)const;
CRect GetCellRect(int iRow, int iColumn)const;
int GetTrueColumnWidth(int nCurrentPosition)const;
CString GetTrueItemText(int row, int col)const;
void HideTitleTip();
void SendSelChangedNotification();
void ShowTitleTip(CPoint point);
// Generated message map functions
protected:
//{{AFX_MSG(CListCtrlH)
afx_msg void OnPaint();
afx_msg void OnSetFocus(CWnd* pOldWnd);
afx_msg void OnKillFocus(CWnd* pNewWnd);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnDestroy();
afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
afx_msg void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
#endif