[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

CListCtrl and WM_MEASUREITEM

Posted on 1997-08-06
9
Medium Priority
?
2,144 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 200 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

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

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

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 …
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

650 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