Hello! I use VS15 without mfc. I figured out how to use the tree view element, how to winpai to go through the files in directories and write them to the tree, but did not understand how to record the element at level 3, i.e. I open the C: \ element there I click on the windows element, but I cannot find out what is in this folder because there is no way, only the name.
//Здесь вывожу все диски в root и во второй уровень записываю файлы и директории находящиеся // в этих дисках на уровень ниже int typeLogicalDrives = 0; for (std::list<char*>::reverse_iterator i = m_logicalDrivesList.rbegin(); i != m_logicalDrivesList.rend(); i++) { typeLogicalDrives = GetDriveType(*i); if (typeLogicalDrives == DRIVE_REMOVABLE || typeLogicalDrives == DRIVE_FIXED) { Root = NULL; Before = NULL; Parent = NULL; tvinsert.hParent = NULL; tvinsert.hInsertAfter = TVI_ROOT; tvinsert.item.pszText = *i; tvinsert.item.iImage = 0; tvinsert.item.iSelectedImage = 1; Parent = (HTREEITEM)SendMessage(treeView, TVM_INSERTITEM, 0, (LPARAM)&tvinsert); WIN32_FIND_DATA file; HANDLE f; char nameDir[256]; strcpy_s(nameDir, *i); strcat_s(nameDir, "*"); f = FindFirstFile(nameDir, &file); if (f != INVALID_HANDLE_VALUE) { Root = Parent; Before = Parent; // handle of the before root tvinsert.hParent = Parent; // handle of the above data tvinsert.hInsertAfter = TVI_LAST; // below parent tvinsert.item.iImage = 0; tvinsert.item.iSelectedImage = 1; do { tvinsert.item.pszText = file.cFileName; Parent = (HTREEITEM)SendMessage(treeView, TVM_INSERTITEM, 0, (LPARAM)&tvinsert); } while (FindNextFile(f, &file)); } FindClose(f); } } ......... // При нажатии на элемент добавляется item case WM_NOTIFY: { if (((LPNMHDR)lParam)->code == NM_DBLCLK) // if code == NM_CLICK - Single click on an item { char Text[256] = ""; memset(&tvi, 0, sizeof(tvi)); Selected = (HTREEITEM)SendMessage(treeView, TVM_GETNEXTITEM, TVGN_CARET, (LPARAM)Selected); if (Selected == NULL) { MessageBox(window, "No Items in TreeView", "Error", MB_OK | MB_ICONINFORMATION); break; } TreeView_EnsureVisible(treeView, Selected); SendMessage(treeView, TVM_SELECTITEM, TVGN_CARET, (LPARAM)Selected); tvi.mask = TVIF_TEXT; tvi.pszText = Text; tvi.cchTextMax = 256; tvi.hItem = Selected; if (SendMessage(treeView, TVM_GETITEM, TVGN_CARET, (LPARAM)&tvi)) { if (CheckFilesInDirectory(tvi.pszText) == true) { MessageBox(0, "Press OK", (LPCSTR)Selected, MB_OK | MB_ICONINFORMATION); tvinsert.hParent = Selected; tvinsert.hInsertAfter = TVI_LAST; tvinsert.item.pszText = "Child Added"; Parent = (HTREEITEM)SendMessage(treeView, TVM_INSERTITEM, 0, (LPARAM)&tvinsert); } } } } break; In the event handler there is such a function CheckFilesInDirectory (tvi.pszText) == true it does not work as instead of the name of the element the path should be indicated. How to make this way?