16 #define TVINSERTSTRUCT TV_INSERTSTRUCT
17 #define TVITEM TV_ITEM
21 static char **events = NULL;
22 static int nevents = 0, negsize = 0;
25 static int sesslist_has_focus;
26 static int requested_help;
28 static struct prefslist cipherlist;
30 void force_normal(HWND hwnd)
32 static int recurse = 0;
40 wp.length = sizeof(wp);
41 if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) {
42 wp.showCmd = SW_SHOWNORMAL;
43 SetWindowPlacement(hwnd, &wp);
48 static void MyGetDlgItemInt(HWND hwnd, int id, int *result)
52 n = GetDlgItemInt(hwnd, id, &ok, FALSE);
57 static void MyGetDlgItemFlt(HWND hwnd, int id, int *result, int scale)
61 ok = GetDlgItemText(hwnd, id, text, sizeof(text) - 1);
63 *result = (int) (scale * atof(text));
66 static void MySetDlgItemFlt(HWND hwnd, int id, double value)
69 sprintf(text, "%g", value);
70 SetDlgItemText(hwnd, id, text);
73 static int CALLBACK LogProc(HWND hwnd, UINT msg,
74 WPARAM wParam, LPARAM lParam)
81 static int tabs[4] = { 78, 108 };
82 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
85 for (i = 0; i < nevents; i++)
86 SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
87 0, (LPARAM) events[i]);
90 switch (LOWORD(wParam)) {
94 SetActiveWindow(GetParent(hwnd));
98 if (HIWORD(wParam) == BN_CLICKED ||
99 HIWORD(wParam) == BN_DOUBLECLICKED) {
102 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
103 LB_GETSELCOUNT, 0, 0);
104 if (selcount == 0) { /* don't even try to copy zero items */
109 selitems = smalloc(selcount * sizeof(int));
111 int count = SendDlgItemMessage(hwnd, IDN_LIST,
118 static unsigned char sel_nl[] = SEL_NL;
120 if (count == 0) { /* can't copy zero stuff */
126 for (i = 0; i < count; i++)
128 strlen(events[selitems[i]]) + sizeof(sel_nl);
130 clipdata = smalloc(size);
133 for (i = 0; i < count; i++) {
134 char *q = events[selitems[i]];
135 int qlen = strlen(q);
138 memcpy(p, sel_nl, sizeof(sel_nl));
141 write_aclip(clipdata, size, TRUE);
146 for (i = 0; i < nevents; i++)
147 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
156 SetActiveWindow(GetParent(hwnd));
163 static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
164 WPARAM wParam, LPARAM lParam)
170 switch (LOWORD(wParam)) {
183 static int CALLBACK AboutProc(HWND hwnd, UINT msg,
184 WPARAM wParam, LPARAM lParam)
188 SetDlgItemText(hwnd, IDA_VERSION, ver);
191 switch (LOWORD(wParam)) {
194 EndDialog(hwnd, TRUE);
197 EnableWindow(hwnd, 0);
198 DialogBox(hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
200 EnableWindow(hwnd, 1);
201 SetActiveWindow(hwnd);
205 /* Load web browser */
206 ShellExecute(hwnd, "open",
207 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
208 0, 0, SW_SHOWDEFAULT);
213 EndDialog(hwnd, TRUE);
220 * Null dialog procedure.
222 static int CALLBACK NullDlgProc(HWND hwnd, UINT msg,
223 WPARAM wParam, LPARAM lParam)
228 static char savedsession[2048];
231 IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
381 IDC_SCROLLBARFULLSCREEN,
396 IDC_FULLSCREENONALTENTER,
399 appearancepanelstart,
400 IDC_TITLE_APPEARANCE,
422 connectionpanelstart,
423 IDC_TITLE_CONNECTION,
542 translationpanelstart,
543 IDC_TITLE_TRANSLATION,
544 IDC_BOX_TRANSLATION1,
545 IDC_BOX_TRANSLATION2,
546 IDC_BOX_TRANSLATION3,
584 static const char *const colours[] = {
585 "Default Foreground", "Default Bold Foreground",
586 "Default Background", "Default Bold Background",
587 "Cursor Text", "Cursor Colour",
588 "ANSI Black", "ANSI Black Bold",
589 "ANSI Red", "ANSI Red Bold",
590 "ANSI Green", "ANSI Green Bold",
591 "ANSI Yellow", "ANSI Yellow Bold",
592 "ANSI Blue", "ANSI Blue Bold",
593 "ANSI Magenta", "ANSI Magenta Bold",
594 "ANSI Cyan", "ANSI Cyan Bold",
595 "ANSI White", "ANSI White Bold"
597 static const int permcolour[] = {
598 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
599 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
600 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
603 static void fmtfont(char *buf)
605 sprintf(buf, "Font: %s, ", cfg.font);
607 strcat(buf, "bold, ");
608 if (cfg.fontheight == 0)
609 strcat(buf, "default height");
611 sprintf(buf + strlen(buf), "%d-point",
612 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
615 char *help_context_cmd(int id)
627 return "JI(`',`session.hostname')";
634 return "JI(`',`session.saved')";
639 return "JI(`',`session.coe')";
640 case IDC_LSTATSTATIC:
644 case IDC_LSTATPACKET:
645 return "JI(`',`logging.main')";
650 return "JI(`',`logging.filename')";
655 return "JI(`',`logging.exists')";
660 return "JI(`',`keyboard.backspace')";
664 return "JI(`',`keyboard.homeend')";
672 return "JI(`',`keyboard.funkeys')";
676 return "JI(`',`keyboard.appkeypad')";
680 return "JI(`',`keyboard.appcursor')";
682 return "JI(`',`keyboard.nethack')";
684 return "JI(`',`keyboard.compose')";
685 case IDC_CTRLALTKEYS:
686 return "JI(`',`keyboard.ctrlalt')";
690 return "JI(`',`features.application')";
692 return "JI(`',`features.mouse')";
694 return "JI(`',`features.resize')";
695 case IDC_NOALTSCREEN:
696 return "JI(`',`features.altscreen')";
698 return "JI(`',`features.retitle')";
699 case IDC_NODBACKSPACE:
700 return "JI(`',`features.dbackspace')";
702 return "JI(`',`features.charset')";
705 return "JI(`',`terminal.autowrap')";
707 return "JI(`',`terminal.decom')";
709 return "JI(`',`terminal.lfhascr')";
711 return "JI(`',`terminal.bce')";
713 return "JI(`',`terminal.blink')";
716 return "JI(`',`terminal.answerback')";
718 case IDC_ECHOBACKEND:
721 return "JI(`',`terminal.localecho')";
723 case IDC_EDITBACKEND:
726 return "JI(`',`terminal.localedit')";
729 case IDC_BELL_DISABLED:
730 case IDC_BELL_DEFAULT:
731 case IDC_BELL_WAVEFILE:
732 case IDC_BELL_VISUAL:
733 case IDC_BELL_WAVESTATIC:
734 case IDC_BELL_WAVEEDIT:
735 case IDC_BELL_WAVEBROWSE:
736 return "JI(`',`bell.style')";
737 case IDC_B_IND_STATIC:
738 case IDC_B_IND_DISABLED:
739 case IDC_B_IND_FLASH:
740 case IDC_B_IND_STEADY:
741 return "JI(`',`bell.taskbar')";
743 case IDC_BELLOVLNSTATIC:
745 case IDC_BELLOVLTSTATIC:
747 case IDC_BELLOVLEXPLAIN:
748 case IDC_BELLOVLSSTATIC:
750 return "JI(`',`bell.overload')";
756 return "JI(`',`window.size')";
757 case IDC_RESIZESTATIC:
761 case IDC_RESIZEEITHER:
762 return "JI(`',`window.resize')";
764 case IDC_SCROLLBARFULLSCREEN:
769 return "JI(`',`window.scrollback')";
772 return "JI(`',`behaviour.closewarn')";
774 return "JI(`',`behaviour.altf4')";
776 return "JI(`',`behaviour.altspace')";
778 return "JI(`',`behaviour.altonly')";
779 case IDC_ALWAYSONTOP:
780 return "JI(`',`behaviour.alwaysontop')";
781 case IDC_FULLSCREENONALTENTER:
782 return "JI(`',`behaviour.altenter')";
784 case IDC_CURSORSTATIC:
789 return "JI(`',`appearance.cursor')";
792 return "JI(`',`appearance.font')";
796 return "JI(`',`appearance.title')";
798 return "JI(`',`appearance.hidemouse')";
802 return "JI(`',`appearance.border')";
806 return "JI(`',`connection.termtype')";
809 return "JI(`',`connection.username')";
812 return "JI(`',`connection.keepalive')";
814 return "JI(`',`connection.nodelay')";
818 return "JI(`',`telnet.termspeed')";
827 return "JI(`',`telnet.environ')";
831 return "JI(`',`telnet.oldenviron')";
835 return "JI(`',`telnet.passive')";
837 return "JI(`',`telnet.specialkeys')";
839 return "JI(`',`telnet.newline')";
843 return "JI(`',`rlogin.termspeed')";
844 case IDC_RLLUSERSTATIC:
845 case IDC_RLLUSEREDIT:
846 return "JI(`',`rlogin.localuser')";
849 return "JI(`',`ssh.nopty')";
850 case IDC_CIPHERSTATIC2:
855 return "JI(`',`ssh.ciphers')";
857 return "JI(`',`ssh.buggymac')";
858 case IDC_SSHPROTSTATIC:
861 return "JI(`',`ssh.protocol')";
864 return "JI(`',`ssh.command')";
866 return "JI(`',`ssh.compress')";
871 return "JI(`',`ssh.auth.privkey')";
873 return "JI(`',`ssh.auth.agentfwd')";
875 return "JI(`',`ssh.auth.changeuser')";
877 return "JI(`',`ssh.auth.tis')";
879 return "JI(`',`ssh.auth.ki')";
884 return "JI(`',`selection.buttons')";
885 case IDC_MOUSEOVERRIDE:
886 return "JI(`',`selection.shiftdrag')";
887 case IDC_SELTYPESTATIC:
889 case IDC_SELTYPERECT:
890 return "JI(`',`selection.rect')";
896 return "JI(`',`selection.charclasses')";
898 return "JI(`',`selection.linedraw')";
900 return "JI(`',`selection.rtf')";
903 return "JI(`',`colours.bold')";
905 return "JI(`',`colours.logpal')";
906 case IDC_COLOURSTATIC:
915 return "JI(`',`colours.config')";
917 case IDC_CODEPAGESTATIC:
919 return "JI(`',`translation.codepage')";
920 case IDC_CAPSLOCKCYR:
921 return "JI(`',`translation.cyrillic')";
928 return "JI(`',`translation.linedraw')";
930 case IDC_X11_FORWARD:
931 case IDC_X11_DISPSTATIC:
932 case IDC_X11_DISPLAY:
933 return "JI(`',`ssh.tunnels.x11')";
935 case IDC_PFWDSTATIC2:
939 case IDC_SPORTSTATIC:
941 case IDC_DPORTSTATIC:
945 return "JI(`',`ssh.tunnels.portfwd')";
948 return "JI(`',`ssh.tunnels.portfwd.localhost')";
955 /* 2nd arg: NZ => don't redraw session list (use when loading
957 static void init_dlg_ctrls(HWND hwnd, int keepsess)
960 char fontstatic[256];
962 SetDlgItemText(hwnd, IDC_HOST, cfg.host);
963 SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
966 n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
967 for (i = n; i-- > 0;)
968 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_DELETESTRING, i, 0);
969 for (i = 0; i < nsessions; i++)
970 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_ADDSTRING,
971 0, (LPARAM) (sessions[i]));
973 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
974 CheckRadioButton(hwnd, IDC_PROTRAW, IDC_PROTSSH,
975 cfg.protocol == PROT_SSH ? IDC_PROTSSH :
976 cfg.protocol == PROT_TELNET ? IDC_PROTTELNET :
978 PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW);
979 SetDlgItemInt(hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
980 CheckDlgButton(hwnd, IDC_NODELAY, cfg.tcp_nodelay);
982 CheckRadioButton(hwnd, IDC_DEL008, IDC_DEL127,
983 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
984 CheckRadioButton(hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
985 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
986 CheckRadioButton(hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
987 cfg.funky_type == 0 ? IDC_FUNCTILDE :
988 cfg.funky_type == 1 ? IDC_FUNCLINUX :
989 cfg.funky_type == 2 ? IDC_FUNCXTERM :
990 cfg.funky_type == 3 ? IDC_FUNCVT400 :
991 cfg.funky_type == 4 ? IDC_FUNCVT100P :
992 cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE);
993 CheckDlgButton(hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
994 CheckDlgButton(hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
995 CheckDlgButton(hwnd, IDC_NOMOUSEREP, cfg.no_mouse_rep);
996 CheckDlgButton(hwnd, IDC_NORESIZE, cfg.no_remote_resize);
997 CheckDlgButton(hwnd, IDC_NOALTSCREEN, cfg.no_alt_screen);
998 CheckDlgButton(hwnd, IDC_NOWINTITLE, cfg.no_remote_wintitle);
999 CheckDlgButton(hwnd, IDC_NODBACKSPACE, cfg.no_dbackspace);
1000 CheckDlgButton(hwnd, IDC_NOCHARSET, cfg.no_remote_charset);
1001 CheckRadioButton(hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
1002 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
1003 CheckRadioButton(hwnd, IDC_KPNORMAL, IDC_KPNH,
1004 cfg.nethack_keypad ? IDC_KPNH :
1005 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
1006 CheckDlgButton(hwnd, IDC_ALTF4, cfg.alt_f4);
1007 CheckDlgButton(hwnd, IDC_ALTSPACE, cfg.alt_space);
1008 CheckDlgButton(hwnd, IDC_ALTONLY, cfg.alt_only);
1009 CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
1010 CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
1011 CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
1012 CheckDlgButton(hwnd, IDC_TELNETRET, cfg.telnet_newline);
1013 CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
1014 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
1015 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
1016 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
1017 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND :
1018 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
1019 SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
1020 CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
1021 CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
1022 CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
1023 CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
1025 CheckDlgButton(hwnd, IDC_WRAPMODE, cfg.wrap_mode);
1026 CheckDlgButton(hwnd, IDC_DECOM, cfg.dec_om);
1027 CheckDlgButton(hwnd, IDC_LFHASCR, cfg.lfhascr);
1028 SetDlgItemInt(hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
1029 SetDlgItemInt(hwnd, IDC_COLSEDIT, cfg.width, FALSE);
1030 SetDlgItemInt(hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
1031 fmtfont(fontstatic);
1032 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
1033 CheckRadioButton(hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
1034 cfg.beep == BELL_DISABLED ? IDC_BELL_DISABLED :
1035 cfg.beep == BELL_DEFAULT ? IDC_BELL_DEFAULT :
1036 cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
1038 BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
1039 CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
1041 B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
1042 B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
1043 B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
1044 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
1045 CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
1046 SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
1047 MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
1048 MySetDlgItemFlt(hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
1050 CheckDlgButton(hwnd, IDC_BCE, cfg.bce);
1051 CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
1053 SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
1054 CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
1055 CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
1056 CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
1057 SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
1058 CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
1059 cfg.cursor_type == 0 ? IDC_CURBLOCK :
1060 cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
1061 CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
1062 CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
1063 CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
1064 CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZEEITHER,
1065 cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
1066 cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
1067 cfg.resize_action == RESIZE_EITHER ? IDC_RESIZEEITHER :
1069 CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
1070 cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
1071 cfg.close_on_exit ==
1072 COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
1073 CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
1075 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1076 SetDlgItemText(hwnd, IDC_TSEDIT, cfg.termspeed);
1077 SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
1078 SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
1079 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1080 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
1081 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATPACKET,
1082 cfg.logtype == LGTYP_NONE ? IDC_LSTATOFF :
1083 cfg.logtype == LGTYP_ASCII ? IDC_LSTATASCII :
1084 cfg.logtype == LGTYP_DEBUG ? IDC_LSTATRAW :
1086 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
1087 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
1088 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
1091 char *p = cfg.environmt;
1092 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
1094 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
1100 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0,
1105 CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC,
1106 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
1107 CheckRadioButton(hwnd, IDC_TPASSIVE, IDC_TACTIVE,
1108 cfg.passive_telnet ? IDC_TPASSIVE : IDC_TACTIVE);
1110 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1111 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1112 CheckDlgButton(hwnd, IDC_NOPTY, cfg.nopty);
1113 CheckDlgButton(hwnd, IDC_COMPRESS, cfg.compression);
1114 CheckDlgButton(hwnd, IDC_BUGGYMAC, cfg.buggymac);
1115 CheckDlgButton(hwnd, IDC_SSH2DES, cfg.ssh2_des_cbc);
1116 CheckDlgButton(hwnd, IDC_AGENTFWD, cfg.agentfwd);
1117 CheckDlgButton(hwnd, IDC_CHANGEUSER, cfg.change_username);
1118 CheckRadioButton(hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
1119 cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
1120 CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
1121 CheckDlgButton(hwnd, IDC_AUTHKI, cfg.try_ki_auth);
1122 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
1123 SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
1127 static const struct { char *s; int c; } ciphers[] = {
1128 { "3DES", CIPHER_3DES },
1129 { "Blowfish", CIPHER_BLOWFISH },
1130 { "DES", CIPHER_DES },
1131 { "AES (SSH 2 only)", CIPHER_AES },
1132 { "-- warn below here --", CIPHER_WARN }
1135 /* Set up the "selected ciphers" box. */
1136 /* (cipherlist assumed to contain all ciphers) */
1137 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_RESETCONTENT, 0, 0);
1138 for (i = 0; i < CIPHER_MAX; i++) {
1139 int c = cfg.ssh_cipherlist[i];
1142 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
1143 if (ciphers[j].c == c) {
1144 cstr = ciphers[j].s;
1148 pos = SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_ADDSTRING,
1150 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_SETITEMDATA,
1156 CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
1157 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
1158 CheckRadioButton(hwnd, IDC_SELTYPELEX, IDC_SELTYPERECT,
1159 cfg.rect_select == 0 ? IDC_SELTYPELEX : IDC_SELTYPERECT);
1160 CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
1161 CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
1162 CheckDlgButton(hwnd, IDC_RTFPASTE, cfg.rtf_paste);
1164 static int tabs[4] = { 25, 61, 96, 128 };
1165 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
1168 for (i = 0; i < 128; i++) {
1170 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
1171 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg.wordness[i]);
1172 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
1176 CheckDlgButton(hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
1177 CheckDlgButton(hwnd, IDC_PALETTE, cfg.try_palette);
1180 n = SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
1181 for (i = n; i-- > 0;)
1182 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
1183 LB_DELETESTRING, i, 0);
1184 for (i = 0; i < 22; i++)
1185 if (cfg.bold_colour || permcolour[i])
1186 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
1187 (LPARAM) colours[i]);
1189 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
1190 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
1191 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
1192 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
1197 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
1198 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
1199 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
1200 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
1201 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
1204 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
1207 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
1208 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
1209 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
1210 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
1211 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
1214 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
1215 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
1217 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
1218 CheckDlgButton(hwnd, IDC_RPORT_ALL, cfg.rport_acceptall);
1219 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
1222 struct treeview_faff {
1224 HTREEITEM lastat[4];
1227 static HTREEITEM treeview_insert(struct treeview_faff *faff,
1228 int level, char *text)
1233 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
1234 ins.hInsertAfter = faff->lastat[level];
1235 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1236 #define INSITEM DUMMYUNIONNAME.item
1238 #define INSITEM item
1240 ins.INSITEM.mask = TVIF_TEXT;
1241 ins.INSITEM.pszText = text;
1242 newitem = TreeView_InsertItem(faff->treeview, &ins);
1244 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
1246 faff->lastat[level] = newitem;
1247 for (i = level + 1; i < 4; i++)
1248 faff->lastat[i] = NULL;
1253 * Create the panelfuls of controls in the configuration box.
1255 static void create_controls(HWND hwnd, int dlgtype, int panel)
1257 if (panel == sessionpanelstart) {
1258 /* The Session panel. Accelerators used: [acgoh] nprtis elvd w */
1260 ctlposinit(&cp, hwnd, 80, 3, 13);
1261 bartitle(&cp, "Basic options for your PuTTY session",
1264 beginbox(&cp, "Specify your connection by host name or IP address",
1267 "Host &Name (or IP address)",
1268 IDC_HOSTSTATIC, IDC_HOST, 75,
1269 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
1270 if (backends[3].backend == NULL) {
1271 /* this is PuTTYtel, so only three protocols available */
1272 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
1273 "&Raw", IDC_PROTRAW,
1274 "&Telnet", IDC_PROTTELNET,
1275 "Rlog&in", IDC_PROTRLOGIN, NULL);
1277 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
1278 "&Raw", IDC_PROTRAW,
1279 "&Telnet", IDC_PROTTELNET,
1280 "Rlog&in", IDC_PROTRLOGIN,
1289 beginbox(&cp, "Load, save or delete a stored session",
1291 sesssaver(&cp, "Sav&ed Sessions",
1292 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
1293 "&Load", IDC_SESSLOAD,
1294 "Sa&ve", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
1297 beginbox(&cp, NULL, IDC_BOX_SESSION3);
1298 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
1299 "Always", IDC_COEALWAYS,
1300 "Never", IDC_COENEVER,
1301 "Only on clean exit", IDC_COENORMAL, NULL);
1305 if (panel == loggingpanelstart) {
1306 /* The Logging panel. Accelerators used: [acgoh] tplsfwe */
1308 ctlposinit(&cp, hwnd, 80, 3, 13);
1309 bartitle(&cp, "Options controlling session logging",
1311 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
1313 "Session logging:", IDC_LSTATSTATIC,
1314 "Logging &turned off completely", IDC_LSTATOFF,
1315 "Log &printable output only", IDC_LSTATASCII,
1316 "&Log all session output", IDC_LSTATRAW,
1317 "Log &SSH packet data", IDC_LSTATPACKET,
1319 editbutton(&cp, "Log &file name:",
1320 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
1322 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
1323 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
1325 "What to do if the log file already &exists:",
1326 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
1327 "Always append to the end of it", IDC_LSTATXAPN,
1328 "Ask the user every time", IDC_LSTATXASK, NULL);
1332 if (panel == terminalpanelstart) {
1333 /* The Terminal panel. Accelerators used: [acgoh] wdren lts */
1335 ctlposinit(&cp, hwnd, 80, 3, 13);
1336 bartitle(&cp, "Options controlling the terminal emulation",
1337 IDC_TITLE_TERMINAL);
1338 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
1339 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
1340 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
1341 checkbox(&cp, "Implicit C&R in every LF", IDC_LFHASCR);
1342 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
1343 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
1345 "An&swerback to ^E:", IDC_ANSWERBACK,
1346 IDC_ANSWEREDIT, 100, NULL);
1349 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
1350 radioline(&cp, "&Local echo:", IDC_ECHOSTATIC, 3,
1351 "Auto", IDC_ECHOBACKEND,
1352 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
1353 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
1354 "Auto", IDC_EDITBACKEND,
1355 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
1359 if (panel == featurespanelstart) {
1360 /* The Features panel. Accelerators used: [acgoh] ukswtbrx */
1362 ctlposinit(&cp, hwnd, 80, 3, 13);
1363 bartitle(&cp, "Enabling and disabling advanced terminal features ",
1364 IDC_TITLE_FEATURES);
1365 beginbox(&cp, NULL, IDC_BOX_FEATURES1);
1366 checkbox(&cp, "Disable application c&ursor keys mode", IDC_NOAPPLICC);
1367 checkbox(&cp, "Disable application &keypad mode", IDC_NOAPPLICK);
1368 checkbox(&cp, "Disable &xterm-style mouse reporting", IDC_NOMOUSEREP);
1369 checkbox(&cp, "Disable remote-controlled terminal re&sizing",
1371 checkbox(&cp, "Disable s&witching to alternate terminal screen",
1373 checkbox(&cp, "Disable remote-controlled window &title changing",
1375 checkbox(&cp, "Disable destructive &backspace on server sending ^?",
1377 checkbox(&cp, "Disable remote-controlled cha&racter set configuration",
1382 if (panel == bellpanelstart) {
1383 /* The Bell panel. Accelerators used: [acgoh] bdsm wit */
1385 ctlposinit(&cp, hwnd, 80, 3, 13);
1386 bartitle(&cp, "Options controlling the terminal bell",
1388 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
1390 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
1391 "None (bell disabled)", IDC_BELL_DISABLED,
1392 "Play Windows Default Sound", IDC_BELL_DEFAULT,
1393 "Play a custom sound file", IDC_BELL_WAVEFILE,
1394 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
1395 editbutton(&cp, "Custom sound file to play as a bell:",
1396 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
1397 "Bro&wse...", IDC_BELL_WAVEBROWSE);
1398 radioline(&cp, "Taskbar/caption &indication on bell:",
1399 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
1400 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
1403 beginbox(&cp, "Control the bell overload behaviour",
1405 checkbox(&cp, "Bell is temporarily &disabled when over-used",
1407 staticedit(&cp, "Over-use means this &many bells...",
1408 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
1409 staticedit(&cp, "... in &this many seconds",
1410 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
1412 "The bell is re-enabled after a few seconds of silence.",
1413 1, IDC_BELLOVLEXPLAIN);
1414 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1419 if (panel == keyboardpanelstart) {
1420 /* The Keyboard panel. Accelerators used: [acgoh] bef rntd */
1422 ctlposinit(&cp, hwnd, 80, 3, 13);
1423 bartitle(&cp, "Options controlling the effects of keys",
1424 IDC_TITLE_KEYBOARD);
1425 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1426 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1427 "Control-H", IDC_DEL008,
1428 "Control-? (127)", IDC_DEL127, NULL);
1429 radioline(&cp, "The Home and &End keys", IDC_HOMESTATIC, 2,
1430 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1431 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1432 "ESC[n~", IDC_FUNCTILDE,
1433 "Linux", IDC_FUNCLINUX,
1434 "Xterm R6", IDC_FUNCXTERM,
1435 "VT400", IDC_FUNCVT400,
1436 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1438 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1439 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1440 "Normal", IDC_CURNORMAL,
1441 "Application", IDC_CURAPPLIC, NULL);
1442 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1443 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1444 "NetHack", IDC_KPNH, NULL);
1446 beginbox(&cp, "Enable extra keyboard features:",
1448 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1449 checkbox(&cp, "Control-Alt is &different from AltGr",
1454 if (panel == windowpanelstart) {
1455 /* The Window panel. Accelerators used: [acgoh] rmz sdikp */
1457 ctlposinit(&cp, hwnd, 80, 3, 13);
1458 bartitle(&cp, "Options controlling PuTTY's window",
1460 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1462 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1463 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
1464 radiobig(&cp, "When window is resi&zed:", IDC_RESIZESTATIC,
1465 "Change the number of rows and columns", IDC_RESIZETERM,
1466 "Change the size of the font", IDC_RESIZEFONT,
1467 "Change font size only when maximised", IDC_RESIZEEITHER,
1468 "Forbid resizing completely", IDC_RESIZENONE, NULL);
1470 beginbox(&cp, "Control the scrollback in the window",
1472 staticedit(&cp, "Lines of &scrollback",
1473 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1474 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
1475 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
1476 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1477 checkbox(&cp, "Reset scrollback on dis&play activity",
1482 if (panel == appearancepanelstart) {
1483 /* The Appearance panel. Accelerators used: [acgoh] luvb n ti p s */
1485 ctlposinit(&cp, hwnd, 80, 3, 13);
1486 bartitle(&cp, "Configure the appearance of PuTTY's window",
1487 IDC_TITLE_APPEARANCE);
1488 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1489 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1490 "B&lock", IDC_CURBLOCK,
1491 "&Underline", IDC_CURUNDER,
1492 "&Vertical line", IDC_CURVERT, NULL);
1493 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1495 beginbox(&cp, "Set the font used in the terminal window",
1496 IDC_BOX_APPEARANCE2);
1497 staticbtn(&cp, "", IDC_FONTSTATIC, "Cha&nge...", IDC_CHOOSEFONT);
1499 beginbox(&cp, "Adjust the use of the window title",
1500 IDC_BOX_APPEARANCE3);
1502 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1503 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
1505 beginbox(&cp, "Adjust the use of the mouse pointer",
1506 IDC_BOX_APPEARANCE4);
1507 checkbox(&cp, "Hide mouse &pointer when typing in window",
1510 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1511 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1513 staticedit(&cp, "Gap between text and window edge",
1514 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
1518 if (panel == behaviourpanelstart) {
1519 /* The Behaviour panel. Accelerators used: [acgoh] w4yltf */
1521 ctlposinit(&cp, hwnd, 80, 3, 13);
1522 bartitle(&cp, "Configure the behaviour of PuTTY's window",
1524 beginbox(&cp, NULL, IDC_BOX_BEHAVIOUR1);
1525 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1526 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1527 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1528 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
1529 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1530 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1534 if (panel == translationpanelstart) {
1535 /* The Translation panel. Accelerators used: [acgoh] rxbepus */
1537 ctlposinit(&cp, hwnd, 80, 3, 13);
1538 bartitle(&cp, "Options controlling character set translation",
1539 IDC_TITLE_TRANSLATION);
1540 beginbox(&cp, "Character set translation on received data",
1541 IDC_BOX_TRANSLATION1);
1542 combobox(&cp, "&Received data assumed to be in which character set:",
1543 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1545 beginbox(&cp, "Enable character set translation on input data",
1546 IDC_BOX_TRANSLATION2);
1547 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
1550 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
1551 IDC_BOX_TRANSLATION3);
1553 "Handling of line drawing characters:", IDC_VTSTATIC,
1554 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1555 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1556 "Use font in O&EM mode only", IDC_VTOEMONLY,
1557 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1558 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
1562 if (panel == selectionpanelstart) {
1563 /* The Selection panel. Accelerators used: [acgoh] df wxp est nr */
1565 ctlposinit(&cp, hwnd, 80, 3, 13);
1566 bartitle(&cp, "Options controlling copy and paste",
1567 IDC_TITLE_SELECTION);
1568 beginbox(&cp, "Translation of pasted characters",
1569 IDC_BOX_SELECTION1);
1571 "&Don't translate line drawing chars into +, - and |",
1574 "Paste to clipboard in RT&F as well as plain text",
1577 beginbox(&cp, "Control which mouse button does which thing",
1578 IDC_BOX_SELECTION2);
1579 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1580 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1581 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1584 "Shift overrides a&pplication's use of mouse",
1587 "Default selection mode (Alt+drag does the other one):",
1588 IDC_SELTYPESTATIC, 2,
1589 "&Normal", IDC_SELTYPELEX,
1590 "&Rectangular block", IDC_SELTYPERECT, NULL);
1592 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1593 IDC_BOX_SELECTION3);
1594 charclass(&cp, "Charact&er classes:", IDC_CCSTATIC, IDC_CCLIST,
1595 "&Set", IDC_CCSET, IDC_CCEDIT,
1596 "&to class", IDC_CCSTATIC2);
1600 if (panel == colourspanelstart) {
1601 /* The Colours panel. Accelerators used: [acgoh] blum */
1603 ctlposinit(&cp, hwnd, 80, 3, 13);
1604 bartitle(&cp, "Options controlling use of colours",
1606 beginbox(&cp, "General options for colour usage",
1608 checkbox(&cp, "&Bolded text is a different colour",
1610 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1612 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1614 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1615 IDC_COLOURSTATIC, IDC_COLOURLIST,
1616 "&Modify...", IDC_CHANGE,
1617 "Red:", IDC_RSTATIC, IDC_RVALUE,
1618 "Green:", IDC_GSTATIC, IDC_GVALUE,
1619 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1623 if (panel == connectionpanelstart) {
1624 /* The Connection panel. Accelerators used: [acgoh] tukn */
1626 ctlposinit(&cp, hwnd, 80, 3, 13);
1627 bartitle(&cp, "Options controlling the connection",
1628 IDC_TITLE_CONNECTION);
1630 beginbox(&cp, "Data to send to the server",
1631 IDC_BOX_CONNECTION1);
1632 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1634 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1638 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1639 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1641 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1645 beginbox(&cp, "Sending of null packets to keep session active",
1646 IDC_BOX_CONNECTION2);
1647 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1648 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1651 beginbox(&cp, "Low-level TCP connection options",
1652 IDC_BOX_CONNECTION3);
1653 checkbox(&cp, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1659 if (panel == telnetpanelstart) {
1660 /* The Telnet panel. Accelerators used: [acgoh] svldr bftk */
1662 ctlposinit(&cp, hwnd, 80, 3, 13);
1664 bartitle(&cp, "Options controlling Telnet connections",
1666 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1667 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1669 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1670 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1671 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1672 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1674 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1675 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1676 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1677 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1678 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1679 "Passive", IDC_TPASSIVE, "Active",
1681 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1683 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1689 if (panel == rloginpanelstart) {
1690 /* The Rlogin panel. Accelerators used: [acgoh] sl */
1692 ctlposinit(&cp, hwnd, 80, 3, 13);
1694 bartitle(&cp, "Options controlling Rlogin connections",
1696 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1697 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1699 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1700 IDC_RLLUSEREDIT, 50);
1705 if (panel == sshpanelstart) {
1706 /* The SSH panel. Accelerators used: [acgoh] r pe12i sd */
1708 ctlposinit(&cp, hwnd, 80, 3, 13);
1710 bartitle(&cp, "Options controlling SSH connections",
1712 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1714 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1717 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
1718 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1719 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1720 radioline(&cp, "Preferred SSH protocol version:",
1721 IDC_SSHPROTSTATIC, 2,
1722 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL);
1723 checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1726 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1727 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1728 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1730 checkbox(&cp, "Enable non-standard use of single-&DES in SSH 2",
1736 if (panel == sshauthpanelstart) {
1737 /* The SSH authentication panel. Accelerators used: [acgoh] m fkiuw */
1739 ctlposinit(&cp, hwnd, 80, 3, 13);
1741 bartitle(&cp, "Options controlling SSH authentication",
1743 beginbox(&cp, "Authentication methods",
1745 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
1747 checkbox(&cp, "Attempt \"keyboard-&interactive\" authentication"
1748 " (SSH2)", IDC_AUTHKI);
1750 beginbox(&cp, "Authentication parameters",
1752 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
1753 checkbox(&cp, "Allow attempted changes of &username in SSH2",
1755 editbutton(&cp, "Private &key file for authentication:",
1756 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
1762 if (panel == tunnelspanelstart) {
1763 /* The Tunnels panel. Accelerators used: [acgoh] deilmrstxp */
1765 ctlposinit(&cp, hwnd, 80, 3, 13);
1767 bartitle(&cp, "Options controlling SSH tunnelling",
1769 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
1770 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
1771 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
1772 IDC_X11_DISPLAY, 50, NULL);
1774 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
1775 checkbox(&cp, "Local ports accept connections from o&ther hosts",
1777 checkbox(&cp, "Remote &ports do the same (SSH v2 only)",
1779 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
1780 "&Remove", IDC_PFWDREMOVE);
1781 fwdsetter(&cp, IDC_PFWDLIST,
1782 "Add new forwarded port:", IDC_PFWDSTATIC2,
1783 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
1784 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
1785 "A&dd", IDC_PFWDADD);
1786 bareradioline(&cp, 2,
1787 "&Local", IDC_PFWDLOCAL,
1788 "Re&mote", IDC_PFWDREMOTE, NULL);
1796 * Helper function to load the session selected in SESSLIST
1797 * if any, as this is done in more than one place in
1798 * GenericMainDlgProc(). 0 => failure.
1800 static int load_selected_session(HWND hwnd)
1802 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1803 LB_GETCURSEL, 0, 0);
1809 isdef = !strcmp(sessions[n], "Default Settings");
1810 load_settings(sessions[n], !isdef, &cfg);
1811 init_dlg_ctrls(hwnd, TRUE);
1813 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
1815 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
1816 /* Restore the selection, which will have been clobbered by
1817 * SESSEDIT handling. */
1818 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
1823 * This function is the configuration box.
1825 static int GenericMainDlgProc(HWND hwnd, UINT msg,
1826 WPARAM wParam, LPARAM lParam, int dlgtype)
1829 struct treeview_faff tvfaff;
1832 char filename[sizeof(cfg.keyfile)];
1835 char fontstatic[256];
1837 struct servent *service;
1839 static UINT draglistmsg = WM_NULL;
1844 SetWindowLong(hwnd, GWL_USERDATA, 0);
1846 SetWindowLong(hwnd, GWL_EXSTYLE,
1847 GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
1849 HWND item = GetDlgItem(hwnd, IDC_HELPBTN);
1851 DestroyWindow(item);
1853 requested_help = FALSE;
1854 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
1855 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
1857 * Centre the window.
1859 { /* centre the window */
1862 hw = GetDesktopWindow();
1863 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
1865 (rs.right + rs.left + rd.left - rd.right) / 2,
1866 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
1867 rd.right - rd.left, rd.bottom - rd.top, TRUE);
1871 * Create the tree view.
1879 r.right = r.left + 75;
1881 r.bottom = r.top + 10;
1882 MapDialogRect(hwnd, &r);
1883 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
1884 WS_CHILD | WS_VISIBLE,
1886 r.right - r.left, r.bottom - r.top,
1887 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
1889 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1890 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1893 r.right = r.left + 75;
1895 r.bottom = r.top + 219;
1896 MapDialogRect(hwnd, &r);
1897 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
1898 WS_CHILD | WS_VISIBLE |
1899 WS_TABSTOP | TVS_HASLINES |
1900 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
1902 TVS_SHOWSELALWAYS, r.left, r.top,
1903 r.right - r.left, r.bottom - r.top,
1904 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
1906 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1907 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1908 tvfaff.treeview = treeview;
1909 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
1913 * Set up the tree view contents.
1915 hsession = treeview_insert(&tvfaff, 0, "Session");
1916 treeview_insert(&tvfaff, 1, "Logging");
1917 treeview_insert(&tvfaff, 0, "Terminal");
1918 treeview_insert(&tvfaff, 1, "Keyboard");
1919 treeview_insert(&tvfaff, 1, "Bell");
1920 treeview_insert(&tvfaff, 1, "Features");
1921 treeview_insert(&tvfaff, 0, "Window");
1922 treeview_insert(&tvfaff, 1, "Appearance");
1923 treeview_insert(&tvfaff, 1, "Behaviour");
1924 treeview_insert(&tvfaff, 1, "Translation");
1925 treeview_insert(&tvfaff, 1, "Selection");
1926 treeview_insert(&tvfaff, 1, "Colours");
1927 treeview_insert(&tvfaff, 0, "Connection");
1929 treeview_insert(&tvfaff, 1, "Telnet");
1930 treeview_insert(&tvfaff, 1, "Rlogin");
1931 if (backends[3].backend != NULL) {
1932 treeview_insert(&tvfaff, 1, "SSH");
1933 /* XXX long name is ugly */
1934 /* XXX make it closed by default? */
1935 treeview_insert(&tvfaff, 2, "Auth");
1936 treeview_insert(&tvfaff, 2, "Tunnels");
1941 * Put the treeview selection on to the Session panel. This
1942 * should also cause creation of the relevant controls.
1944 TreeView_SelectItem(treeview, hsession);
1947 * Set focus into the first available control.
1951 ctl = GetDlgItem(hwnd, IDC_HOST);
1953 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
1957 SetWindowLong(hwnd, GWL_USERDATA, 1);
1958 sesslist_has_focus = 0;
1962 * Button release should trigger WM_OK if there was a
1963 * previous double click on the session list.
1967 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
1970 if (LOWORD(wParam) == IDCX_TREEVIEW &&
1971 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
1973 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
1978 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
1981 item.pszText = buffer;
1982 item.cchTextMax = sizeof(buffer);
1983 item.mask = TVIF_TEXT;
1984 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
1985 for (j = controlstartvalue; j < controlendvalue; j++) {
1986 HWND item = GetDlgItem(hwnd, j);
1988 DestroyWindow(item);
1990 if (!strcmp(buffer, "Session"))
1991 create_controls(hwnd, dlgtype, sessionpanelstart);
1992 if (!strcmp(buffer, "Logging"))
1993 create_controls(hwnd, dlgtype, loggingpanelstart);
1994 if (!strcmp(buffer, "Keyboard"))
1995 create_controls(hwnd, dlgtype, keyboardpanelstart);
1996 if (!strcmp(buffer, "Terminal"))
1997 create_controls(hwnd, dlgtype, terminalpanelstart);
1998 if (!strcmp(buffer, "Bell"))
1999 create_controls(hwnd, dlgtype, bellpanelstart);
2000 if (!strcmp(buffer, "Features"))
2001 create_controls(hwnd, dlgtype, featurespanelstart);
2002 if (!strcmp(buffer, "Window"))
2003 create_controls(hwnd, dlgtype, windowpanelstart);
2004 if (!strcmp(buffer, "Appearance"))
2005 create_controls(hwnd, dlgtype, appearancepanelstart);
2006 if (!strcmp(buffer, "Behaviour"))
2007 create_controls(hwnd, dlgtype, behaviourpanelstart);
2008 if (!strcmp(buffer, "Tunnels"))
2009 create_controls(hwnd, dlgtype, tunnelspanelstart);
2010 if (!strcmp(buffer, "Connection"))
2011 create_controls(hwnd, dlgtype, connectionpanelstart);
2012 if (!strcmp(buffer, "Telnet"))
2013 create_controls(hwnd, dlgtype, telnetpanelstart);
2014 if (!strcmp(buffer, "Rlogin"))
2015 create_controls(hwnd, dlgtype, rloginpanelstart);
2016 if (!strcmp(buffer, "SSH"))
2017 create_controls(hwnd, dlgtype, sshpanelstart);
2018 if (!strcmp(buffer, "Auth"))
2019 create_controls(hwnd, dlgtype, sshauthpanelstart);
2020 if (!strcmp(buffer, "Selection"))
2021 create_controls(hwnd, dlgtype, selectionpanelstart);
2022 if (!strcmp(buffer, "Colours"))
2023 create_controls(hwnd, dlgtype, colourspanelstart);
2024 if (!strcmp(buffer, "Translation"))
2025 create_controls(hwnd, dlgtype, translationpanelstart);
2027 init_dlg_ctrls(hwnd, FALSE);
2029 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
2030 InvalidateRect (hwnd, NULL, TRUE);
2032 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
2038 * Only process WM_COMMAND once the dialog is fully formed.
2040 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
2041 switch (LOWORD(wParam)) {
2043 /* Behaviour of the "Open" button is different if the
2044 * session list has focus, *unless* the user just
2045 * double-clicked... */
2046 if (sesslist_has_focus && !readytogo) {
2047 if (!load_selected_session(hwnd)) {
2052 /* If at this point we have a valid session, go! */
2054 if (requested_help) {
2055 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2056 requested_help = FALSE;
2063 if (HIWORD(wParam) == BN_CLICKED ||
2064 HIWORD(wParam) == BN_DOUBLECLICKED) {
2066 WinHelp(hwnd, help_path,
2067 help_has_contents ? HELP_FINDER : HELP_CONTENTS,
2069 requested_help = TRUE;
2074 if (requested_help) {
2075 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2076 requested_help = FALSE;
2080 case IDC_PROTTELNET:
2081 case IDC_PROTRLOGIN:
2084 if (HIWORD(wParam) == BN_CLICKED ||
2085 HIWORD(wParam) == BN_DOUBLECLICKED) {
2086 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
2087 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
2088 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
2090 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
2093 * When switching using the arrow keys, we
2094 * appear to get two of these messages, both
2095 * mentioning the target button in
2096 * LOWORD(wParam), but one of them called while
2097 * the previous button is still checked. This
2098 * causes an unnecessary reset of the port
2099 * number field, which we fix by ensuring here
2100 * that the button selected is indeed the one
2103 if (IsDlgButtonChecked(hwnd, LOWORD(wParam)) &&
2104 ((cfg.protocol == PROT_SSH && cfg.port != 22)
2105 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
2106 || (cfg.protocol == PROT_RLOGIN
2107 && cfg.port != 513))) {
2108 cfg.port = i ? 22 : j ? 23 : 513;
2109 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
2114 if (HIWORD(wParam) == EN_CHANGE)
2115 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
2116 sizeof(cfg.host) - 1);
2119 if (HIWORD(wParam) == EN_CHANGE) {
2120 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
2121 if (isdigit(portname[0]))
2122 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
2124 service = getservbyname(portname, NULL);
2126 cfg.port = ntohs(service->s_port);
2133 if (HIWORD(wParam) == EN_CHANGE) {
2134 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2136 GetDlgItemText(hwnd, IDC_SESSEDIT,
2137 savedsession, sizeof(savedsession) - 1);
2138 savedsession[sizeof(savedsession) - 1] = '\0';
2142 if (HIWORD(wParam) == BN_CLICKED ||
2143 HIWORD(wParam) == BN_DOUBLECLICKED) {
2148 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
2151 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2152 LB_GETCURSEL, 0, 0);
2157 strcpy(str, sessions[n]);
2159 save_settings(str, !!strcmp(str, "Default Settings"),
2161 get_sesslist(FALSE);
2163 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2165 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2167 for (i = 0; i < nsessions; i++)
2168 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2170 (LPARAM) (sessions[i]));
2171 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2173 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2175 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2181 if (LOWORD(wParam) == IDC_SESSLIST) {
2182 if (HIWORD(wParam) == LBN_SETFOCUS)
2183 sesslist_has_focus = 1;
2184 else if (HIWORD(wParam) == LBN_KILLFOCUS)
2185 sesslist_has_focus = 0;
2187 if (LOWORD(wParam) == IDC_SESSLOAD &&
2188 HIWORD(wParam) != BN_CLICKED &&
2189 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2190 if (LOWORD(wParam) == IDC_SESSLIST &&
2191 HIWORD(wParam) != LBN_DBLCLK) break;
2192 /* Load the session selected in SESSLIST. */
2193 if (load_selected_session(hwnd) &&
2194 LOWORD(wParam) == IDC_SESSLIST) {
2196 * A double-click on a saved session should
2197 * actually start the session, not just load it.
2198 * Unless it's Default Settings or some other
2199 * host-less set of saved settings.
2208 if (HIWORD(wParam) == BN_CLICKED ||
2209 HIWORD(wParam) == BN_DOUBLECLICKED) {
2210 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2211 LB_GETCURSEL, 0, 0);
2212 if (n == LB_ERR || n == 0) {
2216 del_settings(sessions[n]);
2217 get_sesslist(FALSE);
2219 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2221 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2223 for (i = 0; i < nsessions; i++)
2224 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2226 (LPARAM) (sessions[i]));
2227 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2229 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2231 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2235 if (HIWORD(wParam) == EN_CHANGE)
2236 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
2237 &cfg.ping_interval);
2240 if (HIWORD(wParam) == BN_CLICKED ||
2241 HIWORD(wParam) == BN_DOUBLECLICKED)
2243 IsDlgButtonChecked(hwnd, IDC_NODELAY);
2247 if (HIWORD(wParam) == BN_CLICKED ||
2248 HIWORD(wParam) == BN_DOUBLECLICKED)
2249 cfg.bksp_is_delete =
2250 IsDlgButtonChecked(hwnd, IDC_DEL127);
2254 if (HIWORD(wParam) == BN_CLICKED ||
2255 HIWORD(wParam) == BN_DOUBLECLICKED)
2257 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
2263 case IDC_FUNCVT100P:
2265 if (HIWORD(wParam) == BN_CLICKED ||
2266 HIWORD(wParam) == BN_DOUBLECLICKED)
2267 switch (LOWORD(wParam)) {
2280 case IDC_FUNCVT100P:
2290 if (HIWORD(wParam) == BN_CLICKED ||
2291 HIWORD(wParam) == BN_DOUBLECLICKED) {
2293 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
2294 cfg.nethack_keypad = FALSE;
2298 if (HIWORD(wParam) == BN_CLICKED ||
2299 HIWORD(wParam) == BN_DOUBLECLICKED) {
2300 cfg.app_keypad = FALSE;
2301 cfg.nethack_keypad = TRUE;
2306 if (HIWORD(wParam) == BN_CLICKED ||
2307 HIWORD(wParam) == BN_DOUBLECLICKED)
2309 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
2312 if (HIWORD(wParam) == BN_CLICKED ||
2313 HIWORD(wParam) == BN_DOUBLECLICKED)
2315 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
2318 if (HIWORD(wParam) == BN_CLICKED ||
2319 HIWORD(wParam) == BN_DOUBLECLICKED)
2321 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
2323 case IDC_NOMOUSEREP:
2324 if (HIWORD(wParam) == BN_CLICKED ||
2325 HIWORD(wParam) == BN_DOUBLECLICKED)
2327 IsDlgButtonChecked(hwnd, IDC_NOMOUSEREP);
2330 if (HIWORD(wParam) == BN_CLICKED ||
2331 HIWORD(wParam) == BN_DOUBLECLICKED)
2332 cfg.no_remote_resize =
2333 IsDlgButtonChecked(hwnd, IDC_NORESIZE);
2335 case IDC_NOALTSCREEN:
2336 if (HIWORD(wParam) == BN_CLICKED ||
2337 HIWORD(wParam) == BN_DOUBLECLICKED)
2339 IsDlgButtonChecked(hwnd, IDC_NOALTSCREEN);
2341 case IDC_NOWINTITLE:
2342 if (HIWORD(wParam) == BN_CLICKED ||
2343 HIWORD(wParam) == BN_DOUBLECLICKED)
2344 cfg.no_remote_wintitle =
2345 IsDlgButtonChecked(hwnd, IDC_NOWINTITLE);
2347 case IDC_NODBACKSPACE:
2348 if (HIWORD(wParam) == BN_CLICKED ||
2349 HIWORD(wParam) == BN_DOUBLECLICKED)
2351 IsDlgButtonChecked(hwnd, IDC_NODBACKSPACE);
2354 if (HIWORD(wParam) == BN_CLICKED ||
2355 HIWORD(wParam) == BN_DOUBLECLICKED)
2356 cfg.no_remote_charset =
2357 IsDlgButtonChecked(hwnd, IDC_NOCHARSET);
2360 if (HIWORD(wParam) == BN_CLICKED ||
2361 HIWORD(wParam) == BN_DOUBLECLICKED)
2362 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
2365 if (HIWORD(wParam) == BN_CLICKED ||
2366 HIWORD(wParam) == BN_DOUBLECLICKED)
2368 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
2371 if (HIWORD(wParam) == BN_CLICKED ||
2372 HIWORD(wParam) == BN_DOUBLECLICKED)
2374 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
2376 case IDC_ECHOBACKEND:
2379 if (HIWORD(wParam) == BN_CLICKED ||
2380 HIWORD(wParam) == BN_DOUBLECLICKED) {
2381 if (LOWORD(wParam) == IDC_ECHOBACKEND)
2382 cfg.localecho = LD_BACKEND;
2383 if (LOWORD(wParam) == IDC_ECHOYES)
2384 cfg.localecho = LD_YES;
2385 if (LOWORD(wParam) == IDC_ECHONO)
2386 cfg.localecho = LD_NO;
2389 case IDC_EDITBACKEND:
2392 if (HIWORD(wParam) == BN_CLICKED ||
2393 HIWORD(wParam) == BN_DOUBLECLICKED) {
2394 if (LOWORD(wParam) == IDC_EDITBACKEND)
2395 cfg.localedit = LD_BACKEND;
2396 if (LOWORD(wParam) == IDC_EDITYES)
2397 cfg.localedit = LD_YES;
2398 if (LOWORD(wParam) == IDC_EDITNO)
2399 cfg.localedit = LD_NO;
2402 case IDC_ANSWEREDIT:
2403 if (HIWORD(wParam) == EN_CHANGE)
2404 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
2405 sizeof(cfg.answerback) - 1);
2407 case IDC_ALWAYSONTOP:
2408 if (HIWORD(wParam) == BN_CLICKED ||
2409 HIWORD(wParam) == BN_DOUBLECLICKED)
2411 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
2413 case IDC_FULLSCREENONALTENTER:
2414 if (HIWORD(wParam) == BN_CLICKED ||
2415 HIWORD(wParam) == BN_DOUBLECLICKED)
2416 cfg.fullscreenonaltenter =
2417 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
2420 if (HIWORD(wParam) == BN_CLICKED ||
2421 HIWORD(wParam) == BN_DOUBLECLICKED)
2423 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
2425 case IDC_SCROLLDISP:
2426 if (HIWORD(wParam) == BN_CLICKED ||
2427 HIWORD(wParam) == BN_DOUBLECLICKED)
2428 cfg.scroll_on_disp =
2429 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
2431 case IDC_COMPOSEKEY:
2432 if (HIWORD(wParam) == BN_CLICKED ||
2433 HIWORD(wParam) == BN_DOUBLECLICKED)
2435 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
2437 case IDC_CTRLALTKEYS:
2438 if (HIWORD(wParam) == BN_CLICKED ||
2439 HIWORD(wParam) == BN_DOUBLECLICKED)
2441 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
2444 if (HIWORD(wParam) == BN_CLICKED ||
2445 HIWORD(wParam) == BN_DOUBLECLICKED)
2446 cfg.telnet_keyboard =
2447 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
2450 if (HIWORD(wParam) == BN_CLICKED ||
2451 HIWORD(wParam) == BN_DOUBLECLICKED)
2452 cfg.telnet_newline =
2453 IsDlgButtonChecked(hwnd, IDC_TELNETRET);
2456 if (HIWORD(wParam) == BN_CLICKED ||
2457 HIWORD(wParam) == BN_DOUBLECLICKED)
2459 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
2462 if (HIWORD(wParam) == BN_CLICKED ||
2463 HIWORD(wParam) == BN_DOUBLECLICKED)
2464 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
2467 if (HIWORD(wParam) == BN_CLICKED ||
2468 HIWORD(wParam) == BN_DOUBLECLICKED)
2470 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
2473 if (HIWORD(wParam) == EN_CHANGE)
2474 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
2477 if (HIWORD(wParam) == EN_CHANGE)
2478 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
2481 if (HIWORD(wParam) == EN_CHANGE)
2482 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
2484 case IDC_CHOOSEFONT:
2487 lf.lfHeight = -MulDiv(cfg.fontheight,
2488 GetDeviceCaps(hdc, LOGPIXELSY),
2492 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
2493 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
2494 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
2495 lf.lfCharSet = cfg.fontcharset;
2496 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
2497 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
2498 lf.lfQuality = DEFAULT_QUALITY;
2499 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
2500 strncpy(lf.lfFaceName, cfg.font,
2501 sizeof(lf.lfFaceName) - 1);
2502 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
2504 cf.lStructSize = sizeof(cf);
2505 cf.hwndOwner = hwnd;
2507 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
2508 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
2510 if (ChooseFont(&cf)) {
2511 strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
2512 cfg.font[sizeof(cfg.font) - 1] = '\0';
2513 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
2514 cfg.fontcharset = lf.lfCharSet;
2515 cfg.fontheight = cf.iPointSize / 10;
2516 fmtfont(fontstatic);
2517 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
2520 case IDC_BELL_DISABLED:
2521 case IDC_BELL_DEFAULT:
2522 case IDC_BELL_WAVEFILE:
2523 case IDC_BELL_VISUAL:
2524 if (HIWORD(wParam) == BN_CLICKED ||
2525 HIWORD(wParam) == BN_DOUBLECLICKED) {
2526 if (LOWORD(wParam) == IDC_BELL_DISABLED)
2527 cfg.beep = BELL_DISABLED;
2528 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
2529 cfg.beep = BELL_DEFAULT;
2530 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
2531 cfg.beep = BELL_WAVEFILE;
2532 if (LOWORD(wParam) == IDC_BELL_VISUAL)
2533 cfg.beep = BELL_VISUAL;
2536 case IDC_B_IND_DISABLED:
2537 case IDC_B_IND_FLASH:
2538 case IDC_B_IND_STEADY:
2539 if (HIWORD(wParam) == BN_CLICKED ||
2540 HIWORD(wParam) == BN_DOUBLECLICKED) {
2541 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2542 cfg.beep_ind = B_IND_DISABLED;
2543 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2544 cfg.beep_ind = B_IND_FLASH;
2545 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2546 cfg.beep_ind = B_IND_STEADY;
2549 case IDC_BELL_WAVEBROWSE:
2550 memset(&of, 0, sizeof(of));
2551 #ifdef OPENFILENAME_SIZE_VERSION_400
2552 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2554 of.lStructSize = sizeof(of);
2556 of.hwndOwner = hwnd;
2557 of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2558 of.lpstrCustomFilter = NULL;
2559 of.nFilterIndex = 1;
2560 of.lpstrFile = filename;
2561 strcpy(filename, cfg.bell_wavefile);
2562 of.nMaxFile = sizeof(filename);
2563 of.lpstrFileTitle = NULL;
2564 of.lpstrInitialDir = NULL;
2565 of.lpstrTitle = "Select Bell Sound File";
2567 if (GetOpenFileName(&of)) {
2568 strcpy(cfg.bell_wavefile, filename);
2569 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2573 case IDC_BELL_WAVEEDIT:
2574 if (HIWORD(wParam) == EN_CHANGE)
2575 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2577 sizeof(cfg.bell_wavefile) - 1);
2580 if (HIWORD(wParam) == BN_CLICKED ||
2581 HIWORD(wParam) == BN_DOUBLECLICKED)
2583 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2586 if (HIWORD(wParam) == EN_CHANGE)
2587 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2590 if (HIWORD(wParam) == EN_CHANGE)
2591 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2595 if (HIWORD(wParam) == EN_CHANGE)
2596 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2600 if (HIWORD(wParam) == BN_CLICKED ||
2601 HIWORD(wParam) == BN_DOUBLECLICKED)
2603 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2606 if (HIWORD(wParam) == BN_CLICKED ||
2607 HIWORD(wParam) == BN_DOUBLECLICKED)
2608 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2611 if (HIWORD(wParam) == BN_CLICKED ||
2612 HIWORD(wParam) == BN_DOUBLECLICKED)
2613 cfg.win_name_always =
2614 IsDlgButtonChecked(hwnd, IDC_WINNAME);
2617 if (HIWORD(wParam) == BN_CLICKED ||
2618 HIWORD(wParam) == BN_DOUBLECLICKED)
2620 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2622 case IDC_SUNKENEDGE:
2623 if (HIWORD(wParam) == BN_CLICKED ||
2624 HIWORD(wParam) == BN_DOUBLECLICKED)
2626 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2629 if (HIWORD(wParam) == EN_CHANGE)
2630 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2631 &cfg.window_border);
2632 if (cfg.window_border > 32)
2633 cfg.window_border = 32;
2636 if (HIWORD(wParam) == BN_CLICKED ||
2637 HIWORD(wParam) == BN_DOUBLECLICKED)
2638 cfg.cursor_type = 0;
2641 if (HIWORD(wParam) == BN_CLICKED ||
2642 HIWORD(wParam) == BN_DOUBLECLICKED)
2643 cfg.cursor_type = 1;
2646 if (HIWORD(wParam) == BN_CLICKED ||
2647 HIWORD(wParam) == BN_DOUBLECLICKED)
2648 cfg.cursor_type = 2;
2651 if (HIWORD(wParam) == BN_CLICKED ||
2652 HIWORD(wParam) == BN_DOUBLECLICKED)
2654 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2657 if (HIWORD(wParam) == BN_CLICKED ||
2658 HIWORD(wParam) == BN_DOUBLECLICKED)
2660 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2662 case IDC_SCROLLBARFULLSCREEN:
2663 if (HIWORD(wParam) == BN_CLICKED ||
2664 HIWORD(wParam) == BN_DOUBLECLICKED)
2665 cfg.scrollbar_in_fullscreen =
2666 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2668 case IDC_RESIZETERM:
2669 case IDC_RESIZEFONT:
2670 case IDC_RESIZENONE:
2671 case IDC_RESIZEEITHER:
2672 if (HIWORD(wParam) == BN_CLICKED ||
2673 HIWORD(wParam) == BN_DOUBLECLICKED) {
2675 IsDlgButtonChecked(hwnd,
2676 IDC_RESIZETERM) ? RESIZE_TERM :
2677 IsDlgButtonChecked(hwnd,
2678 IDC_RESIZEFONT) ? RESIZE_FONT :
2679 IsDlgButtonChecked(hwnd,
2680 IDC_RESIZEEITHER) ? RESIZE_EITHER :
2685 if (HIWORD(wParam) == EN_CHANGE)
2686 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2687 sizeof(cfg.wintitle) - 1);
2692 if (HIWORD(wParam) == BN_CLICKED ||
2693 HIWORD(wParam) == BN_DOUBLECLICKED) {
2695 IsDlgButtonChecked(hwnd,
2696 IDC_COEALWAYS) ? COE_ALWAYS :
2697 IsDlgButtonChecked(hwnd,
2698 IDC_COENEVER) ? COE_NEVER :
2703 if (HIWORD(wParam) == BN_CLICKED ||
2704 HIWORD(wParam) == BN_DOUBLECLICKED)
2706 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
2709 if (HIWORD(wParam) == EN_CHANGE)
2710 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
2711 sizeof(cfg.termtype) - 1);
2714 if (HIWORD(wParam) == EN_CHANGE)
2715 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
2716 sizeof(cfg.logfilename) - 1);
2719 memset(&of, 0, sizeof(of));
2720 #ifdef OPENFILENAME_SIZE_VERSION_400
2721 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2723 of.lStructSize = sizeof(of);
2725 of.hwndOwner = hwnd;
2726 of.lpstrFilter = "All Files\0*\0\0\0";
2727 of.lpstrCustomFilter = NULL;
2728 of.nFilterIndex = 1;
2729 of.lpstrFile = filename;
2730 strcpy(filename, cfg.logfilename);
2731 of.nMaxFile = sizeof(filename);
2732 of.lpstrFileTitle = NULL;
2733 of.lpstrInitialDir = NULL;
2734 of.lpstrTitle = "Select session log file";
2736 if (GetSaveFileName(&of)) {
2737 strcpy(cfg.logfilename, filename);
2738 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
2742 case IDC_LSTATASCII:
2744 case IDC_LSTATPACKET:
2745 if (HIWORD(wParam) == BN_CLICKED ||
2746 HIWORD(wParam) == BN_DOUBLECLICKED) {
2747 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
2748 cfg.logtype = LGTYP_NONE;
2749 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
2750 cfg.logtype = LGTYP_ASCII;
2751 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
2752 cfg.logtype = LGTYP_DEBUG;
2753 if (IsDlgButtonChecked(hwnd, IDC_LSTATPACKET))
2754 cfg.logtype = LGTYP_PACKETS;
2760 if (HIWORD(wParam) == BN_CLICKED ||
2761 HIWORD(wParam) == BN_DOUBLECLICKED) {
2762 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
2763 cfg.logxfovr = LGXF_ASK;
2764 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
2765 cfg.logxfovr = LGXF_APN;
2766 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
2767 cfg.logxfovr = LGXF_OVR;
2772 if (HIWORD(wParam) == EN_CHANGE)
2773 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
2774 sizeof(cfg.termspeed) - 1);
2777 if (HIWORD(wParam) == EN_CHANGE)
2778 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
2779 sizeof(cfg.username) - 1);
2781 case IDC_RLLUSEREDIT:
2782 if (HIWORD(wParam) == EN_CHANGE)
2783 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
2785 sizeof(cfg.localusername) - 1);
2789 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
2793 cfg.passive_telnet =
2794 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
2797 if (HIWORD(wParam) == BN_CLICKED ||
2798 HIWORD(wParam) == BN_DOUBLECLICKED) {
2799 char str[sizeof(cfg.environmt)];
2801 GetDlgItemText(hwnd, IDC_VAREDIT, str,
2807 p = str + strlen(str);
2809 GetDlgItemText(hwnd, IDC_VALEDIT, p,
2810 sizeof(str) - 1 - (p - str));
2821 if ((p - cfg.environmt) + strlen(str) + 2 <
2822 sizeof(cfg.environmt)) {
2824 p[strlen(str) + 1] = '\0';
2825 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
2827 SetDlgItemText(hwnd, IDC_VAREDIT, "");
2828 SetDlgItemText(hwnd, IDC_VALEDIT, "");
2830 MessageBox(hwnd, "Environment too big",
2831 "PuTTY Error", MB_OK | MB_ICONERROR);
2836 if (HIWORD(wParam) != BN_CLICKED &&
2837 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2839 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
2846 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
2873 if (HIWORD(wParam) == BN_CLICKED ||
2874 HIWORD(wParam) == BN_DOUBLECLICKED)
2875 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
2878 if (HIWORD(wParam) == BN_CLICKED ||
2879 HIWORD(wParam) == BN_DOUBLECLICKED)
2881 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
2884 if (HIWORD(wParam) == BN_CLICKED ||
2885 HIWORD(wParam) == BN_DOUBLECLICKED)
2887 IsDlgButtonChecked(hwnd, IDC_BUGGYMAC);
2890 if (HIWORD(wParam) == BN_CLICKED ||
2891 HIWORD(wParam) == BN_DOUBLECLICKED)
2893 IsDlgButtonChecked(hwnd, IDC_SSH2DES);
2896 if (HIWORD(wParam) == BN_CLICKED ||
2897 HIWORD(wParam) == BN_DOUBLECLICKED)
2899 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
2901 case IDC_CHANGEUSER:
2902 if (HIWORD(wParam) == BN_CLICKED ||
2903 HIWORD(wParam) == BN_DOUBLECLICKED)
2904 cfg.change_username =
2905 IsDlgButtonChecked(hwnd, IDC_CHANGEUSER);
2907 case IDC_CIPHERLIST:
2910 handle_prefslist(&cipherlist,
2911 cfg.ssh_cipherlist, CIPHER_MAX,
2912 0, hwnd, wParam, lParam);
2916 if (HIWORD(wParam) == BN_CLICKED ||
2917 HIWORD(wParam) == BN_DOUBLECLICKED) {
2918 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
2920 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
2925 if (HIWORD(wParam) == BN_CLICKED ||
2926 HIWORD(wParam) == BN_DOUBLECLICKED)
2928 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
2931 if (HIWORD(wParam) == BN_CLICKED ||
2932 HIWORD(wParam) == BN_DOUBLECLICKED)
2934 IsDlgButtonChecked(hwnd, IDC_AUTHKI);
2937 if (HIWORD(wParam) == EN_CHANGE)
2938 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
2939 sizeof(cfg.keyfile) - 1);
2942 if (HIWORD(wParam) == EN_CHANGE)
2943 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
2944 sizeof(cfg.remote_cmd) - 1);
2947 memset(&of, 0, sizeof(of));
2948 #ifdef OPENFILENAME_SIZE_VERSION_400
2949 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2951 of.lStructSize = sizeof(of);
2953 of.hwndOwner = hwnd;
2954 of.lpstrFilter = "All Files\0*\0\0\0";
2955 of.lpstrCustomFilter = NULL;
2956 of.nFilterIndex = 1;
2957 of.lpstrFile = filename;
2958 strcpy(filename, cfg.keyfile);
2959 of.nMaxFile = sizeof(filename);
2960 of.lpstrFileTitle = NULL;
2961 of.lpstrInitialDir = NULL;
2962 of.lpstrTitle = "Select Private Key File";
2964 if (GetOpenFileName(&of)) {
2965 strcpy(cfg.keyfile, filename);
2966 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
2970 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
2973 cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
2977 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
2979 case IDC_SELTYPELEX:
2980 case IDC_SELTYPERECT:
2981 cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
2983 case IDC_MOUSEOVERRIDE:
2984 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
2990 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
2995 for (i = 0; i < 128; i++)
2996 if (SendDlgItemMessage
2997 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
2999 cfg.wordness[i] = n;
3000 SendDlgItemMessage(hwnd, IDC_CCLIST,
3001 LB_DELETESTRING, i, 0);
3002 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
3003 (i >= 0x21 && i != 0x7F) ? i : ' ',
3005 SendDlgItemMessage(hwnd, IDC_CCLIST,
3012 case IDC_BOLDCOLOUR:
3013 if (HIWORD(wParam) == BN_CLICKED ||
3014 HIWORD(wParam) == BN_DOUBLECLICKED) {
3017 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
3018 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
3021 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3023 if (n != 12 + 10 * cfg.bold_colour) {
3024 for (i = n; i-- > 0;)
3025 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3026 LB_DELETESTRING, i, 0);
3027 for (i = 0; i < 22; i++)
3028 if (cfg.bold_colour || permcolour[i])
3029 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3031 (LPARAM) colours[i]);
3033 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
3035 InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
3040 if (HIWORD(wParam) == BN_CLICKED ||
3041 HIWORD(wParam) == BN_DOUBLECLICKED)
3043 IsDlgButtonChecked(hwnd, IDC_PALETTE);
3045 case IDC_COLOURLIST:
3046 if (HIWORD(wParam) == LBN_DBLCLK ||
3047 HIWORD(wParam) == LBN_SELCHANGE) {
3049 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3052 if (!cfg.bold_colour)
3053 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3054 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3056 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3058 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3063 if (HIWORD(wParam) == BN_CLICKED ||
3064 HIWORD(wParam) == BN_DOUBLECLICKED) {
3065 static CHOOSECOLOR cc;
3066 static DWORD custom[16] = { 0 }; /* zero initialisers */
3068 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3071 if (!cfg.bold_colour)
3072 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3073 cc.lStructSize = sizeof(cc);
3074 cc.hwndOwner = hwnd;
3075 cc.hInstance = (HWND) hinst;
3076 cc.lpCustColors = custom;
3078 RGB(cfg.colours[i][0], cfg.colours[i][1],
3080 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
3081 if (ChooseColor(&cc)) {
3083 (unsigned char) (cc.rgbResult & 0xFF);
3085 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
3087 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
3088 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3090 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3092 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3098 if (HIWORD(wParam) == CBN_SELCHANGE) {
3099 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
3100 CB_GETCURSEL, 0, 0);
3101 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
3102 index, (LPARAM)cfg.line_codepage);
3103 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3104 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
3105 sizeof(cfg.line_codepage) - 1);
3106 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
3107 strcpy(cfg.line_codepage,
3108 cp_name(decode_codepage(cfg.line_codepage)));
3109 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
3112 case IDC_CAPSLOCKCYR:
3113 if (HIWORD(wParam) == BN_CLICKED ||
3114 HIWORD(wParam) == BN_DOUBLECLICKED) {
3115 cfg.xlat_capslockcyr =
3116 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
3119 case IDC_VTXWINDOWS:
3125 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
3126 : IsDlgButtonChecked(hwnd,
3127 IDC_VTOEMANSI) ? VT_OEMANSI :
3128 IsDlgButtonChecked(hwnd,
3129 IDC_VTOEMONLY) ? VT_OEMONLY :
3130 IsDlgButtonChecked(hwnd,
3131 IDC_VTUNICODE) ? VT_UNICODE :
3134 case IDC_X11_FORWARD:
3135 if (HIWORD(wParam) == BN_CLICKED ||
3136 HIWORD(wParam) == BN_DOUBLECLICKED)
3138 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
3141 if (HIWORD(wParam) == BN_CLICKED ||
3142 HIWORD(wParam) == BN_DOUBLECLICKED)
3143 cfg.lport_acceptall =
3144 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
3147 if (HIWORD(wParam) == BN_CLICKED ||
3148 HIWORD(wParam) == BN_DOUBLECLICKED)
3149 cfg.rport_acceptall =
3150 IsDlgButtonChecked(hwnd, IDC_RPORT_ALL);
3152 case IDC_X11_DISPLAY:
3153 if (HIWORD(wParam) == EN_CHANGE)
3154 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
3155 sizeof(cfg.x11_display) - 1);
3158 if (HIWORD(wParam) == BN_CLICKED ||
3159 HIWORD(wParam) == BN_DOUBLECLICKED) {
3160 char str[sizeof(cfg.portfwd)];
3162 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
3166 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
3170 "You need to specify a source port number",
3171 "PuTTY Error", MB_OK | MB_ICONERROR);
3174 p = str + strlen(str);
3176 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
3177 sizeof(str) - 1 - (p - str));
3178 if (!*p || !strchr(p, ':')) {
3180 "You need to specify a destination address\n"
3181 "in the form \"host.name:port\"",
3182 "PuTTY Error", MB_OK | MB_ICONERROR);
3191 if ((p - cfg.portfwd) + strlen(str) + 2 <
3192 sizeof(cfg.portfwd)) {
3194 p[strlen(str) + 1] = '\0';
3195 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
3197 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
3198 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
3200 MessageBox(hwnd, "Too many forwardings",
3201 "PuTTY Error", MB_OK | MB_ICONERROR);
3205 case IDC_PFWDREMOVE:
3206 if (HIWORD(wParam) != BN_CLICKED &&
3207 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3208 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
3209 LB_GETCURSEL, 0, 0);
3215 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
3245 int id = ((LPHELPINFO)lParam)->iCtrlId;
3246 char *cmd = help_context_cmd(id);
3248 WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
3249 requested_help = TRUE;
3256 if (requested_help) {
3257 WinHelp(hwnd, help_path, HELP_QUIT, 0);
3258 requested_help = FALSE;
3263 /* Grrr Explorer will maximize Dialogs! */
3265 if (wParam == SIZE_MAXIMIZED)
3271 * Handle application-defined messages eg. DragListBox
3273 /* First find out what the number is (once). */
3274 if (draglistmsg == WM_NULL)
3275 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
3277 if (msg == draglistmsg) {
3278 /* Only process once dialog is fully formed. */
3279 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
3280 case IDC_CIPHERLIST:
3281 return handle_prefslist(&cipherlist,
3282 cfg.ssh_cipherlist, CIPHER_MAX,
3283 1, hwnd, wParam, lParam);
3292 static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
3293 WPARAM wParam, LPARAM lParam)
3295 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
3297 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
3298 EnableWindow(hwnd, 0);
3299 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3300 EnableWindow(hwnd, 1);
3301 SetActiveWindow(hwnd);
3303 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
3306 static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
3307 WPARAM wParam, LPARAM lParam)
3309 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
3312 void defuse_showwindow(void)
3315 * Work around the fact that the app's first call to ShowWindow
3316 * will ignore the default in favour of the shell-provided
3321 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
3323 ShowWindow(hwnd, SW_HIDE);
3324 SetActiveWindow(hwnd);
3325 DestroyWindow(hwnd);
3334 savedsession[0] = '\0';
3336 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
3337 get_sesslist(FALSE);
3342 int do_reconfig(HWND hwnd)
3347 backup_cfg = cfg; /* structure copy */
3349 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
3351 cfg = backup_cfg; /* structure copy */
3356 void logevent(char *string)
3361 if (nevents >= negsize) {
3363 events = srealloc(events, negsize * sizeof(*events));
3367 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
3370 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
3371 strcpy(events[nevents], timebuf);
3372 strcat(events[nevents], string);
3375 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
3376 0, (LPARAM) events[nevents]);
3377 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
3378 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
3383 void showeventlog(HWND hwnd)
3386 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
3388 ShowWindow(logbox, SW_SHOWNORMAL);
3390 SetActiveWindow(logbox);
3393 void showabout(HWND hwnd)
3395 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3398 void verify_ssh_host_key(char *host, int port, char *keytype,
3399 char *keystr, char *fingerprint)
3403 static const char absentmsg[] =
3404 "The server's host key is not cached in the registry. You\n"
3405 "have no guarantee that the server is the computer you\n"
3407 "The server's key fingerprint is:\n"
3409 "If you trust this host, hit Yes to add the key to\n"
3410 "PuTTY's cache and carry on connecting.\n"
3411 "If you want to carry on connecting just once, without\n"
3412 "adding the key to the cache, hit No.\n"
3413 "If you do not trust this host, hit Cancel to abandon the\n"
3416 static const char wrongmsg[] =
3417 "WARNING - POTENTIAL SECURITY BREACH!\n"
3419 "The server's host key does not match the one PuTTY has\n"
3420 "cached in the registry. This means that either the\n"
3421 "server administrator has changed the host key, or you\n"
3422 "have actually connected to another computer pretending\n"
3423 "to be the server.\n"
3424 "The new key fingerprint is:\n"
3426 "If you were expecting this change and trust the new key,\n"
3427 "hit Yes to update PuTTY's cache and continue connecting.\n"
3428 "If you want to carry on connecting but without updating\n"
3429 "the cache, hit No.\n"
3430 "If you want to abandon the connection completely, hit\n"
3431 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3433 static const char mbtitle[] = "PuTTY Security Alert";
3436 /* sensible fingerprint max size */
3437 (sizeof(absentmsg) > sizeof(wrongmsg) ?
3438 sizeof(absentmsg) : sizeof(wrongmsg))];
3441 * Verify the key against the registry.
3443 ret = verify_host_key(host, port, keytype, keystr);
3445 if (ret == 0) /* success - key matched OK */
3447 if (ret == 2) { /* key was different */
3449 sprintf(message, wrongmsg, fingerprint);
3450 mbret = MessageBox(NULL, message, mbtitle,
3451 MB_ICONWARNING | MB_YESNOCANCEL);
3453 store_host_key(host, port, keytype, keystr);
3454 if (mbret == IDCANCEL)
3457 if (ret == 1) { /* key was absent */
3459 sprintf(message, absentmsg, fingerprint);
3460 mbret = MessageBox(NULL, message, mbtitle,
3461 MB_ICONWARNING | MB_YESNOCANCEL);
3463 store_host_key(host, port, keytype, keystr);
3464 if (mbret == IDCANCEL)
3470 * Ask whether the selected cipher is acceptable (since it was
3471 * below the configured 'warn' threshold).
3472 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3474 void askcipher(char *ciphername, int cs)
3476 static const char mbtitle[] = "PuTTY Security Alert";
3477 static const char msg[] =
3478 "The first %.35scipher supported by the server\n"
3479 "is %.64s, which is below the configured\n"
3480 "warning threshold.\n"
3481 "Do you want to continue with this connection?\n";
3482 /* guessed cipher name + type max length */
3483 char message[100 + sizeof(msg)];
3486 sprintf(message, msg,
3488 (cs == 1) ? "client-to-server " :
3489 "server-to-client ",
3491 mbret = MessageBox(NULL, message, mbtitle,
3492 MB_ICONWARNING | MB_YESNO);
3500 * Ask whether to wipe a session log file before writing to it.
3501 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3503 int askappend(char *filename)
3505 static const char mbtitle[] = "PuTTY Log to File";
3506 static const char msgtemplate[] =
3507 "The session log file \"%.*s\" already exists.\n"
3508 "You can overwrite it with a new session log,\n"
3509 "append your session log to the end of it,\n"
3510 "or disable session logging for this session.\n"
3511 "Hit Yes to wipe the file, No to append to it,\n"
3512 "or Cancel to disable logging.";
3513 char message[sizeof(msgtemplate) + FILENAME_MAX];
3515 if (cfg.logxfovr != LGXF_ASK) {
3516 return ((cfg.logxfovr == LGXF_OVR) ? 2 : 1);
3518 sprintf(message, msgtemplate, FILENAME_MAX, filename);
3520 mbret = MessageBox(NULL, message, mbtitle,
3521 MB_ICONQUESTION | MB_YESNOCANCEL);
3524 else if (mbret == IDNO)
3531 * Warn about the obsolescent key file format.
3533 void old_keyfile_warning(void)
3535 static const char mbtitle[] = "PuTTY Key File Warning";
3536 static const char message[] =
3537 "You are loading an SSH 2 private key which has an\n"
3538 "old version of the file format. This means your key\n"
3539 "file is not fully tamperproof. Future versions of\n"
3540 "PuTTY may stop supporting this private key format,\n"
3541 "so we recommend you convert your key to the new\n"
3544 "You can perform this conversion by loading the key\n"
3545 "into PuTTYgen and then saving it again.";
3547 MessageBox(NULL, message, mbtitle, MB_OK);