Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[r5083]: tags / V3_03 / FileDialogExt.cpp Maximize Restore History

Download this file

FileDialogExt.cpp    56 lines (45 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/// \file FileDialogExt.cpp
//-----------------------------------------------------------------------------
#include "stdafx.h"
#include "PasswordSafe.h"
#include "FileDialogExt.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC(CFileDialogExt, CFileDialog)
CFileDialogExt::CFileDialogExt(BOOL bOpenFileDialog,
LPCTSTR lpszDefExt,
LPCTSTR lpszFileName,
DWORD dwFlags,
LPCTSTR lpszFilter,
CWnd* pParentWnd)
: CFileDialog(bOpenFileDialog, lpszDefExt, lpszFileName,
dwFlags, lpszFilter, pParentWnd)
{
m_ext = lpszDefExt;
}
BEGIN_MESSAGE_MAP(CFileDialogExt, CFileDialog)
END_MESSAGE_MAP()
BOOL
CFileDialogExt::OnFileNameOK()
{
if (m_ext != NULL)
{
if (GetFileExt() != m_ext
&& GetFileExt() != "")
{
CString temp = m_ext;
temp = "This file type must have a ."
+ temp
+ " extension.";
MessageBox(temp, "File name error", MB_OK|MB_ICONWARNING);
return 1;
}
}
return CFileDialog::OnFileNameOK();
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------