Files
envi-code/SourceCode/Code2026/ArchCmd/FZSS2Dlg.cpp
T
gjm 164968b62e chore
把非utf8-bom编码的cpp/h文件改为 utf8 bom 编码, msvc识别utf8编码时,如果不是bom格式的,会使用当前cp_oem来解码.
2026-10-04 00:04:20 +08:00

138 lines
3.5 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// FZSS2Dlg.cpp : implementation file
#include "stdafx.h"
#include "FZSS2Dlg.h"
IMPLEMENT_DYNAMIC(CFZSS2Dlg, CDialog)
//CFZSS2Dlg::CFZSS2Dlg(CWnd* pParent /*=nullptr*/)
// : CDialog(IDD_FZSS2_DLG, pParent)
// , m_dOffFrWall(0)
// , m_dEl(0)
// , m_dInThick(20)
// , m_dOutThick(10)
//{
//
//}
CFZSS2Dlg::CFZSS2Dlg(const std::vector<double>& arWidthd, double dOffFrWall, double dEl, double dInThick, double dOutThick, CWnd* pParent)
: CDialog(IDD_FZSS2_DLG, pParent)
, m_arWidthd(arWidthd)
, m_dOffFrWall(dOffFrWall)
, m_dEl(dEl)
, m_dInThick(dInThick)
, m_dOutThick(dOutThick)
{
}
CFZSS2Dlg::~CFZSS2Dlg()
{
}
void CFZSS2Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT2, m_dOffFrWall);
DDX_Text(pDX, IDC_EDIT10, m_dEl);
DDX_Text(pDX, IDC_EDIT3, m_dInThick);
DDX_Text(pDX, IDC_EDIT6, m_dOutThick);
DDX_Control(pDX, IDC_LIST1, m_ListCtrl);
DDX_Control(pDX, IDC_EDIT1, m_EditW);
}
BEGIN_MESSAGE_MAP(CFZSS2Dlg, CDialog)
ON_BN_CLICKED(IDOK, &CFZSS2Dlg::OnBnClickedOk)
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CFZSS2Dlg::OnDblclkList)
ON_EN_KILLFOCUS(IDC_EDIT1, &CFZSS2Dlg::OnKillFocus)
END_MESSAGE_MAP()
BOOL CFZSS2Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
initCtrls();
UpdateData(FALSE);
return TRUE;
}
void CFZSS2Dlg::initCtrls()
{
m_ListCtrl.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_SINGLEROW);
m_ListCtrl.EnableToolTips(TRUE);
CRect rect;
m_ListCtrl.GetClientRect(&rect);// 获取编程语言列表视图控件的位置和大小
m_ListCtrl.InsertColumn(0, _T("分段数"), LVCFMT_LEFT, rect.Width() / 2);
m_ListCtrl.InsertColumn(1, _T("宽度"), LVCFMT_LEFT, rect.Width() / 2);
CString strNum(_T(""));
for (int i(0); i < m_arWidthd.size(); ++i)
{
strNum.Format(_T("第%d段"), (i + 1));
m_ListCtrl.InsertItem(i, strNum);
}
CString strWidth(_T(""));
for (int i(0); i < m_arWidthd.size(); ++i)
{
strWidth.Format(_T("%.2f"), m_arWidthd.at(i));
m_ListCtrl.SetItemText(i, 1, strWidth);
}
}
void CFZSS2Dlg::OnBnClickedOk()
{
CString strW(_T(""));
m_arWidths.clear();
for (int i(0); i < m_arWidthd.size(); ++i)
{
strW = m_ListCtrl.GetItemText(i, 1);
m_arWidths.push_back(strW);
}
OnOK();
}
void CFZSS2Dlg::OnDblclkList(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<NMITEMACTIVATE*>(pNMHDR);
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
CRect rc;
m_Row = pNMListView->iItem;//获得选中的行
m_Col = pNMListView->iSubItem;//获得选中列
int n = m_ListCtrl.GetItemCount();//获取当前一共多少行
if (pNMListView->iSubItem < -1) //如果选择的是子项;
{
return;
}
m_ListCtrl.GetSubItemRect(m_Row, m_Col, LVIR_LABEL, rc);//获得子项的RECT;
m_EditW.SetParent(&m_ListCtrl);//转换坐标为列表框中的坐标
m_EditW.MoveWindow(rc);//移动Edit到RECT坐在的位置;
m_EditW.SetWindowText(m_ListCtrl.GetItemText(m_Row, m_Col));//将该子项中的值放在Edit控件中;
m_EditW.ShowWindow(SW_SHOW);//显示Edit控件;
m_EditW.SetFocus();//设置Edit焦点
m_EditW.ShowCaret();//显示光标
m_EditW.SetSel(-1);//将光标移动到最后
if (m_Row == n - 1)
{
m_ListCtrl.InsertItem(m_Row + 1, _T(""));
}
}
void CFZSS2Dlg::OnKillFocus()
{
CString tem;
m_EditW.GetWindowText(tem); //得到用户输入的新的内容
m_ListCtrl.SetItemText(m_Row, m_Col, tem); //设置编辑框的新内容
m_EditW.ShowWindow(SW_HIDE); //隐藏编辑框
}
void CFZSS2Dlg::getUserInputData(std::vector<CString> & arWidths)
{
arWidths.clear();
arWidths.assign(m_arWidths.begin(), m_arWidths.end());//赋值
return;
}