// EditFuzzyValue.h : header file // // Copyright (C) 2002-2004 William Braynen // Contact information can be found at www.samdurak.com // // The CEditFuzzyValue MFC class consists of two files: // EditFuzzyValue.cpp and EditFuzzyValue.h. It is a subclass of CEdit // and allows on-the-fly user data input validation in a Windows edit // control. It allows the user to input numbers only between 0 and // 1 inclusively [0,1] and automatically formats the number to the // second decimal. So a typed in '1' magically turns into '1.00', and // '0.5' into '0.50'. Of course the user can also type in '0.51'. // Typing a decimal point with no preceding zero ('.') results in '0.' // // Use this class just as you would a regular CEdit class. // Just replace 'CEdit' in the declaration by 'CEditFuzzyValue'. // And don't forget to #include EditFuzzyValue.h (this header file). // // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #if !defined(AFX_EDITFUZZYVALUE_H__0EF472F6_67F6_4588_A4DC_6CAE96B81EB4__INCLUDED_) #define AFX_EDITFUZZYVALUE_H__0EF472F6_67F6_4588_A4DC_6CAE96B81EB4__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 ///////////////////////////////////////////////////////////////////////////// // CEditFuzzyValue window class CEditFuzzyValue : public CEdit { // Construction public: CEditFuzzyValue(); // Attributes public: // Operations public: // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(CEditFuzzyValue) public: virtual BOOL PreTranslateMessage(MSG* pMsg); //}}AFX_VIRTUAL // Implementation public: bool m_bChopOffExtraZeros; void SetValue (float fValue); float GetValue(); CString Format(CString text); virtual ~CEditFuzzyValue(); // Generated message map functions protected: CString FormatExtraZeros (CString text); //{{AFX_MSG(CEditFuzzyValue) afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags); afx_msg void OnKillFocus(CWnd* pNewWnd); //}}AFX_MSG DECLARE_MESSAGE_MAP() }; ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_EDITFUZZYVALUE_H__0EF472F6_67F6_4588_A4DC_6CAE96B81EB4__INCLUDED_)