Solved

CListCtrl and WM_MEASUREITEM

Posted on 1997-08-06
9
1,948 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
 

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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now