Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.1 KiB

  1. // EmOptions.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "emshell.h"
  5. #include "EmOptions.h"
  6. #include <atlbase.h>
  7. #ifdef _DEBUG
  8. #define new DEBUG_NEW
  9. #undef THIS_FILE
  10. static char THIS_FILE[] = __FILE__;
  11. #endif
  12. /////////////////////////////////////////////////////////////////////////////
  13. // CEmOptions dialog
  14. CEmOptions::CEmOptions(CWnd* pParent /*=NULL*/)
  15. : CDialog(CEmOptions::IDD, pParent)
  16. {
  17. //{{AFX_DATA_INIT(CEmOptions)
  18. m_csRefreshRate = _T("");
  19. //}}AFX_DATA_INIT
  20. }
  21. void CEmOptions::DoDataExchange(CDataExchange* pDX)
  22. {
  23. CDialog::DoDataExchange(pDX);
  24. //{{AFX_DATA_MAP(CEmOptions)
  25. DDX_Control(pDX, IDC_OPTION_REFRESHRATE, m_ctrlRefreshRate);
  26. DDX_Text(pDX, IDC_OPTION_REFRESHRATE, m_csRefreshRate);
  27. //}}AFX_DATA_MAP
  28. }
  29. BEGIN_MESSAGE_MAP(CEmOptions, CDialog)
  30. //{{AFX_MSG_MAP(CEmOptions)
  31. //}}AFX_MSG_MAP
  32. END_MESSAGE_MAP()
  33. /////////////////////////////////////////////////////////////////////////////
  34. // CEmOptions message handlers
  35. BOOL CEmOptions::OnInitDialog()
  36. {
  37. CDialog::OnInitDialog();
  38. // TODO: Add extra initialization here
  39. DWORD dwPollSessionsFreq = 0L;
  40. ((CEmshellApp*)AfxGetApp())->GetEmShellRegOptions( TRUE, &dwPollSessionsFreq );
  41. m_csRefreshRate.Format(_T("%d"), dwPollSessionsFreq);
  42. UpdateData(FALSE);
  43. return TRUE; // return TRUE unless you set the focus to a control
  44. // EXCEPTION: OCX Property Pages should return FALSE
  45. }
  46. void CEmOptions::OnOK()
  47. {
  48. UpdateData();
  49. DWORD dwPollSessionsFreq = 0L;
  50. CString strMessage;
  51. strMessage.LoadString( IDS_OUTOFBOUNDS_REFRESHRATE );
  52. dwPollSessionsFreq = _ttol( (LPCTSTR) m_csRefreshRate );
  53. //Varify the data in the polling edit box
  54. if ( dwPollSessionsFreq < 1 || dwPollSessionsFreq > 300 ) {
  55. //Error to the user that they need to select a timing that is greater than 0 or less than 300
  56. ((CEmshellApp*)AfxGetApp())->DisplayErrMsgFromString( strMessage );
  57. //Set the focus into the edit control
  58. m_ctrlRefreshRate.SetFocus();
  59. m_ctrlRefreshRate.SetSel(0, -1);
  60. return;
  61. }
  62. ((CEmshellApp*)AfxGetApp())->SetEmShellRegOptions( TRUE, &dwPollSessionsFreq );
  63. CDialog::OnOK();
  64. }