⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseedit.cpp

📁 用VC+SQL实现的物流管理系统 “RxMediaPlayer” 文件夹中存放《物流综合管理系统》中《媒体播放平台》源程序 “数据库设置”文件夹中存放《物流综合管理系统》辅助工具《数据库设置》源程
💻 CPP
字号:
// BaseEdit.cpp : implementation file
//

#include "stdafx.h"
#include "MyProject.h"
#include "BaseEdit.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CBaseEdit

CBaseEdit::CBaseEdit()
{
	m_IsOnly=false;
	m_IsBool=false;
}

CBaseEdit::~CBaseEdit()
{
}


BEGIN_MESSAGE_MAP(CBaseEdit, CEdit)
	//{{AFX_MSG_MAP(CBaseEdit)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CBaseEdit message handlers

BOOL CBaseEdit::PreTranslateMessage(MSG* pMsg) 
{
	if(m_IsOnly==true && pMsg->message==WM_KEYDOWN)//只允许输入金额
	{
			//如果输入的字符不是1~9或“.”或其它功能键
		if((pMsg->wParam<0x30 || pMsg->wParam>0x39) && pMsg->wParam!=190 && pMsg->wParam!=8 && pMsg->wParam!=13)
			if(pMsg->wParam<VK_NUMPAD0 || pMsg->wParam>VK_NUMPAD9)// &&&&  pMsg->wParam!=VK_PERIOD
				pMsg->wParam=VK_CONTROL;
	}

	if(m_IsBool==true && pMsg->message==WM_KEYDOWN)
	{
		if(pMsg->wParam!=VK_NUMPAD0 && pMsg->wParam!=VK_NUMPAD1&&pMsg->wParam!=0x30 && pMsg->wParam!=0x31 && pMsg->wParam!=8 &&pMsg->wParam!=13)
				pMsg->wParam=VK_CONTROL;
	}
	if(pMsg->message==WM_KEYDOWN && pMsg->wParam==13)
		pMsg->wParam=9;

	if(pMsg->message==WM_KILLFOCUS)
	{
			CString sText;
	this->GetWindowText(sText);
	int Point=sText.Find(".");
	if(Point!=0)
	{
		int NextPoint=sText.Find(".",Point+1);
		if(NextPoint!=-1 && m_IsOnly==true)
		{
			MessageBox("请输入正确的数据!","系统提示",MB_OK|MB_ICONSTOP);
			this->SetFocus();
		}
	}
	}

	return CEdit::PreTranslateMessage(pMsg);
}

void CBaseEdit::IsMoneyOnly(bool bOnly)
{
	m_IsOnly=bOnly;
}


void CBaseEdit::IsBoolOnly(bool bOnly)
{
	m_IsBool=bOnly;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -