Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在应用程序中,我只需要处理在树中选择的项目。我在添加到 Dailog 的属性表中使用 MFC CTreeCtrl。树显示文件夹列表,用户选择一些,当用户按下确定时,我需要处理文件夹。我使用 SetItemData 保存文件夹信息。其他一切工作正常。问题是当用户按下 OK 时,CTreeCtrl 变量为空,因此我不能使用 GetItemData。有没有办法让我在它的对话框关闭后仍然使用该变量?任何帮助将不胜感激。
您必须将信息转移到另一个变量中,该变量将在窗口被销毁时存在。对于文件夹列表,astd::vector<CString>是一个很好的解决方案。
std::vector<CString>
在对话框中,当用户按下确定时,遍历您的树并将文件夹路径复制到向量中。
在对话框之外,代码如下所示:
CMyDlg dlg(this); if(dlg.DoModal() == IDOK) { // Information is in dlg.m_vecFolders available }