📄 wzdxchng.cpp
字号:
// WzdXchng
//
#include "stdafx.h"
#include "WzdXchng.h"
#include "WzdStr.h"
#include <afxpriv.h>
/////////////////////////////////////////////////////////////////////////////
// CWzdXchng
void AFXAPI DDX_Text(CDataExchange* pDX, int nIDC, CByteArray& value)
{
CWzdString str;
HWND hWndCtrl = pDX->PrepareEditCtrl(nIDC);
if (pDX->m_bSaveAndValidate)
{
int nLen = ::GetWindowTextLength(hWndCtrl);
::GetWindowText(hWndCtrl, str.GetBufferSetLength(nLen), nLen+1);
str.ReleaseBuffer();
int size=str.GetLength();
if (size%2)
{
AfxMessageBox("Please enter even number of digits.");
pDX->Fail(); // throws exception
}
size/=2;
value.SetSize(size);
str.GetBinary(value.GetData(),size);
}
else
{
str.PutBinary(value.GetData(),value.GetSize());
AfxSetWindowText(hWndCtrl, str); //sets window text only if it's different
}
}
void AFXAPI DDV_MaxChars(CDataExchange* pDX, CByteArray const& value, int nBytes)
{
if (pDX->m_bSaveAndValidate && value.GetSize() > nBytes)
{
CString str;
str.Format("Maximum characters you can enter is %d!",nBytes);
AfxMessageBox(str, MB_ICONEXCLAMATION);
str.Empty(); // will not return after exception
pDX->Fail();
}
else if (pDX->m_hWndLastControl != NULL && pDX->m_bEditLastControl)
{
// set edit box not to allow more then these bytes
// note that this function depends on being called right after the DDX function
::SendMessage(pDX->m_hWndLastControl, EM_LIMITTEXT, nBytes*2, 0);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -