关闭对话框后检索 CTreeCtrl 项目
在应用程序中,我需要仅处理树中选定的项目。我在添加到 Dailog 的属性表中使用 MFC CTreeCtrl。树显示文件夹列表,用户选择一些文件夹,当用户按“确定”时,我需要处理这些文件夹。我使用 SetItemData 保存文件夹信息。其他一切都工作正常。问题是,当用户按“确定”时,CTreeCtrl 变量变为 null,因此我无法使用 GetItemData。有没有办法即使在对话框关闭后我仍然使用该变量? 任何帮助将不胜感激。
In an application I am required to only process the items selected in a tree. I am using MFC CTreeCtrl in a property sheet added to a Dailog. The tree shows a list of folders, the user selects some and when the user presses OK, I need to process the folders. I save the folder information by using SetItemData. Everything else is working fine. The problem is that when the user presses OK, the CTreeCtrl variable gets null and therefore i cannot use GetItemData. Is there a way that i still use the variable even after its dialog is closed?
Any help will be highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您必须将信息传输到另一个变量中,该变量将在窗口被销毁时存在。对于文件夹列表,
std::vector
是一个很好的解决方案。在对话框中,当用户按“确定”时,浏览树并将文件夹路径复制到向量中。
在对话框之外,代码如下所示:
You have to transfer the information into another variable, that will exist when the window will be destroyed. For a list of folders, a
std::vector<CString>
is a good solutions.Inside the dialog, when the user presses ok, go through your tree and copy the folder paths into the vector.
Outside the dialog, the code looks something like this: