OnMeasureItem与MeasureItem的区别

来源:互联网 发布:录音播放软件 编辑:程序博客网 时间:2024/05/07 06:07

重绘listbox时遇到的问题,开始在OnMeasureItem里做的操作,结果挂了。。。在MeasureItem里OK。
CSDN上达人的解释。。。清楚了。

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.

另一个的解释是OnMeasureItem是响应子控件的WM_MEASUREITEM消息的,MeasureItem是响应反射的自己发送的WM_MEASUREITEM消息的。


上面貌似是MSDN上的...