您的位置:首页 > 其它

打开文件另存为操作

2014-03-11 14:54 106 查看
voidCTestdia1Doc::OnFileSaveAs()

{

// TODO: Add your command handler code here

CFileDialog dlg(TRUE);//<- 其中TRUE是“打开”对话框 FALSE是“另存为”对话框

int ret=dlg.DoModal();

if(ret==IDOK)

{

CString pathname=dlg.GetPathName();

CString filename=dlg.GetFileName();
char tbuf[120];
sprintf(tbuf,"The%s file in %s is saved!",filename,pathname); 
AfxMessageBox(tbuf);  以弹出对话框形式输出字符串信息

}

}
可以显示打开文件和文件另存为,并将选中的文件和文件名输出。

 

int sprintf( char *buffer, const char *format,[ argument] … );

函数是字串格式化命令,主要功能是把格式化的数据写入某个字符串中。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mfc 对话框
相关文章推荐