Solved

CListCtrl and WM_MEASUREITEM

Posted on 1997-08-06
9
1,999 Views
Last Modified: 2013-11-19
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.
0
Comment
Question by:tonysimmonds
9 Comments
 
LVL 4

Expert Comment

by:mbhakta
ID: 1303185
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
 

Author Comment

by:tonysimmonds
ID: 1303186
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
 
LVL 8

Expert Comment

by:gelbert
ID: 1303187
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
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 

Author Comment

by:tonysimmonds
ID: 1303188
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
 
LVL 3

Expert Comment

by:jaba
ID: 1303189
Did you set up style OwnerDrawVariable to this control ?
0
 
LVL 8

Expert Comment

by:gelbert
ID: 1303190
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
 

Author Comment

by:tonysimmonds
ID: 1303191
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
 
LVL 1

Accepted Solution

by:
cnasarre earned 50 total points
ID: 1303192
Take a look at :   http://www.dsp.net/zafir/listview/change_row_height.htmlAll is explained
0
 

Author Comment

by:tonysimmonds
ID: 1303193
Dear cnasaare,
Thanks a lot. It did just the trick I needed.

Regards
Tony
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question