📄 dlgwarnset.cpp
字号:
// DlgWarnSet.cpp : implementation file
//
#include "stdafx.h"
#include "CQuakeDemo.h"
#include "DlgWarnSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgWarnSet dialog
CDlgWarnSet::CDlgWarnSet(CWnd* pParent /*=NULL*/)
: CDialog(CDlgWarnSet::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgWarnSet)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CDlgWarnSet::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgWarnSet)
DDX_Control(pDX, IDC_EDIT_YELLOWMARK, m_edit_yellow);
DDX_Control(pDX, IDC_EDIT_REDMARK, m_edit_red);
DDX_Control(pDX, IDC_STATIC_IM, m_static_im);
DDX_Control(pDX, IDC_LIST_WARN, m_list_warn);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgWarnSet, CDialog)
//{{AFX_MSG_MAP(CDlgWarnSet)
ON_NOTIFY(NM_CLICK, IDC_LIST_WARN, OnClickListWarn)
ON_EN_CHANGE(IDC_EDIT_REDMARK, OnChangeEditRedmark)
ON_EN_CHANGE(IDC_EDIT_YELLOWMARK, OnChangeEditYellowmark)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgWarnSet message handlers
BOOL CDlgWarnSet::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_edit_yellow.SelectStockType(FDT_FLOAT);
m_edit_yellow.ModifyFilter("-","");
m_edit_red.SelectStockType(FDT_FLOAT);
m_edit_red.ModifyFilter("-","");
//
CString str1, str2, str3;
str1.LoadString(IDS_STRING_DLGWARNSET1);
str2.LoadString(IDS_STRING_DLGWARNSET2);
str3.LoadString(IDS_STRING_DLGWARNSET3);
m_list_warn.InsertColumn(0,str1,LVCFMT_LEFT,45);
m_list_warn.InsertColumn(1,str2,LVCFMT_LEFT,165);
m_list_warn.InsertColumn(2,str3,LVCFMT_LEFT,165);
m_list_warn.ModifyStyle(NULL,LVS_SHOWSELALWAYS);
m_list_warn.SetExtendedStyle(LVS_EX_FULLROWSELECT);
m_edit_red.SetLimitText(8);
m_edit_yellow.SetLimitText(8);
FlashList();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgWarnSet::FlashList()
{
m_list_warn.DeleteAllItems();
CString index;
CString strRed;
CString strYellow;
for(int i = 0; i < m_WarnList.GetSize(); i++)
{
index.Format(_T("%d"),m_WarnList.GetSize()-i);
m_list_warn.InsertItem(i,_T(""));
for(int j = 0; j <3; j++)
{
strRed.Format(_T("%f"),m_WarnList.GetAt(i).fRed);
strYellow.Format(_T("%f"),m_WarnList.GetAt(i).fYellow);
switch(j)
{
case 0:m_list_warn.SetItemText(i,j,index);break;
case 1:m_list_warn.SetItemText(i,j,strRed);break;
case 2:m_list_warn.SetItemText(i,j,strYellow);break;
}
}
}
}
void CDlgWarnSet::OnClickListWarn(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
int index = m_list_warn.GetSelectionMark();
if(index == -1)return;
CString im;
CString strLoad;
strLoad.LoadString(IDS_STRING_DLGWARNSET_PROMPT);
im.Format(strLoad,m_WarnList.GetSize()-index);
m_static_im.SetWindowText(im);
//
CString strRed;
CString strYellow;
strRed.Format(_T("%f"),m_WarnList[index].fRed);
strYellow.Format(_T("%f"),m_WarnList[index].fYellow);
m_edit_red.SetWindowText(strRed);
m_edit_yellow.SetWindowText(strYellow);
*pResult = 0;
}
void CDlgWarnSet::OnChangeEditRedmark()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
int index = m_list_warn.GetSelectionMark();
if(index == -1)return;
CString strRed;
m_edit_red.GetWindowText(strRed);
m_list_warn.SetItemText(index,1,strRed);
m_WarnList[index].fRed = fabs(_tcstod(strRed,NULL));
// TODO: Add your control notification handler code here
}
void CDlgWarnSet::OnChangeEditYellowmark()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
int index = m_list_warn.GetSelectionMark();
if(index == -1)return;
CString strYellow;
m_edit_yellow.GetWindowText(strYellow);
m_list_warn.SetItemText(index,2,strYellow);
m_WarnList[index].fYellow = fabs(_tcstod(strYellow,NULL));
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -