-
Notifications
You must be signed in to change notification settings - Fork 76
/
DDV_validation.cpp
73 lines (54 loc) · 1.91 KB
/
DDV_validation.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
#include "stdafx.h"
#include "resource.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
/*
Custom DDX/DDV processing
=========================
This file provides the extra processing which enables the "minimum length" for
CStrings in the Class Wizard.
If you have to rebuild the winforms.CLW file, then you must insert the following
lines in the first section of that file (ie. in the [General Info] section).
They are inserted at the end of the section.
; ClassWizard DDX information for custom DDX functions
ExtraDDXCount=2
ExtraDDX1=E;;String with min and max;CString;;MinMaxString;CString with a minimum and maximum length;MinMaxString;M&inimum length;d;Ma&ximum length;d
ExtraDDX2=M;;String with min and max;CString;;MinMaxCBString;CString with a minimum and maximum length;MinMaxCBString;M&inimum length;d;Ma&ximum length;d
*/
void AFXAPI DDV_MinMaxString(CDataExchange* pDX, CString& value, int nMinChars, int nMaxChars)
{
value.TrimLeft ();
value.TrimRight ();
if (pDX->m_bSaveAndValidate && value.GetLength() < nMinChars)
{
TCHAR szT[32];
if (nMinChars == 1)
TMessageBox("This field may not be blank", MB_ICONEXCLAMATION);
else
{
wsprintf(szT, _T("%d"), nMinChars);
CString prompt;
AfxFormatString1(prompt, IDS_MIN_STRING_SIZE, szT);
AfxMessageBox(prompt, MB_ICONEXCLAMATION, AFX_IDP_PARSE_STRING_SIZE);
prompt.Empty(); // exception prep
}
pDX->Fail();
}
// now test maximum length
DDV_MaxChars (pDX, value, nMaxChars);
}
void AFXAPI DDX_MinMaxString(CDataExchange* pDX, int nIDC, CString& value)
{
DDX_Text(pDX, nIDC, value);
}
void AFXAPI DDV_MinMaxCBString(CDataExchange* pDX, CString& value, int nMinChars, int nMaxChars)
{
DDV_MinMaxString (pDX, value, nMinChars, nMaxChars);
}
void AFXAPI DDX_MinMaxCBString(CDataExchange* pDX, int nIDC, CString& value)
{
DDX_CBString(pDX, nIDC, value);
}