pagz
asked on
Deriving a class from CFileDialog & displaying Open/Save dialog
When creating a dialog based app, I create a new class &
derive it from CFileDialog. I am trying to display the Open & Save dialog, but it doesen't work. I've asked this question before and followed instructions from Answer2000.
Now I am getting a "unresolved external" error after I build the application. Here is a snippet of my code.
The class declaration is here:
#if !defined(AFX_FILEOPENSAVE_ H__7682260 2_5EB8_11D 2_AC74_444 553540000_ _INCLUDED_ )
#define AFX_FILEOPENSAVE_H__768226 02_5EB8_11 D2_AC74_44 4553540000 __INCLUDED _
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// FileOpenSave.h : header file
////////////////////////// ////////// ////////// ////////// ////////// ////////// /
// CFileOpenSave dialog
class CFileOpenSave : public CFileDialog
{
DECLARE_DYNAMIC(CFileOpenS ave)
public:
CFileOpenSave(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
LPCTSTR lpszDefExt = NULL,
LPCTSTR lpszFileName = NULL,
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
LPCTSTR lpszFilter = NULL,
CWnd* pParentWnd = NULL);
CFileOpenSave(); //constructor function declared here
protected:
//{{AFX_MSG(CFileOpenSave)
afx_msg void OnFileOpen();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
////////////////////////// ////////// ////////// ////////// //
////////////////////////// ////////// ////////// ////////// //
The .cpp file is here:
// FileOpenSave.cpp : implementation file
//
#include "stdafx.h"
#include "Table2.h"
#include "FileOpenSave.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
////////////////////////// ////////// ////////// ////////// ////////// ////////// /
// CFileOpenSave
IMPLEMENT_DYNAMIC(CFileOpe nSave, CFileDialog)
CFileOpenSave::CFileOpenSa ve(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :
CFileDialog(bOpenFileDialo g, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd)
{
}
BEGIN_MESSAGE_MAP(CFileOpe nSave, CFileDialog)
//{{AFX_MSG_MAP(CFileOpenS ave)
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CFileOpenSave::OnFileOpen( )
{
CFileOpenSave dlgOpSv;
dlgOpSv.DoModal();
// TODO: Add your command handler code here
//This is my problem. I don't know why it's not //working!
}
My dialog box has a menu with File|Open, but doesn't create the dialog. I've included the <afxdlgs.h> file in the stdfx.h f header & still nothing. The only time
it works is if I create an SDI or MDI app.
If you are out there, please Help, Answers2000.
I've looked in my books to trubleshoot this problem &
in the MFC help. Still having problems. (Remember,
I'm a beginner...)
derive it from CFileDialog. I am trying to display the Open & Save dialog, but it doesen't work. I've asked this question before and followed instructions from Answer2000.
Now I am getting a "unresolved external" error after I build the application. Here is a snippet of my code.
The class declaration is here:
#if !defined(AFX_FILEOPENSAVE_
#define AFX_FILEOPENSAVE_H__768226
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// FileOpenSave.h : header file
//////////////////////////
// CFileOpenSave dialog
class CFileOpenSave : public CFileDialog
{
DECLARE_DYNAMIC(CFileOpenS
public:
CFileOpenSave(BOOL bOpenFileDialog, // TRUE for FileOpen, FALSE for FileSaveAs
LPCTSTR lpszDefExt = NULL,
LPCTSTR lpszFileName = NULL,
DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
LPCTSTR lpszFilter = NULL,
CWnd* pParentWnd = NULL);
CFileOpenSave(); //constructor function declared here
protected:
//{{AFX_MSG(CFileOpenSave)
afx_msg void OnFileOpen();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
//////////////////////////
//////////////////////////
The .cpp file is here:
// FileOpenSave.cpp : implementation file
//
#include "stdafx.h"
#include "Table2.h"
#include "FileOpenSave.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//////////////////////////
// CFileOpenSave
IMPLEMENT_DYNAMIC(CFileOpe
CFileOpenSave::CFileOpenSa
DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :
CFileDialog(bOpenFileDialo
{
}
BEGIN_MESSAGE_MAP(CFileOpe
//{{AFX_MSG_MAP(CFileOpenS
ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void CFileOpenSave::OnFileOpen(
{
CFileOpenSave dlgOpSv;
dlgOpSv.DoModal();
// TODO: Add your command handler code here
//This is my problem. I don't know why it's not //working!
}
My dialog box has a menu with File|Open, but doesn't create the dialog. I've included the <afxdlgs.h> file in the stdfx.h f header & still nothing. The only time
it works is if I create an SDI or MDI app.
If you are out there, please Help, Answers2000.
I've looked in my books to trubleshoot this problem &
in the MFC help. Still having problems. (Remember,
I'm a beginner...)
Give us the unresolved error so we can see it!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.