Leaked source code of windows server 2003
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.

147 lines
3.2 KiB

  1. //Copyright (c) 1997-2000 Microsoft Corporation
  2. #include "pch.hxx" // pch
  3. #pragma hdrstop
  4. #include "resource.h"
  5. #include "pgTmeOut.h"
  6. CAccessTimeOutPg::CAccessTimeOutPg(
  7. LPPROPSHEETPAGE ppsp
  8. ) : WizardPage(ppsp, IDS_WIZACCESSTIMEOUTTITLE, IDS_WIZACCESSTIMEOUTSUBTITLE)
  9. {
  10. m_dwPageId = IDD_WIZACCESSTIMEOUT;
  11. ppsp->pszTemplate = MAKEINTRESOURCE(m_dwPageId);
  12. }
  13. CAccessTimeOutPg::~CAccessTimeOutPg(
  14. VOID
  15. )
  16. {
  17. }
  18. int g_nTimeOuts = 6;
  19. DWORD g_rgdwTimeOuts[] = {5*60000, 10*60000, 15*60000, 20*60000, 25*60000, 30*60000};
  20. LRESULT
  21. CAccessTimeOutPg::OnInitDialog(
  22. HWND hwnd,
  23. WPARAM wParam,
  24. LPARAM lParam
  25. )
  26. {
  27. HWND hwndTimeOut = GetDlgItem(m_hwnd, IDC_TO_TIMEOUTVAL);
  28. // JMC: TODO: Maybe move these into the string table
  29. // Set timeouts for 5 to 30 minutes
  30. int i;
  31. for (i= 0; i < g_nTimeOuts; i++)
  32. {
  33. TCHAR buf[256];
  34. wsprintf(buf,__TEXT("%d"),g_rgdwTimeOuts[i]/60000);
  35. ComboBox_InsertString(hwndTimeOut, i, buf);
  36. }
  37. BOOL bEnable = g_Options.m_schemePreview.m_ACCESSTIMEOUT.dwFlags & ATF_TIMEOUTON;
  38. if(bEnable)
  39. {
  40. Button_SetCheck(GetDlgItem(m_hwnd, IDC_TO_ENABLE), TRUE);
  41. EnableWindow (GetDlgItem(m_hwnd,IDC_TO_TIMEOUTVAL),TRUE);
  42. }
  43. else
  44. {
  45. // Hack for radio buttons
  46. if(GetDlgItem(m_hwnd, IDC_TO_DISABLE))
  47. Button_SetCheck(GetDlgItem(m_hwnd, IDC_TO_DISABLE), TRUE);
  48. EnableWindow (GetDlgItem(m_hwnd,IDC_TO_TIMEOUTVAL),FALSE);
  49. }
  50. // Figure out the time to use as default
  51. int nIndex = 0;
  52. for(i = g_nTimeOuts - 1;i>=0;i--)
  53. {
  54. // Brute Force find the largest value
  55. if(g_rgdwTimeOuts[i] >= g_Options.m_schemePreview.m_ACCESSTIMEOUT.iTimeOutMSec)
  56. nIndex = i;
  57. else
  58. break;
  59. }
  60. ComboBox_SetCurSel(hwndTimeOut, nIndex);
  61. return 1;
  62. }
  63. void CAccessTimeOutPg::UpdateControls()
  64. {
  65. // enable/disable the combo box depending on which radio
  66. // button is selected
  67. if(Button_GetCheck(GetDlgItem(m_hwnd, IDC_TO_ENABLE)))
  68. {
  69. EnableWindow (GetDlgItem(m_hwnd,IDC_TO_TIMEOUTVAL), TRUE);
  70. EnableWindow (GetDlgItem(m_hwnd,IDC_MIN), TRUE);
  71. }
  72. else
  73. {
  74. EnableWindow (GetDlgItem(m_hwnd,IDC_TO_TIMEOUTVAL), FALSE);
  75. EnableWindow (GetDlgItem(m_hwnd,IDC_MIN), FALSE);
  76. }
  77. }
  78. LRESULT
  79. CAccessTimeOutPg::OnCommand(
  80. HWND hwnd,
  81. WPARAM wParam,
  82. LPARAM lParam
  83. )
  84. {
  85. LRESULT lResult = 1;
  86. WORD wNotifyCode = HIWORD(wParam);
  87. WORD wCtlID = LOWORD(wParam);
  88. HWND hwndCtl = (HWND)lParam;
  89. switch(wCtlID)
  90. {
  91. case IDC_TO_DISABLE:
  92. case IDC_TO_ENABLE:
  93. // These commands require us to re-enable/disable the appropriate controls
  94. UpdateControls();
  95. lResult = 0;
  96. break;
  97. default:
  98. break;
  99. }
  100. return lResult;
  101. }
  102. LRESULT
  103. CAccessTimeOutPg::OnPSN_WizNext(
  104. HWND hwnd,
  105. INT idCtl,
  106. LPPSHNOTIFY pnmh
  107. )
  108. {
  109. BOOL bUseAccessTimeOut= Button_GetCheck(GetDlgItem(m_hwnd, IDC_TO_ENABLE));
  110. if(bUseAccessTimeOut)
  111. g_Options.m_schemePreview.m_ACCESSTIMEOUT.dwFlags |= ATF_TIMEOUTON;
  112. else
  113. g_Options.m_schemePreview.m_ACCESSTIMEOUT.dwFlags &= ~ATF_TIMEOUTON;
  114. int nIndex = ComboBox_GetCurSel(GetDlgItem(m_hwnd, IDC_TO_TIMEOUTVAL));
  115. g_Options.m_schemePreview.m_ACCESSTIMEOUT.iTimeOutMSec = g_rgdwTimeOuts[nIndex];
  116. g_Options.ApplyPreview();
  117. return WizardPage::OnPSN_WizNext(hwnd, idCtl, pnmh);
  118. }