Click here to Skip to main content
15,895,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!
I can't change size of my rows in this CListCtrl:
C++
class CResolutionListCtrl : public CMFCListCtrl


That's a method that I realize in class, according different tutorials:

C++
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);



C++
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW,OnCustomDraw)
ON_MESSAGE(WM_SETFONT, OnSetFont)
ON_WM_MEASUREITEM_REFLECT()
ON_WM_MEASUREITEM()



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
Posted

1 solution

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.
 
Share this answer
 
Comments
thomas_wingfield 26-Jun-13 10:01am    
Hello nv3)
Thanks for replaying. I will try right now

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900