Files
geomative/GeomativeStudio/cpp/Views/ModifyIpCurveDlg.cpp
T
coco df489d5640 a
2026-07-03 16:05:30 +08:00

241 lines
6.3 KiB
C++

// ModifyIpCurveDlg.cpp : implementation file
//
#include "stdafx.h"
#include "geomative.h"
#include "ModifyIpCurveDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern int g_iUILanguage;
/////////////////////////////////////////////////////////////////////////////
// CModifyIpCurveDlg dialog
CModifyIpCurveDlg::CModifyIpCurveDlg(CTestingData *f_td, CWnd* pParent /*=NULL*/)
: CDialog(CModifyIpCurveDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CModifyIpCurveDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_nPeriod = 0;
m_pTdType = f_td;
}
// CModifyIpCurveDlg::CModifyIpCurveDlg(CWnd* pParent /*=NULL*/)
// : CDialog(CModifyIpCurveDlg::IDD, pParent)
// {
// //{{AFX_DATA_INIT(CModifyIpCurveDlg)
// // NOTE: the ClassWizard will add member initialization here
// //}}AFX_DATA_INIT
// }
void CModifyIpCurveDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CModifyIpCurveDlg)
DDX_Control(pDX, IDC_EDIT, m_Edit);
DDX_Control(pDX, IDC_RANGE, m_CurveList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CModifyIpCurveDlg, CDialog)
//{{AFX_MSG_MAP(CModifyIpCurveDlg)
ON_NOTIFY(NM_DBLCLK, IDC_RANGE, OnDblclkRange)
ON_WM_LBUTTONDBLCLK()
ON_EN_KILLFOCUS(IDC_EDIT, OnKillfocusEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CModifyIpCurveDlg message handlers
BOOL CModifyIpCurveDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_CurveList.SetExtendedStyle(m_CurveList.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_GRIDLINES);
m_CurveList.InsertColumn(0,"Index", 70,72);
m_CurveList.InsertColumn(1,"Start", 70,72);
m_CurveList.InsertColumn(2,"Width", 70,72);
CString szTmp = _T("");
for (int n = 9; n >= 0; n--)
{
szTmp.Format("M%d", n);
m_CurveList.InsertItem(0, szTmp);
}
m_pTdType->GetTimeWindowList(m_CurveList);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CModifyIpCurveDlg::OnOK()
{
// TODO: Add extra validation here
CStringArray szArray;
CString szTmp = _T("");
CString szData = _T("");
int nTWStart = 0, nTWWidth = 0;
bool bIsWidthEmpty = false;
for (int n = 0; n < 10; n++)
{
//取起始时间
szData = m_CurveList.GetItemText(n, 1);
nTWStart = atoi(szData.GetBuffer(0));
//取宽度
szData = m_CurveList.GetItemText(n, 2);
nTWWidth = atoi(szData.GetBuffer(0));
if (nTWStart < 0 || nTWWidth < 0)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("时窗配置错误!"));
else
MessageBoxEx(NULL, _T("Config time windows info error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
if ((nTWStart + nTWWidth) > m_nPeriod)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("时窗配置超长!"));
else
MessageBoxEx(NULL, _T("Config time window is too long!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
if (0 == nTWWidth && nTWStart != 0)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("时窗配置错误!"));
else
MessageBoxEx(NULL, _T("Config time window info error!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
//如果有配置宽度信息为0
if (0 == nTWWidth)
{
bIsWidthEmpty = true;
}
else
{
//如果在配置时窗宽度的时候,前面有配置过时窗宽度为0,那么此时将报错
if (bIsWidthEmpty)
{
if (LANG_ZHCN == g_iUILanguage)
AfxMessageBox(_T("时窗配置乱序!"));
else
MessageBoxEx(NULL, _T("Config time windows disorder!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
return;
}
}
szTmp.Empty();
szTmp.Format("M%dST = %d", n, nTWStart);
szArray.Add(szTmp);
szTmp.Empty();
szTmp.Format("M%dTW = %d", n, nTWWidth);
szArray.Add(szTmp);
}
szTmp.Empty();
szData.Empty();
CString szSql = _T("");
szSql = "update ac set ";
for (int i = 0; i < szArray.GetSize(); i++)
{
szSql += szArray.GetAt(i);
if (i != szArray.GetSize() - 1)
szSql += ",";
}
szTmp.Format(" where TDID = %d", m_pTdType->m_dwID);
szSql += szTmp;
m_pTdType->ExcuteSql(szSql);
CDialog::OnOK();
}
void CModifyIpCurveDlg::OnDblclkRange(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
NM_LISTVIEW* pNMListView=(NM_LISTVIEW*)pNMHDR;
CRect rc;
if(pNMListView->iItem!=-1)
{
m_row=pNMListView->iItem;//m_row为被选中行的行序号(int类型成员变量)
m_column=pNMListView->iSubItem;//m_column为被选中行的列序号(int类型成员变量)
m_CurveList.GetSubItemRect(pNMListView->iItem, pNMListView->iSubItem,LVIR_LABEL,rc);//取得子项的矩形
rc.top+=14;
rc.left+=16;
rc.right+=16;
rc.bottom+=18;
CString szTmp = _T("");
szTmp = m_CurveList.GetItemText(pNMListView->iItem, pNMListView->iSubItem);
//编辑的表格必须要有内容,且第一列不能编辑
if (szTmp.GetLength() != 0 && szTmp.Left(1) != "M")
{
m_Edit.SetWindowText(szTmp);//将子项的内容显示到编辑框中
m_Edit.ShowWindow(SW_SHOW);//显示编辑框
m_Edit.MoveWindow(&rc);//将编辑框移动到子项上面,覆盖在子项上
m_Edit.SetFocus();//使编辑框取得焦点
m_Edit.CreateSolidCaret(1,rc.Height()-5);//创建一个光标
m_Edit.ShowCaret();//显示光标
m_Edit.SetSel(0, -1);//光标文字全选
// m_Edit.SetSel(-1);//使光标移到最后面
}
}
*pResult = 0;
}
void CModifyIpCurveDlg::OnKillfocusEdit()
{
// TODO: Add your control notification handler code here
// TODO: Add your control notification handler code here
CString str;
m_Edit.GetWindowText(str);//取得编辑框的内容
if (str.GetLength() == 0)
{
str = _T("0");
}
m_CurveList.SetItemText(m_row,m_column,str);//将该内容更新到CListCtrl中
m_Edit.ShowWindow(SW_HIDE);//隐藏编辑框
}
BOOL CModifyIpCurveDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN)
{
return TRUE;
}
return CDialog::PreTranslateMessage(pMsg);
}