ListView_GetHeader returning NULL
I ran into a problem with ListView_GetHeader returning NULL for a ListView that had a header during WM_INITDIALOG. The issue ended up being that if the ListView was initially created hidden, I wasn’t able to get the header window. However, when the ListView control was created with WS_VISIBLE, it returned the header as expected. What I think happens is that the ListView control in Windows doesn’t actually create the header window until the first time it becomes visible, that’s why calls to ListView_GetHeader returned NULL when I thought they shouldn’t have.
So during WM_INITDIALOG, before the dialog is shown, I set each ListView to visible and then back to whatever state it was before. That way it forces the ListView to create the header window internally.
Style = GetWindowLong(ListViewWnd, GWL_STYLE);
ShowWindow(ListViewWnd, SH_SHOW);
if ((Style & WS_VISIBLE) == 0)
ShowWindow(ListViewWnd, SW_HIDE);
HeaderWnd = ListView_GetHeader(ListViewWnd);







