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.

152 lines
5.4 KiB

  1. /*******************************************************************
  2. * DESCRIPTION: General Dialog handler
  3. *******************************************************************/
  4. #include "Access.h"
  5. extern INT_PTR WINAPI SerialKeyDlg(HWND, UINT, WPARAM, LPARAM);
  6. extern LPTSTR HelpFile();
  7. // *******************************************************************
  8. // GeneralDialog handler
  9. // *******************************************************************
  10. INT_PTR WINAPI GeneralDlg (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  11. int i;
  12. SERIALKEYS serk;
  13. BOOL fProcessed = TRUE;
  14. char tempPort[10]; // Max 10 characters for a port name
  15. BOOL isAdmin = TRUE;
  16. switch (uMsg) {
  17. case WM_INITDIALOG:
  18. {
  19. TCHAR szMinutes[50];
  20. int ctch = LoadString(g_hinst, IDS_MINUTES, szMinutes, ARRAY_SIZE(szMinutes));
  21. Assert(ctch);
  22. CheckDlgButton(hwnd, IDC_TO_ENABLE, (g_ato.dwFlags & ATF_TIMEOUTON) ? TRUE : FALSE);
  23. // Init the timeout combobox
  24. for (i= 0; i < 6; i++) {
  25. TCHAR szBuf[256];
  26. wsprintf(szBuf, __TEXT("%d %s"), ((i + 1) * 5), szMinutes);
  27. ComboBox_AddString(GetDlgItem(hwnd, IDC_TO_TIMEOUTVAL), szBuf);
  28. }
  29. ComboBox_SetCurSel(GetDlgItem(hwnd, IDC_TO_TIMEOUTVAL), g_ato.iTimeOutMSec / (1000 * 60 * 5) - 1);
  30. if (!(g_ato.dwFlags & ATF_TIMEOUTON))
  31. EnableWindow(GetDlgItem(hwnd, IDC_TO_TIMEOUTVAL), FALSE);
  32. // Notification: Give wanring...
  33. CheckDlgButton(hwnd, IDC_WARNING_SOUND, g_fShowWarnMsgOnFeatureActivate);
  34. // Notification: Make a sound...
  35. CheckDlgButton(hwnd, IDC_SOUND_ONOFF, g_fPlaySndOnFeatureActivate);
  36. // Support SerialKey devices
  37. CheckDlgButton(hwnd, IDC_SK_ENABLE, (g_serk.dwFlags & SERKF_SERIALKEYSON) ? TRUE : FALSE);
  38. if (!(g_serk.dwFlags & SERKF_AVAILABLE)) {
  39. EnableWindow(GetDlgItem(hwnd, IDC_SK_SETTINGS), FALSE);
  40. EnableWindow(GetDlgItem(hwnd, IDC_SK_ENABLE), FALSE);
  41. }
  42. // JMR: What is this for?
  43. CheckDlgButton(hwnd, IDC_SAVE_SETTINGS, !g_fSaveSettings);
  44. // Administrative options:
  45. // Enable/Disable all admin options.
  46. isAdmin = IsDefaultWritable();
  47. EnableWindow(GetDlgItem(hwnd, IDC_GEN_GROUP_4), isAdmin);
  48. EnableWindow(GetDlgItem(hwnd, IDC_ADMIN_LOGON), isAdmin);
  49. EnableWindow(GetDlgItem(hwnd, IDC_ADMIN_DEFAULT), isAdmin);
  50. }
  51. break;
  52. case WM_HELP:
  53. WinHelp(((LPHELPINFO) lParam)->hItemHandle, HelpFile(), HELP_WM_HELP, (DWORD_PTR) (LPSTR) g_aIds);
  54. break;
  55. case WM_CONTEXTMENU:
  56. WinHelp((HWND) wParam, HelpFile(), HELP_CONTEXTMENU, (DWORD_PTR) (LPSTR) g_aIds);
  57. break;
  58. case WM_COMMAND:
  59. switch (GET_WM_COMMAND_ID(wParam, lParam)) {
  60. case IDC_WARNING_SOUND:
  61. g_fShowWarnMsgOnFeatureActivate = !g_fShowWarnMsgOnFeatureActivate;
  62. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM) hwnd, 0);
  63. break;
  64. case IDC_SOUND_ONOFF:
  65. g_fPlaySndOnFeatureActivate = !g_fPlaySndOnFeatureActivate;
  66. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM) hwnd, 0);
  67. break;
  68. case IDC_SAVE_SETTINGS:
  69. g_fSaveSettings = !g_fSaveSettings;
  70. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM) hwnd, 0);
  71. break;
  72. case IDC_TO_ENABLE:
  73. g_ato.dwFlags ^= ATF_TIMEOUTON;
  74. if (!(g_ato.dwFlags & ATF_TIMEOUTON))
  75. EnableWindow(GetDlgItem(hwnd, IDC_TO_TIMEOUTVAL), FALSE);
  76. else
  77. EnableWindow(GetDlgItem(hwnd, IDC_TO_TIMEOUTVAL), TRUE);
  78. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM) hwnd, 0);
  79. break;
  80. case IDC_SK_ENABLE:
  81. g_serk.dwFlags ^= SERKF_SERIALKEYSON;
  82. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM) hwnd, 0);
  83. break;
  84. case IDC_SK_SETTINGS:
  85. // HACK. Here the pointers are copied. So, When you change
  86. // in the dialog. temporary variable 'serk' looses its original value
  87. // Save that in tempPort and use that instead a-anilk
  88. serk = g_serk;
  89. lstrcpy((LPTSTR)tempPort, g_serk.lpszActivePort);
  90. if (DialogBox(g_hinst, MAKEINTRESOURCE(IDD_SERKEYSETTING), hwnd, SerialKeyDlg) == IDCANCEL)
  91. {
  92. g_serk = serk;
  93. lstrcpy(g_serk.lpszActivePort, (LPCTSTR)tempPort);
  94. }
  95. else SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM) hwnd, 0);
  96. break;
  97. case IDC_TO_TIMEOUTVAL:
  98. switch(HIWORD(wParam)) {
  99. case CBN_CLOSEUP:
  100. i = ComboBox_GetCurSel(GetDlgItem(hwnd, IDC_TO_TIMEOUTVAL));
  101. g_ato.iTimeOutMSec = (ULONG) ((long) ((i + 1) * 5) * 60 * 1000);
  102. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM) hwnd, 0);
  103. break;
  104. }
  105. break;
  106. case IDC_ADMIN_LOGON:
  107. g_fCopyToLogon = !g_fCopyToLogon;
  108. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM) hwnd, 0);
  109. break;
  110. case IDC_ADMIN_DEFAULT:
  111. g_fCopyToDefault = !g_fCopyToDefault;
  112. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM) hwnd, 0);
  113. break;
  114. }
  115. break;
  116. case WM_NOTIFY:
  117. switch (((NMHDR *)lParam)->code) {
  118. case PSN_APPLY: SetAccessibilitySettings(); break;
  119. }
  120. break;
  121. default:
  122. fProcessed = FALSE;
  123. break;
  124. }
  125. return(fProcessed);
  126. }
  127. ///////////////////////////////// End of File /////////////////////////////////