?
Solved

WM_MEASUREITEM

Posted on 2004-09-27
9
Medium Priority
?
919 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
[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 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
Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

 
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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

801 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