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.

1465 lines
41 KiB

  1. /* File: D:\WACKER\emu\emudlg.c (Created: 14-Feb-1994)
  2. *
  3. * Copyright 1991, 1998 by Hilgraeve Inc. -- Monroe, MI
  4. * All rights reserved
  5. *
  6. * $Revision: 21 $
  7. * $Date: 5/15/02 4:43p $
  8. */
  9. #include <windows.h>
  10. #pragma hdrstop
  11. #include <commctrl.h>
  12. #include <tdll\stdtyp.h>
  13. #include <tdll\tdll.h>
  14. #include <tdll\assert.h>
  15. #include <tdll\session.h>
  16. #include <tdll\statusbr.h>
  17. #include <tdll\misc.h>
  18. #include <term\res.h>
  19. #include <tdll\globals.h>
  20. #include <tdll\load_res.h>
  21. #include <tdll\htchar.h>
  22. #include <tdll\hlptable.h>
  23. #include "emu.h"
  24. #include "emuid.h"
  25. #include "emudlgs.h"
  26. #include <tdll\term.hh> // This must be after emu.h
  27. // Static function prototypes...
  28. //
  29. STATIC_FUNC void emudlgInitCursorSettings (HWND hDlg,
  30. PSTEMUSET pstEmuSettings,
  31. INT ID_UNDERLINE,
  32. INT ID_BLOCK,
  33. INT ID_BLINK);
  34. #if DEADWOOD
  35. STATIC_FUNC void emudlgInitCharSetSetting(HWND hDlg,
  36. PSTEMUSET pstEmuSettings,
  37. int nCharSetTableID,
  38. int nDefaultCharSetID);
  39. STATIC_FUNC BOOL emudlgFindCharSetName(HWND hDlg,
  40. BYTE *pbCharSetTable,
  41. int nCharSetID,
  42. LPTSTR *ppszCharSetName,
  43. BOOL fTellDlg);
  44. #endif // DEADWOOD
  45. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  46. STATIC_FUNC void emudlgInitRowsCols(HWND hDlg, PSTEMUSET pstEmuSettings);
  47. STATIC_FUNC void emudlgGetRowColSettings(HWND hDlg, PSTEMUSET pstEmuSettings);
  48. STATIC_FUNC void emudlgCreateUpDownControl(HWND hDlg,
  49. PSTEMUSET pstEmuSettings);
  50. STATIC_FUNC int emudlgValidateEntryFieldSetting(HWND hDlg,
  51. int nIDC,
  52. int nMinVal,
  53. int nMaxVal);
  54. #endif
  55. // Defines...
  56. //
  57. #define IDC_KEYPAD_MODE 104
  58. #define IDC_CURSOR_MODE 106
  59. #define IDC_132_COLUMN 107
  60. #define IDC_TF_CHARACTER_SET 109
  61. #define IDC_CHARACTER_SET 110
  62. #define IDC_BLOCK_CURSOR 112
  63. #define IDC_UNDERLINE_CURSOR 113
  64. #define IDC_BLINK_CURSOR 114
  65. #define IDC_DESTRUCTIVE_BKSP 116
  66. #define IDC_ALT_MODE 117
  67. #define IDC_SEND_POUND_SYMBOL 122
  68. #define IDC_HIDE_CURSOR 119
  69. #define IDC_GR_CURSOR 111
  70. #define IDC_GR_TERMINAL_MODES 118
  71. #define IDC_USE_8_BIT_CODES 120
  72. #define IDC_ALLOW_USERDEFINED_KEYS 121
  73. #define IDC_GR_SCREEN 130
  74. #define IDC_TF_ROWS 131
  75. #define IDC_NUMBER_OF_ROWS 132
  76. #define IDC_TF_COLUMNS 133
  77. #define IDC_NUMBER_OF_COLS 134
  78. #define IDC_PRINT_RAW 135
  79. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  80. * FUNCTION:
  81. * emuSettingsDlg
  82. *
  83. * DESCRIPTION:
  84. * Decide which emulator settings dialog to call.
  85. *
  86. * ARGUMENTS:
  87. * hSession - the session handle.
  88. * nEmuId - emulator id.
  89. * pstEmuSettings - settings structure to fill in. It should be initialized
  90. * up above.
  91. *
  92. * RETURNS:
  93. * fResult - return value from the DoDialog().
  94. *
  95. */
  96. BOOL emuSettingsDlg(const HSESSION hSession, const HWND hwndParent,
  97. const int nEmuId, PSTEMUSET pstEmuSettings)
  98. {
  99. BOOL fResult = FALSE;
  100. assert(hSession && hwndParent);
  101. switch (nEmuId)
  102. {
  103. case EMU_ANSIW:
  104. case EMU_ANSI:
  105. fResult = (BOOL)DoDialog(glblQueryDllHinst(),
  106. MAKEINTRESOURCE(IDD_ANSI_SETTINGS),
  107. hwndParent,
  108. (DLGPROC)emuANSI_SettingsDlgProc,
  109. (LPARAM)pstEmuSettings);
  110. break;
  111. case EMU_TTY:
  112. fResult = (BOOL)DoDialog(glblQueryDllHinst(),
  113. MAKEINTRESOURCE(IDD_TTY_SETTINGS),
  114. hwndParent,
  115. (DLGPROC)emuTTY_SettingsDlgProc,
  116. (LPARAM)pstEmuSettings);
  117. break;
  118. case EMU_VT52:
  119. fResult = (BOOL)DoDialog(glblQueryDllHinst(),
  120. MAKEINTRESOURCE(IDD_VT52_SETTINGS),
  121. hwndParent,
  122. (DLGPROC)emuVT52_SettingsDlgProc,
  123. (LPARAM)pstEmuSettings);
  124. break;
  125. case EMU_VT100:
  126. case EMU_VT100J:
  127. #if defined(INCL_VTUTF8)
  128. case EMU_VTUTF8:
  129. #endif
  130. #if defined(INCL_VT100PLUS)
  131. case EMU_VT100PLUS:
  132. #endif
  133. fResult = (BOOL)DoDialog(glblQueryDllHinst(),
  134. MAKEINTRESOURCE(IDD_VT100_SETTINGS),
  135. hwndParent,
  136. (DLGPROC)emuVT100_SettingsDlgProc,
  137. (LPARAM)pstEmuSettings);
  138. break;
  139. #if defined(INCL_VT220) || defined(INCL_VT320)
  140. #if defined(INCL_VT220)
  141. case EMU_VT220:
  142. #endif // defined(INCL_VT320)
  143. #if defined(INCL_VT320)
  144. case EMU_VT320:
  145. #endif // defined(INCL_VT320)
  146. fResult = (BOOL)DoDialog(glblQueryDllHinst(),
  147. MAKEINTRESOURCE(IDD_VT220_SETTINGS),
  148. hwndParent,
  149. (DLGPROC)emuVT220_SettingsDlgProc,
  150. (LPARAM)pstEmuSettings);
  151. break;
  152. #endif // defined(INCL_VT220) || defined(INCL_VT320)
  153. case EMU_MINI:
  154. fResult = (BOOL)DoDialog(glblQueryDllHinst(),
  155. MAKEINTRESOURCE(IDD_MINITEL_SETTINGS),
  156. hwndParent,
  157. (DLGPROC)emuMinitel_SettingsDlgProc,
  158. (LPARAM)pstEmuSettings);
  159. break;
  160. case EMU_VIEW:
  161. fResult = (BOOL)DoDialog(glblQueryDllHinst(),
  162. MAKEINTRESOURCE(IDD_VIEWDATA_SETTINGS),
  163. hwndParent,
  164. (DLGPROC)emuViewdata_SettingsDlgProc,
  165. (LPARAM)pstEmuSettings);
  166. break;
  167. default:
  168. break;
  169. }
  170. return fResult;
  171. }
  172. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  173. * FUNCTION:
  174. * emuANSI_SettingsDlgProc
  175. *
  176. * DESCRIPTION:
  177. * ANSI Settings dialog proc.
  178. *
  179. * ARGUMENTS:
  180. * Standard window proc parameters.
  181. *
  182. * RETURNS:
  183. * Standerd return value.
  184. *
  185. */
  186. INT_PTR CALLBACK emuANSI_SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  187. {
  188. PSTEMUSET pstEmuSettings;
  189. static DWORD aHlpTable[] =
  190. {
  191. IDC_BLOCK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  192. IDC_UNDERLINE_CURSOR, IDH_TERM_EMUSET_CURSOR,
  193. IDC_BLINK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  194. IDC_GR_CURSOR, IDH_TERM_EMUSET_CURSOR,
  195. IDCANCEL, IDH_CANCEL,
  196. IDOK, IDH_OK,
  197. 0, 0};
  198. switch (wMsg)
  199. {
  200. case WM_INITDIALOG:
  201. pstEmuSettings = (PSTEMUSET)lPar;
  202. SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)pstEmuSettings);
  203. mscCenterWindowOnWindow(hDlg, GetParent(hDlg));
  204. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  205. /* -------------- Screen rows and columns ------------- */
  206. emudlgInitRowsCols(hDlg, pstEmuSettings);
  207. #endif
  208. /* -------------- Cursor characteristics ------------- */
  209. emudlgInitCursorSettings(hDlg, pstEmuSettings, IDC_UNDERLINE_CURSOR,
  210. IDC_BLOCK_CURSOR, IDC_BLINK_CURSOR);
  211. break;
  212. case WM_CONTEXTMENU:
  213. doContextHelp(aHlpTable, wPar, lPar, TRUE, TRUE);
  214. break;
  215. case WM_HELP:
  216. doContextHelp(aHlpTable, wPar, lPar, FALSE, FALSE);
  217. break;
  218. case WM_COMMAND:
  219. switch (wPar)
  220. {
  221. case IDOK:
  222. pstEmuSettings = (PSTEMUSET)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  223. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  224. /* -------------- Screen rows and columns ------------- */
  225. emudlgGetRowColSettings(hDlg, pstEmuSettings);
  226. #endif
  227. /* -------------- Cursor type ------------- */
  228. pstEmuSettings->nCursorType =
  229. (int)(IsDlgButtonChecked(hDlg, IDC_BLOCK_CURSOR) == BST_CHECKED) ?
  230. EMU_CURSOR_BLOCK : EMU_CURSOR_LINE;
  231. /* -------------- Cursor Blink ------------- */
  232. pstEmuSettings->fCursorBlink =
  233. (int)(IsDlgButtonChecked(hDlg, IDC_BLINK_CURSOR) == BST_CHECKED);
  234. EndDialog(hDlg, TRUE);
  235. break;
  236. case IDCANCEL:
  237. EndDialog(hDlg, FALSE);
  238. break;
  239. default:
  240. return FALSE;
  241. }
  242. break;
  243. default:
  244. return FALSE;
  245. }
  246. return TRUE;
  247. }
  248. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  249. * FUNCTION:
  250. * emuTTY_SettingsDlgProc
  251. *
  252. * DESCRIPTION:
  253. * TTY Settings dialog proc.
  254. *
  255. * ARGUMENTS:
  256. * Standard window proc parameters.
  257. *
  258. * RETURNS:
  259. * Standerd return value.
  260. *
  261. */
  262. INT_PTR CALLBACK emuTTY_SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  263. {
  264. PSTEMUSET pstEmuSettings;
  265. static DWORD aHlpTable[] = {IDC_DESTRUCTIVE_BKSP, IDH_TERM_EMUSET_DESTRUCTIVE,
  266. IDC_BLOCK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  267. IDC_UNDERLINE_CURSOR, IDH_TERM_EMUSET_CURSOR,
  268. IDC_BLINK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  269. IDC_GR_CURSOR, IDH_TERM_EMUSET_CURSOR,
  270. IDCANCEL, IDH_CANCEL,
  271. IDOK, IDH_OK,
  272. 0, 0};
  273. switch (wMsg)
  274. {
  275. case WM_INITDIALOG:
  276. pstEmuSettings = (PSTEMUSET)lPar;
  277. SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)pstEmuSettings);
  278. mscCenterWindowOnWindow(hDlg, GetParent(hDlg));
  279. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  280. /* -------------- Screen rows and columns ------------- */
  281. emudlgInitRowsCols(hDlg, pstEmuSettings);
  282. #endif
  283. /* -------------- Destructive Backspace ------------- */
  284. SendDlgItemMessage(hDlg, IDC_DESTRUCTIVE_BKSP, BM_SETCHECK,
  285. (unsigned int)pstEmuSettings->fDestructiveBk, 0);
  286. /* -------------- Cursor characteristics ------------- */
  287. emudlgInitCursorSettings(hDlg, pstEmuSettings, IDC_UNDERLINE_CURSOR,
  288. IDC_BLOCK_CURSOR, IDC_BLINK_CURSOR);
  289. break;
  290. case WM_CONTEXTMENU:
  291. doContextHelp(aHlpTable, wPar, lPar, TRUE, TRUE);
  292. break;
  293. case WM_HELP:
  294. doContextHelp(aHlpTable, wPar, lPar, FALSE, FALSE);
  295. break;
  296. case WM_COMMAND:
  297. switch (wPar)
  298. {
  299. case IDOK:
  300. pstEmuSettings = (PSTEMUSET)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  301. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  302. /* -------------- Screen rows and columns ------------- */
  303. emudlgGetRowColSettings(hDlg, pstEmuSettings);
  304. #endif
  305. /* -------------- Destructive Backspace ------------- */
  306. pstEmuSettings->fDestructiveBk =
  307. (int)(IsDlgButtonChecked(hDlg, IDC_DESTRUCTIVE_BKSP) == BST_CHECKED);
  308. /* -------------- Cursor type ------------- */
  309. pstEmuSettings->nCursorType =
  310. (int)(IsDlgButtonChecked(hDlg, IDC_BLOCK_CURSOR) == BST_CHECKED) ?
  311. EMU_CURSOR_BLOCK : EMU_CURSOR_LINE;
  312. /* -------------- Cursor Blink ------------- */
  313. pstEmuSettings->fCursorBlink =
  314. (int)(IsDlgButtonChecked(hDlg, IDC_BLINK_CURSOR) == BST_CHECKED);
  315. EndDialog(hDlg, TRUE);
  316. break;
  317. case IDCANCEL:
  318. EndDialog(hDlg, FALSE);
  319. break;
  320. default:
  321. return FALSE;
  322. }
  323. break;
  324. default:
  325. return FALSE;
  326. }
  327. return TRUE;
  328. }
  329. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  330. * FUNCTION:
  331. * emuVT52_SettingsDlgProc
  332. *
  333. * DESCRIPTION:
  334. * VT52 Settings dialog proc.
  335. *
  336. * ARGUMENTS:
  337. * Standard window proc parameters.
  338. *
  339. * RETURNS:
  340. * Standerd return value.
  341. *
  342. */
  343. INT_PTR CALLBACK emuVT52_SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  344. {
  345. PSTEMUSET pstEmuSettings;
  346. static DWORD aHlpTable[] = {IDC_ALT_MODE, IDH_TERM_EMUSET_ALTMODE,
  347. IDC_BLOCK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  348. IDC_UNDERLINE_CURSOR, IDH_TERM_EMUSET_CURSOR,
  349. IDC_BLINK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  350. IDC_GR_CURSOR, IDH_TERM_EMUSET_CURSOR,
  351. IDCANCEL, IDH_CANCEL,
  352. IDOK, IDH_OK,
  353. 0, 0};
  354. switch (wMsg)
  355. {
  356. case WM_INITDIALOG:
  357. pstEmuSettings = (PSTEMUSET)lPar;
  358. SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)pstEmuSettings);
  359. mscCenterWindowOnWindow(hDlg, GetParent(hDlg));
  360. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  361. /* -------------- Screen rows and columns ------------- */
  362. emudlgInitRowsCols(hDlg, pstEmuSettings);
  363. #endif
  364. /* -------------- Alternate keypad mode ------------- */
  365. SendDlgItemMessage(hDlg, IDC_ALT_MODE, BM_SETCHECK,
  366. (unsigned int)pstEmuSettings->fAltKeypadMode, 0);
  367. /* -------------- Cursor characteristics ------------- */
  368. emudlgInitCursorSettings(hDlg, pstEmuSettings, IDC_UNDERLINE_CURSOR,
  369. IDC_BLOCK_CURSOR, IDC_BLINK_CURSOR);
  370. break;
  371. case WM_CONTEXTMENU:
  372. doContextHelp(aHlpTable, wPar, lPar, TRUE, TRUE);
  373. break;
  374. case WM_HELP:
  375. doContextHelp(aHlpTable, wPar, lPar, FALSE, FALSE);
  376. break;
  377. case WM_COMMAND:
  378. switch (wPar)
  379. {
  380. case IDOK:
  381. pstEmuSettings = (PSTEMUSET)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  382. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  383. /* -------------- Screen rows and columns ------------- */
  384. emudlgGetRowColSettings(hDlg, pstEmuSettings);
  385. #endif
  386. /* -------------- Alternate keypad mode ------------- */
  387. pstEmuSettings->fAltKeypadMode =
  388. (int)(IsDlgButtonChecked(hDlg, IDC_ALT_MODE) == BST_CHECKED);
  389. /* -------------- Cursor type ------------- */
  390. pstEmuSettings->nCursorType =
  391. (int)(IsDlgButtonChecked(hDlg, IDC_BLOCK_CURSOR) == BST_CHECKED) ?
  392. EMU_CURSOR_BLOCK : EMU_CURSOR_LINE;
  393. /* -------------- Cursor Blink ------------- */
  394. pstEmuSettings->fCursorBlink =
  395. (int)(IsDlgButtonChecked(hDlg, IDC_BLINK_CURSOR) == BST_CHECKED);
  396. EndDialog(hDlg, TRUE);
  397. break;
  398. case IDCANCEL:
  399. EndDialog(hDlg, FALSE);
  400. break;
  401. default:
  402. return FALSE;
  403. }
  404. break;
  405. default:
  406. return FALSE;
  407. }
  408. return TRUE;
  409. }
  410. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  411. * FUNCTION:
  412. * emuVT100_SettingsDlgProc
  413. *
  414. * DESCRIPTION:
  415. * VT100 Settings dialog proc.
  416. *
  417. * ARGUMENTS:
  418. * Standard window proc parameters.
  419. *
  420. * RETURNS:
  421. * Standerd return value.
  422. *
  423. */
  424. INT_PTR CALLBACK emuVT100_SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  425. {
  426. int nIndex;
  427. PSTEMUSET pstEmuSettings;
  428. static DWORD aHlpTable[] = {IDC_KEYPAD_MODE, IDH_TERM_EMUSET_KEYPADMODE,
  429. IDC_CURSOR_MODE, IDH_TERM_EMUSET_CURSORMODE,
  430. IDC_132_COLUMN, IDH_TERM_EMUSET_132COLUMNS,
  431. IDC_GR_TERMINAL_MODES,IDH_TERM_EMUSET_MODES,
  432. #if DEADWOOD
  433. IDC_CHARACTER_SET, IDH_TERM_EMUSET_CHARSETS,
  434. IDC_TF_CHARACTER_SET, IDH_TERM_EMUSET_CHARSETS,
  435. #endif // DEADWOOD
  436. IDC_BLOCK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  437. IDC_UNDERLINE_CURSOR, IDH_TERM_EMUSET_CURSOR,
  438. IDC_BLINK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  439. IDC_GR_CURSOR, IDH_TERM_EMUSET_CURSOR,
  440. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  441. IDC_GR_SCREEN, IDH_TERM_EMUSET_ROWSANDCOLS,
  442. IDC_TF_ROWS, IDH_TERM_EMUSET_ROWSANDCOLS,
  443. IDC_NUMBER_OF_ROWS, IDH_TERM_EMUSET_ROWSANDCOLS,
  444. IDC_TF_COLUMNS, IDH_TERM_EMUSET_ROWSANDCOLS,
  445. IDC_NUMBER_OF_COLS, IDH_TERM_EMUSET_ROWSANDCOLS,
  446. #endif // defined(INCL_TERMINAL_SIZE_AND_COLORS)
  447. IDC_USE_8_BIT_CODES, IDH_TERM_EMUSET_8BITCODES,
  448. IDC_ALLOW_USERDEFINED_KEYS,IDH_TERM_EMUSET_USERDEFKEYS,
  449. IDC_PRINT_RAW, IDH_TERM_EMUSET_PRINTRAW,
  450. IDCANCEL, IDH_CANCEL,
  451. IDOK, IDH_OK,
  452. 0, 0};
  453. switch (wMsg)
  454. {
  455. case WM_INITDIALOG:
  456. pstEmuSettings = (PSTEMUSET)lPar;
  457. SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)pstEmuSettings);
  458. mscCenterWindowOnWindow(hDlg, GetParent(hDlg));
  459. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  460. /* -------------- Screen rows and columns ------------- */
  461. emudlgInitRowsCols(hDlg, pstEmuSettings);
  462. #endif
  463. /* -------------- Keypad application mode ------------- */
  464. SendDlgItemMessage(hDlg, IDC_KEYPAD_MODE, BM_SETCHECK,
  465. (unsigned int)pstEmuSettings->fKeypadAppMode, 0);
  466. /* -------------- Cursor keypad mode ------------- */
  467. SendDlgItemMessage(hDlg, IDC_CURSOR_MODE, BM_SETCHECK,
  468. (unsigned int)pstEmuSettings->fCursorKeypadMode, 0);
  469. #if !defined(INCL_TERMINAL_SIZE_AND_COLORS)
  470. /* -------------- 132 Column Mode ------------- */
  471. SendDlgItemMessage(hDlg, IDC_132_COLUMN, BM_SETCHECK,
  472. (unsigned int)pstEmuSettings->f132Columns, 0);
  473. #endif
  474. #if defined(INCL_PRINT_PASSTHROUGH)
  475. /* -------------- Host Print Mode ------------- */
  476. // mpt;04-22-00 added interface to control host-controlled printing
  477. SendDlgItemMessage(hDlg, IDC_PRINT_RAW, BM_SETCHECK,
  478. (unsigned int)pstEmuSettings->fPrintRaw, 0);
  479. #endif // INCL_PRINT_PASSTHROUGH
  480. /* -------------- Cursor characteristics ------------- */
  481. emudlgInitCursorSettings(hDlg, pstEmuSettings, IDC_UNDERLINE_CURSOR,
  482. IDC_BLOCK_CURSOR, IDC_BLINK_CURSOR);
  483. /* -------------- VT100 Character Sets ------------- */
  484. #if DEADWOOD
  485. emudlgInitCharSetSetting(hDlg, pstEmuSettings,
  486. IDT_EMU_VT100_CHAR_SETS, EMU_CHARSET_ASCII);
  487. #endif // DEADWOOD
  488. break;
  489. case WM_CONTEXTMENU:
  490. doContextHelp(aHlpTable, wPar, lPar, TRUE, TRUE);
  491. break;
  492. case WM_HELP:
  493. doContextHelp(aHlpTable, wPar, lPar, FALSE, FALSE);
  494. break;
  495. case WM_COMMAND:
  496. switch (wPar)
  497. {
  498. case IDOK:
  499. pstEmuSettings = (PSTEMUSET)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  500. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  501. /* -------------- Screen rows and columns ------------- */
  502. emudlgGetRowColSettings(hDlg, pstEmuSettings);
  503. #endif
  504. /* -------------- Keypad Application mode ------------- */
  505. pstEmuSettings->fKeypadAppMode =
  506. (int)(IsDlgButtonChecked(hDlg, IDC_KEYPAD_MODE) == BST_CHECKED);
  507. /* -------------- Cursor Keypad Mode ------------- */
  508. pstEmuSettings->fCursorKeypadMode =
  509. (int)(IsDlgButtonChecked(hDlg, IDC_CURSOR_MODE) == BST_CHECKED);
  510. #if !defined(INCL_TERMINAL_SIZE_AND_COLORS)
  511. /* -------------- 132 Column Mode ------------- */
  512. pstEmuSettings->f132Columns =
  513. (int)(IsDlgButtonChecked(hDlg, IDC_132_COLUMN) == BST_CHECKED);
  514. #endif
  515. #if defined(INCL_PRINT_PASSTHROUGH)
  516. /* -------------- Host Print Mode ------------- */
  517. //mpt:04-22-00
  518. pstEmuSettings->fPrintRaw =
  519. (int)(IsDlgButtonChecked(hDlg, IDC_PRINT_RAW) == BST_CHECKED);
  520. #endif // INCL_PRINT_PASSTHROUGH
  521. /* -------------- Cursor type ------------- */
  522. pstEmuSettings->nCursorType =
  523. (int)(IsDlgButtonChecked(hDlg, IDC_BLOCK_CURSOR) == BST_CHECKED) ?
  524. EMU_CURSOR_BLOCK : EMU_CURSOR_LINE;
  525. /* -------------- Cursor Blink ------------- */
  526. pstEmuSettings->fCursorBlink =
  527. (int)(IsDlgButtonChecked(hDlg, IDC_BLINK_CURSOR) == BST_CHECKED);
  528. /* -------------- VT100 Character Set ------------- */
  529. nIndex = (int)SendDlgItemMessage(hDlg, IDC_CHARACTER_SET, CB_GETCURSEL, 0, 0);
  530. assert(nIndex != CB_ERR);
  531. //JMH 01-09-97 Get the nCharacterSet value associated with this entry
  532. //
  533. pstEmuSettings->nCharacterSet =
  534. (int)SendDlgItemMessage(hDlg, IDC_CHARACTER_SET, CB_GETITEMDATA,
  535. (WPARAM) nIndex, (LPARAM) 0);
  536. assert(pstEmuSettings->nCharacterSet != CB_ERR);
  537. EndDialog(hDlg, TRUE);
  538. break;
  539. case IDCANCEL:
  540. EndDialog(hDlg, FALSE);
  541. break;
  542. default:
  543. return FALSE;
  544. }
  545. break;
  546. default:
  547. return FALSE;
  548. }
  549. return TRUE;
  550. }
  551. #if defined(INCL_VT220)
  552. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  553. * FUNCTION:
  554. * emuVT220_SettingsDlgProc
  555. *
  556. * DESCRIPTION:
  557. * VT220 Settings dialog proc.
  558. *
  559. * ARGUMENTS:
  560. * Standard window proc parameters.
  561. *
  562. * RETURNS:
  563. * Standerd return value.
  564. *
  565. */
  566. INT_PTR CALLBACK emuVT220_SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  567. {
  568. PSTEMUSET pstEmuSettings;
  569. int nIndex;
  570. static DWORD aHlpTable[] = {IDC_KEYPAD_MODE, IDH_TERM_EMUSET_KEYPADMODE,
  571. IDC_CURSOR_MODE, IDH_TERM_EMUSET_CURSORMODE,
  572. IDC_132_COLUMN, IDH_TERM_EMUSET_132COLUMNS,
  573. IDC_GR_TERMINAL_MODES,IDH_TERM_EMUSET_MODES,
  574. #if DEADWOOD
  575. IDC_CHARACTER_SET, IDH_TERM_EMUSET_CHARSETS,
  576. IDC_TF_CHARACTER_SET, IDH_TERM_EMUSET_CHARSETS,
  577. #endif // DEADWOOD
  578. IDC_BLOCK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  579. IDC_UNDERLINE_CURSOR, IDH_TERM_EMUSET_CURSOR,
  580. IDC_BLINK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  581. IDC_GR_CURSOR, IDH_TERM_EMUSET_CURSOR,
  582. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  583. IDC_GR_SCREEN, IDH_TERM_EMUSET_ROWSANDCOLS,
  584. IDC_TF_ROWS, IDH_TERM_EMUSET_ROWSANDCOLS,
  585. IDC_NUMBER_OF_ROWS, IDH_TERM_EMUSET_ROWSANDCOLS,
  586. IDC_TF_COLUMNS, IDH_TERM_EMUSET_ROWSANDCOLS,
  587. IDC_NUMBER_OF_COLS, IDH_TERM_EMUSET_ROWSANDCOLS,
  588. #endif // defined(INCL_TERMINAL_SIZE_AND_COLORS)
  589. IDC_USE_8_BIT_CODES, IDH_TERM_EMUSET_8BITCODES,
  590. IDC_ALLOW_USERDEFINED_KEYS,IDH_TERM_EMUSET_USERDEFKEYS,
  591. IDC_PRINT_RAW, IDH_TERM_EMUSET_PRINTRAW,
  592. IDCANCEL, IDH_CANCEL,
  593. IDOK, IDH_OK,
  594. 0, 0};
  595. switch (wMsg)
  596. {
  597. case WM_INITDIALOG:
  598. pstEmuSettings = (PSTEMUSET)lPar;
  599. SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)pstEmuSettings);
  600. mscCenterWindowOnWindow(hDlg, GetParent(hDlg));
  601. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  602. /* -------------- Screen rows and columns ------------- */
  603. emudlgInitRowsCols(hDlg, pstEmuSettings);
  604. #endif
  605. /* -------------- Keypad application mode ------------- */
  606. SendDlgItemMessage(hDlg, IDC_KEYPAD_MODE, BM_SETCHECK,
  607. (unsigned int)pstEmuSettings->fKeypadAppMode, 0);
  608. /* -------------- Cursor keypad mode ------------- */
  609. SendDlgItemMessage(hDlg, IDC_CURSOR_MODE, BM_SETCHECK,
  610. (unsigned int)pstEmuSettings->fCursorKeypadMode, 0);
  611. #if !defined(INCL_TERMINAL_SIZE_AND_COLORS)
  612. /* -------------- 132 Column Mode ------------- */
  613. SendDlgItemMessage(hDlg, IDC_132_COLUMN, BM_SETCHECK,
  614. (unsigned int)pstEmuSettings->f132Columns, 0);
  615. #endif
  616. #if defined(INCL_PRINT_PASSTHROUGH)
  617. /* -------------- Host Print Mode ------------- */
  618. SendDlgItemMessage(hDlg, IDC_PRINT_RAW, BM_SETCHECK,
  619. (unsigned int)pstEmuSettings->fPrintRaw, 0);
  620. #endif // INCL_PRINT_PASSTHROUGH
  621. /* -------------- Cursor characteristics ------------- */
  622. emudlgInitCursorSettings(hDlg, pstEmuSettings, IDC_UNDERLINE_CURSOR,
  623. IDC_BLOCK_CURSOR, IDC_BLINK_CURSOR);
  624. /* -------------- 8 bit codes mode ------------- */
  625. SendDlgItemMessage(hDlg, IDC_USE_8_BIT_CODES, BM_SETCHECK,
  626. (unsigned int)pstEmuSettings->fUse8BitCodes, 0);
  627. /* -------------- User defined keys ------------- */
  628. SendDlgItemMessage(hDlg, IDC_ALLOW_USERDEFINED_KEYS, BM_SETCHECK,
  629. (unsigned int)pstEmuSettings->fAllowUserKeys, 0);
  630. /* -------------- VT220 Character Sets ------------- */
  631. #if DEADWOOD
  632. emudlgInitCharSetSetting(hDlg, pstEmuSettings,
  633. IDT_EMU_VT220_CHAR_SETS, EMU_CHARSET_MULTINATIONAL);
  634. #endif // DEADWOOD
  635. break;
  636. case WM_CONTEXTMENU:
  637. doContextHelp(aHlpTable, wPar, lPar, TRUE, TRUE);
  638. break;
  639. case WM_HELP:
  640. doContextHelp(aHlpTable, wPar, lPar, FALSE, FALSE);
  641. break;
  642. case WM_COMMAND:
  643. switch (wPar)
  644. {
  645. case IDOK:
  646. pstEmuSettings = (PSTEMUSET)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  647. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  648. /* -------------- Screen rows and columns ------------- */
  649. emudlgGetRowColSettings(hDlg, pstEmuSettings);
  650. #endif
  651. /* -------------- Keypad Application mode ------------- */
  652. pstEmuSettings->fKeypadAppMode =
  653. (int)(IsDlgButtonChecked(hDlg, IDC_KEYPAD_MODE) == BST_CHECKED);
  654. /* -------------- Cursor Keypad Mode ------------- */
  655. pstEmuSettings->fCursorKeypadMode =
  656. (int)(IsDlgButtonChecked(hDlg, IDC_CURSOR_MODE) == BST_CHECKED);
  657. #if !defined(INCL_TERMINAL_SIZE_AND_COLORS)
  658. /* -------------- 132 Column Mode ------------- */
  659. pstEmuSettings->f132Columns =
  660. (int)(IsDlgButtonChecked(hDlg, IDC_132_COLUMN) == BST_CHECKED);
  661. #endif
  662. #if defined(INCL_PRINT_PASSTHROUGH)
  663. /* -------------- Host Print Mode ------------- */
  664. pstEmuSettings->fPrintRaw =
  665. (int)(IsDlgButtonChecked(hDlg, IDC_PRINT_RAW) == BST_CHECKED);
  666. #endif // INCL_PRINT_PASSTHROUGH
  667. /* -------------- Cursor type ------------- */
  668. pstEmuSettings->nCursorType =
  669. (int)(IsDlgButtonChecked(hDlg, IDC_BLOCK_CURSOR) == BST_CHECKED) ?
  670. EMU_CURSOR_BLOCK : EMU_CURSOR_LINE;
  671. /* -------------- Cursor Blink ------------- */
  672. pstEmuSettings->fCursorBlink =
  673. (int)(IsDlgButtonChecked(hDlg, IDC_BLINK_CURSOR) == BST_CHECKED);
  674. /* -------------- 8 bit codes mode ------------- */
  675. pstEmuSettings->fUse8BitCodes =
  676. (int)(IsDlgButtonChecked(hDlg, IDC_USE_8_BIT_CODES) == BST_CHECKED);
  677. /* -------------- User defined keys ------------- */
  678. pstEmuSettings->fAllowUserKeys =
  679. (int)(IsDlgButtonChecked(hDlg, IDC_ALLOW_USERDEFINED_KEYS) == BST_CHECKED);
  680. /* -------------- VT220 Character Set ------------- */
  681. nIndex = SendDlgItemMessage(hDlg, IDC_CHARACTER_SET, CB_GETCURSEL, 0, 0);
  682. assert(nIndex != CB_ERR);
  683. //JMH 01-09-97 Get the nCharacterSet value associated with this entry
  684. //
  685. pstEmuSettings->nCharacterSet =
  686. SendDlgItemMessage(hDlg, IDC_CHARACTER_SET, CB_GETITEMDATA,
  687. (WPARAM) nIndex, (LPARAM) 0);
  688. assert(pstEmuSettings->nCharacterSet != CB_ERR);
  689. EndDialog(hDlg, TRUE);
  690. break;
  691. case IDCANCEL:
  692. EndDialog(hDlg, FALSE);
  693. break;
  694. default:
  695. return FALSE;
  696. }
  697. break;
  698. default:
  699. return FALSE;
  700. }
  701. return TRUE;
  702. }
  703. #endif
  704. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  705. * FUNCTION:
  706. * emuMinitel_SettingsDlgProc
  707. *
  708. * DESCRIPTION:
  709. * TTY Settings dialog proc.
  710. *
  711. * ARGUMENTS:
  712. * Standard window proc parameters.
  713. *
  714. * RETURNS:
  715. * Standerd return value.
  716. *
  717. */
  718. INT_PTR CALLBACK emuMinitel_SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  719. {
  720. PSTEMUSET pstEmuSettings;
  721. static DWORD aHlpTable[] = {IDC_DESTRUCTIVE_BKSP, IDH_TERM_EMUSET_DESTRUCTIVE,
  722. IDC_BLOCK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  723. IDC_UNDERLINE_CURSOR, IDH_TERM_EMUSET_CURSOR,
  724. IDC_BLINK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  725. IDC_GR_CURSOR, IDH_TERM_EMUSET_CURSOR,
  726. IDCANCEL, IDH_CANCEL,
  727. IDOK, IDH_OK,
  728. 0, 0};
  729. switch (wMsg)
  730. {
  731. case WM_INITDIALOG:
  732. pstEmuSettings = (PSTEMUSET)lPar;
  733. SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)pstEmuSettings);
  734. mscCenterWindowOnWindow(hDlg, GetParent(hDlg));
  735. /* -------------- Cursor characteristics ------------- */
  736. emudlgInitCursorSettings(hDlg, pstEmuSettings, IDC_UNDERLINE_CURSOR,
  737. IDC_BLOCK_CURSOR, IDC_BLINK_CURSOR);
  738. break;
  739. case WM_CONTEXTMENU:
  740. doContextHelp(aHlpTable, wPar, lPar, TRUE, TRUE);
  741. break;
  742. case WM_HELP:
  743. doContextHelp(aHlpTable, wPar, lPar, FALSE, FALSE);
  744. break;
  745. case WM_COMMAND:
  746. switch (wPar)
  747. {
  748. case IDOK:
  749. pstEmuSettings = (PSTEMUSET)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  750. /* -------------- Cursor type ------------- */
  751. pstEmuSettings->nCursorType =
  752. (int)(IsDlgButtonChecked(hDlg, IDC_BLOCK_CURSOR) == BST_CHECKED) ?
  753. EMU_CURSOR_BLOCK : EMU_CURSOR_LINE;
  754. /* -------------- Cursor Blink ------------- */
  755. pstEmuSettings->fCursorBlink =
  756. (int)(IsDlgButtonChecked(hDlg, IDC_BLINK_CURSOR) == BST_CHECKED);
  757. EndDialog(hDlg, TRUE);
  758. break;
  759. case IDCANCEL:
  760. EndDialog(hDlg, FALSE);
  761. break;
  762. default:
  763. return FALSE;
  764. }
  765. break;
  766. default:
  767. return FALSE;
  768. }
  769. return TRUE;
  770. }
  771. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  772. * FUNCTION:
  773. * emuViewdata_SettingsDlgProc
  774. *
  775. * DESCRIPTION:
  776. * TTY Settings dialog proc.
  777. *
  778. * ARGUMENTS:
  779. * Standard window proc parameters.
  780. *
  781. * RETURNS:
  782. * Standerd return value.
  783. *
  784. */
  785. INT_PTR CALLBACK emuViewdata_SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wPar, LPARAM lPar)
  786. {
  787. PSTEMUSET pstEmuSettings;
  788. static DWORD aHlpTable[] = {IDC_DESTRUCTIVE_BKSP, IDH_TERM_EMUSET_DESTRUCTIVE,
  789. IDC_BLOCK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  790. IDC_UNDERLINE_CURSOR, IDH_TERM_EMUSET_CURSOR,
  791. IDC_BLINK_CURSOR, IDH_TERM_EMUSET_CURSOR,
  792. IDC_GR_CURSOR, IDH_TERM_EMUSET_CURSOR,
  793. IDC_SEND_POUND_SYMBOL, IDH_TERM_SETTING_ENTER,
  794. IDC_HIDE_CURSOR, IDH_TERM_SETTING_HIDE_CURSOR,
  795. IDCANCEL, IDH_CANCEL,
  796. IDOK, IDH_OK,
  797. 0,0};
  798. switch (wMsg)
  799. {
  800. case WM_INITDIALOG:
  801. pstEmuSettings = (PSTEMUSET)lPar;
  802. SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)pstEmuSettings);
  803. mscCenterWindowOnWindow(hDlg, GetParent(hDlg));
  804. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  805. /* -------------- Screen rows and columns ------------- */
  806. emudlgInitRowsCols(hDlg, pstEmuSettings);
  807. #endif
  808. /* -------------- Hide cursor ------------- */
  809. SendDlgItemMessage(hDlg, IDC_HIDE_CURSOR, BM_SETCHECK,
  810. (pstEmuSettings->nCursorType == EMU_CURSOR_NONE) ? 1 : 0,
  811. 0);
  812. /* -------------- Enter key sends # ------------- */
  813. SendDlgItemMessage(hDlg, IDC_SEND_POUND_SYMBOL, BM_SETCHECK,
  814. (pstEmuSettings->fLbSymbolOnEnter == TRUE) ? 1 : 0, 0);
  815. break;
  816. case WM_CONTEXTMENU:
  817. doContextHelp(aHlpTable, wPar, lPar, TRUE, TRUE);
  818. break;
  819. case WM_HELP:
  820. doContextHelp(aHlpTable, wPar, lPar, FALSE, FALSE);
  821. break;
  822. case WM_COMMAND:
  823. switch (wPar)
  824. {
  825. case IDOK:
  826. pstEmuSettings = (PSTEMUSET)GetWindowLongPtr(hDlg, GWLP_USERDATA);
  827. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  828. /* -------------- Screen rows and columns ------------- */
  829. emudlgGetRowColSettings(hDlg, pstEmuSettings);
  830. #endif
  831. /* -------------- Hide cursor ------------- */
  832. pstEmuSettings->nCursorType =
  833. (int)(IsDlgButtonChecked(hDlg, IDC_HIDE_CURSOR) == BST_CHECKED) ?
  834. EMU_CURSOR_NONE : EMU_CURSOR_LINE;
  835. /* -------------- Enter key sends # ------------- */
  836. pstEmuSettings->fLbSymbolOnEnter =
  837. (int)(IsDlgButtonChecked(hDlg, IDC_SEND_POUND_SYMBOL) == BST_CHECKED);
  838. EndDialog(hDlg, TRUE);
  839. break;
  840. case IDCANCEL:
  841. EndDialog(hDlg, FALSE);
  842. break;
  843. default:
  844. return FALSE;
  845. }
  846. break;
  847. default:
  848. return FALSE;
  849. }
  850. return TRUE;
  851. }
  852. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  853. * FUNCTION:
  854. * emudlgInitCursorSettings
  855. *
  856. * DESCRIPTION:
  857. * Initialize cursor settings.
  858. *
  859. * ARGUMENTS:
  860. * hDlg - dialog window.
  861. * pstEmuSettings - pointer to the emulator settings structure.
  862. *
  863. * RETURNS:
  864. * void.
  865. *
  866. */
  867. STATIC_FUNC void emudlgInitCursorSettings(HWND hDlg,
  868. PSTEMUSET pstEmuSettings,
  869. INT ID_UNDERLINE,
  870. INT ID_BLOCK,
  871. INT ID_BLINK)
  872. {
  873. int i;
  874. switch (pstEmuSettings->nCursorType)
  875. {
  876. case EMU_CURSOR_LINE: i = ID_UNDERLINE; break;
  877. case EMU_CURSOR_BLOCK: i = ID_BLOCK; break;
  878. default: i = ID_UNDERLINE; break;
  879. }
  880. SendDlgItemMessage(hDlg, i, BM_SETCHECK, 1, 0);
  881. SendDlgItemMessage(hDlg, ID_BLINK, BM_SETCHECK,
  882. (unsigned int)pstEmuSettings->fCursorBlink, 0);
  883. if (IsTerminalServicesEnabled())
  884. {
  885. EnableWindow(GetDlgItem(hDlg, ID_BLINK), FALSE);
  886. }
  887. return;
  888. }
  889. #if DEADWOOD
  890. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  891. * FUNCTION:
  892. * emudlgInitCharSetSetting
  893. *
  894. * DESCRIPTION:
  895. * Initialize the character set setting.
  896. *
  897. * ARGUMENTS:
  898. * hDlg - dialog window.
  899. * pstEmuSettings - pointer to the emulator settings structure.
  900. *
  901. * RETURNS:
  902. * void.
  903. *
  904. * AUTHOR: Bob Everett - 3 Jun 98
  905. */
  906. STATIC_FUNC void emudlgInitCharSetSetting(HWND hDlg,
  907. PSTEMUSET pstEmuSettings,
  908. int nCharSetTableID,
  909. int nDefaultCharSetID)
  910. {
  911. BOOL fResult = TRUE;
  912. DWORD nLen;
  913. int nIndex;
  914. BYTE *pb, *pbSel;
  915. if (resLoadDataBlock(glblQueryDllHinst(), nCharSetTableID,
  916. (LPVOID *)&pb, &nLen))
  917. {
  918. assert(FALSE);
  919. }
  920. else
  921. {
  922. if (!emudlgFindCharSetName(hDlg, pb, pstEmuSettings->nCharacterSet,
  923. (LPTSTR *)&pbSel, TRUE))
  924. {
  925. // Couldn't find the current character set in the table of
  926. // characters sets. This happens when switching from one
  927. // terminal type to another that doesn't contain the char
  928. // set. Use the default character set.
  929. pstEmuSettings->nCharacterSet = nDefaultCharSetID;
  930. if (!emudlgFindCharSetName(hDlg, pb, pstEmuSettings->nCharacterSet,
  931. (LPTSTR *)&pbSel, FALSE))
  932. {
  933. // We've got problems.
  934. fResult = FALSE;
  935. assert(FALSE);
  936. }
  937. }
  938. if (fResult)
  939. {
  940. //JMH 01-09-97 Now select the string corresponding to
  941. // nCharacterSet.
  942. nIndex = (int)SendDlgItemMessage(hDlg, IDC_CHARACTER_SET,
  943. CB_SELECTSTRING, 0, (LPARAM)(LPTSTR)pbSel);
  944. assert(nIndex != CB_ERR);
  945. }
  946. }
  947. }
  948. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  949. * FUNCTION:
  950. * emudlgFindCharSetName
  951. *
  952. * DESCRIPTION:
  953. * Finds the appropriate character set settings.
  954. *
  955. * ARGUMENTS:
  956. * hDlg - dialog window handle
  957. * pbCharSetTable - address of the emu's table of character sets
  958. * pszCharSetName - address at which to put the char set name
  959. * fTellDlg - TRUE if the dialog should be made aware of the table
  960. *
  961. * RETURNS:
  962. * TRUE if successful, FALSE if not.
  963. *
  964. * AUTHOR: Bob Everett - 3 Jun 98
  965. */
  966. STATIC_FUNC BOOL emudlgFindCharSetName(HWND hDlg,
  967. BYTE *pbCharSetTable,
  968. int nCharSetID,
  969. LPTSTR *ppszCharSetName,
  970. BOOL fTellDlg)
  971. {
  972. BOOL fRetVal = FALSE;
  973. int nCnt, nLen, nEmuCount, nIndex, nCharSet;
  974. BYTE *pb = pbCharSetTable;
  975. nEmuCount = *(RCDATA_TYPE *)pb;
  976. pb += sizeof(RCDATA_TYPE);
  977. for (nCnt = 0 ; nCnt < nEmuCount; nCnt++)
  978. {
  979. nLen = StrCharGetByteCount((LPTSTR)pb) + (int)sizeof(BYTE);
  980. if (fTellDlg)
  981. {
  982. nIndex = (int)SendDlgItemMessage(hDlg, IDC_CHARACTER_SET, CB_ADDSTRING, 0,
  983. (LPARAM)(LPTSTR)pb);
  984. assert(nIndex != CB_ERR);
  985. }
  986. #if FALSE // DEADWOOD:rde 10 Mar 98
  987. //JMH 01-09-97 Because this list gets sorted, we have to store the
  988. // table index with each entry, or else the selection index we get
  989. // when OK is pressed won't mean much.
  990. //
  991. nIndex = SendDlgItemMessage(hDlg, IDC_CHARACTER_SET, CB_SETITEMDATA,
  992. (WPARAM) nIndex, (LPARAM) i);
  993. assert(nIndex != CB_ERR);
  994. #endif
  995. // Save the real char set id with the string. rde 10 Mar 98
  996. nCharSet = *((RCDATA_TYPE *)(pb + nLen));
  997. if (fTellDlg)
  998. {
  999. nIndex = (int)SendDlgItemMessage(hDlg, IDC_CHARACTER_SET, CB_SETITEMDATA,
  1000. (WPARAM)nIndex, (LPARAM)nCharSet);
  1001. assert(nIndex != CB_ERR);
  1002. }
  1003. // Must match the char set id to nCharacterSet, not the order in
  1004. // which they're listed in the resource data block. rde 10 Mar 98
  1005. //if (i == pstEmuSettings->nCharacterSet)
  1006. if (nCharSet == nCharSetID)
  1007. {
  1008. //JMH 01-09-97 Store a pointer to the string corresponding to
  1009. // nCharacterSet, so we can select the appropriate entry after
  1010. // they've all been sorted.
  1011. //
  1012. *ppszCharSetName = (LPTSTR)pb;
  1013. fRetVal = TRUE;
  1014. }
  1015. pb += (nLen + (int)sizeof(RCDATA_TYPE));
  1016. }
  1017. return fRetVal;
  1018. }
  1019. #endif // DEADWOOD
  1020. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  1021. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1022. * FUNCTION:
  1023. * emudlgInitRowsCols
  1024. *
  1025. * DESCRIPTION:
  1026. * Sets up the row and column fields.
  1027. *
  1028. * ARGUMENTS:
  1029. * hDlg - edit control window.
  1030. * pstEmuSettings - address of emulator settings structure.
  1031. *
  1032. * RETURNS:
  1033. * void.
  1034. *
  1035. * AUTHOR: Bob Everett - 22 Jun 1998
  1036. */
  1037. STATIC_FUNC void emudlgInitRowsCols(HWND hDlg, PSTEMUSET pstEmuSettings)
  1038. {
  1039. TCHAR achString[20];
  1040. TCHAR achFormat[20];
  1041. //
  1042. // Since the number of columns can only be numeric and has a size
  1043. // between MIN_EMUROWS(10) and MAX_EMUROWS(50), limit to 2 characters.
  1044. //
  1045. SendDlgItemMessage(hDlg, IDC_NUMBER_OF_ROWS, EM_LIMITTEXT, 2, FALSE);
  1046. LoadString(glblQueryDllHinst(), IDS_XD_INT, achFormat,
  1047. sizeof(achFormat) / sizeof(TCHAR));
  1048. TCHAR_Fill(achString, TEXT('\0'), sizeof(achString) / sizeof(TCHAR));
  1049. wsprintf(achString, achFormat, pstEmuSettings->nUserDefRows);
  1050. SendDlgItemMessage(hDlg, IDC_NUMBER_OF_ROWS, WM_SETTEXT, 0,
  1051. (LPARAM)(LPTSTR)achString);
  1052. //
  1053. // Since the number of columns can only be numeric and has a size
  1054. // between MIN_EMUCOLS(20) and MAX_EMUCOLS(132), limit to 3 characters.
  1055. //
  1056. SendDlgItemMessage(hDlg, IDC_NUMBER_OF_COLS, EM_LIMITTEXT, 3, FALSE);
  1057. LoadString(glblQueryDllHinst(), IDS_XD_INT, achFormat,
  1058. sizeof(achFormat) / sizeof(TCHAR));
  1059. TCHAR_Fill(achString, TEXT('\0'), sizeof(achString) / sizeof(TCHAR));
  1060. wsprintf(achString, achFormat, pstEmuSettings->nUserDefCols);
  1061. SendDlgItemMessage(hDlg, IDC_NUMBER_OF_COLS, WM_SETTEXT, 0,
  1062. (LPARAM)(LPTSTR)achString);
  1063. // Put the spin buttons on the row and column fields.
  1064. emudlgCreateUpDownControl(hDlg, pstEmuSettings);
  1065. }
  1066. #endif
  1067. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  1068. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1069. * FUNCTION:
  1070. * emudlgCreateUpDownControl
  1071. *
  1072. * DESCRIPTION:
  1073. * Gets the final row and column settings.
  1074. *
  1075. * ARGUMENTS:
  1076. * hDlg - edit control window.
  1077. * pstEmuSettings - address of emulator settings structure.
  1078. *
  1079. * RETURNS:
  1080. * void.
  1081. *
  1082. * AUTHOR: Bob Everett - 22 Jun 1998
  1083. */
  1084. STATIC_FUNC void emudlgGetRowColSettings(HWND hDlg, PSTEMUSET pstEmuSettings)
  1085. {
  1086. pstEmuSettings->nUserDefRows = emudlgValidateEntryFieldSetting(hDlg,
  1087. IDC_NUMBER_OF_ROWS, MIN_EMUROWS, MAX_EMUROWS);
  1088. pstEmuSettings->nUserDefCols = emudlgValidateEntryFieldSetting(hDlg,
  1089. IDC_NUMBER_OF_COLS, MIN_EMUCOLS, MAX_EMUCOLS);
  1090. pstEmuSettings->f132Columns =
  1091. (pstEmuSettings->nUserDefCols == 132 ? TRUE : FALSE);
  1092. }
  1093. #endif
  1094. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  1095. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1096. * FUNCTION:
  1097. * emudlgCreateUpDownControl
  1098. *
  1099. * DESCRIPTION:
  1100. * This function puts an up-down control on the edit field for the row and
  1101. * column fields. This gives us bounds checking for free... just set the
  1102. * appropriate parameters in the CreateUpDownControl call.
  1103. *
  1104. * NOTE: This is a duplicate of CreateUpDownControl
  1105. *
  1106. * ARGUMENTS:
  1107. * hDlg - edit control window.
  1108. *
  1109. * RETURNS:
  1110. * void.
  1111. *
  1112. * AUTHOR: Bob Everett - 8 Jun 1998
  1113. */
  1114. STATIC_FUNC void emudlgCreateUpDownControl(HWND hDlg, PSTEMUSET pstEmuSettings)
  1115. {
  1116. RECT rc;
  1117. int nHeight, nWidth;
  1118. DWORD dwFlags;
  1119. HWND hwndChild;
  1120. // Draw a spin control for the rows field.
  1121. GetClientRect(GetDlgItem(hDlg, IDC_NUMBER_OF_ROWS), &rc);
  1122. nHeight = rc.top - rc.bottom;
  1123. nWidth = (nHeight / 3) * 2;
  1124. dwFlags = WS_CHILD | WS_VISIBLE |
  1125. UDS_ALIGNRIGHT | UDS_ARROWKEYS | UDS_SETBUDDYINT;
  1126. hwndChild = CreateUpDownControl(
  1127. dwFlags, // create window flags
  1128. rc.right, // left edge
  1129. rc.top, // top edge
  1130. nWidth, // width
  1131. nHeight, // height
  1132. hDlg, // parent window
  1133. IDC_EDIT_ROWS,
  1134. (HINSTANCE)GetWindowLongPtr(hDlg, GWLP_HINSTANCE),
  1135. GetDlgItem(hDlg, IDC_NUMBER_OF_ROWS),
  1136. MAX_EMUROWS,
  1137. MIN_EMUROWS,
  1138. pstEmuSettings->nUserDefRows);
  1139. // Repeat for the columns field.
  1140. GetClientRect(GetDlgItem(hDlg, IDC_NUMBER_OF_COLS), &rc);
  1141. nHeight = rc.top - rc.bottom;
  1142. nWidth = (nHeight / 3) * 2;
  1143. hwndChild = CreateUpDownControl(
  1144. dwFlags, // create window flags
  1145. rc.right, // left edge
  1146. rc.top, // top edge
  1147. nWidth, // width
  1148. nHeight, // height
  1149. hDlg, // parent window
  1150. IDC_EDIT_COLUMNS,
  1151. (HINSTANCE)GetWindowLongPtr(hDlg, GWLP_HINSTANCE),
  1152. GetDlgItem(hDlg, IDC_NUMBER_OF_COLS),
  1153. MAX_EMUCOLS,
  1154. MIN_EMUCOLS,
  1155. pstEmuSettings->nUserDefCols);
  1156. assert(hwndChild);
  1157. }
  1158. #endif
  1159. #if defined(INCL_TERMINAL_SIZE_AND_COLORS)
  1160. /*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  1161. * FUNCTION:
  1162. * emudlgValidateEntryFieldSetting
  1163. *
  1164. * DESCRIPTION:
  1165. * If the user entered a value outside of the range we support force the
  1166. * value into the range.
  1167. *
  1168. * Note: copied from propValidateBackscrlSize.
  1169. *
  1170. * ARGUMENTS:
  1171. * hDlg - dialog window handle.
  1172. *
  1173. * RETURNS:
  1174. * nNewValue - number of lines to keep in the backscrol buffer.
  1175. *
  1176. * AUTHOR: Bob Everett - 8 Jun 1998
  1177. */
  1178. STATIC_FUNC int emudlgValidateEntryFieldSetting(HWND hDlg,
  1179. int nIDC,
  1180. int nMinVal,
  1181. int nMaxVal)
  1182. {
  1183. int nValue = 0, nNewValue = 0;
  1184. TCHAR achStrEntered[20], achFormat[20];
  1185. TCHAR_Fill(achStrEntered, TEXT('\0'),
  1186. sizeof(achStrEntered) / sizeof(TCHAR));
  1187. GetDlgItemText(hDlg, nIDC, achStrEntered,
  1188. sizeof(achStrEntered) / sizeof(TCHAR));
  1189. nNewValue = nValue = atoi(achStrEntered);
  1190. if (nValue > nMaxVal)
  1191. nNewValue = nMaxVal;
  1192. else if (nValue < nMinVal)
  1193. nNewValue = nMinVal;
  1194. if (nNewValue != nValue)
  1195. {
  1196. LoadString(glblQueryDllHinst(),
  1197. IDS_XD_INT,
  1198. achFormat,
  1199. sizeof(achFormat) / sizeof(TCHAR));
  1200. TCHAR_Fill(achStrEntered,
  1201. TEXT('\0'),
  1202. sizeof(achStrEntered) / sizeof(TCHAR));
  1203. wsprintf(achStrEntered, achFormat, nNewValue);
  1204. SendDlgItemMessage(hDlg,
  1205. nIDC,
  1206. WM_SETTEXT,
  1207. 0,
  1208. (LPARAM)(LPTSTR)achStrEntered);
  1209. }
  1210. return (nNewValue);
  1211. }
  1212. #endif