Reputation: 2598
I have implemented this MFC class.(Note that what is written here is just a part of my class)
here is the file 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;
};
and here is the file 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
and in the file InitialJobProject2Dlg.h that is the header of the class related to my Dialog window and is derived from the class CDialogEx, I have this code:
#include "FilesWorkFlow.h"
......
private:
CWndResizer m_resizer;
FilesWorkFlow m_filesWorkFlow;
and finally this is what is in file FilesWorkFlow.cpp
void CInitialJobProject2Dlg::OnBnClickedBtnbrowse()
{
// TODO: Add your control notification handler code here
m_filesWorkFlow = FilesWorkFlow();
CString filepath = m_filesWorkFlow.GetPath();
}
I can't find the reason for the error specified?
Upvotes: 0
Views: 2068
Reputation: 10415
You are trying to assign a CFileDialog to a CFileDialog, which is not a supported operation. Initialize dlgFile this way:
CFileDialog dlgFile(...);
Upvotes: 1