Solved

WM_MEASUREITEM

Posted on 2004-09-27
9
877 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

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: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

743 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

16 Experts available now in Live!

Get 1:1 Help Now