Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ MFC
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()
 

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 26-Jun-13 4:10am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
thomas_wingfield at 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)



Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 26 Jun 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100