本文介绍了具有报表样式的CListCtrl中的多行文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有CListCtrl类型的报告.
我需要在其中输入多行文字.
I have CListCtrl type report.
I need to write into it''s items multiline text.
How can i achieve this?
推荐答案
class CYourCtrl : public CListCtrl
{
public:
CYourCtrl();
virtual ~CYourCtrl();
protected:
//{{AFX_MSG(CYourCtrl)
virtual void DrawItem (LPDRAWITEMSTRUCT);
afx_msg void MeasureItem (LPMEASUREITEMSTRUCT);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
...
BEGIN_MESSAGE_MAP(CYourCtrl, CListCtrl)
ON_WM_MEASUREITEM_REFLECT()
END_MESSAGE_MAP()
//
void CYourCtrl::MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct)
{
if (lpMeasureItemStruct) {
lpMeasureItemStruct->itemHeight = ...; // set your hight here
}
}
请记住设置LVS_OWNERDRAWFIXED
在创建控件或在.rc
文件中时:)
Please remember to set the LVS_OWNERDRAWFIXED
at creating of your control or in your .rc
file :)
void CYourCtrl::DrawItem(LPDRAWITEMSTRUCT pDIS)
{
if (pDIS) {
// the first step
if (ODA_DRAWENTIRE == pDIS->itemAction) {
// Draw your content here
}
// there are other cases too :)
}
}
这篇关于具有报表样式的CListCtrl中的多行文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!