Solved

WM_MEASUREITEM

Posted on 2004-09-27
9
896 Views
Last Modified: 2013-11-20
Hello:

   I am creating additional windows in my application where I first create a FrameWnd by calling CreateEx(...) which in turn creates a view by calling CreateView(...) and passes a CRuntimeClass pointer to a CView which in turn creates a CListCtrl who subclasses a CHeaderCtrl.  All of these a derived classes.  My problem is that OnMeasureItem is never being called for my CListCtrl and I don't know how to get it to be called.  I created the method for all of these classes and it was never called for any of them.  Furthermore, I created PreTranslateMessage(...) for each of these and looked to see if WM_MEASUREITEM was passed and it never seemed to be.  If I try to subclass the list control I get assertions.  Without a WM_MEASUREITEM message being called I cannot properly resize the list control when the user changes the font.  The funny thing is, I was able to earlier when I simply created a CWnd that created the CListCtrl and subclassed the CHeaderCtrl, but then I couldn't get a dockable toolbar, so I went this more cumbersome route to get the toolbar and suddenly lost the measure item call.  In any event, I guess I'm looking for possibly one of two answers.

1.  Is there a way I can force MFC to issue the WM_MEASUREITEM message so I can resize my CListCtrl's row heights?
2.  Is there a way I can get a dockable toolbar without a whole lot of code for a CWnd not a CFrameWnd.

I prefer the 1st question to be answered but if no one knows I'll take the second.

Thank you for your help,
0
Comment
Question by:Catalepsy
9 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 12160030
Your problem is probably the subclassing.  When the WM_MEASUREITEM message is generated you have not yet done the subclassing, so you aren't catching it.
What you could try is to modify the style dynamically when you perform the subclassing, switching to the ownerdraw stayle at that point.  (I haven't tested it so it may not work, however it should be quick for you to put the necessary code into your app)
0
 
LVL 3

Author Comment

by:Catalepsy
ID: 12160776
Delaying when owner draw is set did not cause OnMeasureItem() to be called in any of the above mentioned classes.  It is my belief that something is preventing it further up stream and I need to know how to disable this decision.

Thank you,
0
 
LVL 3

Author Comment

by:Catalepsy
ID: 12161877
Well, it appears I needed to override OnChildNotify in the list control derived class because, as a co-worker put it after googling this problem, MFC has a problem.  I traced this down inside wincore and saw that the routine knew I had this message mapped but could not get an entry for it.

Thanks anyway,
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 12

Expert Comment

by:migel
ID: 12162956
Hi!
Have you
      ON_WM_MEASUREITEM_REFLECT()
entry in the your listview derived class MESSAGE MAP?
0
 
LVL 7

Expert Comment

by:J_Mak
ID: 12187404
Here's a way of MFC generating the WM_MEASUREITEM message:

AfxGetApp()->GetMainWnd()->SendMessage(WM_MEASUREITEM, ID_OF_Whatever)

When this is executed, the corresponding message handler for ID_OF_Whatever is invoked. Or you can simply use AfxGetMainWnd()->SendMessage(WM_MEASUREITEM)

Hope that helps.
0
 
LVL 3

Author Comment

by:Catalepsy
ID: 12189568
Thanks for the input, but I tried that and it didn't work.  I'm past that problem anyway as I went ahead and wrote my own list control so I can make it do whatever I want without being forced to take default functionality.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 12867762
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
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.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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