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.

1256 lines
35 KiB

  1. /* File: D:\WACKER\tdll\propterm.c (Created: 22-Feb-1994)
  2. *
  3. * Copyright 1994, 1998 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 27 $
  7. * $Date: 7/08/02 6:46p $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include <commctrl.h>
  12. #include <tchar.h>
  13. #include "assert.h"
  14. #include "stdtyp.h"
  15. #include "misc.h"
  16. #include "mc.h"
  17. #include "globals.h"
  18. #include "session.h"
  19. #include "load_res.h"
  20. #include "statusbr.h"
  21. #include "tdll.h"
  22. #include "hlptable.h"
  23. #include "backscrl.h"
  24. #include "cloop.h"
  25. #include "htchar.h"
  26. #include "errorbox.h"
  27. #include <emu\emuid.h>
  28. #include <emu\emu.h>
  29. #include "com.h"
  30. #include "COMDEV.H"
  31. #include "com.hh"
  32. #include <emu\emudlgs.h>
  33. #include <term\res.h>
  34. #if defined(CHARACTER_TRANSLATION)
  35. #include <tdll\translat.hh>
  36. #include <tdll\translat.h>
  37. #if defined(INCL_VTUTF8)
  38. #include <htrn_jis\htrn_jis.hh>
  39. #endif // INCL_VTUTF8
  40. #endif // CHARACTER_TRANSLATION
  41. #include "property.h"
  42. #include "property.hh"
  43. // Function prototypes...
  44. //
  45. STATIC_FUNC void prop_WM_INITDIALOG_Terminal(HWND hDlg);
  46. STATIC_FUNC int prop_SAVE_Terminal(HWND hDlg);
  47. STATIC_FUNC void propCreateUpDownControl(HWND hDlg);
  48. STATIC_FUNC LRESULT prop_WM_NOTIFY(const HWND hwnd, const int nId);
  49. //STATIC_FUNC int propGetIdFromEmuName(LPTSTR pacEmuName);
  50. STATIC_FUNC LRESULT prop_WM_CMD(const HWND hwnd,
  51. const int nId,
  52. const int nNotify,
  53. const HWND hwndCtrl);
  54. STATIC_FUNC int propValidateBackscrlSize(HWND hDlg);
  55. STATIC_FUNC BOOL propHasValidBackscrlSize(HWND hDlg, int * pBackScrlSize);
  56. STATIC_FUNC int propValidateTelnetId(HWND hDlg, TCHAR * pszTelnetId,
  57. int iMaxChars);
  58. // Defines for the TERMINAL TAB of the Property Sheet.
  59. //
  60. #define IDC_TERMINAL_CK_SOUND 304
  61. #define IDC_TERMINAL_CB_EMULATION 322
  62. #define IDC_TERMINAL_TF_EMULATION 321
  63. #define IDC_TERMINAL_PB_TERMINAL 326
  64. #define IDC_TERMINAL_PB_ASCII 327
  65. #define IDC_TERMINAL_RB_TERMKEYS 324
  66. #define IDC_TERMINAL_RB_WINDKEYS 325
  67. #define IDC_TERMINAL_GR_USEKEYS 323
  68. #define IDC_TERMINAL_EF_BACKSCRL 328
  69. #define IDC_TERMINAL_TF_BACKSCRL 308
  70. #define IDC_TERMINAL_EF_BACKSCRLTAB 329
  71. #define IDC_TERMINAL_PB_TRANSLATE 330
  72. #ifdef INCL_USER_DEFINED_BACKSPACE_AND_TELNET_TERMINAL_ID
  73. // IDs for new controls. - cab:11/14/96
  74. //
  75. #define IDC_TERMINAL_GR_BACKSPACE 331
  76. #define IDC_TERMINAL_RB_CTRLH 332
  77. #define IDC_TERMINAL_RB_DEL 333
  78. #define IDC_TERMINAL_RB_CTRLHSPACE 334
  79. #define IDC_TERMINAL_TF_TELNETID 335
  80. #define IDC_TERMINAL_EF_TELNETID 336
  81. #endif
  82. #define IDC_TERMINAL_CK_EXIT 337
  83. #define IDC_TERMINAL_CK_HOSTXFERS 338
  84. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  85. * FUNCTION:
  86. * Terminal Dialog
  87. *
  88. * DESCRIPTION:
  89. * Dialog manager stub
  90. *
  91. * ARGUMENTS:
  92. * Standard Windows dialog manager
  93. *
  94. * RETURNS:
  95. * Standard Windows dialog manager
  96. *
  97. */
  98. INT_PTR CALLBACK TerminalTabDlg(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  99. {
  100. pSDS pS;
  101. // TODO:cab,11/14/96 - add help for new controls.
  102. //
  103. static DWORD aHlpTable[] =
  104. {
  105. IDC_TERMINAL_CK_SOUND, IDH_TERM_SETTING_SOUND,
  106. IDC_TERMINAL_CB_EMULATION, IDH_TERM_SETTING_EMULATION,
  107. IDC_TERMINAL_TF_EMULATION, IDH_TERM_SETTING_EMULATION,
  108. IDC_TERMINAL_PB_TERMINAL, IDH_TERM_SETTING_TERMSET,
  109. IDC_TERMINAL_PB_ASCII, IDH_TERM_SETTING_ASCIISET,
  110. IDC_TERMINAL_RB_TERMKEYS, IDH_TERM_SETTING_USEKEYS,
  111. IDC_TERMINAL_RB_WINDKEYS, IDH_TERM_SETTING_USEKEYS,
  112. IDC_TERMINAL_GR_USEKEYS, IDH_TERM_SETTING_USEKEYS,
  113. IDC_TERMINAL_TF_BACKSCRL, IDH_TERM_SETTING_BACKSCROLL,
  114. IDC_TERMINAL_EF_BACKSCRL, IDH_TERM_SETTING_BACKSCROLL,
  115. #ifdef INCL_USER_DEFINED_BACKSPACE_AND_TELNET_TERMINAL_ID
  116. IDC_TERMINAL_GR_BACKSPACE, IDH_TERM_SETTING_BACKSPACE,
  117. IDC_TERMINAL_RB_CTRLH, IDH_TERM_SETTING_CTRLH,
  118. IDC_TERMINAL_RB_DEL, IDH_TERM_SETTING_DEL,
  119. IDC_TERMINAL_RB_CTRLHSPACE, IDH_TERM_SETTING_CTRLH2,
  120. IDC_TERMINAL_TF_TELNETID, IDH_TERM_SETTING_TELNETID,
  121. IDC_TERMINAL_EF_TELNETID, IDH_TERM_SETTING_TELNETID,
  122. #endif
  123. #ifdef INCL_EXIT_ON_DISCONNECT
  124. IDC_TERMINAL_CK_EXIT, IDH_TERM_SETTING_EXIT,
  125. #endif
  126. #ifdef INCL_TERMINAL_SIZE_AND_COLORS
  127. IDC_TERMINAL_SIZE_AND_COLORS, IDH_TERM_SETTING_COLOR,
  128. #endif
  129. IDC_TERMINAL_CK_HOSTXFERS, IDH_TERM_SETTING_HOSTXFERS,
  130. IDC_TERMINAL_PB_TRANSLATE, IDH_HTRN_DIALOG,
  131. IDCANCEL, IDH_CANCEL,
  132. IDOK, IDH_OK,
  133. 0, 0,
  134. };
  135. switch (wMsg)
  136. {
  137. case WM_INITDIALOG:
  138. pS = (SDS *)malloc(sizeof(SDS));
  139. if (pS == (SDS *)0)
  140. {
  141. /* TODO: decide if we need to display an error here */
  142. assert(FALSE);
  143. EndDialog(hDlg, FALSE);
  144. break;
  145. }
  146. pS->hSession = (HSESSION)(((LPPROPSHEETPAGE)lPar)->lParam);
  147. // Don't center any except first tabbed dialog in the property sheet.
  148. // Otherwise if a user moves the property sheet it will be forced back
  149. // to the centered position.
  150. //
  151. // mscCenterWindowOnWindow(GetParent(hDlg), sessQueryHwnd(pS->hSession));
  152. SetWindowLongPtr(hDlg, DWLP_USER, (LONG_PTR)pS);
  153. prop_WM_INITDIALOG_Terminal(hDlg);
  154. break;
  155. case WM_CONTEXTMENU:
  156. doContextHelp(aHlpTable, wPar, lPar, TRUE, TRUE);
  157. break;
  158. case WM_HELP:
  159. doContextHelp(aHlpTable, wPar, lPar, FALSE, FALSE);
  160. break;
  161. case WM_DESTROY:
  162. // OK, now we know that we are actually leaving the dialog for good, so
  163. // free the storage...
  164. //
  165. pS = (pSDS)GetWindowLongPtr(hDlg, DWLP_USER);
  166. if (pS)
  167. {
  168. free(pS);
  169. pS = NULL;
  170. }
  171. break;
  172. case WM_NOTIFY:
  173. return prop_WM_NOTIFY(hDlg, (int)((NMHDR *)lPar)->code);
  174. case WM_COMMAND:
  175. return prop_WM_CMD(hDlg, LOWORD(wPar), HIWORD(wPar), (HWND)lPar);
  176. default:
  177. return FALSE;
  178. }
  179. return TRUE;
  180. }
  181. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  182. * FUNCTION:
  183. * prop_WM_NOTIFY
  184. *
  185. * DESCRIPTION:
  186. * Process Property Sheet Notification messages.
  187. *
  188. * ARGUMENTS:
  189. * hDlg - dialog window handle.
  190. * nId - (NMHDR *)lPar->code
  191. *
  192. * RETURNS:
  193. * LRESULT
  194. */
  195. STATIC_FUNC LRESULT prop_WM_NOTIFY(const HWND hDlg, const int nId)
  196. {
  197. switch (nId)
  198. {
  199. default:
  200. break;
  201. #if 0
  202. case PSN_SETACTIVE:
  203. break;
  204. #endif
  205. case PSN_KILLACTIVE:
  206. {
  207. int nBackscrlSize = 0;
  208. if (propHasValidBackscrlSize(hDlg, &nBackscrlSize) == FALSE)
  209. {
  210. //
  211. // Invalid backscroll buffer size.
  212. //
  213. TCHAR acFormat[256];
  214. TCHAR acBuffer[256];
  215. TCHAR_Fill(acFormat, TEXT('\0'), sizeof(acFormat)/sizeof(TCHAR));
  216. TCHAR_Fill(acBuffer, TEXT('\0'), sizeof(acBuffer)/sizeof(TCHAR));
  217. //
  218. // Display an error message.
  219. //
  220. LoadString(glblQueryDllHinst(), IDS_ER_BACKSCROLL_SIZE,
  221. acFormat, sizeof(acFormat)/sizeof(TCHAR));
  222. wsprintf(acBuffer, acFormat,
  223. BKSCRL_USERLINES_DEFAULT_MIN,
  224. BKSCRL_USERLINES_DEFAULT_MAX,
  225. nBackscrlSize);
  226. TimedMessageBox(hDlg, acBuffer, NULL, MB_OK | MB_ICONEXCLAMATION, 0);
  227. //
  228. // Set the backscroll size to the value returned in
  229. // propHasValidBackscrlSize().
  230. //
  231. SetDlgItemInt(hDlg, IDC_TERMINAL_EF_BACKSCRL, nBackscrlSize, FALSE);
  232. //
  233. // Do not exit the property page!
  234. //
  235. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, (LONG_PTR)PSNRET_INVALID_NOCHANGEPAGE);
  236. return TRUE;
  237. }
  238. }
  239. break;
  240. case PSN_APPLY:
  241. //
  242. // Do whatever saving is necessary
  243. //
  244. if ( prop_SAVE_Terminal(hDlg) == 0 )
  245. {
  246. // Okay to exit the dialog.
  247. //
  248. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, (LONG_PTR)PSNRET_NOERROR);
  249. }
  250. else
  251. {
  252. // Do not exit the dialog!
  253. //
  254. SetWindowLongPtr(hDlg, DWLP_MSGRESULT, (LONG_PTR)PSNRET_INVALID_NOCHANGEPAGE);
  255. }
  256. return TRUE;
  257. #if 0
  258. case PSN_RESET:
  259. // Cancel has been selected... good place to confirm.
  260. //
  261. break;
  262. #endif
  263. }
  264. return FALSE;
  265. }
  266. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  267. * FUNCTION:
  268. * prop_WM_CMD
  269. *
  270. * DESCRIPTION:
  271. * Process WM_COMMAND messages.
  272. *
  273. * ARGUMENTS:
  274. * hDlg - dialog window handle.
  275. * nId - LOWORD(wPar)
  276. * nNotify - HIWORD(wPar)
  277. * hwndCtrl - (HWND)lPar
  278. *
  279. * RETURNS:
  280. * LRESULT
  281. *
  282. */
  283. STATIC_FUNC LRESULT prop_WM_CMD(const HWND hDlg, const int nId,
  284. const int nNotify, const HWND hwndCtrl)
  285. {
  286. pSDS pS;
  287. int iId;
  288. STEMUSET stEmuSettingsCopy;
  289. STASCIISET stAsciiSettingsCopy;
  290. BOOL fResult;
  291. #if defined(INCL_USER_DEFINED_BACKSPACE_AND_TELNET_TERMINAL_ID)
  292. TCHAR achTempTelnetId[EMU_MAX_TELNETID];
  293. #endif // defined(INCL_USER_DEFINED_BACKSPACE_AND_TELNET_TERMINAL_ID)
  294. switch(nId)
  295. {
  296. case IDC_TERMINAL_CB_EMULATION:
  297. //
  298. // TODO: Possibly a new emulator was selected. If so then load the
  299. // stEmuSettings with the default values for that emulator.
  300. // See what we decide to do here...
  301. if ((pS = (pSDS)GetWindowLongPtr(hDlg, DWLP_USER)) == 0)
  302. {
  303. assert(FALSE);
  304. break;
  305. }
  306. iId = propGetEmuIdfromEmuCombo(hDlg, pS->hSession);
  307. // Dim the emulator settings push button if the current emulator is
  308. // "Auto detect".
  309. //
  310. EnableWindow(GetDlgItem(hDlg, IDC_TERMINAL_PB_TERMINAL),
  311. (iId == EMU_AUTO ) ? FALSE : TRUE);
  312. #if defined(INCL_VTUTF8)
  313. // Hide the "Input Translation..." button if the curent emulator is
  314. // "VT-UTF8". REV: 05/21/2001.
  315. //
  316. EnableWindow(GetDlgItem(hDlg, IDC_TERMINAL_PB_TRANSLATE),
  317. (iId == EMU_VTUTF8) ? FALSE : TRUE);
  318. #endif // INCL_VTUTF8
  319. #if defined(INCL_USER_DEFINED_BACKSPACE_AND_TELNET_TERMINAL_ID)
  320. // Load the default telnet terminal id when a
  321. // new emulator is selected. - cab:11/15/96
  322. //
  323. if ( nNotify == CBN_SELCHANGE )
  324. {
  325. achTempTelnetId[0] = TEXT('\0');
  326. emuQueryDefaultTelnetId(iId, achTempTelnetId, EMU_MAX_TELNETID);
  327. if ( achTempTelnetId[0] != TEXT('\0') )
  328. {
  329. SendDlgItemMessage(hDlg, IDC_TERMINAL_EF_TELNETID, WM_SETTEXT,
  330. 0, (LPARAM)(LPTSTR)achTempTelnetId);
  331. }
  332. }
  333. #endif //defined(INCL_USER_DEFINED_BACKSPACE_AND_TELNET_TERMINAL_ID)
  334. break;
  335. case IDC_TERMINAL_PB_TERMINAL:
  336. if ((pS = (pSDS)GetWindowLongPtr(hDlg, DWLP_USER)) == 0)
  337. {
  338. assert(FALSE);
  339. break;
  340. }
  341. MemCopy(&stEmuSettingsCopy, &(pS->stEmuSettings), sizeof(STEMUSET));
  342. if (emuSettingsDlg(pS->hSession, hDlg, propGetEmuIdfromEmuCombo(hDlg, pS->hSession), &(pS->stEmuSettings)) == IDCANCEL)
  343. MemCopy(&(pS->stEmuSettings), &stEmuSettingsCopy, sizeof(STEMUSET));
  344. break;
  345. case IDC_TERMINAL_PB_ASCII:
  346. if ((pS = (pSDS)GetWindowLongPtr(hDlg, DWLP_USER)) == 0)
  347. {
  348. assert(FALSE);
  349. break;
  350. }
  351. MemCopy(&stEmuSettingsCopy, &(pS->stEmuSettings), sizeof(STEMUSET));
  352. //
  353. // Make sure to set the correct terminal id so the controls
  354. // can be initialized correctly in the terminal ASCII Settings
  355. // dialog. NOTE: This is done after copying the settings in
  356. // case of a cancel from the ASCII Settings dialog so that the
  357. // terminal id is not saved. REV: 07/25/2001
  358. //
  359. pS->stEmuSettings.nEmuId = propGetEmuIdfromEmuCombo(hDlg, pS->hSession);
  360. MemCopy(&stAsciiSettingsCopy, &(pS->stAsciiSettings), sizeof(STASCIISET));
  361. fResult = (BOOL)DoDialog(glblQueryDllHinst(),
  362. MAKEINTRESOURCE(IDD_ASCII_SETUP),
  363. hDlg,
  364. asciiSetupDlgProc,
  365. (LPARAM)pS);
  366. if (fResult == IDCANCEL)
  367. {
  368. MemCopy(&(pS->stEmuSettings), &stEmuSettingsCopy, sizeof(STEMUSET));
  369. MemCopy(&(pS->stAsciiSettings), &stAsciiSettingsCopy, sizeof(STASCIISET));
  370. }
  371. else if (pS->stEmuSettings.nEmuId == EMU_VTUTF8)
  372. {
  373. //
  374. // Reset the sending and receiving CR with LF and forcing
  375. // 7-bit ASCII when the emulator is VT-UTF8 (these setting
  376. // will always be set to FALSE for the VT-UTF8 emulator.
  377. // We don't want to save these settings when the emulator
  378. // is VT-UTF8 since the user may select another emulator
  379. // prior to saving the properties or may switch to another
  380. // property page. REV: 07/25/2001
  381. //
  382. pS->stAsciiSettings.fsetSendCRLF = stAsciiSettingsCopy.fsetSendCRLF;
  383. pS->stAsciiSettings.fsetAddLF = stAsciiSettingsCopy.fsetAddLF;
  384. pS->stAsciiSettings.fsetASCII7 = stAsciiSettingsCopy.fsetASCII7;
  385. }
  386. break;
  387. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  388. case IDC_TERMINAL_SIZE_AND_COLORS:
  389. if ((pS = (pSDS)GetWindowLongPtr(hDlg, DWLP_USER)) == 0)
  390. {
  391. assert(FALSE);
  392. break;
  393. }
  394. fResult = emuColorSettingsDlg(pS->hSession, hDlg, &(pS->stEmuSettings));
  395. break;
  396. #endif
  397. #if defined(CHARACTER_TRANSLATION)
  398. case IDC_TERMINAL_PB_TRANSLATE:
  399. {
  400. HHTRANSLATE hTrans = NULL;
  401. if ((pS = (pSDS)GetWindowLongPtr(hDlg, DWLP_USER)) == 0)
  402. {
  403. assert(FALSE);
  404. break;
  405. }
  406. hTrans = (HHTRANSLATE)sessQueryTranslateHdl(pS->hSession);
  407. if (hTrans)
  408. {
  409. if ((*hTrans->pfnIsDeviceLoaded)(hTrans->pDllHandle))
  410. {
  411. (*hTrans->pfnDoDialog)(hDlg, hTrans->pDllHandle);
  412. }
  413. }
  414. }
  415. break;
  416. #endif // defined(CHARACTER_TRANSLATION)
  417. default:
  418. break;
  419. }
  420. return (LRESULT) 0; // REV 8/17/98
  421. }
  422. #if 0
  423. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  424. * FUNCTION:
  425. * propLoadEmulationCombo
  426. *
  427. * DESCRIPTION:
  428. * Fill in the emulator combo box with the emulators that we support and
  429. * select the current one.
  430. *
  431. * ARGUMENTS:
  432. * hDlg - dialog handle.
  433. * hSession - the session handle.
  434. *
  435. * RETURNS:
  436. * void.
  437. *
  438. */
  439. void propLoadEmulationCombo(const HWND hDlg, const HSESSION hSession)
  440. {
  441. BYTE *pv;
  442. int i;
  443. DWORD nLen;
  444. int nEmuCount;
  445. HEMU hEmulator;
  446. TCHAR acEmuName[256];
  447. // Get the emulator name...
  448. // We have to select the emulator in the combo box by name because the
  449. // combo is sorted, which makes sense, and in translated versions
  450. // the index to the emulator name in the combo box won't correspond
  451. // to the emulator id.
  452. //
  453. hEmulator = (HEMU)sessQueryEmuHdl(hSession);
  454. TCHAR_Fill(acEmuName, TEXT('\0'), sizeof(acEmuName) / sizeof(TCHAR));
  455. emuQueryName(hEmulator, acEmuName, sizeof(acEmuName) / sizeof(TCHAR));
  456. // Load the emulator name table from the resources
  457. //
  458. if (resLoadDataBlock(glblQueryDllHinst(), IDT_EMU_NAMES, (LPVOID *)&pv, &nLen))
  459. {
  460. assert(FALSE);
  461. return;
  462. }
  463. // Load the combo box with the table items.
  464. //
  465. nEmuCount = *(RCDATA_TYPE *)pv;
  466. pv += sizeof(RCDATA_TYPE);
  467. for (i = 0 ; i < nEmuCount; i++)
  468. {
  469. nLen = (DWORD)StrCharGetByteCount((LPTSTR)pv) + (DWORD)sizeof(BYTE);
  470. SendDlgItemMessage(hDlg, IDC_TERMINAL_CB_EMULATION, CB_ADDSTRING, 0,
  471. (LPARAM)(LPTSTR)pv);
  472. pv += (nLen + (DWORD)sizeof(RCDATA_TYPE));
  473. }
  474. SendDlgItemMessage(hDlg, IDC_TERMINAL_CB_EMULATION, CB_SELECTSTRING,
  475. (WPARAM)-1, (LPARAM)(LPTSTR)acEmuName);
  476. }
  477. #endif
  478. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  479. * FUNCTION:
  480. * propLoadEmulationCombo
  481. *
  482. * DESCRIPTION:
  483. * Fill in the emulator combo box with the emulators that we support and
  484. * select the current one.
  485. *
  486. * ARGUMENTS:
  487. * hDlg - dialog handle.
  488. * hSession - the session handle.
  489. *
  490. * RETURNS:
  491. * void.
  492. *
  493. */
  494. void propLoadEmulationCombo(const HWND hDlg, const HSESSION hSession)
  495. {
  496. int i;
  497. HEMU hEmulator;
  498. TCHAR acEmuName[256],
  499. achText[EMU_MAX_NAMELEN];
  500. // Get the emulator name...
  501. // We have to select the emulator in the combo box by name because the
  502. // combo is sorted, which makes sense, and in translated versions
  503. // the index to the emulator name in the combo box won't correspond
  504. // to the emulator id.
  505. //
  506. hEmulator = (HEMU)sessQueryEmuHdl(hSession);
  507. TCHAR_Fill(acEmuName, TEXT('\0'), sizeof(acEmuName) / sizeof(TCHAR));
  508. emuQueryName(hEmulator, acEmuName, sizeof(acEmuName) / sizeof(TCHAR));
  509. for (i = IDS_EMUNAME_BASE ; i < IDS_EMUNAME_BASE + NBR_EMULATORS; i++)
  510. {
  511. #if !defined(INCL_VT100J)
  512. if (i == IDS_EMUNAME_VT100J)
  513. continue;
  514. #endif
  515. #if !defined(INCL_ANSIW)
  516. if (i == IDS_EMUNAME_ANSIW)
  517. continue;
  518. #endif
  519. #if !defined(INCL_VT220)
  520. if (i == IDS_EMUNAME_VT220)
  521. continue;
  522. #endif
  523. #if !defined(INCL_VT320)
  524. if (i == IDS_EMUNAME_VT320)
  525. continue;
  526. #endif
  527. #if !defined(INCL_VT100PLUS)
  528. if (i == IDS_EMUNAME_VT100PLUS)
  529. continue;
  530. #endif
  531. #if !defined(INCL_VTUTF8)
  532. if (i == IDS_EMUNAME_VTUTF8)
  533. continue;
  534. #endif
  535. LoadString(glblQueryDllHinst(), (unsigned int)i, achText, sizeof(achText) / sizeof(TCHAR));
  536. SendDlgItemMessage(hDlg, IDC_TERMINAL_CB_EMULATION, CB_ADDSTRING, 0,
  537. (LPARAM)(LPTSTR)achText);
  538. }
  539. SendDlgItemMessage(hDlg, IDC_TERMINAL_CB_EMULATION, CB_SELECTSTRING,
  540. (WPARAM)-1, (LPARAM)(LPTSTR)acEmuName);
  541. }
  542. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  543. * FUNCTION:
  544. * propGetEmuIdfromEmuCombo
  545. *
  546. * DESCRIPTION:
  547. * Return the emulator id for the emulator selected in the emulator combo
  548. * box or if none selected, return current emulator id.
  549. *
  550. * ARGUMENTS:
  551. * hDlg - dialog handle.
  552. *
  553. * RETURNS:
  554. * nEmuId - the emulator id.
  555. */
  556. int propGetEmuIdfromEmuCombo(HWND hDlg, HSESSION hSession)
  557. {
  558. int nEmuId;
  559. INT_PTR nRet;
  560. TCHAR acEmulator[256];
  561. if ((nRet = SendDlgItemMessage(hDlg, IDC_TERMINAL_CB_EMULATION, CB_GETCURSEL, 0, 0)) == CB_ERR)
  562. {
  563. nEmuId = emuQueryEmulatorId(sessQueryEmuHdl(hSession));
  564. }
  565. else
  566. {
  567. TCHAR_Fill(acEmulator, TEXT('\0'), sizeof(acEmulator) / sizeof(TCHAR));
  568. SendDlgItemMessage(hDlg, IDC_TERMINAL_CB_EMULATION, CB_GETLBTEXT,
  569. (WPARAM)nRet, (LPARAM)(LPTSTR)acEmulator);
  570. //nEmuId = propGetIdFromEmuName(acEmulator);
  571. nEmuId = emuGetIdFromName(sessQueryEmuHdl(hSession), acEmulator);
  572. }
  573. // DbgOutStr("nEmuId = %d\r\n", nEmuId, 0, 0, 0, 0);
  574. return (nEmuId);
  575. }
  576. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  577. * FUNCTION:
  578. * prop_WM_INITDIALOG_Terminal
  579. *
  580. * DESCRIPTION:
  581. * This function processes the WM_INIDIALOG message for the "Settings" tab
  582. * of the property sheet.
  583. *
  584. * ARGUMENTS:
  585. * hDlg - dialog window handle.
  586. *
  587. * RETURNS:
  588. * void.
  589. *
  590. */
  591. STATIC_FUNC void prop_WM_INITDIALOG_Terminal(HWND hDlg)
  592. {
  593. HWND hTmp;
  594. HEMU hEmulator;
  595. pSDS pS;
  596. TCHAR ach[100], acBuffer[100];
  597. int nEmuId;
  598. HCLOOP hCLoop = (HCLOOP)0;
  599. pS = (pSDS)GetWindowLongPtr(hDlg, DWLP_USER);
  600. hTmp = GetDlgItem(hDlg, IDC_TERMINAL_PB_TRANSLATE);
  601. if (IsWindow(hTmp))
  602. {
  603. #if defined(CHARACTER_TRANSLATION)
  604. HHTRANSLATE hTrans = NULL;
  605. hTrans = (HHTRANSLATE)sessQueryTranslateHdl(pS->hSession);
  606. if (!hTrans || !(*hTrans->pfnIsDeviceLoaded)(hTrans->pDllHandle))
  607. {
  608. ShowWindow(hTmp, SW_HIDE);
  609. }
  610. #else
  611. ShowWindow(hTmp, SW_HIDE);
  612. #endif
  613. }
  614. hCLoop = sessQueryCLoopHdl(pS->hSession);
  615. if (hCLoop == (HCLOOP)0)
  616. assert(FALSE);
  617. // Set ASCII Settings to the currently used valudes...
  618. //
  619. memset(&(pS->stAsciiSettings), 0, sizeof(STASCIISET));
  620. pS->stAsciiSettings.fsetSendCRLF = CLoopGetSendCRLF(hCLoop);
  621. pS->stAsciiSettings.fsetLocalEcho = CLoopGetLocalEcho(hCLoop);
  622. pS->stAsciiSettings.fsetAddLF = CLoopGetAddLF(hCLoop);
  623. pS->stAsciiSettings.fsetASCII7 = CLoopGetASCII7(hCLoop);
  624. pS->stAsciiSettings.iLineDelay = CLoopGetLineDelay(hCLoop);
  625. pS->stAsciiSettings.iCharDelay = CLoopGetCharDelay(hCLoop);
  626. // Set emulator settings structures do default values...
  627. //
  628. hEmulator = (HEMU)sessQueryEmuHdl(pS->hSession);
  629. emuQuerySettings(hEmulator, &(pS->stEmuSettings));
  630. // Set the backscroll buffer edit box...
  631. //
  632. //
  633. // Since the backscroll buffer can only be numeric and has a
  634. // size between BKSCRL_USERLINES_DEFAULT_MIN(0) and
  635. // BKSCRL_USERLINES_DEFAULT_MAX(500), limit to 3 characters.
  636. //
  637. SendDlgItemMessage(hDlg, IDC_TERMINAL_EF_BACKSCRL, EM_LIMITTEXT, 3, 0);
  638. propCreateUpDownControl(hDlg);
  639. LoadString(glblQueryDllHinst(), IDS_XD_INT, ach, sizeof(ach) / sizeof(TCHAR));
  640. TCHAR_Fill(acBuffer, TEXT('\0'), sizeof(acBuffer) / sizeof(TCHAR));
  641. wsprintf(acBuffer, ach, backscrlGetUNumLines(sessQueryBackscrlHdl(pS->hSession)));
  642. SendDlgItemMessage(hDlg, IDC_TERMINAL_EF_BACKSCRL, WM_SETTEXT, 0, (LPARAM)(LPTSTR)acBuffer);
  643. // Set sound checkbox...
  644. //
  645. SendDlgItemMessage(hDlg, IDC_TERMINAL_CK_SOUND, BM_SETCHECK,
  646. (unsigned int)sessQuerySound(pS->hSession), 0);
  647. // Set exit checkbox...
  648. //mpt:10-28-97
  649. SendDlgItemMessage(hDlg, IDC_TERMINAL_CK_EXIT, BM_SETCHECK,
  650. (unsigned int)sessQueryExit(pS->hSession), 0);
  651. // Set 'Allow host initiated file transfer' feature
  652. //
  653. SendDlgItemMessage(hDlg, IDC_TERMINAL_CK_HOSTXFERS, BM_SETCHECK,
  654. (BOOL)sessQueryAllowHostXfers(pS->hSession), 0);
  655. // Set keys radio buttons...
  656. //
  657. SendDlgItemMessage(hDlg, (pS->stEmuSettings.nTermKeys) ?
  658. IDC_TERMINAL_RB_TERMKEYS : IDC_TERMINAL_RB_WINDKEYS, BM_SETCHECK, 1, 0);
  659. //
  660. // Load Emulation combo box
  661. //
  662. propLoadEmulationCombo(hDlg, pS->hSession);
  663. // Dim the emulator settings push button if the current emulator is
  664. // "Auto detect".
  665. //
  666. hEmulator = (HEMU)sessQueryEmuHdl(pS->hSession);
  667. nEmuId = emuQueryEmulatorId(hEmulator);
  668. EnableWindow(GetDlgItem(hDlg, IDC_TERMINAL_PB_TERMINAL),
  669. (nEmuId == EMU_AUTO) ? FALSE : TRUE);
  670. #if defined(INCL_VTUTF8) && defined(CHARACTER_TRANSLATION)
  671. // Hide the "Input Translation..." button if the curent emulator is
  672. // "VT-UTF8". REV: 05/21/2001.
  673. //
  674. EnableWindow(GetDlgItem(hDlg, IDC_TERMINAL_PB_TRANSLATE),
  675. (nEmuId == EMU_VTUTF8) ? FALSE : TRUE);
  676. #endif // INCL_VTUTF8 && CHARACTER_TRANSLATION
  677. #ifdef INCL_USER_DEFINED_BACKSPACE_AND_TELNET_TERMINAL_ID
  678. // Set the backspace radio buttons - cab:11/14/96
  679. //
  680. switch(pS->stEmuSettings.nBackspaceKeys)
  681. {
  682. default:
  683. case EMU_BKSPKEYS_CTRLH:
  684. SendDlgItemMessage(hDlg, IDC_TERMINAL_RB_CTRLH, BM_SETCHECK, 1, 0);
  685. break;
  686. case EMU_BKSPKEYS_DEL:
  687. SendDlgItemMessage(hDlg, IDC_TERMINAL_RB_DEL, BM_SETCHECK, 1, 0);
  688. break;
  689. case EMU_BKSPKEYS_CTRLHSPACE:
  690. SendDlgItemMessage(hDlg, IDC_TERMINAL_RB_CTRLHSPACE, BM_SETCHECK, 1, 0);
  691. break;
  692. }
  693. // Set the telnet terminal id text - cab:11/15/96
  694. //
  695. SendDlgItemMessage(hDlg, IDC_TERMINAL_EF_TELNETID, EM_SETLIMITTEXT,
  696. EMU_MAX_TELNETID - 1, 0);
  697. SendDlgItemMessage(hDlg, IDC_TERMINAL_EF_TELNETID, WM_SETTEXT, 0,
  698. (LPARAM)(LPTSTR)pS->stEmuSettings.acTelnetId);
  699. // TODO: cab,11/18/96 Disable window if the connection is not WinSock.
  700. //
  701. #endif
  702. }
  703. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  704. * FUNCTION:
  705. * prop_SAVE_Terminal
  706. *
  707. * DESCRIPTION:
  708. * We are either applying the changes or closing the property sheet, so
  709. * commit all of the changes.
  710. *
  711. * ARGUMENTS:
  712. * hDlg - dialog handle.
  713. *
  714. * RETURNS:
  715. * Returns 0 if data was valid, -1 otherwise.
  716. *
  717. */
  718. STATIC_FUNC int prop_SAVE_Terminal(HWND hDlg)
  719. {
  720. int iRet = 0;
  721. pSDS pS;
  722. HEMU hEmulator;
  723. HCLOOP hCLoop = (HCLOOP)0;
  724. HCOM hCom = NULL;
  725. #if defined(INCL_MINITEL)
  726. BOOL fAutoDetect = FALSE;
  727. #endif // INCL_MINITEL
  728. pS = (pSDS)GetWindowLongPtr(hDlg, DWLP_USER);
  729. if (pS == 0)
  730. {
  731. assert(FALSE);
  732. return -1;
  733. }
  734. hCLoop = sessQueryCLoopHdl(pS->hSession);
  735. // Convey the ascii settings to cloop...
  736. //
  737. CLoopSetSendCRLF(hCLoop, pS->stAsciiSettings.fsetSendCRLF);
  738. CLoopSetLocalEcho(hCLoop, pS->stAsciiSettings.fsetLocalEcho);
  739. CLoopSetAddLF(hCLoop, pS->stAsciiSettings.fsetAddLF);
  740. CLoopSetASCII7(hCLoop, pS->stAsciiSettings.fsetASCII7);
  741. CLoopSetLineDelay(hCLoop, pS->stAsciiSettings.iLineDelay);
  742. CLoopSetCharDelay(hCLoop, pS->stAsciiSettings.iCharDelay);
  743. // Record the change of emulator, if any.
  744. //
  745. pS->stEmuSettings.nEmuId = propGetEmuIdfromEmuCombo(hDlg, pS->hSession);
  746. // Record the terminal keys change, if any.
  747. //
  748. pS->stEmuSettings.nTermKeys =
  749. (int)(IsDlgButtonChecked(hDlg, IDC_TERMINAL_RB_TERMKEYS) == BST_CHECKED);
  750. // Record the sound change, if any.
  751. //
  752. sessSetSound(pS->hSession,
  753. (int)(IsDlgButtonChecked(hDlg, IDC_TERMINAL_CK_SOUND) == BST_CHECKED));
  754. // Record the exit change, if any.
  755. //mpt:10-28-97 added 'exit on disconnect' feature
  756. sessSetExit(pS->hSession,
  757. (int)(IsDlgButtonChecked(hDlg, IDC_TERMINAL_CK_EXIT) == BST_CHECKED));
  758. //
  759. // Record 'Allow host initiated file transfer' feature
  760. //
  761. sessSetAllowHostXfers(pS->hSession,
  762. (IsDlgButtonChecked(hDlg, IDC_TERMINAL_CK_HOSTXFERS) == BST_CHECKED));
  763. // Record the value of the backscroll buffer.
  764. //
  765. backscrlSetUNumLines(sessQueryBackscrlHdl(pS->hSession),
  766. propValidateBackscrlSize(hDlg));
  767. hEmulator = (HEMU)sessQueryEmuHdl(pS->hSession);
  768. #if defined(INCL_MINITEL)
  769. hCom = sessQueryComHdl(pS->hSession);
  770. if (hCom && ComValidHandle(hCom) &&
  771. pS->stEmuSettings.nEmuId == EMU_MINI &&
  772. hEmulator && emuQueryEmulatorId(hEmulator) != EMU_MINI)
  773. {
  774. int iDataBits = 8;
  775. int iParity = NOPARITY;
  776. int iStopBits = ONESTOPBIT;
  777. ComGetDataBits(hCom, &iDataBits);
  778. ComGetParity(hCom, &iParity);
  779. ComGetStopBits(hCom, &iStopBits);
  780. //
  781. // Turn on AutoDetect so that the Dial dialog will
  782. if (iDataBits != 7 || iParity != EVENPARITY || iStopBits != ONESTOPBIT)
  783. {
  784. ComSetDataBits(hCom, 7);
  785. ComSetParity(hCom, EVENPARITY);
  786. ComSetStopBits(hCom, ONESTOPBIT);
  787. ComSetAutoDetect(hCom, FALSE);
  788. }
  789. //
  790. // Force the incoming ASCII data to 7 bit.
  791. //
  792. pS->stAsciiSettings.fsetASCII7 = TRUE;
  793. CLoopSetASCII7(hCLoop, pS->stAsciiSettings.fsetASCII7);
  794. }
  795. #endif //INCL_MINITEL
  796. #if defined(INCL_VTUTF8)
  797. hCom = sessQueryComHdl(pS->hSession);
  798. if (hCom && ComValidHandle(hCom) &&
  799. pS->stEmuSettings.nEmuId == EMU_VTUTF8 &&
  800. hEmulator && emuQueryEmulatorId(hEmulator) != EMU_VTUTF8)
  801. {
  802. //
  803. // Force the appending carriage returns to line ends when
  804. // sending ASCII data to FALSE.
  805. //
  806. pS->stAsciiSettings.fsetAddLF = FALSE;
  807. CLoopSetSendCRLF(hCLoop, pS->stAsciiSettings.fsetSendCRLF);
  808. //
  809. // Force the appending carriage returns to line ends when
  810. // receiving ASCII data to FALSE.
  811. //
  812. pS->stAsciiSettings.fsetAddLF = FALSE;
  813. CLoopSetAddLF(hCLoop, pS->stAsciiSettings.fsetAddLF);
  814. //
  815. // Force the incoming ASCII data to 8 bit.
  816. //
  817. pS->stAsciiSettings.fsetASCII7 = FALSE;
  818. CLoopSetASCII7(hCLoop, pS->stAsciiSettings.fsetASCII7);
  819. }
  820. #endif // INCL_VTUTF8
  821. #ifdef INCL_USER_DEFINED_BACKSPACE_AND_TELNET_TERMINAL_ID
  822. // Record the backspace key change, if any. - cab:11/14/96
  823. //
  824. if ( IsDlgButtonChecked(hDlg, IDC_TERMINAL_RB_DEL) == BST_CHECKED )
  825. {
  826. pS->stEmuSettings.nBackspaceKeys = EMU_BKSPKEYS_DEL;
  827. }
  828. else if ( IsDlgButtonChecked(hDlg, IDC_TERMINAL_RB_CTRLHSPACE) == BST_CHECKED )
  829. {
  830. pS->stEmuSettings.nBackspaceKeys = EMU_BKSPKEYS_CTRLHSPACE;
  831. }
  832. else
  833. {
  834. // Default to CTRL-H if none are selected.
  835. //
  836. pS->stEmuSettings.nBackspaceKeys = EMU_BKSPKEYS_CTRLH;
  837. }
  838. // Record the new telnet terminal id - cab:11/15/96
  839. //
  840. if ( propValidateTelnetId(hDlg, pS->stEmuSettings.acTelnetId,
  841. sizeof(pS->stEmuSettings.acTelnetId)) != 0 )
  842. {
  843. iRet = -1;
  844. }
  845. #endif // INCL_USER_DEFINED_BACKSPACE_AND_TELNET_TERMINAL_ID
  846. #if defined(INCL_VTUTF8)
  847. #if defined(CHARACTER_TRANSLATION)
  848. //
  849. // If this is the VT_UTF8 terminal emulator, then set the translation
  850. // to passthrough mode so no translations get executed. REV: 05/21/2001
  851. //
  852. if (pS->stEmuSettings.nEmuId == EMU_VTUTF8)
  853. {
  854. HHTRANSLATE hTrans = (HHTRANSLATE)sessQueryTranslateHdl(pS->hSession);
  855. if (hTrans)
  856. {
  857. pstICT pstI = (pstICT)hTrans->pDllHandle;
  858. if (pstI)
  859. {
  860. pstI->nInputMode = PASS_THRU_MODE;
  861. pstI->nOutputMode = PASS_THRU_MODE;
  862. }
  863. }
  864. }
  865. #endif // CHARACTER_TRANSLATION
  866. #endif // INCL_VTUTF8
  867. // Commit the emulator settings changes
  868. //
  869. if (emuSetSettings(hEmulator, &(pS->stEmuSettings)) != 0)
  870. assert(FALSE);
  871. if (emuLoad(sessQueryEmuHdl(pS->hSession), pS->stEmuSettings.nEmuId) != 0)
  872. assert(0);
  873. PostMessage(sessQueryHwndStatusbar(pS->hSession), SBR_NTFY_REFRESH,
  874. (WPARAM)SBR_MAX_PARTS, 0);
  875. return iRet;
  876. }
  877. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  878. * FUNCTION:
  879. * propCreateUpDownControl
  880. *
  881. * DESCRIPTION:
  882. * This function puts an up-down control on the edit field for the backscroll
  883. * buffer. This gives us bounds checking for free... just set the appro-
  884. * priate parameters in the CreateUpDownControl call.
  885. *
  886. * ARGUMENTS:
  887. * hDlg - edit control window.
  888. *
  889. * RETURNS:
  890. * void.
  891. *
  892. */
  893. STATIC_FUNC void propCreateUpDownControl(HWND hDlg)
  894. {
  895. RECT rc;
  896. int nHeight, nWidth;
  897. DWORD dwFlags;
  898. HWND hwndChild;
  899. GetClientRect(GetDlgItem(hDlg, IDC_TERMINAL_EF_BACKSCRL), &rc);
  900. nHeight = rc.top - rc.bottom;
  901. nWidth = (nHeight / 3) * 2;
  902. dwFlags = WS_CHILD | WS_VISIBLE |
  903. UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_SETBUDDYINT;
  904. hwndChild = CreateUpDownControl(
  905. dwFlags, // create window flags
  906. rc.right, // left edge
  907. rc.top, // top edge
  908. nWidth, // width
  909. nHeight, // height
  910. hDlg, // parent window
  911. IDC_TERMINAL_EF_BACKSCRLTAB,
  912. (HINSTANCE)GetWindowLongPtr(hDlg, GWLP_HINSTANCE),
  913. GetDlgItem(hDlg, IDC_TERMINAL_EF_BACKSCRL),
  914. BKSCRL_USERLINES_DEFAULT_MAX,
  915. BKSCRL_USERLINES_DEFAULT_MIN,
  916. 111); // starting position - picked a weird
  917. // value so that we can tell that is
  918. // is the default
  919. assert(hwndChild);
  920. }
  921. #if 0
  922. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  923. * FUNCTION:
  924. * propGetIdFromEmuName
  925. *
  926. * DESCRIPTION:
  927. * Return the emulator id given the emulator name. I couldn't decide if this
  928. * functin should go with the emulator code, or here. Since it doesn't need
  929. * to access the internal emulator handle I decided to put it here.
  930. *
  931. * ARGUMENTS:
  932. * pacEmuName - the name of an emulator.
  933. *
  934. * RETURNS:
  935. * int nEmuId - return the id number for that emulator.
  936. */
  937. STATIC_FUNC int propGetIdFromEmuName(LPTSTR pacEmuName)
  938. {
  939. BYTE *pv;
  940. BYTE *temp;
  941. DWORD nLen;
  942. int i;
  943. int nEmuCount;
  944. if (resLoadDataBlock(glblQueryDllHinst(), IDT_EMU_NAMES, (LPVOID *)&pv, &nLen))
  945. {
  946. assert(FALSE);
  947. return 0;
  948. }
  949. nEmuCount = *(RCDATA_TYPE *)pv;
  950. pv += sizeof(RCDATA_TYPE);
  951. for (i = 0 ; i < nEmuCount ; i++)
  952. {
  953. nLen = (DWORD)StrCharGetByteCount((LPTSTR)pv) + (DWORD)sizeof(BYTE);
  954. if (nLen == 0)
  955. {
  956. assert(FALSE);
  957. return 0;
  958. }
  959. temp = pv + nLen;
  960. // Match on the name...
  961. //
  962. if (StrCharCmp(pacEmuName, pv) == 0)
  963. return (*(RCDATA_TYPE *)temp);
  964. pv += (nLen + (DWORD)sizeof(RCDATA_TYPE));
  965. }
  966. return 0;
  967. }
  968. #endif
  969. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  970. * FUNCTION:
  971. * propValidateBackscrlSize
  972. *
  973. * DESCRIPTION:
  974. * If the user entered a value outside of the range we support force the
  975. * value into the range.
  976. *
  977. * ARGUMENTS:
  978. * hDlg - dialog window handle.
  979. *
  980. * RETURNS:
  981. * nNewValue - number of lines to keep in the backscrol buffer.
  982. *
  983. */
  984. STATIC_FUNC int propValidateBackscrlSize(HWND hDlg)
  985. {
  986. TCHAR ach[256], acBuffer[256];
  987. int nNewValue = 0;
  988. if (propHasValidBackscrlSize(hDlg, &nNewValue) == FALSE)
  989. {
  990. LoadString(glblQueryDllHinst(), IDS_XD_INT, ach, sizeof(ach) / sizeof(TCHAR));
  991. TCHAR_Fill(acBuffer, TEXT('\0'), sizeof(acBuffer) / sizeof(TCHAR));
  992. wsprintf(acBuffer, ach, nNewValue);
  993. SendDlgItemMessage(hDlg, IDC_TERMINAL_EF_BACKSCRL, WM_SETTEXT, 0, (LPARAM)(LPTSTR)acBuffer);
  994. }
  995. return (nNewValue);
  996. }
  997. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  998. * FUNCTION:
  999. * propHasValidBackscrlSize
  1000. *
  1001. * DESCRIPTION:
  1002. * If the user entered a value outside of the range we support force the
  1003. * value into the range.
  1004. *
  1005. * ARGUMENTS:
  1006. * hDlg - dialog window handle.
  1007. * pBackScrlSize - a valid size for the backscroll.
  1008. *
  1009. * RETURNS:
  1010. * TRUE if the backscroll size is set to a valid range.
  1011. *
  1012. */
  1013. STATIC_FUNC int propHasValidBackscrlSize(HWND hDlg, int * pBackScrlSize)
  1014. {
  1015. BOOL fTranslated;
  1016. BOOL fReturn = FALSE;
  1017. int nValue = GetDlgItemInt(hDlg, IDC_TERMINAL_EF_BACKSCRL, &fTranslated, FALSE);
  1018. if (fTranslated)
  1019. {
  1020. if (nValue > BKSCRL_USERLINES_DEFAULT_MAX)
  1021. {
  1022. if (pBackScrlSize != NULL)
  1023. {
  1024. *pBackScrlSize = BKSCRL_USERLINES_DEFAULT_MAX;
  1025. }
  1026. }
  1027. else if (nValue < BKSCRL_USERLINES_DEFAULT_MIN)
  1028. {
  1029. if (pBackScrlSize != NULL)
  1030. {
  1031. *pBackScrlSize = BKSCRL_USERLINES_DEFAULT_MIN;
  1032. }
  1033. }
  1034. else if (pBackScrlSize != NULL)
  1035. {
  1036. *pBackScrlSize = nValue;
  1037. fReturn = TRUE;
  1038. }
  1039. }
  1040. return (fReturn);
  1041. }
  1042. #ifdef INCL_USER_DEFINED_BACKSPACE_AND_TELNET_TERMINAL_ID
  1043. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1044. * FUNCTION:
  1045. * propValidateTelnetId
  1046. *
  1047. * DESCRIPTION:
  1048. * Validates the telnet terminal id. If there is no telnet id, an
  1049. * error message is displayed.
  1050. *
  1051. * ARGUMENTS:
  1052. * hDlg - dialog window handle.
  1053. * pszTelnetId - buffer for the telnet id.
  1054. * iMaxChars - size of the telnet id buffer (in characters)
  1055. *
  1056. * RETURNS:
  1057. * Returns 0 if the id was valid, -1 otherwise.
  1058. *
  1059. * AUTHOR: C. Baumgartner, 11/15/96
  1060. */
  1061. STATIC_FUNC int propValidateTelnetId(HWND hDlg, TCHAR * pszTelnetId,
  1062. int iMaxChars)
  1063. {
  1064. int iRet = 0;
  1065. TCHAR * pszTempCopy;
  1066. // First create a temporary copy to get the unvalidated value,
  1067. // because we don't want to trash pszTelnetId if the value is
  1068. // invalid.
  1069. //
  1070. pszTempCopy = malloc(iMaxChars * sizeof(TCHAR));
  1071. if (pszTempCopy == NULL)
  1072. {
  1073. return -1;
  1074. }
  1075. TCHAR_Fill(pszTempCopy, TEXT('\0'), iMaxChars);
  1076. // Get the edit box text.
  1077. //
  1078. GetDlgItemText(hDlg, IDC_TERMINAL_EF_TELNETID, pszTempCopy, iMaxChars);
  1079. // We must have a value in the string.
  1080. //
  1081. if ( StrCharGetStrLength(pszTempCopy) )
  1082. {
  1083. StrCharCopyN(pszTelnetId, pszTempCopy, iMaxChars);
  1084. iRet = 0;
  1085. }
  1086. else
  1087. {
  1088. LoadString(glblQueryDllHinst(), IDS_ER_INVALID_TELNETID, pszTempCopy,
  1089. iMaxChars);
  1090. TimedMessageBox(hDlg, pszTempCopy, NULL, MB_OK | MB_ICONEXCLAMATION, 0);
  1091. iRet = -1;
  1092. }
  1093. free(pszTempCopy);
  1094. pszTempCopy = NULL;
  1095. return iRet;
  1096. }
  1097. #endif