当前位置: 首页> 游戏> 游戏 > 番禺网站推广_仿站工具教程_网络新闻发布平台发稿_销售crm客户管理系统

番禺网站推广_仿站工具教程_网络新闻发布平台发稿_销售crm客户管理系统

时间:2025/7/14 0:37:00来源:https://blog.csdn.net/weixin_42350092/article/details/142986148 浏览次数:0次
番禺网站推广_仿站工具教程_网络新闻发布平台发稿_销售crm客户管理系统

承接专栏《MFC工控项目实例二十三模拟量输入设置界面》
对模拟量输入的零点校正值及满量程对应的电压值进行输入。
1、在SenSet.h文件中添加代码

#include "BtnST.h"
#include "ShadeButtonST.h"/
// SenSet dialogclass SenSet : public CDialog
{
// Construction
public:SenSet(CWnd* pParent = NULL);   // standard constructorCFont m_font;CString	m_Path;CString strFilePath;int nSel;CString nSel_str;// Dialog Data//{{AFX_DATA(SenSet)enum { IDD = IDD_DIALOG_SEN_TEST };CListCtrl	m_IDC_LIST2;CListBox	m_IDC_LIST1;CShadeButtonST	m_bAdd_2;CShadeButtonST	m_bDel_2;CShadeButtonST	m_bParameter_2;CShadeButtonST	m_bReturn_2;//}}AFX_DATA// Overrides// ClassWizard generated virtual function overrides//{{AFX_VIRTUAL(SenSet)protected:virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support//}}AFX_VIRTUAL// Implementation
protected:// Generated message map functions//{{AFX_MSG(SenSet)virtual BOOL OnInitDialog();afx_msg void OnButton7();afx_msg void OnSelchangeList1();afx_msg void OnClickList2(NMHDR* pNMHDR, LRESULT* pResult);afx_msg void OnButton1();//}}AFX_MSGDECLARE_MESSAGE_MAP()
};

2、在SenSet.cpp文件中添加代码

