SetupDlg.cpp
上传用户:pumpssky
上传日期:2007-12-07
资源大小:110k
文件大小:3k
- // SetupDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "gmark.h"
- #include "SetupDlg.h"
- #include "define.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- extern CONF_DATA gtConfData;
- /////////////////////////////////////////////////////////////////////////////
- // CSetupDlg dialog
- CSetupDlg::CSetupDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CSetupDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSetupDlg)
- m_bAutoStart = -1;
- m_szRoverID = _T("");
- m_szRoverDesc = _T("");
- m_dOrigLon = 0.0;
- m_dOrigLat = 0.0;
- m_bDispGGA = FALSE;
- m_bDispRTCM = FALSE;
- //}}AFX_DATA_INIT
- }
- void CSetupDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSetupDlg)
- DDX_Radio(pDX, IDC_RADIO_AUTO, m_bAutoStart);
- DDX_Text(pDX, IDC_EDIT_ROVERID, m_szRoverID);
- DDV_MaxChars(pDX, m_szRoverID, 3);
- DDX_Text(pDX, IDC_EDIT_ROVERDES, m_szRoverDesc);
- DDV_MaxChars(pDX, m_szRoverDesc, 20);
- DDX_Text(pDX, IDC_EDIT_REFLON, m_dOrigLon);
- DDX_Text(pDX, IDC_EDIT_REFLAT, m_dOrigLat);
- DDX_Check(pDX, IDC_CHECK_DISPGGA, m_bDispGGA);
- DDX_Check(pDX, IDC_CHECK_DISPRTCM, m_bDispRTCM);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CSetupDlg, CDialog)
- //{{AFX_MSG_MAP(CSetupDlg)
- ON_BN_CLICKED(IDC_BUTTON_SAVE, OnButtonSave)
- ON_BN_CLICKED(IDC_BUTTON_CLEAR, OnButtonClear)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CSetupDlg message handlers
- void CSetupDlg::OnButtonSave()
- {
- // TODO: Add your control notification handler code here
- UpdateData();
- if(m_bAutoStart == 0) gtConfData.bAutoStart = TRUE;
- else gtConfData.bAutoStart = FALSE;
- gtConfData.bDispNEMA = m_bDispGGA;
- gtConfData.bDispRTCM = m_bDispRTCM;
- wcstombs(gtConfData.szRoverID, m_szRoverID.GetBuffer(0), sizeof(gtConfData.szRoverID));
- wcstombs(gtConfData.szRoverDesc, m_szRoverDesc.GetBuffer(0), sizeof(gtConfData.szRoverDesc));
- gtConfData.dOrigLon = m_dOrigLon;
- gtConfData.dOrigLat = m_dOrigLat;
- //Save to file
- FILE *fp;
- #ifndef _WIN32_WCE_CEPC
- fp = fopen("\ResidentFlash\config.txt","wt");
- #else
- fp = fopen("\config.txt","wt");
- #endif
- if(fp == NULL)
- {
- // MessageBox(_T("Open configuration file failed"));
- // return;
- }
- fprintf(fp, "%sn", gtConfData.szRoverID);
- fprintf(fp, "%sn", gtConfData.szRoverDesc);
- fprintf(fp, "%sn", gtConfData.szBaseIP);
- fprintf(fp, "%fn", gtConfData.dOrigLon);
- fprintf(fp, "%fn", gtConfData.dOrigLat);
-
- fprintf(fp, "%dn", gtConfData.bAutoStart);
- fprintf(fp, "%dn", gtConfData.bDispNEMA);
- fprintf(fp, "%dn", gtConfData.bDispRTCM);
- fclose(fp);
- }
- void CSetupDlg::OnButtonClear()
- {
- // TODO: Add your control notification handler code here
- if(gtConfData.bAutoStart)
- {
- m_bAutoStart = 0;
- }
- else
- {
- m_bAutoStart = 1;
- }
- if(gtConfData.bDispNEMA)
- {
- m_bDispGGA = 1;
- }
- else
- {
- m_bDispGGA = 0;
- }
- if(gtConfData.bDispRTCM)
- {
- m_bDispRTCM = 1;
- }
- else
- {
- m_bDispRTCM = 0;
- }
- m_szRoverID = gtConfData.szRoverID;
-
- m_szRoverDesc = gtConfData.szRoverDesc;
- m_dOrigLon = gtConfData.dOrigLon;
- m_dOrigLat = gtConfData.dOrigLat;
- UpdateData(FALSE);
- }
- BOOL CSetupDlg::OnInitDialog()
- {
- CDialog::OnInitDialog();
-
- // TODO: Add extra initialization here
-
- OnButtonClear();
-
- return TRUE; // return TRUE unless you set the focus to a control
- // EXCEPTION: OCX Property Pages should return FALSE
- }