Wednesday, August 12, 2015

Missing ON_WM_MEASUREITEM_REFLECT

Last week i have come across a strange issue in customized CListCtrl. A dialog is having two ListCtrls of them. The row height changes are not getting reflected to the second control while changing font size. 

Why is it happening for the second control or  is it happening only for the second object?
I swapped it for confirmation. Surprisingly the result was same. So the issue is not with the object, it could be with the Tab order. But the control does not have any tab order specific implementation.

To uncover this bizarre, i had gone through MFC source code implementation of CWnd::OnMeasureItem() since it is responsible for row height and width manipulation. As per the implementation of this method, it iterates all the ListCtrls in a dialog using CWnd::GetDescendantWindow() and invokes virtual method CWnd::MeasureItem()CWnd::GetDescendantWindow() method uses control ID to uniquely identify each control. In our scenario, the control ID was same for both ListCtrls and it only invokes  CWnd::MeasureItem() for the first control.

It can happen for other handlers too. So be conscientious while setting the control ID.




No comments:

Post a Comment

Keep an eye on your Native API prototype for interop calls

Few weeks back, we have observed "an unexpected process termination" crash in a WPF app. From the crash dump, provides below calls...