#include "stdafx.h"
#include "seal_pressure.h"
#include "SenSet.h"
#include "Data_2.h"
#include "PC60002K.H"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif/
// SenSet dialogSenSet::SenSet(CWnd* pParent /*=NULL*/): CDialog(SenSet::IDD, pParent)
{
m_font.CreateFont(-28,0,0,0,700,FALSE,FALSE,0,134,OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,FF_SWISS,"楷体_GB2312");TCHAR exeFullPath[MAX_PATH];GetModuleFileName(NULL,exeFullPath,MAX_PATH);m_Path = exeFullPath;for(int i = m_Path.GetLength() - 1; i > 0 ; i --){if(m_Path.GetAt(i) == '\\')break;}SetCurrentDirectory(m_Path);m_Path = m_Path.Left(i);strFilePath= m_Path + "\\Test.ini";nAddr_AD_2=0x110;	COMB_Data_AD_Number_2=(sizeof(COMB_Data_AD_2) / sizeof(COMB_Data_AD_2[1]));
}void SenSet::DoDataExchange(CDataExchange* pDX)
{CDialog::DoDataExchange(pDX);//{{AFX_DATA_MAP(SenSet)DDX_Control(pDX, IDC_LIST2, m_IDC_LIST2);DDX_Control(pDX, IDC_LIST1, m_IDC_LIST1);DDX_Control(pDX, IDC_BUTTON1, m_bAdd_2);DDX_Control(pDX, IDC_BUTTON2, m_bDel_2);DDX_Control(pDX, IDC_BUTTON6, m_bParameter_2);DDX_Control(pDX, IDC_BUTTON7, m_bReturn_2);//}}AFX_DATA_MAP
}BEGIN_MESSAGE_MAP(SenSet, CDialog)//{{AFX_MSG_MAP(SenSet)ON_BN_CLICKED(IDC_BUTTON7, OnButton7)ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)ON_NOTIFY(NM_CLICK, IDC_LIST2, OnClickList2)ON_BN_CLICKED(IDC_BUTTON1, OnButton1)//}}AFX_MSG_MAP
END_MESSAGE_MAP()/
// SenSet message handlersBOOL SenSet::OnInitDialog() 
{CDialog::OnInitDialog();m_bAdd_2.SetShade(CShadeButtonST::SHS_HARDBUMP);m_bDel_2.SetShade(CShadeButtonST::SHS_HARDBUMP);m_bParameter_2.SetShade(CShadeButtonST::SHS_HARDBUMP);m_bReturn_2.SetShade(CShadeButtonST::SHS_HARDBUMP);DWORD dwExStyles = m_IDC_LIST2.GetExtendedStyle();m_IDC_LIST2.SetExtendedStyle(dwExStyles |LVS_EX_GRIDLINES |LVS_EX_FULLROWSELECT | LVS_EX_FLATSB |LVS_EX_ONECLICKACTIVATE);LVCOLUMN cloumn;int i;cloumn.mask = LVCF_TEXT|LVCF_WIDTH;cloumn.pszText = "序号";cloumn.cx =50;i = m_IDC_LIST2.InsertColumn(0,&cloumn);cloumn.mask = LVCF_TEXT|LVCF_WIDTH;cloumn.pszText = "电压";cloumn.cx =120;i =m_IDC_LIST2.InsertColumn(1,&cloumn);cloumn.pszText = "对应值";cloumn.cx =120;i = m_IDC_LIST2.InsertColumn(2,&cloumn);for( i=0;i<COMB_Data_AD_Number_2;i++){GetPrivateProfileString("AD输入",COMB_Data_AD_2[i],NULL,b_str_AD_2[i].GetBuffer(20),20,strFilePath);if (b_str_AD_2[i]!="-1" ){//  AD_2[i]=_ttoi(b_str_AD_2[i]);m_IDC_LIST1.AddString(COMB_Data_AD_2[i]);}}if( OpenDevice6K() != TRUE )
AfxMessageBox("Open device failed!");return TRUE;  // return TRUE unless you set the focus to a control// EXCEPTION: OCX Property Pages should return FALSE
}void SenSet::OnButton7() 
{EndDialog(IDD_DIALOG_BOA_TEST);}void SenSet::OnSelchangeList1() 
{m_bAdd_2.EnableWindow(true);m_bParameter_2.EnableWindow(true);nSel =m_IDC_LIST1.GetCurSel();m_IDC_LIST1.GetText(nSel,nSel_str);Sleep(500);CString str;str.Format("%d",nSel);CString str6[16],str7[16],str8[16],str9[16];GetPrivateProfileString("A/D设置",nSel_str+"零点电压",NULL,str6[16].GetBuffer(20),20,strFilePath);GetPrivateProfileString("A/D设置",nSel_str+"零点数值",NULL,str7[16].GetBuffer(20),20,strFilePath);GetPrivateProfileString("A/D设置",nSel_str+"量程电压",NULL,str8[16].GetBuffer(20),20,strFilePath);GetPrivateProfileString("A/D设置",nSel_str+"量程数值",NULL,str9[16].GetBuffer(20),20,strFilePath);m_IDC_LIST2.DeleteAllItems();m_IDC_LIST2.InsertItem(0, _T("1"));   m_IDC_LIST2.SetItemText(0, 1,_T(str6[16]));  m_IDC_LIST2.SetItemText(0, 2,str7[16]);m_IDC_LIST2.InsertItem(1, _T("2"));   m_IDC_LIST2.SetItemText(1, 1,str8[16]);  m_IDC_LIST2.SetItemText(1, 2,str9[16]);//	SetDlgItemText(IDC_STATIC99,str);  
}void SenSet::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult) 
{m_bDel_2.EnableWindow(true);	*pResult = 0;
}void SenSet::OnButton1() 
{CString str1,str2,str4,str5;CString str6[16],str7[16],str8[16],str9[16];GetDlgItemText(IDC_EDIT1,str1);GetDlgItemText(IDC_EDIT2,str2);GetDlgItemText(IDC_EDIT4,str4);GetDlgItemText(IDC_EDIT5,str5);WritePrivateProfileString("A/D设置",nSel_str+"零点电压",str1,strFilePath);WritePrivateProfileString("A/D设置",nSel_str+"零点数值",str2,strFilePath);WritePrivateProfileString("A/D设置",nSel_str+"量程电压",str4,strFilePath);WritePrivateProfileString("A/D设置",nSel_str+"量程数值",str5,strFilePath);Sleep(500);GetPrivateProfileString("A/D设置",nSel_str+"零点电压",NULL,str6[16].GetBuffer(20),20,strFilePath);GetPrivateProfileString("A/D设置",nSel_str+"零点数值",NULL,str7[16].GetBuffer(20),20,strFilePath);GetPrivateProfileString("A/D设置",nSel_str+"量程电压",NULL,str8[16].GetBuffer(20),20,strFilePath);GetPrivateProfileString("A/D设置",nSel_str+"量程数值",NULL,str9[16].GetBuffer(20),20,strFilePath);Sleep(500);m_IDC_LIST2.DeleteAllItems();m_IDC_LIST2.InsertItem(0, _T("1"));   m_IDC_LIST2.SetItemText(0, 1,_T(str6[16]));  m_IDC_LIST2.SetItemText(0, 2,str7[16]); 
//	m_IDC_LIST2.DeleteAllItems();m_IDC_LIST2.InsertItem(1, _T("2"));   m_IDC_LIST2.SetItemText(1, 1,str8[16]);  m_IDC_LIST2.SetItemText(1, 2,str9[16]);    }

运行程序
在这里插入图片描述

关键字:番禺网站推广_仿站工具教程_网络新闻发布平台发稿_销售crm客户管理系统

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: