⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cartestdlg.cpp

📁 汽车数据采集
💻 CPP
字号:
// cartestDlg.cpp : implementation file
//

#include "stdafx.h"
#include "cartest.h"
#include "cartestDlg.h"
#include"Login.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	afx_msg void OnStart();
	afx_msg void OnStart3();
	afx_msg void OnStop();
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
	//{{AFX_MSG_MAP(CAboutDlg)
	ON_BN_CLICKED(IDC_Start, OnStart)
	ON_BN_CLICKED(IDC_Start3, OnStart3)
	ON_BN_CLICKED(IDC_Stop, OnStop)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCartestDlg dialog

CCartestDlg::CCartestDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CCartestDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CCartestDlg)
	m_ed1 = _T("");
	m_ed2 = _T("");
	m_ed7 = _T("");
	m_ed8 = _T("");
	m_ed3 = _T("");
	m_ed5 = _T("");
	m_ed6 = _T("");
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CCartestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCartestDlg)
	DDX_Control(pDX, IDC_Redit, m_redit);
	DDX_Control(pDX, IDC_Ledit, m_ledit);
	DDX_Control(pDX, IDC_LIST, m_list);
	DDX_Control(pDX, IDC_Graph, m_graph);
	DDX_Control(pDX, IDC_smtitle, m_smtitle);
	DDX_Control(pDX, IDC_Title, m_title);
	DDX_Text(pDX, IDC_EDIT1, m_ed1);
	DDX_Text(pDX, IDC_EDIT2, m_ed2);
	DDX_Text(pDX, IDC_EDIT7, m_ed7);
	DDX_Text(pDX, IDC_EDIT8, m_ed8);
	DDX_Text(pDX, IDC_EDIT3, m_ed3);
	DDX_Text(pDX, IDC_EDIT5, m_ed5);
	DDX_Text(pDX, IDC_EDIT6, m_ed6);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CCartestDlg, CDialog)
	//{{AFX_MSG_MAP(CCartestDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
	ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_Button5, OnButton5)
	ON_BN_CLICKED(IDC_Button6, OnButton6)
	ON_BN_CLICKED(IDC_PRintG, OnPRintG)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCartestDlg message handlers
