VC++关于用MFC创建界面窗口菜单的“打开”按钮程序!!!!求解???
voidCMyDlg::OnOpen(){//TODO:AddyourcommandhandlercodehereCFileDialog*lpszOpenFile;//定...
void CMyDlg::OnOpen()
{
// TODO: Add your command handler code here
CFileDialog*lpszOpenFile; //定义一个CfileDialog对象
lpszOpenFile=new
CFileDialog(TRUE," "," ",OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,"文件类型(*.yourfiletype)|*.yourfiletype||");
//生成一个对话框
if(lpzsOpenFile->DoModal()==ID_OK) //假如点击对话框确定按钮
{
CString szGetName;
szGetName=lpszOpenFile->GetPathName(); //得到打开文件的路径
SetWindowText(szGetName); //在窗口标题上显示路径
}
delete lpszOpenfile; //释放分配的对话框
}
请问哪里错了??? 展开
{
// TODO: Add your command handler code here
CFileDialog*lpszOpenFile; //定义一个CfileDialog对象
lpszOpenFile=new
CFileDialog(TRUE," "," ",OFN_FILEMUSTEXIST|OFN_HIDEREADONLY,"文件类型(*.yourfiletype)|*.yourfiletype||");
//生成一个对话框
if(lpzsOpenFile->DoModal()==ID_OK) //假如点击对话框确定按钮
{
CString szGetName;
szGetName=lpszOpenFile->GetPathName(); //得到打开文件的路径
SetWindowText(szGetName); //在窗口标题上显示路径
}
delete lpszOpenfile; //释放分配的对话框
}
请问哪里错了??? 展开
1个回答
展开全部
lpzsOpenFile->DoModal()写反了吧,是lpszOpenFile
还有,这个其实没有必要new,在这个函数后就删除的话直接用变量就可以了
还有,这个其实没有必要new,在这个函数后就删除的话直接用变量就可以了
更多追问追答
追问
error C2065: 'ID_OK' : undeclared identifier
error C2065: 'lpszOpenfile' : undeclared identifier
error C2541: delete : cannot delete objects that are not pointers
还是有错误,哪里错了,求解!!
error C2065: 'ID_OK' : undeclared identifier
error C2065: 'lpszOpenfile' : undeclared identifier
error C2541: delete : cannot delete objects that are not pointers
还是有错误,哪里错了,求解!!
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询