-
Notifications
You must be signed in to change notification settings - Fork 0
/
GotoPageDlg.cpp
104 lines (79 loc) · 2.45 KB
/
GotoPageDlg.cpp
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
// WinDjView
// Copyright (C) 2004-2009 Andrew Zhezherun
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
// http://www.gnu.org/copyleft/gpl.html
// $Id: GotoPageDlg.cpp,v 1.9 2009/01/28 16:59:19 zhezherun Exp $
#include "stdafx.h"
#include "WinDjView.h"
#include "GotoPageDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#endif
// CGotoPageDlg dialog
IMPLEMENT_DYNAMIC(CGotoPageDlg, CMyDialog)
CGotoPageDlg::CGotoPageDlg(int nPage, int nPageCount, CWnd* pParent)
: CMyDialog(CGotoPageDlg::IDD, pParent), m_nPage(nPage + 1), m_nPageCount(nPageCount)
{
m_edtPage.SetInteger();
}
CGotoPageDlg::~CGotoPageDlg()
{
}
void CGotoPageDlg::DoDataExchange(CDataExchange* pDX)
{
CMyDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PAGE, m_edtPage);
DDX_Text(pDX, IDC_PAGE, m_nPage);
if (!pDX->m_bSaveAndValidate)
{
CString strPageCount = FormatString(IDS_OF_PAGE_COUNT, m_nPageCount);
DDX_Text(pDX, IDC_PAGE_COUNT, strPageCount);
}
}
BEGIN_MESSAGE_MAP(CGotoPageDlg, CMyDialog)
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN_PAGE, OnPageUpDown)
ON_EN_KILLFOCUS(IDC_PAGE, OnUpdateDialogData)
END_MESSAGE_MAP()
// CGotoPageDlg message handlers
void CGotoPageDlg::OnPageUpDown(NMHDR* pNMHDR, LRESULT* pResult)
{
UpdateData();
LPNMUPDOWN pNMUpDown = reinterpret_cast<LPNMUPDOWN>(pNMHDR);
if (pNMUpDown->iDelta < 0)
++m_nPage;
else
--m_nPage;
if (m_nPage < 1)
m_nPage = 1;
else if (m_nPage > m_nPageCount)
m_nPage = m_nPageCount;
UpdateData(false);
*pResult = 0;
}
void CGotoPageDlg::OnUpdateDialogData()
{
UpdateData();
if (m_nPage < 1)
m_nPage = 1;
else if (m_nPage > m_nPageCount)
m_nPage = m_nPageCount;
UpdateData(false);
}
void CGotoPageDlg::OnOK()
{
OnUpdateDialogData();
CMyDialog::OnOK();
}