如何在CListCtrl中更改行的高度? [英] How can I change height of rows in CListCtrl?
问题描述
您好!
我无法在此CListCtrl中更改行的大小:
Hello!
I can't change size of my rows in this CListCtrl:
class CResolutionListCtrl : public CMFCListCtrl
这是一个我在课堂上实现的方法,根据不同的教程:
That's a method that I realize in class, according different tutorials:
afx_msg void MeasureItem ( LPMEASUREITEMSTRUCT lpMeasureItemStruct );
virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
afx_msg void OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult);
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW,OnCustomDraw)
ON_MESSAGE(WM_SETFONT, OnSetFont)
ON_WM_MEASUREITEM_REFLECT()
ON_WM_MEASUREITEM()
我无法以任何方式改变身高:
甚至这个非常受欢迎的教程
改变所有者绘制的控件中的行高 [ ^ ]
实际上我的OnMeasureItem和MeasureItem从不打电话。我已经尝试过改变不同的标志,例如:
所有者Draw等
请提供一些简单的例子来改变单元格的大小,因为我找到的所有东西都非常多编码或不工作。
非常感谢
I can't change height in any ways:
even with this very popular tutorial
Changing Row Height in an owner drawn Control[^]
And actually my OnMeasureItem and MeasureItem never call. I've already tried change different flags like:
owner Draw etc.
Please provide some simple example to change size of cell, because everything that I found is really a lot of coding or doesn't work.
Thank you a lot
推荐答案
如果你的OnMearureItem至少没有被调用一次,那就是一个指示该控件不是所有者绘制控件。您可能希望使用Spy ++来检查它。
也许MSDN文档中的以下代码段可以帮助您找到原因:
仅当控件的类在运行时创建,或者使用LBS_OWNERDRAWVARIABLE或CBS_OWNERDRAWVARIABLE样式创建时,才会调用OnMeasureItem。如果控件是由对话框编辑器创建的,则不会调用OnMeasureItem。这是因为WM_MEASUREITEM消息是在控件的创建过程的早期发送的。如果使用DDX_Control,SubclassDlgItem或SubclassWindow进行子类化,则子类化通常在创建过程之后进行。因此,无法在控件的OnChildNotify函数中处理WM_MEASUREITEM消息,这是MFC用于实现ON_WM_MEASUREITEM_REFLECT的机制。
有关更多信息,请参阅http://msdn.microsoft.com/en-us/library/z8wwd4x6%28v= vs.80%29.aspx [ ^ ]
希望能解决您的问题。
If your OnMearureItem is not called at least once that is an indication that the control is not an owner-draw control. You might want to use Spy++ to check that.
Perhaps the following snippet from the MSDN documentation will help you find the reason for that:
OnMeasureItem will be called only if the control's class is created at run time, or it is created with the LBS_OWNERDRAWVARIABLE or CBS_OWNERDRAWVARIABLE style. If the control is created by the dialog editor, OnMeasureItem will not be called. This is because the WM_MEASUREITEM message is sent early in the creation process of the control. If you subclass by using DDX_Control, SubclassDlgItem, or SubclassWindow, the subclassing usually occurs after the creation process. Therefore, there is no way to handle the WM_MEASUREITEM message in the control's OnChildNotify function, which is the mechanism MFC uses to implement ON_WM_MEASUREITEM_REFLECT.
For more see http://msdn.microsoft.com/en-us/library/z8wwd4x6%28v=vs.80%29.aspx[^]
Hope that solves your problem.
这篇关于如何在CListCtrl中更改行的高度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!