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.

281 lines
7.7 KiB

  1. /* File: D:\WACKER\tdll\asciidlg.c (Created: 21-Feb-1994)
  2. *
  3. * Copyright 1994 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 11 $
  7. * $Date: 5/17/02 2:25p $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include <tchar.h>
  12. #include <limits.h>
  13. #include "assert.h"
  14. #include "stdtyp.h"
  15. #include "misc.h"
  16. #include "globals.h"
  17. #include "session.h"
  18. #include "hlptable.h"
  19. #include "..\emu\emu.h"
  20. #include "property.hh"
  21. #include "htchar.h"
  22. #include "errorbox.h"
  23. #include "..\term\res.h"
  24. // Function prototypes...
  25. //
  26. INT_PTR CALLBACK asciiSetupDlgProc(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar);
  27. #define IDC_GR_ASCII_SENDING 400
  28. #define IDC_ASCII_SEND_LINE 401
  29. #define IDC_ASCII_SEND_ECHO 402
  30. #define IDC_GR_ASCII_RECEIVING 403
  31. #define IDC_ASCII_REC_APPEND 404
  32. #define IDC_ASCII_REC_FORCE 405
  33. #define IDC_ASCII_REC_WRAP 406
  34. #define IDC_ASCII_SEND_LINE_DELAY_LABEL 407
  35. #define IDC_ASCII_SEND_LINE_DELAY 408
  36. #define IDC_ASCII_SEND_LINE_DELAY_MSECS 409
  37. #define IDC_ASCII_SEND_CHAR_DELAY_LABEL 410
  38. #define IDC_ASCII_SEND_CHAR_DELAY 411
  39. #define IDC_ASCII_SEND_CHAR_DELAY_MSECS 412
  40. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  41. * FUNCTION:
  42. *
  43. * DESCRIPTION:
  44. *
  45. * ARGUMENTS:
  46. *
  47. * RETURNS:
  48. *
  49. */
  50. INT_PTR CALLBACK asciiSetupDlgProc(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  51. {
  52. static DWORD aHlpTable[] =
  53. {
  54. IDC_ASCII_SEND_LINE, IDH_TERM_ASCII_SEND_LINE,
  55. IDC_ASCII_SEND_ECHO, IDH_TERM_ASCII_SEND_ECHO,
  56. IDC_GR_ASCII_SENDING, IDH_TERM_ASCII_SENDING,
  57. IDC_GR_ASCII_RECEIVING, IDH_TERM_ASCII_RECEIVING,
  58. IDC_ASCII_REC_APPEND, IDH_TERM_ASCII_REC_APPEND,
  59. IDC_ASCII_REC_FORCE, IDH_TERM_ASCII_REC_FORCE,
  60. IDC_ASCII_REC_WRAP, IDH_TERM_ASCII_REC_WRAP,
  61. IDC_ASCII_SEND_CHAR_DELAY_LABEL, IDH_TERM_ASCII_CHAR_DELAY,
  62. IDC_ASCII_SEND_CHAR_DELAY, IDH_TERM_ASCII_CHAR_DELAY,
  63. IDC_ASCII_SEND_CHAR_DELAY_MSECS, IDH_TERM_ASCII_CHAR_DELAY,
  64. IDC_ASCII_SEND_LINE_DELAY_LABEL, IDH_TERM_ASCII_LINE_DELAY,
  65. IDC_ASCII_SEND_LINE_DELAY, IDH_TERM_ASCII_LINE_DELAY,
  66. IDC_ASCII_SEND_LINE_DELAY_MSECS, IDH_TERM_ASCII_LINE_DELAY,
  67. IDCANCEL, IDH_CANCEL,
  68. IDOK, IDH_OK,
  69. 0, 0
  70. };
  71. switch (wMsg)
  72. {
  73. case WM_INITDIALOG:
  74. {
  75. BOOL isVTUTF8;
  76. pSDS pS = (SDS *)lPar;
  77. if (pS == NULL)
  78. {
  79. assert(FALSE);
  80. return FALSE;
  81. }
  82. SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)pS);
  83. mscCenterWindowOnWindow(hDlg, GetParent(hDlg));
  84. // Initialize various controls...
  85. //
  86. isVTUTF8 = (pS->stEmuSettings.nEmuId == EMU_VTUTF8);
  87. EnableWindow(GetDlgItem(hDlg, IDC_ASCII_SEND_LINE), !isVTUTF8);
  88. SendDlgItemMessage(hDlg, IDC_ASCII_SEND_LINE, BM_SETCHECK,
  89. (isVTUTF8) ? 0 : pS->stAsciiSettings.fsetSendCRLF, 0);
  90. SendDlgItemMessage(hDlg, IDC_ASCII_SEND_ECHO, BM_SETCHECK,
  91. pS->stAsciiSettings.fsetLocalEcho, 0);
  92. EnableWindow(GetDlgItem(hDlg, IDC_ASCII_REC_APPEND), !isVTUTF8);
  93. SendDlgItemMessage(hDlg, IDC_ASCII_REC_APPEND, BM_SETCHECK,
  94. (isVTUTF8) ? 0 : pS->stAsciiSettings.fsetAddLF, 0);
  95. EnableWindow(GetDlgItem(hDlg, IDC_ASCII_REC_FORCE), !isVTUTF8);
  96. SendDlgItemMessage(hDlg, IDC_ASCII_REC_FORCE, BM_SETCHECK,
  97. (isVTUTF8) ? 0 : pS->stAsciiSettings.fsetASCII7, 0);
  98. SendDlgItemMessage(hDlg, IDC_ASCII_REC_WRAP, BM_SETCHECK,
  99. pS->stEmuSettings.fWrapLines, 0);
  100. SetDlgItemInt(hDlg, IDC_ASCII_SEND_LINE_DELAY,
  101. pS->stAsciiSettings.iLineDelay, FALSE);
  102. //
  103. // Since the send line delay can only be numeric and has a
  104. // size between 0 and INT_MAX(2147483647), limit to 10 characters.
  105. //
  106. SendDlgItemMessage(hDlg, IDC_ASCII_SEND_LINE_DELAY,
  107. EM_LIMITTEXT, 10, 0);
  108. //
  109. // Since the send character delay can only be numeric and has a
  110. // size between 0 and INT_MAX(2147483647), limit to 10 characters.
  111. //
  112. SetDlgItemInt(hDlg, IDC_ASCII_SEND_CHAR_DELAY,
  113. pS->stAsciiSettings.iCharDelay, FALSE);
  114. SendDlgItemMessage(hDlg, IDC_ASCII_SEND_CHAR_DELAY,
  115. EM_LIMITTEXT, 10, 0);
  116. }
  117. break;
  118. case WM_DESTROY:
  119. break;
  120. case WM_CONTEXTMENU:
  121. doContextHelp(aHlpTable, wPar, lPar, TRUE, TRUE);
  122. break;
  123. case WM_HELP:
  124. doContextHelp(aHlpTable, wPar, lPar, FALSE, FALSE);
  125. break;
  126. case WM_COMMAND:
  127. switch (wPar)
  128. {
  129. case IDOK:
  130. {
  131. BOOL fTranslated = FALSE;
  132. UINT uiMessage = 0;
  133. pSDS pS = (pSDS)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  134. if (pS == NULL)
  135. {
  136. assert(FALSE);
  137. }
  138. else
  139. {
  140. pSTASCIISET pstAsciiSet = (pSTASCIISET)&pS->stAsciiSettings;
  141. PSTEMUSET pstEmuSet = (PSTEMUSET)&pS->stEmuSettings;
  142. assert(pstAsciiSet);
  143. assert(pstEmuSet);
  144. if (pstAsciiSet)
  145. {
  146. int nVal = 0;
  147. pstAsciiSet->fsetSendCRLF =
  148. (IsDlgButtonChecked(hDlg, IDC_ASCII_SEND_LINE) == BST_CHECKED);
  149. pstAsciiSet->fsetLocalEcho =
  150. (IsDlgButtonChecked(hDlg, IDC_ASCII_SEND_ECHO) == BST_CHECKED);
  151. pstAsciiSet->fsetAddLF =
  152. (IsDlgButtonChecked(hDlg, IDC_ASCII_REC_APPEND) == BST_CHECKED);
  153. pstAsciiSet->fsetASCII7 =
  154. (IsDlgButtonChecked(hDlg, IDC_ASCII_REC_FORCE) == BST_CHECKED);
  155. //
  156. // NOTE: since the edit boxes are marked as ES_NUMBER, we don't
  157. // have to worry that a negative number will be returned for
  158. // the IDC_ASCII_SEND_LINE_DELAY editbox control. REV: 3/27/2002
  159. //
  160. nVal = GetDlgItemInt(hDlg, IDC_ASCII_SEND_LINE_DELAY, &fTranslated, TRUE);
  161. if (!fTranslated)
  162. {
  163. uiMessage = IDS_ER_LINE_DELAY_SIZE;
  164. SetFocus(GetDlgItem(hDlg, IDC_ASCII_SEND_LINE_DELAY));
  165. }
  166. else
  167. {
  168. pstAsciiSet->iLineDelay = nVal;
  169. //
  170. // NOTE: since the edit boxes are marked as ES_NUMBER, we don't
  171. // have to worry that a negative number will be returned for
  172. // the IDC_ASCII_SEND_CHAR_DELAY editbox control. REV: 3/27/2002
  173. //
  174. nVal = GetDlgItemInt(hDlg, IDC_ASCII_SEND_CHAR_DELAY, &fTranslated, TRUE);
  175. if (!fTranslated)
  176. {
  177. uiMessage = IDS_ER_CHAR_DELAY_SIZE;
  178. SetFocus(GetDlgItem(hDlg, IDC_ASCII_SEND_CHAR_DELAY));
  179. }
  180. else
  181. {
  182. pstAsciiSet->iCharDelay = nVal;
  183. }
  184. }
  185. }
  186. if (pstEmuSet)
  187. {
  188. pstEmuSet->fWrapLines =
  189. (IsDlgButtonChecked(hDlg, IDC_ASCII_REC_WRAP) == BST_CHECKED);
  190. }
  191. }
  192. if (uiMessage != 0)
  193. {
  194. TCHAR acBuffer[256];
  195. TCHAR acFormat[256];
  196. //
  197. // Display an error message.
  198. //
  199. if (LoadString(glblQueryDllHinst(), uiMessage, acFormat, 256) == 0)
  200. {
  201. if (uiMessage == IDS_ER_LINE_DELAY_SIZE)
  202. {
  203. StrCharCopyN(acFormat,
  204. TEXT("Invalid line delay time. Line delay time must be between %d and %d milliseconds."),
  205. 256);
  206. }
  207. else if (uiMessage == IDS_ER_CHAR_DELAY_SIZE)
  208. {
  209. StrCharCopyN(acFormat,
  210. TEXT("Invalid character delay time. Character delay time must be between %d and %d milliseconds."),
  211. 256);
  212. }
  213. }
  214. wsprintf(acBuffer, acFormat, 0, INT_MAX);
  215. TimedMessageBox(hDlg, acBuffer, NULL,
  216. MB_OK | MB_ICONEXCLAMATION, 0);
  217. break;
  218. }
  219. EndDialog(hDlg, fTranslated);
  220. }
  221. break;
  222. case IDCANCEL:
  223. EndDialog(hDlg, FALSE);
  224. break;
  225. default:
  226. return FALSE;
  227. }
  228. break;
  229. default:
  230. return FALSE;
  231. }
  232. return TRUE;
  233. }