这段代码有什么问题吗?

ren20 2001-03-26 07:29:00
编译通过,但是运行出现 “终止” “重试” “忽略”
CFileDialog TFileDlg(TRUE,"*.trk",NULL,OFN_HIDEREADONLY,"Terrain File(*.ter)|*.ter||",NULL);
TFileDlg.m_ofn.Flags=OFN_ALLOWMULTISELECT;
TFileDlg.m_ofn.lpstrFile="Terrain File Dialog ";
TFileDlg.m_ofn.nMaxFile=4096;

if(TFileDlg.DoModal()==IDOK)
{

}
...全文
448 14 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
14 条回复
切换为时间正序
请发表友善的回复…
发表回复
Jans 2001-03-27
  • 打赏
  • 举报
回复
没有分配Buffer嘛
kevin_gao 2001-03-27
  • 打赏
  • 举报
回复
VC+BCB不好吗?都是C++的东西应该不错吧,我以为。虽然BCB我不太懂!
ren20 2001-03-26
  • 打赏
  • 举报
回复
谢谢,我的程序已经好了,多亏了大家的帮助

请问,我原来的程序那里出了问题?
Jans 2001-03-26
  • 打赏
  • 举报
回复
这样好像可以了
char szFiles[4096];
CFileDialog TFileDlg(TRUE,"*.trk",NULL,OFN_HIDEREADONLY,"Terrain File(*.ter)|*.*||",NULL);
TFileDlg.m_ofn.Flags|=OFN_ALLOWMULTISELECT;
strcpy(str," All Files");
TFileDlg.m_ofn.lpstrFile=szFiles;
TFileDlg.m_ofn.nMaxFile=4096;
if(TFileDlg.DoModal()==IDOK)
{

}
Jans 2001-03-26
  • 打赏
  • 举报
回复
Specifies that the File Name list box allows multiple selections. If you also set the OFN_EXPLORER flag, the dialog box uses the Explorer-style user interface; otherwise, it uses the old-style user interface.
If the user selects more than one file, the lpstrFile buffer returns the path to the current directory followed by the file names of the selected files. The nFileOffset member is the offset, in bytes or characters, to the first file name, and the nFileExtension member is not used. For Explorer-style dialog boxes, the directory and file name strings are NULL separated, with an extra NULL character after the last file name. This format enables the Explorer-style dialog boxes to return long file names that include spaces. For old-style dialog boxes, the directory and file name strings are separated by spaces and the function uses short file names for file names with spaces. You can use the FindFirstFile function to convert between long and short file names.

If you specify a custom template for an old-style dialog box, the definition of the File Name list box must contain the LBS_EXTENDEDSEL value.
ren20 2001-03-26
  • 打赏
  • 举报
回复
能不能当对话框打开时, 设置缺省目录为 d:\abc
ren20 2001-03-26
  • 打赏
  • 举报
回复
对话框只显示 扩展名为 trk 的文件。
joke100 2001-03-26
  • 打赏
  • 举报
回复
是不是搞错了呀。。。

char bigBuff[2048] = ""; // maximum common dialog buffer size
char szFilter[] =
"All Files (*.*)|*.*|Text Files (*.txt)|*.txt||";
CFileDialog dlg(TRUE, NULL, NULL,
OFN_ALLOWMULTISELECT, szFilter);

// Modify OPENFILENAME members directly to point to bigBuff
dlg.m_ofn.lpstrFile = bigBuff;
dlg.m_ofn.nMaxFile = sizeof(bigBuff);

dlg.DoModal();
ren20 2001-03-26
  • 打赏
  • 举报
回复
TFileDlg.m_ofn.Flags=OFN_ALLOWMULTISELECT;
TFileDlg.m_ofn.lpstrFile="Terrain File Dialog ";
TFileDlg.m_ofn.nMaxFile=4096;

我把这3句去掉,就可以运行了,怎么回事?
ren20 2001-03-26
  • 打赏
  • 举报
回复
怎么改,高手?
joke100 2001-03-26
  • 打赏
  • 举报
回复
If the OFN_ALLOWMULTISELECT flag is set and the user selects multiple files, the m_ofn.lpstrFile contains the current directory followed by the file names of the selected files.
ren20 2001-03-26
  • 打赏
  • 举报
回复
2位的方法还是不行呀
panda_w 2001-03-26
  • 打赏
  • 举报
回复
把最后参数改为this试试
joke100 2001-03-26
  • 打赏
  • 举报
回复
增加一句
TFileDlg.m_ofn.hInstance = AfxGetInstanceHandle();


16,548

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • AIGC Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