📄 listedit.cpp
字号:
// ListEdit.cpp : implementation file
//
#include "stdafx.h"
#include "人员管理系统.h"
#include "ListEdit.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CListEdit
CListEdit::CListEdit()
{
m_list=NULL;
m_record=NULL;
m_brush=::CreateSolidBrush(RGB(128,255,0));
m_isnumber=FALSE;
}
CListEdit::~CListEdit()
{
}
BEGIN_MESSAGE_MAP(CListEdit, CEdit)
//{{AFX_MSG_MAP(CListEdit)
ON_WM_KILLFOCUS()
ON_WM_CTLCOLOR_REFLECT()
ON_WM_RBUTTONDOWN()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CListEdit message handlers
void CListEdit::OnKillFocus(CWnd* pNewWnd)
{
CEdit::OnKillFocus(pNewWnd);
// TODO: Add your message handler code here
CString title;
GetWindowText(title);
if(title!=m_title)
{
CString sql;
sql="update "+m_table+" set ";
sql+=m_name+"='";
sql+=title+"' where ";
sql+="编号="+m_id;
try
{
m_record->m_pDatabase->ExecuteSQL(sql);
m_list->SetItemText(m_item,m_subitem,title);
}
catch(CDBException *e)
{
SetWindowText(m_title);
e->ReportError();
}
}
ShowWindow(SW_HIDE);
}
HBRUSH CListEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
// TODO: Change any attributes of the DC here
pDC->SetBkColor(RGB(128,255,0));
// TODO: Return a non-NULL brush if the parent's handler should not be called
return m_brush;
}
BOOL CListEdit::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_CHAR && m_isnumber)
{
UINT key=pMsg->wParam;
if( (key<'0' || key>'9') && (key!=8 && key!='.' && key!='-'))
return TRUE;
}
return CEdit::PreTranslateMessage(pMsg);
}
void CListEdit::OnRButtonDown(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_isnumber) return;
CEdit::OnRButtonDown(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -