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.

151 lines
5.3 KiB

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