关闭对话框后检索 CTreeCtrl 项目

发布于 2024-12-19 03:39:39 字数 225 浏览 7 评论 0原文

在应用程序中,我需要仅处理树中选定的项目。我在添加到 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自此以后,行同陌路 2024-12-26 03:39:39

您必须将信息传输到另一个变量中,该变量将在窗口被销毁时存在。对于文件夹列表,std::vector 是一个很好的解决方案。

在对话框中,当用户按“确定”时,浏览树并将文件夹路径复制到向量中。

在对话框之外,代码如下所示:

CMyDlg dlg(this);
if(dlg.DoModal() == IDOK)
{
    // Information is in dlg.m_vecFolders available
}

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:

CMyDlg dlg(this);
if(dlg.DoModal() == IDOK)
{
    // Information is in dlg.m_vecFolders available
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文