TVN_ITEMEXPANDING not firing
I've got an app in which the TVN_ITEMEXPANDING flag is refusing to be sent.
I'm adding the items like this:
TVINSERTSTRUCT tvis = {0};
tvis.item.iImage = tviteminfo::gServerDisconnectedIconIndex;
tvis.item.iSelectedImage = tviteminfo::gServerDisconnectedIconIndex;
tvis.item.pszText = (LPTSTR)(servername.data());
tvis.item.cChildren = 1;
tvis.item.mask = TVIF_IMAGE | TVIF_SELECTEDIMAGE | TVIF_TEXT | TVIF_CHILDREN
| TVIF_PARAM;
tvis.hInsertAfter = TVI_SORT;
tvis.hParent = TVI_ROOT;
tvis.item.lParam = (LPARAM)(new tviteminfoserver(servername));
tvis.item.hItem = TreeView_InsertItem(mTreeView->mhWnd, &tvis);
and TRYING to receive the WM_NOTIFY / TVN_ITEMEXPANDING combination like this:
LRESULT windowmain::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
lParam)
{
switch(uMsg)
{
case WM_NOTIFY:
{
LPNMHDR lpnmhdr = (LPNMHDR)lParam;
if (lpnmhdr->hwndFrom == mTreeView->mhWnd) return TreeViewNotify(lpnmhdr);
....
LRESULT windowmain::TreeViewNotify(LPNMHDR lpnmhdr)
{
//gets to here fine for all other notifications, e.g. NM_RCLICK,
TVN_DELETEITEM.
switch(lpnmhdr->code)
{
case TVN_ITEMEXPANDING:
{
//never gets to here.
LPNMTREEVIEW lpnmtv = (LPNMTREEVIEW)lpnmhdr;
In case it was due to the TVIS_EXPANDEDONCE flag being set (which the docs
seem to suggest prevents the notification I'm looking for) I tried putting
the line
TreeView_Expand(mTreeView->mhWnd, tvis.item.hItem, TVE_COLLAPSE |
TVE_COLLAPSERESET);
straight after the item was added, but it didn't make any difference - I
didn't think this would be a problem as it only says this takes effect when
the item has been already expanded once, and it hasn't been.
Any ideas?