- Visual C++源码
- Visual Basic源码
- C++ Builder源码
- Java源码
- Delphi源码
- C/C++源码
- PHP源码
- Perl源码
- Python源码
- Asm源码
- Pascal源码
- Borland C++源码
- Others源码
- SQL源码
- VBScript源码
- JavaScript源码
- ASP/ASPX源码
- C#源码
- Flash/ActionScript源码
- matlab源码
- PowerBuilder源码
- LabView源码
- Flex源码
- MathCAD源码
- VBA源码
- IDL源码
- Lisp/Scheme源码
- VHDL源码
- Objective-C源码
- Fortran源码
- tcl/tk源码
- QT源码
NumericEdit.cpp
资源名称:pciexp.zip [点击查看]
上传用户:zhuqijet
上传日期:2007-01-04
资源大小:138k
文件大小:3k
源码类别:
驱动编程
开发平台:
Visual C++
- // NumericEdit.cpp : implementation file
- //
- #include "stdafx.h"
- #include "stdlib.h"
- #include "NumericEdit.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // NumericEdit
- CNumericEdit::CNumericEdit()
- {
- deffmt = NULL;
- }
- CNumericEdit::CNumericEdit(LPCTSTR fmt)
- {
- deffmt = fmt;
- }
- CNumericEdit::~CNumericEdit()
- {
- }
- BEGIN_MESSAGE_MAP(CNumericEdit, CEdit)
- //{{AFX_MSG_MAP(CNumericEdit)
- // NOTE - the ClassWizard will add and remove mapping macros here.
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // NumericEdit message handlers
- /****************************************************************************
- * CNumericEdit.SetWindowText
- * Inputs:
- * int val: Value to set
- * LPCTSTR fmt: Format value to use
- * Result: void
- *
- * Effect:
- * Sets a representation of the numeric value to the window
- ****************************************************************************/
- void CNumericEdit::SetWindowText(int val, LPCTSTR fmt)
- {
- if(fmt == NULL)
- { /* no explict format */
- if(deffmt == NULL)
- fmt = _T("%d");
- else
- fmt = deffmt;
- } /* no explict format */
- CString s;
- s.Format(fmt, val);
- // Reduce flicker: see if we have same string; don't set text if
- // strings are identical.
- CString oldstr;
- CEdit::GetWindowText(oldstr);
- if(lstrcmp(oldstr, s) != 0)
- CEdit::SetWindowText(s);
- }
- /****************************************************************************
- * CNumericEdit::GetWindowInt
- * Result: int
- * Integer value stored in edit control
- ****************************************************************************/
- int CNumericEdit::GetWindowInt()
- {
- CString s;
- GetWindowText(s);
- int val;
- // TODO: Write Hex recognition code here...
- #ifdef _UNICODE
- val = _wtoi(s);
- #else
- val = atoi(s);
- #endif
- return val;
- }
- /****************************************************************************
- * CNumericEdit::Blank
- * Result: void
- *
- * Effect:
- * Blanks the contents of the control
- ****************************************************************************/
- void CNumericEdit::Blank()
- {
- CEdit::SetWindowText(_T(""));
- }