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.

110 lines
3.3 KiB

  1. /*******************************************************************
  2. *
  3. * DESCRIPTION: Serial Keys Dialog handler
  4. *
  5. * HISTORY:
  6. *
  7. *******************************************************************/
  8. #include "Access.h"
  9. #define NUMPORTS 8
  10. #define NUMRATES 6
  11. extern LPTSTR HelpFile();
  12. INT_PTR WINAPI SerialKeyDlg (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
  13. int i;
  14. UINT uBaud;
  15. UINT uBaudRates[] = { 300, 1200, 2400, 4800, 9600, 19200 };
  16. TCHAR szBuf[256];
  17. BOOL fProcessed = TRUE;
  18. switch (uMsg) {
  19. case WM_INITDIALOG:
  20. LoadString(g_hinst, IDS_COMPORT, szBuf, ARRAY_SIZE(szBuf));
  21. for (i=1; i <= 4; i++) {
  22. TCHAR szBuf2[256];
  23. // Make a correct port name and add it to the list box.
  24. wsprintf(szBuf2, __TEXT("%s%d"), szBuf, i);
  25. ComboBox_AddString(GetDlgItem(hwnd, IDC_SK_PORT), szBuf2);
  26. }
  27. // Select the current com port.
  28. if (g_serk.lpszActivePort[0] != '\0') {
  29. int cport;
  30. // For now we assume that the format of the string is
  31. // com[digit]. So comport[3] = the com port number
  32. // Set all invalid ports to 'COM1'
  33. cport = g_serk.lpszActivePort[3] - '1';
  34. if (cport < 0) cport = 0;
  35. if (cport > 4) cport = 0;
  36. // Set the active port.
  37. ComboBox_SetCurSel(GetDlgItem(hwnd, IDC_SK_PORT), cport);
  38. } else {
  39. // Else default to COM1.
  40. ComboBox_SetCurSel(GetDlgItem(hwnd, IDC_SK_PORT), 0);
  41. lstrcpy(g_serk.lpszActivePort, __TEXT("COM1"));
  42. }
  43. // Fill in the BAUD RATE options
  44. uBaud = 1; // Default baud rate.
  45. for (i = 0; i < NUMRATES; i++) {
  46. TCHAR szBuf1[256]; // renamed to avoid name clash with szBuf
  47. wsprintf(szBuf1, __TEXT("%d"), uBaudRates[i]);
  48. ComboBox_AddString(GetDlgItem(hwnd, IDC_SK_BAUD), szBuf1);
  49. if (g_serk.iBaudRate == uBaudRates[i]) uBaud = i;
  50. }
  51. ComboBox_SetCurSel(GetDlgItem(hwnd, IDC_SK_BAUD), uBaud);
  52. break;
  53. case WM_HELP: // F1
  54. WinHelp(((LPHELPINFO) lParam)->hItemHandle, HelpFile(), HELP_WM_HELP, (DWORD_PTR) (LPSTR) g_aIds);
  55. break;
  56. case WM_CONTEXTMENU: // right mouse click
  57. WinHelp((HWND) wParam, HelpFile(), HELP_CONTEXTMENU, (DWORD_PTR) (LPSTR) g_aIds);
  58. break;
  59. case WM_COMMAND:
  60. switch (GET_WM_COMMAND_ID(wParam, lParam)) {
  61. // Watch for combobox changes.
  62. case IDC_SK_BAUD:
  63. switch (HIWORD(wParam)) {
  64. case CBN_CLOSEUP:
  65. case CBN_SELCHANGE:
  66. i = ComboBox_GetCurSel(GetDlgItem(hwnd, IDC_SK_BAUD));
  67. g_serk.iBaudRate = uBaudRates[i];
  68. SendMessage(GetParent(hwnd), PSM_CHANGED, (WPARAM) hwnd, 0);
  69. break;
  70. }
  71. break;
  72. case IDC_SK_PORT:
  73. switch (HIWORD(wParam)) {
  74. case CBN_SELCHANGE:
  75. i = 1 + ComboBox_GetCurSel(GetDlgItem(hwnd, IDC_SK_PORT));
  76. wsprintf(g_serk.lpszActivePort, __TEXT("COM%d"), i);
  77. EnableWindow(GetDlgItem(hwnd, IDC_SK_BAUD), TRUE);
  78. break;
  79. }
  80. break;
  81. case IDOK: case IDCANCEL:
  82. EndDialog(hwnd, GET_WM_COMMAND_ID(wParam, lParam));
  83. break;
  84. }
  85. break;
  86. default:
  87. fProcessed = FALSE; break;
  88. }
  89. return(fProcessed);
  90. }
  91. ///////////////////////////////// End of File /////////////////////////////////