CListCtrl and WM_MEASUREITEM

I have an ownerdraw CListCtrl. I have drawn vertical and horizontal grids, and would like to make the items a bit bigger in height.
I have tried Serge's OnNotify, and do not seem to see the WM_MEASUREITEM message. I have tried OnChildNotify and dont see the DrawItem messages any more. Has anybody tried successfully.
tonysimmondsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mbhaktaCommented:
If you are looking for some ready made answer to your question try the following URL : http://www.visualc.com/Library/Downloads/MFC/You will find a freebee CListCtrl based grid control class written by Paul Gerhert. I haven't tried it myself but have heard qquite a lot from some people about this site.
0
tonysimmondsAuthor Commented:
Dear mbhakta,

Thanks for replying to me. I had already looked at the CListCtrl
from Paul Gerhert. It illustrates grid lines, and full line select using LVS_OWNERDRAWFIXED, but does not change the item height.

Regards
Tony
0
gelbertCommented:
Use CWnd::OnMeasureItem( int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct );

The framework calls this member function by the framework for the owner of an owner-draw list box when the control is created.

Override this member function and fill in the MEASUREITEMSTRUCT data structure pointed to by lpMeasureItemStruct and return; this informs Windows of the dimensions of the control and allows Windows to process user interaction with the control correctly.

If a list box  is created with the LBS_OWNERDRAWVARIABLE style, the framework calls this function for the owner for each item in the control; otherwise this function is called once.

Windows initiates the call to OnMeasureItem for the owner of list boxes created with the OWNERDRAWFIXED style before sending the WM_INITDIALOG message. As a result, when the owner receives this call, Windows has not yet determined the height and width of the font used in the control; function calls and calculations that require these values should occur in the main function of the application or library.

Override the MeasureItem member function of the appropriate control's class to calculate and set the size of each item.

OnMeasureItem will be called only if the control's class is created at run time, or it is created with the LBS_OWNERDRAWVARIABLEstyle. 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.

Note   This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

tonysimmondsAuthor Commented:
Dear Gelbert,

Thanks for replying, but I am using a ListView (CListCtrl), and not a listbox. I have tried the OnMeasureItem, and it does not appear to be called for the CListCtrl.

Regards
Tony
0
jabaCommented:
Did you set up style OwnerDrawVariable to this control ?
0
gelbertCommented:
Hi Tony Simmonds!

Have you tried to use LBS_OWNERDRAWVARIABLE and change rcItem of  DRAWITEMSTRUCT for specific items to force it to new size in OnDraw().

BTW. I am surprised that OnMeasureItem is not called! It is function of CWnd which is base class of CListView. Are you sure that you are right?
   
0
tonysimmondsAuthor Commented:
Dear Jaba and Gelbert,

I have created the CListCtrl with LVS_OWNERDRAWFIXED. I would not think the style LBS_OWNERDRAWVARIABLE would work with a ListView
control. I am not using CListView or CListBox, but CListCtrl, and I cannot see a LVS_OWNERDRAWVARIABLE in any of the include files anywhere.

Regards
Tony
0
cnasarreCommented:
Take a look at :   http://www.dsp.net/zafir/listview/change_row_height.htmlAll is explained
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tonysimmondsAuthor Commented:
Dear cnasaare,
Thanks a lot. It did just the trick I needed.

Regards
Tony
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
System Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.