BEGIN_MESSAGE_MAP(CUSB_I2C_SRF08App, CWinApp)
//{{AFX_MSG_MAP(CUSB_I2C_SRF08App)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG
ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUSB_I2C_SRF08App construction
CUSB_I2C_SRF08App::CUSB_I2C_SRF08App()
{
// TODO: add construction code here,
// Place all significant initialization in InitInstance
}
/////////////////////////////////////////////////////////////////////////////
// The one and only CUSB_I2C_SRF08App object
// Standard initialization
// If you are not using these features and wish to reduce the size
// of your final executable, you should remove from the following
// the specific initialization routines you do not need.
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
CUSB_I2C_SRF08Dlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
CUSB_I2C_SRF08Dlg::CUSB_I2C_SRF08Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CUSB_I2C_SRF08Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CUSB_I2C_SRF08Dlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CUSB_I2C_SRF08Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUSB_I2C_SRF08Dlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
// 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
CWinApp* App = AfxGetApp( );
CommPort = App->GetProfileInt("SETTINGS","COMPORT",0);
switch(CommPort) {
case 1: SetupCommPort("COM1");
((CButton*)GetDlgItem(IDC_COM1))->SetCheck(1);
break;
case 2: SetupCommPort("COM2");
((CButton*)GetDlgItem(IDC_COM2))->SetCheck(1);
break;
case 3: SetupCommPort("COM3");
((CButton*)GetDlgItem(IDC_COM3))->SetCheck(1);
break;
case 4: SetupCommPort("COM4");
((CButton*)GetDlgItem(IDC_COM4))->SetCheck(1);
break;
case 5: SetupCommPort("COM5");
((CButton*)GetDlgItem(IDC_COM5))->SetCheck(1);
break;
case 6: SetupCommPort("COM6");
((CButton*)GetDlgItem(IDC_COM6))->SetCheck(1);
break;
case 7: SetupCommPort("COM7");
((CButton*)GetDlgItem(IDC_COM7))->SetCheck(1);
break;
case 8: SetupCommPort("COM8");
((CButton*)GetDlgItem(IDC_COM8))->SetCheck(1);
break;
default: ((CButton*)GetDlgItem(IDC_COM1))->SetCheck(0);
}
SetTimer(1, 600, 0);
return TRUE; // return TRUE unless you set the focus to a control
}
// 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 CUSB_I2C_SRF08Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
// 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 CUSB_I2C_SRF08Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
s.Format("%i ", sbuf[1]);
SetDlgItemText( IDC_SRF08_LIGHT, s );
n = sbuf[2]<<8;
n |= sbuf[3];
s.Format("%i", n);
SetDlgItemText( IDC_SRF08_US, s );
s.Format("%i", n/58);
SetDlgItemText( IDC_SRF08_CM, s );
s.Format("%i", n/148);
SetDlgItemText( IDC_SRF08_INCH, s );