15,979
社区成员
发帖
与我相关
我的任务
分享
void CWriteVADlg::OnEnChangeVa01()
{
UpdateData(true);
}
void CWriteVADlg::OnEnChangeVa02()
{
UpdateData(true);
}
void CWriteVADlg::OnBnClickedOk()
{
if (OpenRunDB())
{
SetVAValue("VA01",float_VA01);
SetVAValue("VA02",float_VA02);
CloseRunDB();
AfxMessageBox(_T("变量值写入成功!"));
}
else
{
AfxMessageBox(_T("变量值写入失败,请重试!"));
}
OnOK();
}
void CWriteVADlg::OnBnClickedCancel()
{
OnCancel();
}
其它的代码都是vs自己生成的,我也不知道怎么生成的,分别有啥用。BOOL CNewEdit::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(WM_KEYDOWN == pMsg->message)
{
WPARAM ch = pMsg->wParam;
if((ch >= _T('0') && ch <= _T('9'))
|| (ch == VK_DELETE)
|| (ch == VK_BACK)
|| (VK_SUBTRACT == ch)
|| (0xbe == ch)
|| (0xbd == ch)
|| (VK_LEFT == ch)
|| (VK_RIGHT == ch))
{
return CEdit::PreTranslateMessage(pMsg);
}
return TRUE;
}
return CEdit::PreTranslateMessage(pMsg);
}
void CEditEx::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if((nChar>='0'&&nChar<='9')||nChar=='-')
{
if(nChar=='-')
{
CString str;
GetWindowText(str);
if(str.GetLength()>0)
{
AfxMessageBox("负号只能在第一位");
return;
}
}
}
else
{
AfxMessageBox("输入有误");
return;
}
CEdit::OnChar(nChar, nRepCnt, nFlags);
}
if (!_AfxSimpleFloatParse(szBuffer, d))
{
AfxMessageBox(AFX_IDP_PARSE_REAL);
pDX->Fail(); // throws exception
}