_ConnectionPtr mpconnection;
BOOL CCartestDlg::OnInitDialog()
{

	hWnd=GetSafeHwnd();
	g_end.ResetEvent ();
	AfxEnableControlContainer();
	CLogin login;	
GetDlgItem(IDC_BUTTON3)->EnableWindow(false);
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CCartestDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.



void CCartestDlg::OnPaint() 
{

	CPaintDC dc(this); // device context for painting
	
	SetDlgItemText(IDC_EDIT1,number[0]);
	SetDlgItemText(IDC_EDIT2,number[1]);
	SetDlgItemText(IDC_EDIT3,number[2]);
		SetDlgItemText(IDC_EDIT7,number[3]);
	SetDlgItemText(IDC_EDIT8,number[4]);
	SetDlgItemText(IDC_EDIT5,number[5]);
	SetDlgItemText(IDC_EDIT6,number[6]);
	CBitmap bit;
	CDC memDC;
	CRect rect;
	this->GetClientRect(&rect);
	bit.LoadBitmap(IDB_BITMAP1);
	memDC.CreateCompatibleDC(&dc);
	memDC.SelectObject(&bit);
	dc.BitBlt(0,0,rect.Width(),rect.Height(),&memDC,0,0,SRCCOPY);
	memDC.DeleteDC();
	::DeleteObject(&bit);
	dc.TextOut (200,180,"在此修改登陆信息!");
	dc.TextOut (160,220,"被检车主名:");
	dc.TextOut (160,250,"被检车牌号:");
	dc.TextOut (160,280,"被检车发动机号:");
	dc.TextOut (820,230,"检验员");
	dc.TextOut (820,270,"协调时间");
	dc.TextOut (750,170,"制动力总和/整车重");
	dc.TextOut (750,200,"制动力总和/整车重");
	
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}    
	
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CCartestDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CCartestDlg::OnButton4() 
{  
	CFont font;
	GetDlgItem(IDC_BUTTON4)->EnableWindow(false);
	GetDlgItem(IDC_BUTTON3)->EnableWindow(true);
	GetDlgItem(IDC_BUTTON1)->EnableWindow(false);
    GetDlgItem(IDC_EDIT1)->EnableWindow(false);
	GetDlgItem(IDC_EDIT2)->EnableWindow(false);
	GetDlgItem(IDC_EDIT3)->EnableWindow(false);
  SetDlgItemText(IDC_Title,"正在从机器读数,请稍候.......");
    	GetDlgItem(IDC_Title)->SetFont(&font);
   AfxBeginThread(ThreadProc,GetSafeHwnd());

// TODO: Add your control notification handler code here
	
}

void CCartestDlg::OnButton3() 
{

CFont font;
GetDlgItem(IDC_BUTTON3)->EnableWindow(false);
   GetDlgItem(IDC_BUTTON4)->EnableWindow(true);
GetDlgItem(IDC_BUTTON1)->EnableWindow(true);
GetDlgItem(IDC_EDIT1)->EnableWindow(true);
	GetDlgItem(IDC_EDIT2)->EnableWindow(true);
	GetDlgItem(IDC_EDIT3)->EnableWindow(true);
SetDlgItemText(IDC_Title,"待命检测........");

GetDlgItem(IDC_Title)->SetFont(&font);
	// TODO: Add your control notification handler code here
	
}

void CCartestDlg::OnButton2() 
{
//TODO: Add your control notification handler code here
	
}

void CCartestDlg::OnButton1() 
{
	CAboutDlg sys;
	sys.DoModal ();
	// TODO: Add your control notification handler code here
	
}



void CCartestDlg::OnButton5() 
{
	MessageBox("请检查GetValue.DLL,调用GetValue.DLL失败",NULL,MB_OK);

  // TODO: Add your control notification handler code here
	
}
   


void CCartestDlg::OnButton6() 
{
CCartestDlg dlg;
	CString carname,carnumber,motonumber,checkname,time,dipan;

	CString s;
	

			m_set.m_strFilter.Format("[车主名]='%s'",number[0]);
		if(m_set.IsOpen())
        m_set.Requery();
            else 
				m_set.Open();
		
		 m_set.AddNew();
		m_set.m_column1=number[0];
		 m_set.m_column2=number[1];
	  m_set.m_column3=number[2];
		 m_set.m_column4=number[3];
		 m_set.m_column5=number[4];
		 m_set.m_column6=number[5];
		 m_set.Update();
			 m_set.m_strFilter="";
			 MessageBox(number[0]);
			MessageBox("保存成功!","恭喜",MB_OK);
			m_set.Close();
		
		

		
	
	 
}

void CCartestDlg::OnPRintG() 
{
	// TODO: Add your control notification handler code here

	MessageBox("调用GetValue.DLL失败,没有可打印的图形,确定退出!");
}

void CAboutDlg::OnStart() 
{
	// TODO: Add your control notification handler code here
MessageBox("没有获得左电机信息!","电机控制",MB_OKCANCEL);
GetDlgItem(IDC_Stop)->EnableWindow(true);
}

void CAboutDlg::OnStart3() 
{
	// TODO: Add your control notification handler code here
GetDlgItem(IDC_Stop)->EnableWindow(true);
	MessageBox("没有获得右电机的信息!","电机控制",MB_OKCANCEL);
}

void CAboutDlg::OnStop() 
{
	// TODO: Add your control notification handler code here

}

BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
GetDlgItem(IDC_Stop)->EnableWindow(false);	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
//画图函数,在控件PICTRUE上画曲线
float pic1draw(float x,float y,CDC dc)
{ 
	
	newpen.CreatePen (PS_DASH,1,RGB(255,0,0));
	dc.SelectObject (&newpen);
	dc.MoveTo (0,4);
	dc.LineTo (x,y);
	dc.SelectObject (oldpen);
	

	return true;
}
//开始检测开线程的回调函数
UINT ThreadProc(LPVOID pPar)
{

   
		::Sleep(100);
		//::pic1draw (x,y,globaldc);
		return 0;
   
		
	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -