我已经实现了这个MFC类。(注意这里写的只是我班级的一部分)
这是文件FilesWorkFlow.h
#pragma once
// FilesWorkFlow
class FilesWorkFlow : public CWnd
{
DECLARE_DYNAMIC(FilesWorkFlow)
public:
FilesWorkFlow();
virtual ~FilesWorkFlow();
CString GetPath();
protected:
DECLARE_MESSAGE_MAP()
private:
wchar_t* lpszFilter;
};
这是文件FilesWorkFlow.cpp
// FilesWorkFlow.cpp : implementation file
//
#include "stdafx.h"
#include "InitialJobProject2.h"
#include "FilesWorkFlow.h"
// FilesWorkFlow
IMPLEMENT_DYNAMIC(FilesWorkFlow, CWnd)
FilesWorkFlow::FilesWorkFlow()
{
lpszFilter = _T("JPEG Files (*.jpg)|*.jpg|")
_T("TIFF Files (*.tif)|*.tif|")_T("PNG Files (*.png)|*.png|")_T("Bitmap Files (*.bmp)|*.bmp|");
}
FilesWorkFlow::~FilesWorkFlow()
{
}
CString FilesWorkFlow::GetPath()
{
CFileDialog dlgFile = CFileDialog(true,0,0,OFN_ENABLESIZING | OFN_HIDEREADONLY,lpszFilter,0,0,true);
if (dlgFile.DoModal() == IDOK)
{
CString pathname = dlgFile.GetPathName();
return pathname;
}
}
BEGIN_MESSAGE_MAP(FilesWorkFlow, CWnd)
END_MESSAGE_MAP()
// FilesWorkFlow message handlers
并且在文件InitialJobProject2Dlg.h中,它是与我的Dialog窗口相关的类的标题,并且是从类CDialogEx派生的,我有这样的代码:
#include "FilesWorkFlow.h"
......
private:
CWndResizer m_resizer;
FilesWorkFlow m_filesWorkFlow;
最后这就是文件FilesWorkFlow.cpp
中的内容void CInitialJobProject2Dlg::OnBnClickedBtnbrowse()
{
// TODO: Add your control notification handler code here
m_filesWorkFlow = FilesWorkFlow();
CString filepath = m_filesWorkFlow.GetPath();
}
我找不到指定错误的原因?
答案 0 :(得分:1)
您正在尝试将CFileDialog分配给CFileDialog,这不是受支持的操作。以这种方式初始化dlgFile:
CFileDialog dlgFile(...);