Background:
I have an MFC application with per-monitor DPI awareness mode. When I shift the window to another monitor having another screen scaling, I receive and process the WM_DPICHANGED_AFTERPARENT
message.
My owner drawn combo box (with style CBS_OWNERDRAWFIXED
) is already filled with items which height I need to update according to the new scaling factor. For this I calculate the new height and call:
SetItemHeight(-1, height); // resizes the closed box
SetItemHeight(0, height); // do this on every item's index from 0 to n
Problem: A combo box not yet opened in former scaling, but opened after having changed the items' height appears wrong. The list opens with the second half of all entries and the lower half is empty. Closing and re-opening it fixes the problem.
I tried workarounds I know from other update problems like Invalidate()
, show and hide the combo box, but it doesn't help.
Complete re-filling all entries works, but this is slow and leads into flickering (I'm having 12 such boxes in that window).
Any idea? Thank you!
EDIT: The problem obviously only occurs when increasing the items' height (so when moving my window from the 100% to the 200% monitor).
index
parameter correctly. According to msdn.microsoft.com/en-us/ie/aa278721(v=vs.100),nIndex must be 0 and the height of all list items will be set
. – Vlad FeinsteinSetWindowPos()
function (docs.microsoft.com/en-us/windows/win32/api/winuser/…) withSWP_FRAMECHANGED
when some internal state of the control needs to be updated. – Vlad Feinstein