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

x
?
Solved

WM_MEASUREITEM

Posted on 2004-09-27
9
Medium Priority
?
928 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 45

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
Industry Leaders: 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!

 
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

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

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…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

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