Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
MyCombo.cpp
Package: 44757463.rar [view]
Upload User: lj3531212
Upload Date: 2007-06-18
Package Size: 346k
Code Size: 3k
Category:
Graph Drawing
Development Platform:
Visual C++
- // MyCombo.cpp : implementation file
- //
- #include "stdafx.h"
- #include "GraphSoft.h"
- #include "MyCombo.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMyCombo
- CMyCombo::CMyCombo()
- {
- }
- CMyCombo::~CMyCombo()
- {
- }
- BEGIN_MESSAGE_MAP(CMyCombo, CComboBox)
- //{{AFX_MSG_MAP(CMyCombo)
- ON_WM_KEYDOWN()
- ON_WM_KEYUP()
- ON_WM_SYSKEYDOWN()
- ON_WM_SYSKEYUP()
- ON_WM_CHAR()
- ON_CONTROL_REFLECT(CBN_EDITCHANGE, OnEditchange)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CMyCombo message handlers
- void CMyCombo::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: Add your message handler code here and/or call default
- if(nChar>=(UINT)'0'&&nChar<=(UINT)'9')
- CComboBox::OnKeyDown(nChar, nRepCnt, nFlags);
- }
- void CMyCombo::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: Add your message handler code here and/or call default
- if(nChar>=(UINT)'0'&&nChar<=(UINT)'9')
- CComboBox::OnKeyUp(nChar, nRepCnt, nFlags);
- }
- void CMyCombo::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: Add your message handler code here and/or call default
- if(nChar>=(UINT)'0'&&nChar<=(UINT)'9')
- CComboBox::OnSysKeyDown(nChar, nRepCnt, nFlags);
- }
- void CMyCombo::OnSysKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: Add your message handler code here and/or call default
- if(nChar>=(UINT)'0'&&nChar<=(UINT)'9')
- CComboBox::OnSysKeyUp(nChar, nRepCnt, nFlags);
- }
- void CMyCombo::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
- {
- // TODO: Add your message handler code here and/or call default
- if(nChar>=(UINT)'0'&&nChar<=(UINT)'9')
- CComboBox::OnChar(nChar, nRepCnt, nFlags);
- }
- void CMyCombo::OnEditchange()
- {
- // TODO: Add your control notification handler code here
- CString m_str;
- GetWindowText(m_str);
- if(m_str.GetLength()>0)
- {
- if(IsNumber(m_str))
- {
- if(atoi(m_str)>999){
- SetWindowText(m_str.Left(3));
- SetEditSel(3,3);
- }else if(atoi(m_str)<-999){//多了一个‘-’号
- SetWindowText(m_str.Left(4));
- SetEditSel(4,4);
- }
- }
- else
- {
- SetWindowText(GetNumberStr(m_str));
- SetEditSel(GetNumberStr(m_str).GetLength(),GetNumberStr(m_str).GetLength());
- }
- }
- }
- BOOL CMyCombo::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
- return CComboBox::PreTranslateMessage(pMsg);
- }
- BOOL CMyCombo::IsNumber(CString str)
- {
- int i,j;
- i=0;
- j=str.GetLength();
- if((str[0]<'0'||str[0]>'9')&&str[0]!='-')
- return FALSE;
- for(i=1;i<j;i++)
- {
- if(str[i]<'0'||str[i]>'9')
- return FALSE;
- }
- return TRUE;
- }
- CString CMyCombo::GetNumberStr(CString str)
- {
- int i,j,k;
- char* m_pchar=new char[str.GetLength()];
- k=0;
- j=str.GetLength();
- i=0;
- if(str[0]=='-'){
- i=1;
- m_pchar[k++]='-';
- }
- for(;i<j;i++)
- {
- if(str[i]<'0'||str[i]>'9')
- {
- }
- else
- {
- m_pchar[k++]=str[i];
- }
- }
- m_pchar[k]='';
- CString m_str(m_pchar);
- delete[] m_pchar;
- return m_str;
- }