Solved

WM_MEASUREITEM

Posted on 2004-09-27
9
899 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
sum67 challenge 35 108
matchUp  challenge 6 69
how to use laptop or pad camera in vb.net windows application 2 86
Capture logon name 13 87
Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
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…
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 an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

856 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