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 #define PRINTER_DISABLED_STRING "None (printing disabled)"
32 void force_normal(HWND hwnd)
34 static int recurse = 0;
42 wp.length = sizeof(wp);
43 if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) {
44 wp.showCmd = SW_SHOWNORMAL;
45 SetWindowPlacement(hwnd, &wp);
50 static void MyGetDlgItemInt(HWND hwnd, int id, int *result)
54 n = GetDlgItemInt(hwnd, id, &ok, FALSE);
59 static void MyGetDlgItemFlt(HWND hwnd, int id, int *result, int scale)
63 ok = GetDlgItemText(hwnd, id, text, sizeof(text) - 1);
65 *result = (int) (scale * atof(text));
68 static void MySetDlgItemFlt(HWND hwnd, int id, double value)
71 sprintf(text, "%g", value);
72 SetDlgItemText(hwnd, id, text);
75 static int CALLBACK LogProc(HWND hwnd, UINT msg,
76 WPARAM wParam, LPARAM lParam)
83 static int tabs[4] = { 78, 108 };
84 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
87 for (i = 0; i < nevents; i++)
88 SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
89 0, (LPARAM) events[i]);
92 switch (LOWORD(wParam)) {
96 SetActiveWindow(GetParent(hwnd));
100 if (HIWORD(wParam) == BN_CLICKED ||
101 HIWORD(wParam) == BN_DOUBLECLICKED) {
104 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
105 LB_GETSELCOUNT, 0, 0);
106 if (selcount == 0) { /* don't even try to copy zero items */
111 selitems = smalloc(selcount * sizeof(int));
113 int count = SendDlgItemMessage(hwnd, IDN_LIST,
120 static unsigned char sel_nl[] = SEL_NL;
122 if (count == 0) { /* can't copy zero stuff */
128 for (i = 0; i < count; i++)
130 strlen(events[selitems[i]]) + sizeof(sel_nl);
132 clipdata = smalloc(size);
135 for (i = 0; i < count; i++) {
136 char *q = events[selitems[i]];
137 int qlen = strlen(q);
140 memcpy(p, sel_nl, sizeof(sel_nl));
143 write_aclip(clipdata, size, TRUE);
148 for (i = 0; i < nevents; i++)
149 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
158 SetActiveWindow(GetParent(hwnd));
165 static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
166 WPARAM wParam, LPARAM lParam)
172 switch (LOWORD(wParam)) {
185 static int CALLBACK AboutProc(HWND hwnd, UINT msg,
186 WPARAM wParam, LPARAM lParam)
190 SetDlgItemText(hwnd, IDA_VERSION, ver);
193 switch (LOWORD(wParam)) {
196 EndDialog(hwnd, TRUE);
199 EnableWindow(hwnd, 0);
200 DialogBox(hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
202 EnableWindow(hwnd, 1);
203 SetActiveWindow(hwnd);
207 /* Load web browser */
208 ShellExecute(hwnd, "open",
209 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
210 0, 0, SW_SHOWDEFAULT);
215 EndDialog(hwnd, TRUE);
222 * Null dialog procedure.
224 static int CALLBACK NullDlgProc(HWND hwnd, UINT msg,
225 WPARAM wParam, LPARAM lParam)
230 static char savedsession[2048];
233 IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
386 IDC_SCROLLBARFULLSCREEN,
401 IDC_FULLSCREENONALTENTER,
404 appearancepanelstart,
405 IDC_TITLE_APPEARANCE,
427 connectionpanelstart,
428 IDC_TITLE_CONNECTION,
453 IDC_PROXYEXCLUDESTATIC,
454 IDC_PROXYEXCLUDEEDIT,
460 IDC_PROXYTELNETCMDSTATIC,
461 IDC_PROXYTELNETCMDEDIT,
462 IDC_PROXYSOCKSVERSTATIC,
591 translationpanelstart,
592 IDC_TITLE_TRANSLATION,
593 IDC_BOX_TRANSLATION1,
594 IDC_BOX_TRANSLATION2,
595 IDC_BOX_TRANSLATION3,
633 static const char *const colours[] = {
634 "Default Foreground", "Default Bold Foreground",
635 "Default Background", "Default Bold Background",
636 "Cursor Text", "Cursor Colour",
637 "ANSI Black", "ANSI Black Bold",
638 "ANSI Red", "ANSI Red Bold",
639 "ANSI Green", "ANSI Green Bold",
640 "ANSI Yellow", "ANSI Yellow Bold",
641 "ANSI Blue", "ANSI Blue Bold",
642 "ANSI Magenta", "ANSI Magenta Bold",
643 "ANSI Cyan", "ANSI Cyan Bold",
644 "ANSI White", "ANSI White Bold"
646 static const int permcolour[] = {
647 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
648 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
649 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
652 static void fmtfont(char *buf)
654 sprintf(buf, "Font: %s, ", cfg.font);
656 strcat(buf, "bold, ");
657 if (cfg.fontheight == 0)
658 strcat(buf, "default height");
660 sprintf(buf + strlen(buf), "%d-point",
661 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
664 char *help_context_cmd(int id)
676 return "JI(`',`session.hostname')";
683 return "JI(`',`session.saved')";
688 return "JI(`',`session.coe')";
689 case IDC_LSTATSTATIC:
693 case IDC_LSTATPACKET:
694 return "JI(`',`logging.main')";
699 return "JI(`',`logging.filename')";
704 return "JI(`',`logging.exists')";
709 return "JI(`',`keyboard.backspace')";
713 return "JI(`',`keyboard.homeend')";
721 return "JI(`',`keyboard.funkeys')";
725 return "JI(`',`keyboard.appkeypad')";
729 return "JI(`',`keyboard.appcursor')";
731 return "JI(`',`keyboard.nethack')";
733 return "JI(`',`keyboard.compose')";
734 case IDC_CTRLALTKEYS:
735 return "JI(`',`keyboard.ctrlalt')";
739 return "JI(`',`features.application')";
741 return "JI(`',`features.mouse')";
743 return "JI(`',`features.resize')";
744 case IDC_NOALTSCREEN:
745 return "JI(`',`features.altscreen')";
747 return "JI(`',`features.retitle')";
748 case IDC_NODBACKSPACE:
749 return "JI(`',`features.dbackspace')";
751 return "JI(`',`features.charset')";
754 return "JI(`',`terminal.autowrap')";
756 return "JI(`',`terminal.decom')";
758 return "JI(`',`terminal.lfhascr')";
760 return "JI(`',`terminal.bce')";
762 return "JI(`',`terminal.blink')";
765 return "JI(`',`terminal.answerback')";
767 case IDC_ECHOBACKEND:
770 return "JI(`',`terminal.localecho')";
772 case IDC_EDITBACKEND:
775 return "JI(`',`terminal.localedit')";
776 case IDC_PRINTERSTATIC:
778 return "JI(`',`terminal.printing')";
781 case IDC_BELL_DISABLED:
782 case IDC_BELL_DEFAULT:
783 case IDC_BELL_WAVEFILE:
784 case IDC_BELL_VISUAL:
785 case IDC_BELL_WAVESTATIC:
786 case IDC_BELL_WAVEEDIT:
787 case IDC_BELL_WAVEBROWSE:
788 return "JI(`',`bell.style')";
789 case IDC_B_IND_STATIC:
790 case IDC_B_IND_DISABLED:
791 case IDC_B_IND_FLASH:
792 case IDC_B_IND_STEADY:
793 return "JI(`',`bell.taskbar')";
795 case IDC_BELLOVLNSTATIC:
797 case IDC_BELLOVLTSTATIC:
799 case IDC_BELLOVLEXPLAIN:
800 case IDC_BELLOVLSSTATIC:
802 return "JI(`',`bell.overload')";
808 return "JI(`',`window.size')";
809 case IDC_RESIZESTATIC:
813 case IDC_RESIZEEITHER:
814 return "JI(`',`window.resize')";
816 case IDC_SCROLLBARFULLSCREEN:
821 return "JI(`',`window.scrollback')";
824 return "JI(`',`behaviour.closewarn')";
826 return "JI(`',`behaviour.altf4')";
828 return "JI(`',`behaviour.altspace')";
830 return "JI(`',`behaviour.altonly')";
831 case IDC_ALWAYSONTOP:
832 return "JI(`',`behaviour.alwaysontop')";
833 case IDC_FULLSCREENONALTENTER:
834 return "JI(`',`behaviour.altenter')";
836 case IDC_CURSORSTATIC:
841 return "JI(`',`appearance.cursor')";
844 return "JI(`',`appearance.font')";
848 return "JI(`',`appearance.title')";
850 return "JI(`',`appearance.hidemouse')";
854 return "JI(`',`appearance.border')";
858 return "JI(`',`connection.termtype')";
861 return "JI(`',`connection.username')";
864 return "JI(`',`connection.keepalive')";
866 return "JI(`',`connection.nodelay')";
870 return "JI(`',`telnet.termspeed')";
879 return "JI(`',`telnet.environ')";
883 return "JI(`',`telnet.oldenviron')";
887 return "JI(`',`telnet.passive')";
889 return "JI(`',`telnet.specialkeys')";
891 return "JI(`',`telnet.newline')";
895 return "JI(`',`rlogin.termspeed')";
896 case IDC_RLLUSERSTATIC:
897 case IDC_RLLUSEREDIT:
898 return "JI(`',`rlogin.localuser')";
901 return "JI(`',`ssh.nopty')";
902 case IDC_CIPHERSTATIC2:
907 return "JI(`',`ssh.ciphers')";
908 case IDC_SSHPROTSTATIC:
909 case IDC_SSHPROT1ONLY:
912 case IDC_SSHPROT2ONLY:
913 return "JI(`',`ssh.protocol')";
916 return "JI(`',`ssh.command')";
918 return "JI(`',`ssh.compress')";
923 return "JI(`',`ssh.auth.privkey')";
925 return "JI(`',`ssh.auth.agentfwd')";
927 return "JI(`',`ssh.auth.changeuser')";
929 return "JI(`',`ssh.auth.tis')";
931 return "JI(`',`ssh.auth.ki')";
936 return "JI(`',`selection.buttons')";
937 case IDC_MOUSEOVERRIDE:
938 return "JI(`',`selection.shiftdrag')";
939 case IDC_SELTYPESTATIC:
941 case IDC_SELTYPERECT:
942 return "JI(`',`selection.rect')";
948 return "JI(`',`selection.charclasses')";
950 return "JI(`',`selection.linedraw')";
952 return "JI(`',`selection.rtf')";
955 return "JI(`',`colours.bold')";
957 return "JI(`',`colours.logpal')";
958 case IDC_COLOURSTATIC:
967 return "JI(`',`colours.config')";
969 case IDC_CODEPAGESTATIC:
971 return "JI(`',`translation.codepage')";
972 case IDC_CAPSLOCKCYR:
973 return "JI(`',`translation.cyrillic')";
980 return "JI(`',`translation.linedraw')";
982 case IDC_X11_FORWARD:
983 case IDC_X11_DISPSTATIC:
984 case IDC_X11_DISPLAY:
985 return "JI(`',`ssh.tunnels.x11')";
987 case IDC_PFWDSTATIC2:
991 case IDC_SPORTSTATIC:
993 case IDC_DPORTSTATIC:
997 return "JI(`',`ssh.tunnels.portfwd')";
1000 return "JI(`',`ssh.tunnels.portfwd.localhost')";
1002 case IDC_BUGS_IGNORE1:
1003 case IDC_BUGD_IGNORE1:
1004 return "JI(`',`ssh.bugs.ignore1')";
1005 case IDC_BUGS_PLAINPW1:
1006 case IDC_BUGD_PLAINPW1:
1007 return "JI(`',`ssh.bugs.plainpw1')";
1010 return "JI(`',`ssh.bugs.rsa1')";
1011 case IDC_BUGS_HMAC2:
1012 case IDC_BUGD_HMAC2:
1013 return "JI(`',`ssh.bugs.hmac2')";
1014 case IDC_BUGS_DERIVEKEY2:
1015 case IDC_BUGD_DERIVEKEY2:
1016 return "JI(`',`ssh.bugs.derivekey2')";
1017 case IDC_BUGS_RSAPAD2:
1018 case IDC_BUGD_RSAPAD2:
1019 return "JI(`',`ssh.bugs.rsapad2')";
1026 /* 2nd arg: NZ => don't redraw session list (use when loading
1028 static void init_dlg_ctrls(HWND hwnd, int keepsess)
1031 char fontstatic[256];
1033 SetDlgItemText(hwnd, IDC_HOST, cfg.host);
1034 SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
1037 n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
1038 for (i = n; i-- > 0;)
1039 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_DELETESTRING, i, 0);
1040 for (i = 0; i < nsessions; i++)
1041 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_ADDSTRING,
1042 0, (LPARAM) (sessions[i]));
1044 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
1045 CheckRadioButton(hwnd, IDC_PROTRAW, IDC_PROTSSH,
1046 cfg.protocol == PROT_SSH ? IDC_PROTSSH :
1047 cfg.protocol == PROT_TELNET ? IDC_PROTTELNET :
1049 PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW);
1050 SetDlgItemInt(hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
1051 CheckDlgButton(hwnd, IDC_NODELAY, cfg.tcp_nodelay);
1053 CheckRadioButton(hwnd, IDC_DEL008, IDC_DEL127,
1054 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
1055 CheckRadioButton(hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
1056 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
1057 CheckRadioButton(hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
1058 cfg.funky_type == 0 ? IDC_FUNCTILDE :
1059 cfg.funky_type == 1 ? IDC_FUNCLINUX :
1060 cfg.funky_type == 2 ? IDC_FUNCXTERM :
1061 cfg.funky_type == 3 ? IDC_FUNCVT400 :
1062 cfg.funky_type == 4 ? IDC_FUNCVT100P :
1063 cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE);
1064 CheckDlgButton(hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
1065 CheckDlgButton(hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
1066 CheckDlgButton(hwnd, IDC_NOMOUSEREP, cfg.no_mouse_rep);
1067 CheckDlgButton(hwnd, IDC_NORESIZE, cfg.no_remote_resize);
1068 CheckDlgButton(hwnd, IDC_NOALTSCREEN, cfg.no_alt_screen);
1069 CheckDlgButton(hwnd, IDC_NOWINTITLE, cfg.no_remote_wintitle);
1070 CheckDlgButton(hwnd, IDC_NODBACKSPACE, cfg.no_dbackspace);
1071 CheckDlgButton(hwnd, IDC_NOCHARSET, cfg.no_remote_charset);
1072 CheckRadioButton(hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
1073 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
1074 CheckRadioButton(hwnd, IDC_KPNORMAL, IDC_KPNH,
1075 cfg.nethack_keypad ? IDC_KPNH :
1076 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
1077 CheckDlgButton(hwnd, IDC_ALTF4, cfg.alt_f4);
1078 CheckDlgButton(hwnd, IDC_ALTSPACE, cfg.alt_space);
1079 CheckDlgButton(hwnd, IDC_ALTONLY, cfg.alt_only);
1080 CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
1081 CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
1082 CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
1083 CheckDlgButton(hwnd, IDC_TELNETRET, cfg.telnet_newline);
1084 CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
1085 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
1086 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
1087 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
1088 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND :
1089 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
1090 SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
1091 CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
1092 CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
1093 CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
1094 CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
1096 CheckDlgButton(hwnd, IDC_WRAPMODE, cfg.wrap_mode);
1097 CheckDlgButton(hwnd, IDC_DECOM, cfg.dec_om);
1098 CheckDlgButton(hwnd, IDC_LFHASCR, cfg.lfhascr);
1099 SetDlgItemInt(hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
1100 SetDlgItemInt(hwnd, IDC_COLSEDIT, cfg.width, FALSE);
1101 SetDlgItemInt(hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
1102 fmtfont(fontstatic);
1103 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
1104 CheckRadioButton(hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
1105 cfg.beep == BELL_DISABLED ? IDC_BELL_DISABLED :
1106 cfg.beep == BELL_DEFAULT ? IDC_BELL_DEFAULT :
1107 cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
1109 BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
1110 CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
1112 B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
1113 B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
1114 B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
1115 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
1116 CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
1117 SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
1118 MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
1119 MySetDlgItemFlt(hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
1121 CheckDlgButton(hwnd, IDC_BCE, cfg.bce);
1122 CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
1124 SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
1125 CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
1126 CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
1127 CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
1128 SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
1129 CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
1130 cfg.cursor_type == 0 ? IDC_CURBLOCK :
1131 cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
1132 CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
1133 CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
1134 CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
1135 CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZEEITHER,
1136 cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
1137 cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
1138 cfg.resize_action == RESIZE_EITHER ? IDC_RESIZEEITHER :
1140 CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
1141 cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
1142 cfg.close_on_exit ==
1143 COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
1144 CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
1146 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1147 SetDlgItemText(hwnd, IDC_TSEDIT, cfg.termspeed);
1148 SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
1149 SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
1150 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1151 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
1152 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATPACKET,
1153 cfg.logtype == LGTYP_NONE ? IDC_LSTATOFF :
1154 cfg.logtype == LGTYP_ASCII ? IDC_LSTATASCII :
1155 cfg.logtype == LGTYP_DEBUG ? IDC_LSTATRAW :
1157 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
1158 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
1159 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
1162 char *p = cfg.environmt;
1163 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
1165 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
1171 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0,
1176 CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC,
1177 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
1178 CheckRadioButton(hwnd, IDC_TPASSIVE, IDC_TACTIVE,
1179 cfg.passive_telnet ? IDC_TPASSIVE : IDC_TACTIVE);
1181 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1182 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1183 CheckDlgButton(hwnd, IDC_NOPTY, cfg.nopty);
1184 CheckDlgButton(hwnd, IDC_COMPRESS, cfg.compression);
1185 CheckDlgButton(hwnd, IDC_SSH2DES, cfg.ssh2_des_cbc);
1186 CheckDlgButton(hwnd, IDC_AGENTFWD, cfg.agentfwd);
1187 CheckDlgButton(hwnd, IDC_CHANGEUSER, cfg.change_username);
1188 CheckRadioButton(hwnd, IDC_SSHPROT1ONLY, IDC_SSHPROT2ONLY,
1189 cfg.sshprot == 1 ? IDC_SSHPROT1 :
1190 cfg.sshprot == 2 ? IDC_SSHPROT2 :
1191 cfg.sshprot == 3 ? IDC_SSHPROT2ONLY : IDC_SSHPROT1ONLY);
1192 CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
1193 CheckDlgButton(hwnd, IDC_AUTHKI, cfg.try_ki_auth);
1194 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
1195 SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
1199 static const struct { char *s; int c; } ciphers[] = {
1200 { "3DES", CIPHER_3DES },
1201 { "Blowfish", CIPHER_BLOWFISH },
1202 { "DES", CIPHER_DES },
1203 { "AES (SSH 2 only)", CIPHER_AES },
1204 { "-- warn below here --", CIPHER_WARN }
1207 /* Set up the "selected ciphers" box. */
1208 /* (cipherlist assumed to contain all ciphers) */
1209 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_RESETCONTENT, 0, 0);
1210 for (i = 0; i < CIPHER_MAX; i++) {
1211 int c = cfg.ssh_cipherlist[i];
1214 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
1215 if (ciphers[j].c == c) {
1216 cstr = ciphers[j].s;
1220 pos = SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_ADDSTRING,
1222 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_SETITEMDATA,
1228 CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
1229 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
1230 CheckRadioButton(hwnd, IDC_SELTYPELEX, IDC_SELTYPERECT,
1231 cfg.rect_select == 0 ? IDC_SELTYPELEX : IDC_SELTYPERECT);
1232 CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
1233 CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
1234 CheckDlgButton(hwnd, IDC_RTFPASTE, cfg.rtf_paste);
1236 static int tabs[4] = { 25, 61, 96, 128 };
1237 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
1240 for (i = 0; i < 128; i++) {
1242 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
1243 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg.wordness[i]);
1244 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
1248 CheckDlgButton(hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
1249 CheckDlgButton(hwnd, IDC_PALETTE, cfg.try_palette);
1252 n = SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
1253 for (i = n; i-- > 0;)
1254 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
1255 LB_DELETESTRING, i, 0);
1256 for (i = 0; i < 22; i++)
1257 if (cfg.bold_colour || permcolour[i])
1258 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
1259 (LPARAM) colours[i]);
1261 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
1262 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
1263 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
1264 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
1269 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
1270 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
1271 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
1272 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
1273 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
1276 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
1282 pe = printer_start_enum(&nprinters);
1283 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_RESETCONTENT, 0, 0);
1284 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1285 0, (LPARAM) PRINTER_DISABLED_STRING);
1286 for (i = 0; i < nprinters; i++) {
1287 char *printer_name = printer_get_name(pe, i);
1288 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1289 0, (LPARAM) printer_name);
1291 printer_finish_enum(pe);
1292 SetDlgItemText(hwnd, IDC_PRINTER,
1293 *cfg.printer ? cfg.printer : PRINTER_DISABLED_STRING);
1296 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
1297 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
1298 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
1299 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
1300 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
1303 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
1304 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
1306 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
1307 CheckDlgButton(hwnd, IDC_RPORT_ALL, cfg.rport_acceptall);
1308 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
1311 CheckRadioButton(hwnd, IDC_PROXYTYPENONE, IDC_PROXYTYPETELNET,
1312 cfg.proxy_type == PROXY_HTTP ? IDC_PROXYTYPEHTTP :
1313 cfg.proxy_type == PROXY_SOCKS ? IDC_PROXYTYPESOCKS :
1314 cfg.proxy_type == PROXY_TELNET ? IDC_PROXYTYPETELNET : IDC_PROXYTYPENONE);
1315 SetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host);
1316 SetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, cfg.proxy_port, FALSE);
1317 SetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT, cfg.proxy_exclude_list);
1318 SetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT, cfg.proxy_telnet_command);
1319 SetDlgItemText(hwnd, IDC_PROXYUSEREDIT, cfg.proxy_username);
1320 SetDlgItemText(hwnd, IDC_PROXYPASSEDIT, cfg.proxy_password);
1321 CheckRadioButton(hwnd, IDC_PROXYSOCKSVER5, IDC_PROXYSOCKSVER4,
1322 cfg.proxy_socks_version == 4 ? IDC_PROXYSOCKSVER4 : IDC_PROXYSOCKSVER5);
1324 /* SSH bugs config */
1325 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_RESETCONTENT, 0, 0);
1326 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1327 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"Off");
1328 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"On");
1329 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_SETCURSEL,
1330 cfg.sshbug_ignore1 == BUG_ON ? 2 :
1331 cfg.sshbug_ignore1 == BUG_OFF ? 1 : 0, 0);
1332 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_RESETCONTENT, 0, 0);
1333 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1334 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Off");
1335 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"On");
1336 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_SETCURSEL,
1337 cfg.sshbug_plainpw1 == BUG_ON ? 2 :
1338 cfg.sshbug_plainpw1 == BUG_OFF ? 1 : 0, 0);
1339 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_RESETCONTENT, 0, 0);
1340 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1341 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Off");
1342 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"On");
1343 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_SETCURSEL,
1344 cfg.sshbug_rsa1 == BUG_ON ? 2 :
1345 cfg.sshbug_rsa1 == BUG_OFF ? 1 : 0, 0);
1346 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_RESETCONTENT, 0, 0);
1347 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1348 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Off");
1349 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"On");
1350 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_SETCURSEL,
1351 cfg.sshbug_hmac2 == BUG_ON ? 2 :
1352 cfg.sshbug_hmac2 == BUG_OFF ? 1 : 0, 0);
1353 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_RESETCONTENT, 0, 0);
1354 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1355 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Off");
1356 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"On");
1357 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_SETCURSEL,
1358 cfg.sshbug_derivekey2 == BUG_ON ? 2 :
1359 cfg.sshbug_derivekey2 == BUG_OFF ? 1 : 0, 0);
1360 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_RESETCONTENT, 0, 0);
1361 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1362 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Off");
1363 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"On");
1364 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_SETCURSEL,
1365 cfg.sshbug_rsapad2 == BUG_ON ? 2 :
1366 cfg.sshbug_rsapad2 == BUG_OFF ? 1 : 0, 0);
1369 struct treeview_faff {
1371 HTREEITEM lastat[4];
1374 static HTREEITEM treeview_insert(struct treeview_faff *faff,
1375 int level, char *text)
1380 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
1381 ins.hInsertAfter = faff->lastat[level];
1382 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1383 #define INSITEM DUMMYUNIONNAME.item
1385 #define INSITEM item
1387 ins.INSITEM.mask = TVIF_TEXT;
1388 ins.INSITEM.pszText = text;
1389 newitem = TreeView_InsertItem(faff->treeview, &ins);
1391 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
1393 faff->lastat[level] = newitem;
1394 for (i = level + 1; i < 4; i++)
1395 faff->lastat[i] = NULL;
1400 * Create the panelfuls of controls in the configuration box.
1402 static void create_controls(HWND hwnd, int dlgtype, int panel)
1404 if (panel == sessionpanelstart) {
1405 /* The Session panel. Accelerators used: [acgoh] nprtis elvd w */
1407 ctlposinit(&cp, hwnd, 80, 3, 13);
1408 bartitle(&cp, "Basic options for your PuTTY session",
1411 beginbox(&cp, "Specify your connection by host name or IP address",
1414 "Host &Name (or IP address)",
1415 IDC_HOSTSTATIC, IDC_HOST, 75,
1416 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
1417 if (backends[3].backend == NULL) {
1418 /* this is PuTTYtel, so only three protocols available */
1419 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
1420 "&Raw", IDC_PROTRAW,
1421 "&Telnet", IDC_PROTTELNET,
1422 "Rlog&in", IDC_PROTRLOGIN, NULL);
1424 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
1425 "&Raw", IDC_PROTRAW,
1426 "&Telnet", IDC_PROTTELNET,
1427 "Rlog&in", IDC_PROTRLOGIN,
1436 beginbox(&cp, "Load, save or delete a stored session",
1438 sesssaver(&cp, "Sav&ed Sessions",
1439 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
1440 "&Load", IDC_SESSLOAD,
1441 "Sa&ve", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
1444 beginbox(&cp, NULL, IDC_BOX_SESSION3);
1445 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
1446 "Always", IDC_COEALWAYS,
1447 "Never", IDC_COENEVER,
1448 "Only on clean exit", IDC_COENORMAL, NULL);
1452 if (panel == loggingpanelstart) {
1453 /* The Logging panel. Accelerators used: [acgoh] tplsfwe */
1455 ctlposinit(&cp, hwnd, 80, 3, 13);
1456 bartitle(&cp, "Options controlling session logging",
1458 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
1460 "Session logging:", IDC_LSTATSTATIC,
1461 "Logging &turned off completely", IDC_LSTATOFF,
1462 "Log &printable output only", IDC_LSTATASCII,
1463 "&Log all session output", IDC_LSTATRAW,
1464 "Log &SSH packet data", IDC_LSTATPACKET,
1466 editbutton(&cp, "Log &file name:",
1467 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
1469 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
1470 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
1472 "What to do if the log file already &exists:",
1473 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
1474 "Always append to the end of it", IDC_LSTATXAPN,
1475 "Ask the user every time", IDC_LSTATXASK, NULL);
1479 if (panel == terminalpanelstart) {
1480 /* The Terminal panel. Accelerators used: [acgoh] wdren lts p */
1482 ctlposinit(&cp, hwnd, 80, 3, 13);
1483 bartitle(&cp, "Options controlling the terminal emulation",
1484 IDC_TITLE_TERMINAL);
1485 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
1486 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
1487 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
1488 checkbox(&cp, "Implicit C&R in every LF", IDC_LFHASCR);
1489 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
1490 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
1492 "An&swerback to ^E:", IDC_ANSWERBACK,
1493 IDC_ANSWEREDIT, 100, NULL);
1496 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
1497 radioline(&cp, "&Local echo:", IDC_ECHOSTATIC, 3,
1498 "Auto", IDC_ECHOBACKEND,
1499 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
1500 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
1501 "Auto", IDC_EDITBACKEND,
1502 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
1505 beginbox(&cp, "Remote-controlled printing", IDC_BOX_TERMINAL3);
1506 combobox(&cp, "&Printer to send ANSI printer output to:",
1507 IDC_PRINTERSTATIC, IDC_PRINTER);
1511 if (panel == featurespanelstart) {
1512 /* The Features panel. Accelerators used: [acgoh] ukswtbrx */
1514 ctlposinit(&cp, hwnd, 80, 3, 13);
1515 bartitle(&cp, "Enabling and disabling advanced terminal features ",
1516 IDC_TITLE_FEATURES);
1517 beginbox(&cp, NULL, IDC_BOX_FEATURES1);
1518 checkbox(&cp, "Disable application c&ursor keys mode", IDC_NOAPPLICC);
1519 checkbox(&cp, "Disable application &keypad mode", IDC_NOAPPLICK);
1520 checkbox(&cp, "Disable &xterm-style mouse reporting", IDC_NOMOUSEREP);
1521 checkbox(&cp, "Disable remote-controlled terminal re&sizing",
1523 checkbox(&cp, "Disable s&witching to alternate terminal screen",
1525 checkbox(&cp, "Disable remote-controlled window &title changing",
1527 checkbox(&cp, "Disable destructive &backspace on server sending ^?",
1529 checkbox(&cp, "Disable remote-controlled cha&racter set configuration",
1534 if (panel == bellpanelstart) {
1535 /* The Bell panel. Accelerators used: [acgoh] bdsm wit */
1537 ctlposinit(&cp, hwnd, 80, 3, 13);
1538 bartitle(&cp, "Options controlling the terminal bell",
1540 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
1542 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
1543 "None (bell disabled)", IDC_BELL_DISABLED,
1544 "Play Windows Default Sound", IDC_BELL_DEFAULT,
1545 "Play a custom sound file", IDC_BELL_WAVEFILE,
1546 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
1547 editbutton(&cp, "Custom sound file to play as a bell:",
1548 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
1549 "Bro&wse...", IDC_BELL_WAVEBROWSE);
1550 radioline(&cp, "Taskbar/caption &indication on bell:",
1551 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
1552 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
1555 beginbox(&cp, "Control the bell overload behaviour",
1557 checkbox(&cp, "Bell is temporarily &disabled when over-used",
1559 staticedit(&cp, "Over-use means this &many bells...",
1560 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
1561 staticedit(&cp, "... in &this many seconds",
1562 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
1564 "The bell is re-enabled after a few seconds of silence.",
1565 1, IDC_BELLOVLEXPLAIN);
1566 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1571 if (panel == keyboardpanelstart) {
1572 /* The Keyboard panel. Accelerators used: [acgoh] bef rntd */
1574 ctlposinit(&cp, hwnd, 80, 3, 13);
1575 bartitle(&cp, "Options controlling the effects of keys",
1576 IDC_TITLE_KEYBOARD);
1577 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1578 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1579 "Control-H", IDC_DEL008,
1580 "Control-? (127)", IDC_DEL127, NULL);
1581 radioline(&cp, "The Home and &End keys", IDC_HOMESTATIC, 2,
1582 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1583 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1584 "ESC[n~", IDC_FUNCTILDE,
1585 "Linux", IDC_FUNCLINUX,
1586 "Xterm R6", IDC_FUNCXTERM,
1587 "VT400", IDC_FUNCVT400,
1588 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1590 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1591 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1592 "Normal", IDC_CURNORMAL,
1593 "Application", IDC_CURAPPLIC, NULL);
1594 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1595 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1596 "NetHack", IDC_KPNH, NULL);
1598 beginbox(&cp, "Enable extra keyboard features:",
1600 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1601 checkbox(&cp, "Control-Alt is &different from AltGr",
1606 if (panel == windowpanelstart) {
1607 /* The Window panel. Accelerators used: [acgoh] rmz sdikp */
1609 ctlposinit(&cp, hwnd, 80, 3, 13);
1610 bartitle(&cp, "Options controlling PuTTY's window",
1612 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1614 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1615 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
1616 radiobig(&cp, "When window is resi&zed:", IDC_RESIZESTATIC,
1617 "Change the number of rows and columns", IDC_RESIZETERM,
1618 "Change the size of the font", IDC_RESIZEFONT,
1619 "Change font size only when maximised", IDC_RESIZEEITHER,
1620 "Forbid resizing completely", IDC_RESIZENONE, NULL);
1622 beginbox(&cp, "Control the scrollback in the window",
1624 staticedit(&cp, "Lines of &scrollback",
1625 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1626 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
1627 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
1628 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1629 checkbox(&cp, "Reset scrollback on dis&play activity",
1634 if (panel == appearancepanelstart) {
1635 /* The Appearance panel. Accelerators used: [acgoh] luvb n ti p s */
1637 ctlposinit(&cp, hwnd, 80, 3, 13);
1638 bartitle(&cp, "Configure the appearance of PuTTY's window",
1639 IDC_TITLE_APPEARANCE);
1640 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1641 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1642 "B&lock", IDC_CURBLOCK,
1643 "&Underline", IDC_CURUNDER,
1644 "&Vertical line", IDC_CURVERT, NULL);
1645 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1647 beginbox(&cp, "Set the font used in the terminal window",
1648 IDC_BOX_APPEARANCE2);
1649 staticbtn(&cp, "", IDC_FONTSTATIC, "Cha&nge...", IDC_CHOOSEFONT);
1651 beginbox(&cp, "Adjust the use of the window title",
1652 IDC_BOX_APPEARANCE3);
1654 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1655 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
1657 beginbox(&cp, "Adjust the use of the mouse pointer",
1658 IDC_BOX_APPEARANCE4);
1659 checkbox(&cp, "Hide mouse &pointer when typing in window",
1662 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1663 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1665 staticedit(&cp, "Gap between text and window edge",
1666 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
1670 if (panel == behaviourpanelstart) {
1671 /* The Behaviour panel. Accelerators used: [acgoh] w4yltf */
1673 ctlposinit(&cp, hwnd, 80, 3, 13);
1674 bartitle(&cp, "Configure the behaviour of PuTTY's window",
1676 beginbox(&cp, NULL, IDC_BOX_BEHAVIOUR1);
1677 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1678 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1679 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1680 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
1681 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1682 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1686 if (panel == translationpanelstart) {
1687 /* The Translation panel. Accelerators used: [acgoh] rxbepus */
1689 ctlposinit(&cp, hwnd, 80, 3, 13);
1690 bartitle(&cp, "Options controlling character set translation",
1691 IDC_TITLE_TRANSLATION);
1692 beginbox(&cp, "Character set translation on received data",
1693 IDC_BOX_TRANSLATION1);
1694 combobox(&cp, "&Received data assumed to be in which character set:",
1695 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1697 beginbox(&cp, "Enable character set translation on input data",
1698 IDC_BOX_TRANSLATION2);
1699 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
1702 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
1703 IDC_BOX_TRANSLATION3);
1705 "Handling of line drawing characters:", IDC_VTSTATIC,
1706 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1707 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1708 "Use font in O&EM mode only", IDC_VTOEMONLY,
1709 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1710 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
1714 if (panel == selectionpanelstart) {
1715 /* The Selection panel. Accelerators used: [acgoh] df wxp est nr */
1717 ctlposinit(&cp, hwnd, 80, 3, 13);
1718 bartitle(&cp, "Options controlling copy and paste",
1719 IDC_TITLE_SELECTION);
1720 beginbox(&cp, "Translation of pasted characters",
1721 IDC_BOX_SELECTION1);
1723 "&Don't translate line drawing chars into +, - and |",
1726 "Paste to clipboard in RT&F as well as plain text",
1729 beginbox(&cp, "Control which mouse button does which thing",
1730 IDC_BOX_SELECTION2);
1731 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1732 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1733 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1736 "Shift overrides a&pplication's use of mouse",
1739 "Default selection mode (Alt+drag does the other one):",
1740 IDC_SELTYPESTATIC, 2,
1741 "&Normal", IDC_SELTYPELEX,
1742 "&Rectangular block", IDC_SELTYPERECT, NULL);
1744 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1745 IDC_BOX_SELECTION3);
1746 charclass(&cp, "Charact&er classes:", IDC_CCSTATIC, IDC_CCLIST,
1747 "&Set", IDC_CCSET, IDC_CCEDIT,
1748 "&to class", IDC_CCSTATIC2);
1752 if (panel == colourspanelstart) {
1753 /* The Colours panel. Accelerators used: [acgoh] blum */
1755 ctlposinit(&cp, hwnd, 80, 3, 13);
1756 bartitle(&cp, "Options controlling use of colours",
1758 beginbox(&cp, "General options for colour usage",
1760 checkbox(&cp, "&Bolded text is a different colour",
1762 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1764 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1766 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1767 IDC_COLOURSTATIC, IDC_COLOURLIST,
1768 "&Modify...", IDC_CHANGE,
1769 "Red:", IDC_RSTATIC, IDC_RVALUE,
1770 "Green:", IDC_GSTATIC, IDC_GVALUE,
1771 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1775 if (panel == connectionpanelstart) {
1776 /* The Connection panel. Accelerators used: [acgoh] tukn */
1778 ctlposinit(&cp, hwnd, 80, 3, 13);
1779 bartitle(&cp, "Options controlling the connection",
1780 IDC_TITLE_CONNECTION);
1782 beginbox(&cp, "Data to send to the server",
1783 IDC_BOX_CONNECTION1);
1784 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1786 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1790 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1791 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1793 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1797 beginbox(&cp, "Sending of null packets to keep session active",
1798 IDC_BOX_CONNECTION2);
1799 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1800 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1803 beginbox(&cp, "Low-level TCP connection options",
1804 IDC_BOX_CONNECTION3);
1805 checkbox(&cp, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1811 if (panel == proxypanelstart) {
1812 /* The Proxy panel. Accelerators used: [acgoh] ntslypeuwmv */
1814 ctlposinit(&cp, hwnd, 80, 3, 13);
1816 bartitle(&cp, "Options controlling proxy usage",
1818 beginbox(&cp, "Proxy basics", IDC_BOX_PROXY1);
1819 radioline(&cp, "Proxy type:", IDC_PROXYTYPESTATIC, 4,
1820 "&None", IDC_PROXYTYPENONE,
1821 "H&TTP", IDC_PROXYTYPEHTTP,
1822 "&SOCKS", IDC_PROXYTYPESOCKS,
1823 "Te&lnet", IDC_PROXYTYPETELNET, NULL);
1825 "Prox&y Host", IDC_PROXYHOSTSTATIC, IDC_PROXYHOSTEDIT, 80,
1826 "&Port", IDC_PROXYPORTSTATIC, IDC_PROXYPORTEDIT, 20, NULL);
1828 "&Exclude Hosts/IPs", IDC_PROXYEXCLUDESTATIC,
1829 IDC_PROXYEXCLUDEEDIT, 100, NULL);
1830 staticedit(&cp, "&Username", IDC_PROXYUSERSTATIC,
1831 IDC_PROXYUSEREDIT, 60);
1832 staticpassedit(&cp, "Pass&word", IDC_PROXYPASSSTATIC,
1833 IDC_PROXYPASSEDIT, 60);
1835 beginbox(&cp, "Misc. proxy settings", IDC_BOX_PROXY2);
1837 "Telnet co&mmand", IDC_PROXYTELNETCMDSTATIC,
1838 IDC_PROXYTELNETCMDEDIT, 100, NULL);
1839 radioline(&cp, "SOCKS &Version", IDC_PROXYSOCKSVERSTATIC,
1840 2, "Version 5", IDC_PROXYSOCKSVER5, "Version 4",
1841 IDC_PROXYSOCKSVER4, NULL);
1846 if (panel == telnetpanelstart) {
1847 /* The Telnet panel. Accelerators used: [acgoh] svldr bftk */
1849 ctlposinit(&cp, hwnd, 80, 3, 13);
1851 bartitle(&cp, "Options controlling Telnet connections",
1853 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1854 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1856 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1857 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1858 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1859 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1861 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1862 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1863 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1864 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1865 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1866 "Passive", IDC_TPASSIVE, "Active",
1868 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1870 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1876 if (panel == rloginpanelstart) {
1877 /* The Rlogin panel. Accelerators used: [acgoh] sl */
1879 ctlposinit(&cp, hwnd, 80, 3, 13);
1881 bartitle(&cp, "Options controlling Rlogin connections",
1883 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1884 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1886 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1887 IDC_RLLUSEREDIT, 50);
1892 if (panel == sshpanelstart) {
1893 /* The SSH panel. Accelerators used: [acgoh] r pe12ni sd */
1895 ctlposinit(&cp, hwnd, 80, 3, 13);
1897 bartitle(&cp, "Options controlling SSH connections",
1899 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1901 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1904 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
1905 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1906 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1907 radioline(&cp, "Preferred SSH protocol version:",
1908 IDC_SSHPROTSTATIC, 4,
1909 "1 on&ly", IDC_SSHPROT1ONLY,
1910 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2,
1911 "2 o&nly", IDC_SSHPROT2ONLY, NULL);
1913 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1914 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1915 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1917 checkbox(&cp, "Enable non-standard use of single-&DES in SSH 2",
1923 if (panel == sshauthpanelstart) {
1924 /* The SSH authentication panel. Accelerators used: [acgoh] m fkiuw */
1926 ctlposinit(&cp, hwnd, 80, 3, 13);
1928 bartitle(&cp, "Options controlling SSH authentication",
1930 beginbox(&cp, "Authentication methods",
1932 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
1934 checkbox(&cp, "Attempt \"keyboard-&interactive\" authentication"
1935 " (SSH2)", IDC_AUTHKI);
1937 beginbox(&cp, "Authentication parameters",
1939 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
1940 checkbox(&cp, "Allow attempted changes of &username in SSH2",
1942 editbutton(&cp, "Private &key file for authentication:",
1943 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
1949 if (panel == sshbugspanelstart) {
1950 /* The SSH bugs panel. Accelerators used: [acgoh] isrmep */
1952 ctlposinit(&cp, hwnd, 80, 3, 13);
1954 bartitle(&cp, "Workarounds for SSH server bugs",
1956 beginbox(&cp, "Detection of known bugs in SSH servers",
1958 staticddl(&cp, "Chokes on SSH1 &ignore messages",
1959 IDC_BUGS_IGNORE1, IDC_BUGD_IGNORE1, 20);
1960 staticddl(&cp, "Refuses all SSH1 pa&ssword camouflage",
1961 IDC_BUGS_PLAINPW1, IDC_BUGD_PLAINPW1, 20);
1962 staticddl(&cp, "Chokes on SSH1 &RSA authentication",
1963 IDC_BUGS_RSA1, IDC_BUGD_RSA1, 20);
1964 staticddl(&cp, "Miscomputes SSH2 H&MAC keys",
1965 IDC_BUGS_HMAC2, IDC_BUGD_HMAC2, 20);
1966 staticddl(&cp, "Miscomputes SSH2 &encryption keys",
1967 IDC_BUGS_DERIVEKEY2, IDC_BUGD_DERIVEKEY2, 20);
1968 staticddl(&cp, "Requires &padding on SSH2 RSA signatures",
1969 IDC_BUGS_RSAPAD2, IDC_BUGD_RSAPAD2, 20);
1974 if (panel == tunnelspanelstart) {
1975 /* The Tunnels panel. Accelerators used: [acgoh] deilmrstxp */
1977 ctlposinit(&cp, hwnd, 80, 3, 13);
1979 bartitle(&cp, "Options controlling SSH tunnelling",
1981 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
1982 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
1983 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
1984 IDC_X11_DISPLAY, 50, NULL);
1986 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
1987 checkbox(&cp, "Local ports accept connections from o&ther hosts",
1989 checkbox(&cp, "Remote &ports do the same (SSH v2 only)",
1991 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
1992 "&Remove", IDC_PFWDREMOVE);
1993 fwdsetter(&cp, IDC_PFWDLIST,
1994 "Add new forwarded port:", IDC_PFWDSTATIC2,
1995 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
1996 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
1997 "A&dd", IDC_PFWDADD);
1998 bareradioline(&cp, 2,
1999 "&Local", IDC_PFWDLOCAL,
2000 "Re&mote", IDC_PFWDREMOTE, NULL);
2008 * Helper function to load the session selected in SESSLIST
2009 * if any, as this is done in more than one place in
2010 * GenericMainDlgProc(). 0 => failure.
2012 static int load_selected_session(HWND hwnd)
2014 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2015 LB_GETCURSEL, 0, 0);
2021 isdef = !strcmp(sessions[n], "Default Settings");
2022 load_settings(sessions[n], !isdef, &cfg);
2023 init_dlg_ctrls(hwnd, TRUE);
2025 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
2027 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
2028 /* Restore the selection, which will have been clobbered by
2029 * SESSEDIT handling. */
2030 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
2035 * This function is the configuration box.
2037 static int GenericMainDlgProc(HWND hwnd, UINT msg,
2038 WPARAM wParam, LPARAM lParam, int dlgtype)
2041 struct treeview_faff tvfaff;
2044 char filename[sizeof(cfg.keyfile)];
2047 char fontstatic[256];
2049 struct servent *service;
2051 static UINT draglistmsg = WM_NULL;
2056 SetWindowLong(hwnd, GWL_USERDATA, 0);
2058 SetWindowLong(hwnd, GWL_EXSTYLE,
2059 GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
2061 HWND item = GetDlgItem(hwnd, IDC_HELPBTN);
2063 DestroyWindow(item);
2065 requested_help = FALSE;
2066 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
2067 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
2069 * Centre the window.
2071 { /* centre the window */
2074 hw = GetDesktopWindow();
2075 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
2077 (rs.right + rs.left + rd.left - rd.right) / 2,
2078 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
2079 rd.right - rd.left, rd.bottom - rd.top, TRUE);
2083 * Create the tree view.
2091 r.right = r.left + 75;
2093 r.bottom = r.top + 10;
2094 MapDialogRect(hwnd, &r);
2095 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
2096 WS_CHILD | WS_VISIBLE,
2098 r.right - r.left, r.bottom - r.top,
2099 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
2101 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
2102 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2105 r.right = r.left + 75;
2107 r.bottom = r.top + 219;
2108 MapDialogRect(hwnd, &r);
2109 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
2110 WS_CHILD | WS_VISIBLE |
2111 WS_TABSTOP | TVS_HASLINES |
2112 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
2114 TVS_SHOWSELALWAYS, r.left, r.top,
2115 r.right - r.left, r.bottom - r.top,
2116 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
2118 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
2119 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2120 tvfaff.treeview = treeview;
2121 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
2125 * Set up the tree view contents.
2127 hsession = treeview_insert(&tvfaff, 0, "Session");
2128 treeview_insert(&tvfaff, 1, "Logging");
2129 treeview_insert(&tvfaff, 0, "Terminal");
2130 treeview_insert(&tvfaff, 1, "Keyboard");
2131 treeview_insert(&tvfaff, 1, "Bell");
2132 treeview_insert(&tvfaff, 1, "Features");
2133 treeview_insert(&tvfaff, 0, "Window");
2134 treeview_insert(&tvfaff, 1, "Appearance");
2135 treeview_insert(&tvfaff, 1, "Behaviour");
2136 treeview_insert(&tvfaff, 1, "Translation");
2137 treeview_insert(&tvfaff, 1, "Selection");
2138 treeview_insert(&tvfaff, 1, "Colours");
2139 treeview_insert(&tvfaff, 0, "Connection");
2141 treeview_insert(&tvfaff, 1, "Proxy");
2142 treeview_insert(&tvfaff, 1, "Telnet");
2143 treeview_insert(&tvfaff, 1, "Rlogin");
2144 if (backends[3].backend != NULL) {
2145 treeview_insert(&tvfaff, 1, "SSH");
2146 /* XXX long name is ugly */
2147 /* XXX make it closed by default? */
2148 treeview_insert(&tvfaff, 2, "Auth");
2149 treeview_insert(&tvfaff, 2, "Tunnels");
2150 treeview_insert(&tvfaff, 2, "Bugs");
2155 * Put the treeview selection on to the Session panel. This
2156 * should also cause creation of the relevant controls.
2158 TreeView_SelectItem(treeview, hsession);
2161 * Set focus into the first available control.
2165 ctl = GetDlgItem(hwnd, IDC_HOST);
2167 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
2171 SetWindowLong(hwnd, GWL_USERDATA, 1);
2172 sesslist_has_focus = 0;
2176 * Button release should trigger WM_OK if there was a
2177 * previous double click on the session list.
2181 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
2184 if (LOWORD(wParam) == IDCX_TREEVIEW &&
2185 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
2187 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
2192 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
2195 item.pszText = buffer;
2196 item.cchTextMax = sizeof(buffer);
2197 item.mask = TVIF_TEXT;
2198 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
2199 for (j = controlstartvalue; j < controlendvalue; j++) {
2200 HWND item = GetDlgItem(hwnd, j);
2202 DestroyWindow(item);
2204 if (!strcmp(buffer, "Session"))
2205 create_controls(hwnd, dlgtype, sessionpanelstart);
2206 if (!strcmp(buffer, "Logging"))
2207 create_controls(hwnd, dlgtype, loggingpanelstart);
2208 if (!strcmp(buffer, "Keyboard"))
2209 create_controls(hwnd, dlgtype, keyboardpanelstart);
2210 if (!strcmp(buffer, "Terminal"))
2211 create_controls(hwnd, dlgtype, terminalpanelstart);
2212 if (!strcmp(buffer, "Bell"))
2213 create_controls(hwnd, dlgtype, bellpanelstart);
2214 if (!strcmp(buffer, "Features"))
2215 create_controls(hwnd, dlgtype, featurespanelstart);
2216 if (!strcmp(buffer, "Window"))
2217 create_controls(hwnd, dlgtype, windowpanelstart);
2218 if (!strcmp(buffer, "Appearance"))
2219 create_controls(hwnd, dlgtype, appearancepanelstart);
2220 if (!strcmp(buffer, "Behaviour"))
2221 create_controls(hwnd, dlgtype, behaviourpanelstart);
2222 if (!strcmp(buffer, "Tunnels"))
2223 create_controls(hwnd, dlgtype, tunnelspanelstart);
2224 if (!strcmp(buffer, "Connection"))
2225 create_controls(hwnd, dlgtype, connectionpanelstart);
2226 if (!strcmp(buffer, "Proxy"))
2227 create_controls(hwnd, dlgtype, proxypanelstart);
2228 if (!strcmp(buffer, "Telnet"))
2229 create_controls(hwnd, dlgtype, telnetpanelstart);
2230 if (!strcmp(buffer, "Rlogin"))
2231 create_controls(hwnd, dlgtype, rloginpanelstart);
2232 if (!strcmp(buffer, "SSH"))
2233 create_controls(hwnd, dlgtype, sshpanelstart);
2234 if (!strcmp(buffer, "Auth"))
2235 create_controls(hwnd, dlgtype, sshauthpanelstart);
2236 if (!strcmp(buffer, "Bugs"))
2237 create_controls(hwnd, dlgtype, sshbugspanelstart);
2238 if (!strcmp(buffer, "Selection"))
2239 create_controls(hwnd, dlgtype, selectionpanelstart);
2240 if (!strcmp(buffer, "Colours"))
2241 create_controls(hwnd, dlgtype, colourspanelstart);
2242 if (!strcmp(buffer, "Translation"))
2243 create_controls(hwnd, dlgtype, translationpanelstart);
2245 init_dlg_ctrls(hwnd, FALSE);
2247 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
2248 InvalidateRect (hwnd, NULL, TRUE);
2250 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
2256 * Only process WM_COMMAND once the dialog is fully formed.
2258 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
2259 switch (LOWORD(wParam)) {
2261 /* Behaviour of the "Open" button is different if the
2262 * session list has focus, *unless* the user just
2263 * double-clicked... */
2264 if (sesslist_has_focus && !readytogo) {
2265 if (!load_selected_session(hwnd)) {
2270 /* If at this point we have a valid session, go! */
2272 if (requested_help) {
2273 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2274 requested_help = FALSE;
2281 if (HIWORD(wParam) == BN_CLICKED ||
2282 HIWORD(wParam) == BN_DOUBLECLICKED) {
2284 WinHelp(hwnd, help_path,
2285 help_has_contents ? HELP_FINDER : HELP_CONTENTS,
2287 requested_help = TRUE;
2292 if (requested_help) {
2293 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2294 requested_help = FALSE;
2298 case IDC_PROTTELNET:
2299 case IDC_PROTRLOGIN:
2302 if (HIWORD(wParam) == BN_CLICKED ||
2303 HIWORD(wParam) == BN_DOUBLECLICKED) {
2304 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
2305 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
2306 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
2308 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
2311 * When switching using the arrow keys, we
2312 * appear to get two of these messages, both
2313 * mentioning the target button in
2314 * LOWORD(wParam), but one of them called while
2315 * the previous button is still checked. This
2316 * causes an unnecessary reset of the port
2317 * number field, which we fix by ensuring here
2318 * that the button selected is indeed the one
2321 if (IsDlgButtonChecked(hwnd, LOWORD(wParam)) &&
2322 ((cfg.protocol == PROT_SSH && cfg.port != 22)
2323 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
2324 || (cfg.protocol == PROT_RLOGIN
2325 && cfg.port != 513))) {
2326 cfg.port = i ? 22 : j ? 23 : 513;
2327 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
2332 if (HIWORD(wParam) == EN_CHANGE)
2333 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
2334 sizeof(cfg.host) - 1);
2337 if (HIWORD(wParam) == EN_CHANGE) {
2338 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
2339 if (isdigit(portname[0]))
2340 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
2342 service = getservbyname(portname, NULL);
2344 cfg.port = ntohs(service->s_port);
2351 if (HIWORD(wParam) == EN_CHANGE) {
2352 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2354 GetDlgItemText(hwnd, IDC_SESSEDIT,
2355 savedsession, sizeof(savedsession) - 1);
2356 savedsession[sizeof(savedsession) - 1] = '\0';
2360 if (HIWORD(wParam) == BN_CLICKED ||
2361 HIWORD(wParam) == BN_DOUBLECLICKED) {
2366 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
2369 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2370 LB_GETCURSEL, 0, 0);
2375 strcpy(str, sessions[n]);
2377 save_settings(str, !!strcmp(str, "Default Settings"),
2379 get_sesslist(FALSE);
2381 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2383 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2385 for (i = 0; i < nsessions; i++)
2386 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2388 (LPARAM) (sessions[i]));
2389 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2391 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2393 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2399 if (LOWORD(wParam) == IDC_SESSLIST) {
2400 if (HIWORD(wParam) == LBN_SETFOCUS)
2401 sesslist_has_focus = 1;
2402 else if (HIWORD(wParam) == LBN_KILLFOCUS)
2403 sesslist_has_focus = 0;
2405 if (LOWORD(wParam) == IDC_SESSLOAD &&
2406 HIWORD(wParam) != BN_CLICKED &&
2407 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2408 if (LOWORD(wParam) == IDC_SESSLIST &&
2409 HIWORD(wParam) != LBN_DBLCLK) break;
2410 /* Load the session selected in SESSLIST. */
2411 if (load_selected_session(hwnd) &&
2412 LOWORD(wParam) == IDC_SESSLIST) {
2414 * A double-click on a saved session should
2415 * actually start the session, not just load it.
2416 * Unless it's Default Settings or some other
2417 * host-less set of saved settings.
2426 if (HIWORD(wParam) == BN_CLICKED ||
2427 HIWORD(wParam) == BN_DOUBLECLICKED) {
2428 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2429 LB_GETCURSEL, 0, 0);
2430 if (n == LB_ERR || n == 0) {
2434 del_settings(sessions[n]);
2435 get_sesslist(FALSE);
2437 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2439 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2441 for (i = 0; i < nsessions; i++)
2442 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2444 (LPARAM) (sessions[i]));
2445 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2447 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2449 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2453 if (HIWORD(wParam) == EN_CHANGE)
2454 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
2455 &cfg.ping_interval);
2458 if (HIWORD(wParam) == BN_CLICKED ||
2459 HIWORD(wParam) == BN_DOUBLECLICKED)
2461 IsDlgButtonChecked(hwnd, IDC_NODELAY);
2465 if (HIWORD(wParam) == BN_CLICKED ||
2466 HIWORD(wParam) == BN_DOUBLECLICKED)
2467 cfg.bksp_is_delete =
2468 IsDlgButtonChecked(hwnd, IDC_DEL127);
2472 if (HIWORD(wParam) == BN_CLICKED ||
2473 HIWORD(wParam) == BN_DOUBLECLICKED)
2475 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
2481 case IDC_FUNCVT100P:
2483 if (HIWORD(wParam) == BN_CLICKED ||
2484 HIWORD(wParam) == BN_DOUBLECLICKED)
2485 switch (LOWORD(wParam)) {
2498 case IDC_FUNCVT100P:
2508 if (HIWORD(wParam) == BN_CLICKED ||
2509 HIWORD(wParam) == BN_DOUBLECLICKED) {
2511 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
2512 cfg.nethack_keypad = FALSE;
2516 if (HIWORD(wParam) == BN_CLICKED ||
2517 HIWORD(wParam) == BN_DOUBLECLICKED) {
2518 cfg.app_keypad = FALSE;
2519 cfg.nethack_keypad = TRUE;
2524 if (HIWORD(wParam) == BN_CLICKED ||
2525 HIWORD(wParam) == BN_DOUBLECLICKED)
2527 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
2530 if (HIWORD(wParam) == BN_CLICKED ||
2531 HIWORD(wParam) == BN_DOUBLECLICKED)
2533 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
2536 if (HIWORD(wParam) == BN_CLICKED ||
2537 HIWORD(wParam) == BN_DOUBLECLICKED)
2539 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
2541 case IDC_NOMOUSEREP:
2542 if (HIWORD(wParam) == BN_CLICKED ||
2543 HIWORD(wParam) == BN_DOUBLECLICKED)
2545 IsDlgButtonChecked(hwnd, IDC_NOMOUSEREP);
2548 if (HIWORD(wParam) == BN_CLICKED ||
2549 HIWORD(wParam) == BN_DOUBLECLICKED)
2550 cfg.no_remote_resize =
2551 IsDlgButtonChecked(hwnd, IDC_NORESIZE);
2553 case IDC_NOALTSCREEN:
2554 if (HIWORD(wParam) == BN_CLICKED ||
2555 HIWORD(wParam) == BN_DOUBLECLICKED)
2557 IsDlgButtonChecked(hwnd, IDC_NOALTSCREEN);
2559 case IDC_NOWINTITLE:
2560 if (HIWORD(wParam) == BN_CLICKED ||
2561 HIWORD(wParam) == BN_DOUBLECLICKED)
2562 cfg.no_remote_wintitle =
2563 IsDlgButtonChecked(hwnd, IDC_NOWINTITLE);
2565 case IDC_NODBACKSPACE:
2566 if (HIWORD(wParam) == BN_CLICKED ||
2567 HIWORD(wParam) == BN_DOUBLECLICKED)
2569 IsDlgButtonChecked(hwnd, IDC_NODBACKSPACE);
2572 if (HIWORD(wParam) == BN_CLICKED ||
2573 HIWORD(wParam) == BN_DOUBLECLICKED)
2574 cfg.no_remote_charset =
2575 IsDlgButtonChecked(hwnd, IDC_NOCHARSET);
2578 if (HIWORD(wParam) == BN_CLICKED ||
2579 HIWORD(wParam) == BN_DOUBLECLICKED)
2580 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
2583 if (HIWORD(wParam) == BN_CLICKED ||
2584 HIWORD(wParam) == BN_DOUBLECLICKED)
2586 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
2589 if (HIWORD(wParam) == BN_CLICKED ||
2590 HIWORD(wParam) == BN_DOUBLECLICKED)
2592 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
2594 case IDC_ECHOBACKEND:
2597 if (HIWORD(wParam) == BN_CLICKED ||
2598 HIWORD(wParam) == BN_DOUBLECLICKED) {
2599 if (LOWORD(wParam) == IDC_ECHOBACKEND)
2600 cfg.localecho = LD_BACKEND;
2601 if (LOWORD(wParam) == IDC_ECHOYES)
2602 cfg.localecho = LD_YES;
2603 if (LOWORD(wParam) == IDC_ECHONO)
2604 cfg.localecho = LD_NO;
2607 case IDC_EDITBACKEND:
2610 if (HIWORD(wParam) == BN_CLICKED ||
2611 HIWORD(wParam) == BN_DOUBLECLICKED) {
2612 if (LOWORD(wParam) == IDC_EDITBACKEND)
2613 cfg.localedit = LD_BACKEND;
2614 if (LOWORD(wParam) == IDC_EDITYES)
2615 cfg.localedit = LD_YES;
2616 if (LOWORD(wParam) == IDC_EDITNO)
2617 cfg.localedit = LD_NO;
2620 case IDC_ANSWEREDIT:
2621 if (HIWORD(wParam) == EN_CHANGE)
2622 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
2623 sizeof(cfg.answerback) - 1);
2625 case IDC_ALWAYSONTOP:
2626 if (HIWORD(wParam) == BN_CLICKED ||
2627 HIWORD(wParam) == BN_DOUBLECLICKED)
2629 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
2631 case IDC_FULLSCREENONALTENTER:
2632 if (HIWORD(wParam) == BN_CLICKED ||
2633 HIWORD(wParam) == BN_DOUBLECLICKED)
2634 cfg.fullscreenonaltenter =
2635 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
2638 if (HIWORD(wParam) == BN_CLICKED ||
2639 HIWORD(wParam) == BN_DOUBLECLICKED)
2641 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
2643 case IDC_SCROLLDISP:
2644 if (HIWORD(wParam) == BN_CLICKED ||
2645 HIWORD(wParam) == BN_DOUBLECLICKED)
2646 cfg.scroll_on_disp =
2647 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
2649 case IDC_COMPOSEKEY:
2650 if (HIWORD(wParam) == BN_CLICKED ||
2651 HIWORD(wParam) == BN_DOUBLECLICKED)
2653 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
2655 case IDC_CTRLALTKEYS:
2656 if (HIWORD(wParam) == BN_CLICKED ||
2657 HIWORD(wParam) == BN_DOUBLECLICKED)
2659 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
2662 if (HIWORD(wParam) == BN_CLICKED ||
2663 HIWORD(wParam) == BN_DOUBLECLICKED)
2664 cfg.telnet_keyboard =
2665 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
2668 if (HIWORD(wParam) == BN_CLICKED ||
2669 HIWORD(wParam) == BN_DOUBLECLICKED)
2670 cfg.telnet_newline =
2671 IsDlgButtonChecked(hwnd, IDC_TELNETRET);
2674 if (HIWORD(wParam) == BN_CLICKED ||
2675 HIWORD(wParam) == BN_DOUBLECLICKED)
2677 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
2680 if (HIWORD(wParam) == BN_CLICKED ||
2681 HIWORD(wParam) == BN_DOUBLECLICKED)
2682 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
2685 if (HIWORD(wParam) == BN_CLICKED ||
2686 HIWORD(wParam) == BN_DOUBLECLICKED)
2688 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
2691 if (HIWORD(wParam) == EN_CHANGE)
2692 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
2695 if (HIWORD(wParam) == EN_CHANGE)
2696 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
2699 if (HIWORD(wParam) == EN_CHANGE)
2700 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
2702 case IDC_CHOOSEFONT:
2705 lf.lfHeight = -MulDiv(cfg.fontheight,
2706 GetDeviceCaps(hdc, LOGPIXELSY),
2710 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
2711 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
2712 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
2713 lf.lfCharSet = cfg.fontcharset;
2714 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
2715 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
2716 lf.lfQuality = DEFAULT_QUALITY;
2717 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
2718 strncpy(lf.lfFaceName, cfg.font,
2719 sizeof(lf.lfFaceName) - 1);
2720 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
2722 cf.lStructSize = sizeof(cf);
2723 cf.hwndOwner = hwnd;
2725 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
2726 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
2728 if (ChooseFont(&cf)) {
2729 strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
2730 cfg.font[sizeof(cfg.font) - 1] = '\0';
2731 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
2732 cfg.fontcharset = lf.lfCharSet;
2733 cfg.fontheight = cf.iPointSize / 10;
2734 fmtfont(fontstatic);
2735 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
2738 case IDC_BELL_DISABLED:
2739 case IDC_BELL_DEFAULT:
2740 case IDC_BELL_WAVEFILE:
2741 case IDC_BELL_VISUAL:
2742 if (HIWORD(wParam) == BN_CLICKED ||
2743 HIWORD(wParam) == BN_DOUBLECLICKED) {
2744 if (LOWORD(wParam) == IDC_BELL_DISABLED)
2745 cfg.beep = BELL_DISABLED;
2746 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
2747 cfg.beep = BELL_DEFAULT;
2748 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
2749 cfg.beep = BELL_WAVEFILE;
2750 if (LOWORD(wParam) == IDC_BELL_VISUAL)
2751 cfg.beep = BELL_VISUAL;
2754 case IDC_B_IND_DISABLED:
2755 case IDC_B_IND_FLASH:
2756 case IDC_B_IND_STEADY:
2757 if (HIWORD(wParam) == BN_CLICKED ||
2758 HIWORD(wParam) == BN_DOUBLECLICKED) {
2759 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2760 cfg.beep_ind = B_IND_DISABLED;
2761 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2762 cfg.beep_ind = B_IND_FLASH;
2763 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2764 cfg.beep_ind = B_IND_STEADY;
2767 case IDC_BELL_WAVEBROWSE:
2768 memset(&of, 0, sizeof(of));
2769 #ifdef OPENFILENAME_SIZE_VERSION_400
2770 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2772 of.lStructSize = sizeof(of);
2774 of.hwndOwner = hwnd;
2775 of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2776 of.lpstrCustomFilter = NULL;
2777 of.nFilterIndex = 1;
2778 of.lpstrFile = filename;
2779 strcpy(filename, cfg.bell_wavefile);
2780 of.nMaxFile = sizeof(filename);
2781 of.lpstrFileTitle = NULL;
2782 of.lpstrInitialDir = NULL;
2783 of.lpstrTitle = "Select Bell Sound File";
2785 if (GetOpenFileName(&of)) {
2786 strcpy(cfg.bell_wavefile, filename);
2787 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2791 case IDC_BELL_WAVEEDIT:
2792 if (HIWORD(wParam) == EN_CHANGE)
2793 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2795 sizeof(cfg.bell_wavefile) - 1);
2798 if (HIWORD(wParam) == BN_CLICKED ||
2799 HIWORD(wParam) == BN_DOUBLECLICKED)
2801 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2804 if (HIWORD(wParam) == EN_CHANGE)
2805 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2808 if (HIWORD(wParam) == EN_CHANGE)
2809 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2813 if (HIWORD(wParam) == EN_CHANGE)
2814 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2818 if (HIWORD(wParam) == BN_CLICKED ||
2819 HIWORD(wParam) == BN_DOUBLECLICKED)
2821 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2824 if (HIWORD(wParam) == BN_CLICKED ||
2825 HIWORD(wParam) == BN_DOUBLECLICKED)
2826 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2829 if (HIWORD(wParam) == BN_CLICKED ||
2830 HIWORD(wParam) == BN_DOUBLECLICKED)
2831 cfg.win_name_always =
2832 IsDlgButtonChecked(hwnd, IDC_WINNAME);
2835 if (HIWORD(wParam) == BN_CLICKED ||
2836 HIWORD(wParam) == BN_DOUBLECLICKED)
2838 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2840 case IDC_SUNKENEDGE:
2841 if (HIWORD(wParam) == BN_CLICKED ||
2842 HIWORD(wParam) == BN_DOUBLECLICKED)
2844 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2847 if (HIWORD(wParam) == EN_CHANGE)
2848 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2849 &cfg.window_border);
2850 if (cfg.window_border > 32)
2851 cfg.window_border = 32;
2854 if (HIWORD(wParam) == BN_CLICKED ||
2855 HIWORD(wParam) == BN_DOUBLECLICKED)
2856 cfg.cursor_type = 0;
2859 if (HIWORD(wParam) == BN_CLICKED ||
2860 HIWORD(wParam) == BN_DOUBLECLICKED)
2861 cfg.cursor_type = 1;
2864 if (HIWORD(wParam) == BN_CLICKED ||
2865 HIWORD(wParam) == BN_DOUBLECLICKED)
2866 cfg.cursor_type = 2;
2869 if (HIWORD(wParam) == BN_CLICKED ||
2870 HIWORD(wParam) == BN_DOUBLECLICKED)
2872 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2875 if (HIWORD(wParam) == BN_CLICKED ||
2876 HIWORD(wParam) == BN_DOUBLECLICKED)
2878 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2880 case IDC_SCROLLBARFULLSCREEN:
2881 if (HIWORD(wParam) == BN_CLICKED ||
2882 HIWORD(wParam) == BN_DOUBLECLICKED)
2883 cfg.scrollbar_in_fullscreen =
2884 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2886 case IDC_RESIZETERM:
2887 case IDC_RESIZEFONT:
2888 case IDC_RESIZENONE:
2889 case IDC_RESIZEEITHER:
2890 if (HIWORD(wParam) == BN_CLICKED ||
2891 HIWORD(wParam) == BN_DOUBLECLICKED) {
2893 IsDlgButtonChecked(hwnd,
2894 IDC_RESIZETERM) ? RESIZE_TERM :
2895 IsDlgButtonChecked(hwnd,
2896 IDC_RESIZEFONT) ? RESIZE_FONT :
2897 IsDlgButtonChecked(hwnd,
2898 IDC_RESIZEEITHER) ? RESIZE_EITHER :
2903 if (HIWORD(wParam) == EN_CHANGE)
2904 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2905 sizeof(cfg.wintitle) - 1);
2910 if (HIWORD(wParam) == BN_CLICKED ||
2911 HIWORD(wParam) == BN_DOUBLECLICKED) {
2913 IsDlgButtonChecked(hwnd,
2914 IDC_COEALWAYS) ? COE_ALWAYS :
2915 IsDlgButtonChecked(hwnd,
2916 IDC_COENEVER) ? COE_NEVER :
2921 if (HIWORD(wParam) == BN_CLICKED ||
2922 HIWORD(wParam) == BN_DOUBLECLICKED)
2924 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
2927 if (HIWORD(wParam) == EN_CHANGE)
2928 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
2929 sizeof(cfg.termtype) - 1);
2933 case IDC_PROXYHOSTEDIT:
2934 if (HIWORD(wParam) == EN_CHANGE)
2935 GetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host,
2936 sizeof(cfg.proxy_host) - 1);
2938 case IDC_PROXYPORTEDIT:
2939 if (HIWORD(wParam) == EN_CHANGE) {
2940 GetDlgItemText(hwnd, IDC_PROXYPORTEDIT, portname, 31);
2941 if (isdigit(portname[0]))
2942 MyGetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, &cfg.proxy_port);
2944 service = getservbyname(portname, NULL);
2946 cfg.proxy_port = ntohs(service->s_port);
2952 case IDC_PROXYEXCLUDEEDIT:
2953 if (HIWORD(wParam) == EN_CHANGE)
2954 GetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT,
2955 cfg.proxy_exclude_list,
2956 sizeof(cfg.proxy_exclude_list) - 1);
2958 case IDC_PROXYUSEREDIT:
2959 if (HIWORD(wParam) == EN_CHANGE)
2960 GetDlgItemText(hwnd, IDC_PROXYUSEREDIT,
2962 sizeof(cfg.proxy_username) - 1);
2964 case IDC_PROXYPASSEDIT:
2965 if (HIWORD(wParam) == EN_CHANGE)
2966 GetDlgItemText(hwnd, IDC_PROXYPASSEDIT,
2968 sizeof(cfg.proxy_password) - 1);
2970 case IDC_PROXYTELNETCMDEDIT:
2971 if (HIWORD(wParam) == EN_CHANGE)
2972 GetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT,
2973 cfg.proxy_telnet_command,
2974 sizeof(cfg.proxy_telnet_command) - 1);
2976 case IDC_PROXYSOCKSVER5:
2977 case IDC_PROXYSOCKSVER4:
2978 if (HIWORD(wParam) == BN_CLICKED ||
2979 HIWORD(wParam) == BN_DOUBLECLICKED) {
2980 cfg.proxy_socks_version =
2981 IsDlgButtonChecked(hwnd, IDC_PROXYSOCKSVER4) ? 4 : 5;
2984 case IDC_PROXYTYPENONE:
2985 case IDC_PROXYTYPEHTTP:
2986 case IDC_PROXYTYPESOCKS:
2987 case IDC_PROXYTYPETELNET:
2988 if (HIWORD(wParam) == BN_CLICKED ||
2989 HIWORD(wParam) == BN_DOUBLECLICKED) {
2991 IsDlgButtonChecked(hwnd, IDC_PROXYTYPEHTTP) ? PROXY_HTTP :
2992 IsDlgButtonChecked(hwnd, IDC_PROXYTYPESOCKS) ? PROXY_SOCKS :
2993 IsDlgButtonChecked(hwnd, IDC_PROXYTYPETELNET) ? PROXY_TELNET :
2999 if (HIWORD(wParam) == EN_CHANGE)
3000 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
3001 sizeof(cfg.logfilename) - 1);
3004 memset(&of, 0, sizeof(of));
3005 #ifdef OPENFILENAME_SIZE_VERSION_400
3006 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3008 of.lStructSize = sizeof(of);
3010 of.hwndOwner = hwnd;
3011 of.lpstrFilter = "All Files\0*\0\0\0";
3012 of.lpstrCustomFilter = NULL;
3013 of.nFilterIndex = 1;
3014 of.lpstrFile = filename;
3015 strcpy(filename, cfg.logfilename);
3016 of.nMaxFile = sizeof(filename);
3017 of.lpstrFileTitle = NULL;
3018 of.lpstrInitialDir = NULL;
3019 of.lpstrTitle = "Select session log file";
3021 if (GetSaveFileName(&of)) {
3022 strcpy(cfg.logfilename, filename);
3023 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
3027 case IDC_LSTATASCII:
3029 case IDC_LSTATPACKET:
3030 if (HIWORD(wParam) == BN_CLICKED ||
3031 HIWORD(wParam) == BN_DOUBLECLICKED) {
3032 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
3033 cfg.logtype = LGTYP_NONE;
3034 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
3035 cfg.logtype = LGTYP_ASCII;
3036 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
3037 cfg.logtype = LGTYP_DEBUG;
3038 if (IsDlgButtonChecked(hwnd, IDC_LSTATPACKET))
3039 cfg.logtype = LGTYP_PACKETS;
3045 if (HIWORD(wParam) == BN_CLICKED ||
3046 HIWORD(wParam) == BN_DOUBLECLICKED) {
3047 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
3048 cfg.logxfovr = LGXF_ASK;
3049 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
3050 cfg.logxfovr = LGXF_APN;
3051 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
3052 cfg.logxfovr = LGXF_OVR;
3057 if (HIWORD(wParam) == EN_CHANGE)
3058 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
3059 sizeof(cfg.termspeed) - 1);
3062 if (HIWORD(wParam) == EN_CHANGE)
3063 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
3064 sizeof(cfg.username) - 1);
3066 case IDC_RLLUSEREDIT:
3067 if (HIWORD(wParam) == EN_CHANGE)
3068 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
3070 sizeof(cfg.localusername) - 1);
3074 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
3078 cfg.passive_telnet =
3079 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
3082 if (HIWORD(wParam) == BN_CLICKED ||
3083 HIWORD(wParam) == BN_DOUBLECLICKED) {
3084 char str[sizeof(cfg.environmt)];
3086 GetDlgItemText(hwnd, IDC_VAREDIT, str,
3092 p = str + strlen(str);
3094 GetDlgItemText(hwnd, IDC_VALEDIT, p,
3095 sizeof(str) - 1 - (p - str));
3106 if ((p - cfg.environmt) + strlen(str) + 2 <
3107 sizeof(cfg.environmt)) {
3109 p[strlen(str) + 1] = '\0';
3110 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
3112 SetDlgItemText(hwnd, IDC_VAREDIT, "");
3113 SetDlgItemText(hwnd, IDC_VALEDIT, "");
3115 MessageBox(hwnd, "Environment too big",
3116 "PuTTY Error", MB_OK | MB_ICONERROR);
3121 if (HIWORD(wParam) != BN_CLICKED &&
3122 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3124 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
3131 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
3158 if (HIWORD(wParam) == BN_CLICKED ||
3159 HIWORD(wParam) == BN_DOUBLECLICKED)
3160 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
3163 if (HIWORD(wParam) == BN_CLICKED ||
3164 HIWORD(wParam) == BN_DOUBLECLICKED)
3166 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
3169 if (HIWORD(wParam) == BN_CLICKED ||
3170 HIWORD(wParam) == BN_DOUBLECLICKED)
3172 IsDlgButtonChecked(hwnd, IDC_SSH2DES);
3175 if (HIWORD(wParam) == BN_CLICKED ||
3176 HIWORD(wParam) == BN_DOUBLECLICKED)
3178 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
3180 case IDC_CHANGEUSER:
3181 if (HIWORD(wParam) == BN_CLICKED ||
3182 HIWORD(wParam) == BN_DOUBLECLICKED)
3183 cfg.change_username =
3184 IsDlgButtonChecked(hwnd, IDC_CHANGEUSER);
3186 case IDC_CIPHERLIST:
3189 handle_prefslist(&cipherlist,
3190 cfg.ssh_cipherlist, CIPHER_MAX,
3191 0, hwnd, wParam, lParam);
3193 case IDC_SSHPROT1ONLY:
3196 case IDC_SSHPROT2ONLY:
3197 if (HIWORD(wParam) == BN_CLICKED ||
3198 HIWORD(wParam) == BN_DOUBLECLICKED) {
3199 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1ONLY))
3201 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
3203 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
3205 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2ONLY))
3210 if (HIWORD(wParam) == BN_CLICKED ||
3211 HIWORD(wParam) == BN_DOUBLECLICKED)
3213 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
3216 if (HIWORD(wParam) == BN_CLICKED ||
3217 HIWORD(wParam) == BN_DOUBLECLICKED)
3219 IsDlgButtonChecked(hwnd, IDC_AUTHKI);
3222 if (HIWORD(wParam) == EN_CHANGE)
3223 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
3224 sizeof(cfg.keyfile) - 1);
3227 if (HIWORD(wParam) == EN_CHANGE)
3228 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
3229 sizeof(cfg.remote_cmd) - 1);
3232 memset(&of, 0, sizeof(of));
3233 #ifdef OPENFILENAME_SIZE_VERSION_400
3234 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3236 of.lStructSize = sizeof(of);
3238 of.hwndOwner = hwnd;
3239 of.lpstrFilter = "PuTTY Private Key Files\0*.PPK\0"
3240 "AllFiles\0*\0\0\0";
3241 of.lpstrCustomFilter = NULL;
3242 of.nFilterIndex = 1;
3243 of.lpstrFile = filename;
3244 strcpy(filename, cfg.keyfile);
3245 of.nMaxFile = sizeof(filename);
3246 of.lpstrFileTitle = NULL;
3247 of.lpstrInitialDir = NULL;
3248 of.lpstrTitle = "Select Private Key File";
3250 if (GetOpenFileName(&of)) {
3251 strcpy(cfg.keyfile, filename);
3252 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
3256 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
3259 cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
3263 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
3265 case IDC_SELTYPELEX:
3266 case IDC_SELTYPERECT:
3267 cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
3269 case IDC_MOUSEOVERRIDE:
3270 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
3276 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
3281 for (i = 0; i < 128; i++)
3282 if (SendDlgItemMessage
3283 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
3285 cfg.wordness[i] = n;
3286 SendDlgItemMessage(hwnd, IDC_CCLIST,
3287 LB_DELETESTRING, i, 0);
3288 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
3289 (i >= 0x21 && i != 0x7F) ? i : ' ',
3291 SendDlgItemMessage(hwnd, IDC_CCLIST,
3298 case IDC_BOLDCOLOUR:
3299 if (HIWORD(wParam) == BN_CLICKED ||
3300 HIWORD(wParam) == BN_DOUBLECLICKED) {
3303 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
3304 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
3307 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3309 if (n != 12 + 10 * cfg.bold_colour) {
3310 for (i = n; i-- > 0;)
3311 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3312 LB_DELETESTRING, i, 0);
3313 for (i = 0; i < 22; i++)
3314 if (cfg.bold_colour || permcolour[i])
3315 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3317 (LPARAM) colours[i]);
3319 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
3321 InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
3326 if (HIWORD(wParam) == BN_CLICKED ||
3327 HIWORD(wParam) == BN_DOUBLECLICKED)
3329 IsDlgButtonChecked(hwnd, IDC_PALETTE);
3331 case IDC_COLOURLIST:
3332 if (HIWORD(wParam) == LBN_DBLCLK ||
3333 HIWORD(wParam) == LBN_SELCHANGE) {
3335 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3338 if (!cfg.bold_colour)
3339 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3340 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3342 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3344 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3349 if (HIWORD(wParam) == BN_CLICKED ||
3350 HIWORD(wParam) == BN_DOUBLECLICKED) {
3351 static CHOOSECOLOR cc;
3352 static DWORD custom[16] = { 0 }; /* zero initialisers */
3354 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3357 if (!cfg.bold_colour)
3358 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3359 cc.lStructSize = sizeof(cc);
3360 cc.hwndOwner = hwnd;
3361 cc.hInstance = (HWND) hinst;
3362 cc.lpCustColors = custom;
3364 RGB(cfg.colours[i][0], cfg.colours[i][1],
3366 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
3367 if (ChooseColor(&cc)) {
3369 (unsigned char) (cc.rgbResult & 0xFF);
3371 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
3373 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
3374 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3376 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3378 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3384 if (HIWORD(wParam) == CBN_SELCHANGE) {
3385 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
3386 CB_GETCURSEL, 0, 0);
3387 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
3388 index, (LPARAM)cfg.line_codepage);
3389 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3390 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
3391 sizeof(cfg.line_codepage) - 1);
3392 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
3393 strcpy(cfg.line_codepage,
3394 cp_name(decode_codepage(cfg.line_codepage)));
3395 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
3399 if (HIWORD(wParam) == CBN_SELCHANGE) {
3400 int index = SendDlgItemMessage(hwnd, IDC_PRINTER,
3401 CB_GETCURSEL, 0, 0);
3402 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_GETLBTEXT,
3403 index, (LPARAM)cfg.printer);
3404 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3405 GetDlgItemText(hwnd, IDC_PRINTER, cfg.printer,
3406 sizeof(cfg.printer) - 1);
3408 if (!strcmp(cfg.printer, PRINTER_DISABLED_STRING))
3409 *cfg.printer = '\0';
3411 case IDC_CAPSLOCKCYR:
3412 if (HIWORD(wParam) == BN_CLICKED ||
3413 HIWORD(wParam) == BN_DOUBLECLICKED) {
3414 cfg.xlat_capslockcyr =
3415 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
3418 case IDC_VTXWINDOWS:
3424 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
3425 : IsDlgButtonChecked(hwnd,
3426 IDC_VTOEMANSI) ? VT_OEMANSI :
3427 IsDlgButtonChecked(hwnd,
3428 IDC_VTOEMONLY) ? VT_OEMONLY :
3429 IsDlgButtonChecked(hwnd,
3430 IDC_VTUNICODE) ? VT_UNICODE :
3433 case IDC_X11_FORWARD:
3434 if (HIWORD(wParam) == BN_CLICKED ||
3435 HIWORD(wParam) == BN_DOUBLECLICKED)
3437 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
3440 if (HIWORD(wParam) == BN_CLICKED ||
3441 HIWORD(wParam) == BN_DOUBLECLICKED)
3442 cfg.lport_acceptall =
3443 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
3446 if (HIWORD(wParam) == BN_CLICKED ||
3447 HIWORD(wParam) == BN_DOUBLECLICKED)
3448 cfg.rport_acceptall =
3449 IsDlgButtonChecked(hwnd, IDC_RPORT_ALL);
3451 case IDC_X11_DISPLAY:
3452 if (HIWORD(wParam) == EN_CHANGE)
3453 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
3454 sizeof(cfg.x11_display) - 1);
3457 if (HIWORD(wParam) == BN_CLICKED ||
3458 HIWORD(wParam) == BN_DOUBLECLICKED) {
3459 char str[sizeof(cfg.portfwd)];
3461 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
3465 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
3469 "You need to specify a source port number",
3470 "PuTTY Error", MB_OK | MB_ICONERROR);
3473 p = str + strlen(str);
3475 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
3476 sizeof(str) - 1 - (p - str));
3477 if (!*p || !strchr(p, ':')) {
3479 "You need to specify a destination address\n"
3480 "in the form \"host.name:port\"",
3481 "PuTTY Error", MB_OK | MB_ICONERROR);
3490 if ((p - cfg.portfwd) + strlen(str) + 2 <
3491 sizeof(cfg.portfwd)) {
3493 p[strlen(str) + 1] = '\0';
3494 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
3496 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
3497 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
3499 MessageBox(hwnd, "Too many forwardings",
3500 "PuTTY Error", MB_OK | MB_ICONERROR);
3504 case IDC_PFWDREMOVE:
3505 if (HIWORD(wParam) != BN_CLICKED &&
3506 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3507 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
3508 LB_GETCURSEL, 0, 0);
3514 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
3540 case IDC_BUGD_IGNORE1:
3541 if (HIWORD(wParam) == CBN_SELCHANGE) {
3542 int index = SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1,
3543 CB_GETCURSEL, 0, 0);
3544 cfg.sshbug_ignore1 = (index == 0 ? BUG_AUTO :
3545 index == 1 ? BUG_OFF : BUG_ON);
3548 case IDC_BUGD_PLAINPW1:
3549 if (HIWORD(wParam) == CBN_SELCHANGE) {
3550 int index = SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1,
3551 CB_GETCURSEL, 0, 0);
3552 cfg.sshbug_plainpw1 = (index == 0 ? BUG_AUTO :
3553 index == 1 ? BUG_OFF : BUG_ON);
3557 if (HIWORD(wParam) == CBN_SELCHANGE) {
3558 int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSA1,
3559 CB_GETCURSEL, 0, 0);
3560 cfg.sshbug_rsa1 = (index == 0 ? BUG_AUTO :
3561 index == 1 ? BUG_OFF : BUG_ON);
3564 case IDC_BUGD_HMAC2:
3565 if (HIWORD(wParam) == CBN_SELCHANGE) {
3566 int index = SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2,
3567 CB_GETCURSEL, 0, 0);
3568 cfg.sshbug_hmac2 = (index == 0 ? BUG_AUTO :
3569 index == 1 ? BUG_OFF : BUG_ON);
3572 case IDC_BUGD_DERIVEKEY2:
3573 if (HIWORD(wParam) == CBN_SELCHANGE) {
3574 int index = SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2,
3575 CB_GETCURSEL, 0, 0);
3576 cfg.sshbug_derivekey2 = (index == 0 ? BUG_AUTO :
3577 index == 1 ? BUG_OFF : BUG_ON);
3580 case IDC_BUGD_RSAPAD2:
3581 if (HIWORD(wParam) == CBN_SELCHANGE) {
3582 int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2,
3583 CB_GETCURSEL, 0, 0);
3584 cfg.sshbug_rsapad2 = (index == 0 ? BUG_AUTO :
3585 index == 1 ? BUG_OFF : BUG_ON);
3592 int id = ((LPHELPINFO)lParam)->iCtrlId;
3593 char *cmd = help_context_cmd(id);
3595 WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
3596 requested_help = TRUE;
3603 if (requested_help) {
3604 WinHelp(hwnd, help_path, HELP_QUIT, 0);
3605 requested_help = FALSE;
3610 /* Grrr Explorer will maximize Dialogs! */
3612 if (wParam == SIZE_MAXIMIZED)
3618 * Handle application-defined messages eg. DragListBox
3620 /* First find out what the number is (once). */
3621 if (draglistmsg == WM_NULL)
3622 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
3624 if (msg == draglistmsg) {
3625 /* Only process once dialog is fully formed. */
3626 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
3627 case IDC_CIPHERLIST:
3628 return handle_prefslist(&cipherlist,
3629 cfg.ssh_cipherlist, CIPHER_MAX,
3630 1, hwnd, wParam, lParam);
3639 static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
3640 WPARAM wParam, LPARAM lParam)
3642 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
3644 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
3645 EnableWindow(hwnd, 0);
3646 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3647 EnableWindow(hwnd, 1);
3648 SetActiveWindow(hwnd);
3650 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
3653 static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
3654 WPARAM wParam, LPARAM lParam)
3656 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
3659 void defuse_showwindow(void)
3662 * Work around the fact that the app's first call to ShowWindow
3663 * will ignore the default in favour of the shell-provided
3668 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
3670 ShowWindow(hwnd, SW_HIDE);
3671 SetActiveWindow(hwnd);
3672 DestroyWindow(hwnd);
3681 savedsession[0] = '\0';
3683 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
3684 get_sesslist(FALSE);
3689 int do_reconfig(HWND hwnd)
3694 backup_cfg = cfg; /* structure copy */
3696 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
3698 cfg = backup_cfg; /* structure copy */
3703 void logevent(char *string)
3708 log_eventlog(string);
3710 if (nevents >= negsize) {
3712 events = srealloc(events, negsize * sizeof(*events));
3716 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
3719 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
3720 strcpy(events[nevents], timebuf);
3721 strcat(events[nevents], string);
3724 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
3725 0, (LPARAM) events[nevents]);
3726 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
3727 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
3732 void showeventlog(HWND hwnd)
3735 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
3737 ShowWindow(logbox, SW_SHOWNORMAL);
3739 SetActiveWindow(logbox);
3742 void showabout(HWND hwnd)
3744 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3747 void verify_ssh_host_key(char *host, int port, char *keytype,
3748 char *keystr, char *fingerprint)
3752 static const char absentmsg[] =
3753 "The server's host key is not cached in the registry. You\n"
3754 "have no guarantee that the server is the computer you\n"
3756 "The server's key fingerprint is:\n"
3758 "If you trust this host, hit Yes to add the key to\n"
3759 "PuTTY's cache and carry on connecting.\n"
3760 "If you want to carry on connecting just once, without\n"
3761 "adding the key to the cache, hit No.\n"
3762 "If you do not trust this host, hit Cancel to abandon the\n"
3765 static const char wrongmsg[] =
3766 "WARNING - POTENTIAL SECURITY BREACH!\n"
3768 "The server's host key does not match the one PuTTY has\n"
3769 "cached in the registry. This means that either the\n"
3770 "server administrator has changed the host key, or you\n"
3771 "have actually connected to another computer pretending\n"
3772 "to be the server.\n"
3773 "The new key fingerprint is:\n"
3775 "If you were expecting this change and trust the new key,\n"
3776 "hit Yes to update PuTTY's cache and continue connecting.\n"
3777 "If you want to carry on connecting but without updating\n"
3778 "the cache, hit No.\n"
3779 "If you want to abandon the connection completely, hit\n"
3780 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3782 static const char mbtitle[] = "PuTTY Security Alert";
3785 /* sensible fingerprint max size */
3786 (sizeof(absentmsg) > sizeof(wrongmsg) ?
3787 sizeof(absentmsg) : sizeof(wrongmsg))];
3790 * Verify the key against the registry.
3792 ret = verify_host_key(host, port, keytype, keystr);
3794 if (ret == 0) /* success - key matched OK */
3796 if (ret == 2) { /* key was different */
3798 sprintf(message, wrongmsg, fingerprint);
3799 mbret = MessageBox(NULL, message, mbtitle,
3800 MB_ICONWARNING | MB_YESNOCANCEL);
3802 store_host_key(host, port, keytype, keystr);
3803 if (mbret == IDCANCEL)
3806 if (ret == 1) { /* key was absent */
3808 sprintf(message, absentmsg, fingerprint);
3809 mbret = MessageBox(NULL, message, mbtitle,
3810 MB_ICONWARNING | MB_YESNOCANCEL);
3812 store_host_key(host, port, keytype, keystr);
3813 if (mbret == IDCANCEL)
3819 * Ask whether the selected cipher is acceptable (since it was
3820 * below the configured 'warn' threshold).
3821 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3823 void askcipher(char *ciphername, int cs)
3825 static const char mbtitle[] = "PuTTY Security Alert";
3826 static const char msg[] =
3827 "The first %.35scipher supported by the server\n"
3828 "is %.64s, which is below the configured\n"
3829 "warning threshold.\n"
3830 "Do you want to continue with this connection?\n";
3831 /* guessed cipher name + type max length */
3832 char message[100 + sizeof(msg)];
3835 sprintf(message, msg,
3837 (cs == 1) ? "client-to-server " :
3838 "server-to-client ",
3840 mbret = MessageBox(NULL, message, mbtitle,
3841 MB_ICONWARNING | MB_YESNO);
3849 * Ask whether to wipe a session log file before writing to it.
3850 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3852 int askappend(char *filename)
3854 static const char mbtitle[] = "PuTTY Log to File";
3855 static const char msgtemplate[] =
3856 "The session log file \"%.*s\" already exists.\n"
3857 "You can overwrite it with a new session log,\n"
3858 "append your session log to the end of it,\n"
3859 "or disable session logging for this session.\n"
3860 "Hit Yes to wipe the file, No to append to it,\n"
3861 "or Cancel to disable logging.";
3862 char message[sizeof(msgtemplate) + FILENAME_MAX];
3864 if (cfg.logxfovr != LGXF_ASK) {
3865 return ((cfg.logxfovr == LGXF_OVR) ? 2 : 1);
3867 sprintf(message, msgtemplate, FILENAME_MAX, filename);
3869 mbret = MessageBox(NULL, message, mbtitle,
3870 MB_ICONQUESTION | MB_YESNOCANCEL);
3873 else if (mbret == IDNO)
3880 * Warn about the obsolescent key file format.
3882 void old_keyfile_warning(void)
3884 static const char mbtitle[] = "PuTTY Key File Warning";
3885 static const char message[] =
3886 "You are loading an SSH 2 private key which has an\n"
3887 "old version of the file format. This means your key\n"
3888 "file is not fully tamperproof. Future versions of\n"
3889 "PuTTY may stop supporting this private key format,\n"
3890 "so we recommend you convert your key to the new\n"
3893 "You can perform this conversion by loading the key\n"
3894 "into PuTTYgen and then saving it again.";
3896 MessageBox(NULL, message, mbtitle, MB_OK);