📄 floatedit.cpp
字号:
// FloatEdit.cpp : implementation file
//
#include "stdafx.h"
#include "Calend_CE.h"
#include "FloatEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFloatEdit
CFloatEdit::CFloatEdit()
{
}
CFloatEdit::~CFloatEdit()
{
}
BEGIN_MESSAGE_MAP(CFloatEdit, CEdit)
//{{AFX_MSG_MAP(CFloatEdit)
ON_WM_CHAR()
ON_CONTROL_REFLECT(EN_CHANGE, OnChange)
// ON_CONTROL_REFLECT(EN_UPDATE, OnUpdate)
ON_WM_KEYDOWN()
ON_WM_KEYUP()
ON_CONTROL_REFLECT(EN_ERRSPACE, OnErrspace)
ON_CONTROL_REFLECT(EN_KILLFOCUS, OnKillfocus)
ON_CONTROL_REFLECT(EN_MAXTEXT, OnMaxtext)
ON_CONTROL_REFLECT(EN_SETFOCUS, OnSetfocus)
ON_WM_CLOSE()
ON_WM_COMPAREITEM()
ON_WM_CREATE()
ON_WM_KILLFOCUS()
ON_WM_SETFOCUS()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFloatEdit message handlers
void CFloatEdit::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
static CString separators(_T("."));
TCHAR tChar=(TCHAR)nChar;
if((IsCharAlphaNumeric(tChar)&&!IsCharAlpha(tChar))
||separators.Find(nChar)!=-1
||tChar==8)
{
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
else
MessageBeep(MB_ICONASTERISK);
}
CFloatEdit::operator float()
{
double dReturn;
CString number;
LPTSTR endpointer;
GetWindowText(number);
#ifdef _UNICODE
dReturn=wcstod((LPCTSTR)number,&endpointer);
#else
dReturn=strtod((LPCTSTR)number,&endpointer);
#endif
return (float)dReturn;
}
float CFloatEdit::operator =(float f)
{
return f;
}
void CFloatEdit::OnChange()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CEdit::OnInitDialog()
// function to send the EM_SETEVENTMASK message to the control
// with the ENM_CHANGE flag ORed into the lParam mask.
// TODO: Add your control notification handler code here
}
void CFloatEdit::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CEdit::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CFloatEdit::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
CEdit::OnKeyUp(nChar, nRepCnt, nFlags);
}
BOOL CFloatEdit::OnChildNotify(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pLResult)
{
// TODO: Add your specialized code here and/or call the base class
return CEdit::OnChildNotify(message, wParam, lParam, pLResult);
}
BOOL CFloatEdit::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo)
{
// TODO: Add your specialized code here and/or call the base class
return CEdit::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
BOOL CFloatEdit::OnCommand(WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
return CEdit::OnCommand(wParam, lParam);
}
BOOL CFloatEdit::OnNotify(WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
// TODO: Add your specialized code here and/or call the base class
return CEdit::OnNotify(wParam, lParam, pResult);
}
void CFloatEdit::OnFinalRelease()
{
// TODO: Add your specialized code here and/or call the base class
CEdit::OnFinalRelease();
}
BOOL CFloatEdit::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Add your specialized code here and/or call the base class
return CEdit::PreCreateWindow(cs);
}
void CFloatEdit::PreSubclassWindow()
{
// TODO: Add your specialized code here and/or call the base class
//SubclassWindow(m_hWnd);
CEdit::PreSubclassWindow();
}
void CFloatEdit::OnErrspace()
{
// TODO: Add your control notification handler code here
}
void CFloatEdit::OnKillfocus()
{
// TODO: Add your control notification handler code here
}
void CFloatEdit::OnMaxtext()
{
// TODO: Add your control notification handler code here
}
void CFloatEdit::OnSetfocus()
{
// TODO: Add your control notification handler code here
}
void CFloatEdit::OnClose()
{
// TODO: Add your message handler code here and/or call default
CEdit::OnClose();
}
int CFloatEdit::OnCompareItem(int nIDCtl, LPCOMPAREITEMSTRUCT lpCompareItemStruct)
{
// TODO: Add your message handler code here and/or call default
return CEdit::OnCompareItem(nIDCtl, lpCompareItemStruct);
}
int CFloatEdit::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CEdit::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
return 0;
}
void CFloatEdit::OnKillFocus(CWnd* pNewWnd)
{
CEdit::OnKillFocus(pNewWnd);
// TODO: Add your message handler code here
}
void CFloatEdit::OnSetFocus(CWnd* pOldWnd)
{
CEdit::OnSetFocus(pOldWnd);
// TODO: Add your message handler code here
}
WNDPROC* CFloatEdit::GetSuperWndProcAddr()
{
static WNDPROC NEAR pfnSuper;
return &pfnSuper;
}
LRESULT CFloatEdit::DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
return CEdit::DefWindowProc(message, wParam, lParam);
}
LRESULT CFloatEdit::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
return CEdit::WindowProc(message, wParam, lParam);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -