// ConfigDlg.cpp : implementation file
//

#include "stdafx.h"
#include "ConfigDlg.h"

#include "TConfig.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// ConfigDlg dialog


ConfigDlg::ConfigDlg(CWnd* pParent /*=NULL*/)
   : CDialog(ConfigDlg::IDD, pParent)
{
   //{{AFX_DATA_INIT(ConfigDlg)
      // NOTE: the ClassWizard will add member initialization here
   //}}AFX_DATA_INIT
}


void ConfigDlg::DoDataExchange(CDataExchange* pDX)
{
   CDialog::DoDataExchange(pDX);
   //{{AFX_DATA_MAP(ConfigDlg)
      // NOTE: the ClassWizard will add DDX and DDV calls here
   //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(ConfigDlg, CDialog)
   //{{AFX_MSG_MAP(ConfigDlg)
   ON_EN_CHANGE(IDC_EDIT_TIME_DELAY, OnChangeEdit1)
   ON_WM_DESTROY()
   //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// ConfigDlg message handlers

void ConfigDlg::OnOK() 
{
   // TODO: Add extra validation here

   EndDialog(0);
}

void ConfigDlg::OnChangeEdit1() 
{
   // TODO: If this is a RICHEDIT control, the control will not
   // send this notification unless you override the CDialog::OnInitDialog()
   // function and call CRichEditCtrl().SetEventMask()
   // with the ENM_CHANGE flag ORed into the mask.
   
   // TODO: Add your control notification handler code here
}

BOOL ConfigDlg::OnInitDialog() 
{
   CDialog::OnInitDialog();
   
   // TODO: Add extra initialization here
   
   editTimeDelay = (CEdit*)GetDlgItem(IDC_EDIT_TIME_DELAY);

   CString str;
   int t = config.getTimeDelay();
   str.Format( "%d", t );
   editTimeDelay->SetWindowText( str );

   return TRUE;  // return TRUE unless you set the focus to a control
                 // EXCEPTION: OCX Property Pages should return FALSE
}

void ConfigDlg::OnDestroy() 
{
   CDialog::OnDestroy();
   
   // TODO: Add your message handler code here
   char buf[20];
   editTimeDelay->GetWindowText( buf, 20 );
   int timeDelay = atoi(buf);
   config.setTimeDelay( timeDelay );
}
