我已经实现了这个 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();
}
我找不到指定错误的原因?