且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

当文件路径很长时,为什么CFileDialog :: GetNextPathName不起作用?

更新时间:2023-11-12 08:32:22

MFC使用大小为_MAX_PATH的默认缓冲区,这就是为什么您看到这种行为的原因.查看dlgfile.cpp以了解CFileDialog::CFileDialog的实现,您将看到m_ofn.lpstrFilem_ofn.nMaxFile被设置.

MFC uses a default buffer of size _MAX_PATH and that's why you are seeing that behavior. Look at dlgfile.cpp for the implementation of CFileDialog::CFileDialog and you will see m_ofn.lpstrFile and m_ofn.nMaxFile being set.

如果需要,可以指定更大的缓冲区.在调用DoModal之前,您可以访问CFileDialog::m_pOFN成员以获取指向OPENFILENAME将要使用的OPENFILENAME的指针并直接对其进行更新,或者调用CFileDialog::GetOFN以获得对该结构的引用并对其进行更新.

You can specify a larger buffer if you want to. Before calling DoModal you can either access the CFileDialog::m_pOFN member to get a pointer to the OPENFILENAME that the CFileDialog will use and update it directly or call CFileDialog::GetOFN to get a reference to the structure and update that.

无论哪种方式,您都将找到帮助: http ://msdn.microsoft.com/zh-CN/library/ms646839(v = vs.80).aspx

Either way you will find this helpful: http://msdn.microsoft.com/en-US/library/ms646839(v=vs.80).aspx