In my MFC app, the user can minimize a window that has a CListCtrl inside. I need to know how many visible items the list control will be showing once the user restores the window.
The first implementation used GetCountPerPage
. This was working great until we noticed the minimized window case and found it was returning zero.
I've also tried GetClientRect
, GetWindowRect
and GetWindowPlacement
(using rcNormalPosition
) to attempt to figure out the size of the CListCtrl so I can compute the page count manually. All these APIs return empty rectangles positioned at various offscreen locations.
What's the best way to figure out what the CListCtrl's height will be once I restore the window? Surely the real window rectangle is available somehow.
GetCountPerPage
should not fail unless you are in icon view or something. When the window is minimized (or iconized)GetCountPerPage
andGetClientRect
will return the same numbers. The only difference is that there is no paint message. Maybe you are resizing the control or something. Some minimal code would help. - Barmak ShemiraniOnSize
. On first call,HWND
ofListView
may not be available so you get strange results for invalid window. For resizing window's children, check main window'sGetClientRect
, if width/height is zero then don't do anything because it's minimized. - Barmak Shemirani