-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNotesDlg.cpp
More file actions
114 lines (91 loc) · 2.04 KB
/
Copy pathNotesDlg.cpp
File metadata and controls
114 lines (91 loc) · 2.04 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// NotesDlg.cpp : implementation file
//
#include "stdafx.h"
#include "McWinnClient.h"
#include "NotesDlg.h"
#include "afxdialogex.h"
// CNotesDlg dialog
IMPLEMENT_DYNAMIC(CNotesDlg, CDialogEx)
CNotesDlg::CNotesDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(CNotesDlg::IDD, pParent)
, m_Notes(_T(""))
{
}
CNotesDlg::~CNotesDlg()
{
}
void CNotesDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_NOTES_DIALOG_NOTES, m_NotesCtrl);
DDX_Control(pDX, IDOK, m_Confirm);
DDX_Text(pDX, IDC_NOTES_DIALOG_NOTES, m_Notes);
}
BEGIN_MESSAGE_MAP(CNotesDlg, CDialogEx)
ON_WM_SYSCOMMAND()
ON_BN_CLICKED(IDOK, &CNotesDlg::OnBnClickedOk)
ON_WM_CLOSE()
END_MESSAGE_MAP()
// CNotesDlg message handlers
BOOL CNotesDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
// TODO: Add extra initialization here
m_NotesCtrl.SetWindowTextW(m_Notes);
if (mode == DIALOG_VIEW)
{
m_NotesCtrl.EnableWindow(FALSE);
m_Confirm.SetWindowTextW(TEXT("Close"));
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CNotesDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->message == WM_KEYDOWN)
{
if (pMsg->wParam == VK_ESCAPE)
{
if (CheckChanges())
{
SaveChanges();
return TRUE;
}
}
}
return CDialogEx::PreTranslateMessage(pMsg);
}
BOOL CNotesDlg::CheckChanges(BOOL ask)
{
CString new_Notes;
m_NotesCtrl.GetWindowTextW(new_Notes);
if (new_Notes.Compare(m_Notes) != 0)
{
if (ask)
return (AfxMessageBox(TEXT("Save Changes?"), MB_YESNO) == IDYES);
else
return TRUE;
}
return FALSE;
}
void CNotesDlg::SaveChanges()
{
CDialogEx::OnOK();
}
void CNotesDlg::OnBnClickedOk()
{
// TODO: Add your control notification handler code here
if (!CheckChanges(FALSE))
CDialogEx::OnCancel();
else
SaveChanges();
}
void CNotesDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
if (!CheckChanges())
CDialogEx::OnClose();
else
SaveChanges();
}