CFileDialog保存文件问题
发布网友
发布时间:2024-07-17 21:52
我来回答
共1个回答
热心网友
时间:2024-07-17 22:26
在 pFileDlg->m_ofn.lpstrFile=cf; 前加上下面这句话:
pFileDlg->m_ofn.nMaxFile = 256;
运行通过
原因如下:
MSDN中关于CFileDialog有以下原文:
Do this by replacing m_ofn.lpstrFile with a pointer to a buffer you have allocated, after constructing the CFileDialog, but before calling DoModal. Additionally, you must set m_ofn.nMaxFile with the number of characters in the buffer pointed to by m_ofn.lpstrFile.
大意就是要指定nMaxFile值,否则你在按下保存后
pFileDlg变为NULL了(与API的内部实现方式有关)
热心网友
时间:2024-07-17 22:43
在 pFileDlg->m_ofn.lpstrFile=cf; 前加上下面这句话:
pFileDlg->m_ofn.nMaxFile = 256;
运行通过
原因如下:
MSDN中关于CFileDialog有以下原文:
Do this by replacing m_ofn.lpstrFile with a pointer to a buffer you have allocated, after constructing the CFileDialog, but before calling DoModal. Additionally, you must set m_ofn.nMaxFile with the number of characters in the buffer pointed to by m_ofn.lpstrFile.
大意就是要指定nMaxFile值,否则你在按下保存后
pFileDlg变为NULL了(与API的内部实现方式有关)