C++ Windows API DlgDirList 有时不会 return 正确的列表

C++ Windows API DlgDirList sometimes don't return the correct listing

我有 2 个列表框,一个总是列出路径中的目录,另一个列出 selected 目录中的文件。

第一次我select一个目录,文件显示正确,但如果我select另一个目录,它什么也没有列出。

这是我当前的 main.cpp,所有 GUI 内容都发生在此处:http://pastebin.com/PjSb8aKy

列表框代码从第 31 行到第 45 行和第 150 行到第 165 行。

提前致谢。

-------------------------------------------- -----编辑-------------------------------- ----------------------------

我在sel字符串上放了一个简单的std::cout,结果在第一个目录iselect上是“”,然后就变成了"DirectoryName\",我尝试将 sel 字符串更改为“./DirectoryName”,但没有成功,“\”仍然出现,但这不是困扰我的地方,真正奇怪的是首先 selection 将“”返回到 sel 字符串...

我认为线索在 DlgDirList 函数的文档中:

If lpPathSpec specifies a directory, DlgDirListComboBox changes the current directory to the specified directory before filling the list box.

我自己从未使用过这些函数,但我敢打赌您的当前目录正在修改,因此对 DlgDirList 的后续调用查找错误的位置。