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,
593 translationpanelstart,
594 IDC_TITLE_TRANSLATION,
595 IDC_BOX_TRANSLATION1,
596 IDC_BOX_TRANSLATION2,
597 IDC_BOX_TRANSLATION3,
635 static const char *const colours[] = {
636 "Default Foreground", "Default Bold Foreground",
637 "Default Background", "Default Bold Background",
638 "Cursor Text", "Cursor Colour",
639 "ANSI Black", "ANSI Black Bold",
640 "ANSI Red", "ANSI Red Bold",
641 "ANSI Green", "ANSI Green Bold",
642 "ANSI Yellow", "ANSI Yellow Bold",
643 "ANSI Blue", "ANSI Blue Bold",
644 "ANSI Magenta", "ANSI Magenta Bold",
645 "ANSI Cyan", "ANSI Cyan Bold",
646 "ANSI White", "ANSI White Bold"
648 static const int permcolour[] = {
649 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
650 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
651 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
654 static void fmtfont(char *buf)
656 sprintf(buf, "Font: %s, ", cfg.font);
658 strcat(buf, "bold, ");
659 if (cfg.fontheight == 0)
660 strcat(buf, "default height");
662 sprintf(buf + strlen(buf), "%d-point",
663 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
666 char *help_context_cmd(int id)
678 return "JI(`',`session.hostname')";
685 return "JI(`',`session.saved')";
690 return "JI(`',`session.coe')";
691 case IDC_LSTATSTATIC:
695 case IDC_LSTATPACKET:
696 return "JI(`',`logging.main')";
701 return "JI(`',`logging.filename')";
706 return "JI(`',`logging.exists')";
711 return "JI(`',`keyboard.backspace')";
715 return "JI(`',`keyboard.homeend')";
723 return "JI(`',`keyboard.funkeys')";
727 return "JI(`',`keyboard.appkeypad')";
731 return "JI(`',`keyboard.appcursor')";
733 return "JI(`',`keyboard.nethack')";
735 return "JI(`',`keyboard.compose')";
736 case IDC_CTRLALTKEYS:
737 return "JI(`',`keyboard.ctrlalt')";
741 return "JI(`',`features.application')";
743 return "JI(`',`features.mouse')";
745 return "JI(`',`features.resize')";
746 case IDC_NOALTSCREEN:
747 return "JI(`',`features.altscreen')";
749 return "JI(`',`features.retitle')";
750 case IDC_NODBACKSPACE:
751 return "JI(`',`features.dbackspace')";
753 return "JI(`',`features.charset')";
756 return "JI(`',`terminal.autowrap')";
758 return "JI(`',`terminal.decom')";
760 return "JI(`',`terminal.lfhascr')";
762 return "JI(`',`terminal.bce')";
764 return "JI(`',`terminal.blink')";
767 return "JI(`',`terminal.answerback')";
769 case IDC_ECHOBACKEND:
772 return "JI(`',`terminal.localecho')";
774 case IDC_EDITBACKEND:
777 return "JI(`',`terminal.localedit')";
778 case IDC_PRINTERSTATIC:
780 return "JI(`',`terminal.printing')";
783 case IDC_BELL_DISABLED:
784 case IDC_BELL_DEFAULT:
785 case IDC_BELL_WAVEFILE:
786 case IDC_BELL_VISUAL:
787 case IDC_BELL_WAVESTATIC:
788 case IDC_BELL_WAVEEDIT:
789 case IDC_BELL_WAVEBROWSE:
790 return "JI(`',`bell.style')";
791 case IDC_B_IND_STATIC:
792 case IDC_B_IND_DISABLED:
793 case IDC_B_IND_FLASH:
794 case IDC_B_IND_STEADY:
795 return "JI(`',`bell.taskbar')";
797 case IDC_BELLOVLNSTATIC:
799 case IDC_BELLOVLTSTATIC:
801 case IDC_BELLOVLEXPLAIN:
802 case IDC_BELLOVLSSTATIC:
804 return "JI(`',`bell.overload')";
810 return "JI(`',`window.size')";
811 case IDC_RESIZESTATIC:
815 case IDC_RESIZEEITHER:
816 return "JI(`',`window.resize')";
818 case IDC_SCROLLBARFULLSCREEN:
823 return "JI(`',`window.scrollback')";
826 return "JI(`',`behaviour.closewarn')";
828 return "JI(`',`behaviour.altf4')";
830 return "JI(`',`behaviour.altspace')";
832 return "JI(`',`behaviour.altonly')";
833 case IDC_ALWAYSONTOP:
834 return "JI(`',`behaviour.alwaysontop')";
835 case IDC_FULLSCREENONALTENTER:
836 return "JI(`',`behaviour.altenter')";
838 case IDC_CURSORSTATIC:
843 return "JI(`',`appearance.cursor')";
846 return "JI(`',`appearance.font')";
850 return "JI(`',`appearance.title')";
852 return "JI(`',`appearance.hidemouse')";
856 return "JI(`',`appearance.border')";
860 return "JI(`',`connection.termtype')";
863 return "JI(`',`connection.username')";
866 return "JI(`',`connection.keepalive')";
868 return "JI(`',`connection.nodelay')";
870 case IDC_PROXYTYPESTATIC:
871 case IDC_PROXYTYPENONE:
872 case IDC_PROXYTYPEHTTP:
873 case IDC_PROXYTYPESOCKS:
874 case IDC_PROXYTYPETELNET:
875 return "JI(`',`proxy.type')";
876 case IDC_PROXYHOSTSTATIC:
877 case IDC_PROXYHOSTEDIT:
878 case IDC_PROXYPORTSTATIC:
879 case IDC_PROXYPORTEDIT:
880 return "JI(`',`proxy.main')";
881 case IDC_PROXYEXCLUDESTATIC:
882 case IDC_PROXYEXCLUDEEDIT:
883 return "JI(`',`proxy.exclude')";
884 case IDC_PROXYUSERSTATIC:
885 case IDC_PROXYUSEREDIT:
886 case IDC_PROXYPASSSTATIC:
887 case IDC_PROXYPASSEDIT:
888 return "JI(`',`proxy.auth')";
889 case IDC_PROXYTELNETCMDSTATIC:
890 case IDC_PROXYTELNETCMDEDIT:
891 return "JI(`',`proxy.command')";
892 case IDC_PROXYSOCKSVERSTATIC:
893 case IDC_PROXYSOCKSVER5:
894 case IDC_PROXYSOCKSVER4:
895 return "JI(`',`proxy.socksver')";
899 return "JI(`',`telnet.termspeed')";
908 return "JI(`',`telnet.environ')";
912 return "JI(`',`telnet.oldenviron')";
916 return "JI(`',`telnet.passive')";
918 return "JI(`',`telnet.specialkeys')";
920 return "JI(`',`telnet.newline')";
924 return "JI(`',`rlogin.termspeed')";
925 case IDC_RLLUSERSTATIC:
926 case IDC_RLLUSEREDIT:
927 return "JI(`',`rlogin.localuser')";
930 return "JI(`',`ssh.nopty')";
931 case IDC_CIPHERSTATIC2:
936 return "JI(`',`ssh.ciphers')";
937 case IDC_SSHPROTSTATIC:
938 case IDC_SSHPROT1ONLY:
941 case IDC_SSHPROT2ONLY:
942 return "JI(`',`ssh.protocol')";
945 return "JI(`',`ssh.command')";
947 return "JI(`',`ssh.compress')";
952 return "JI(`',`ssh.auth.privkey')";
954 return "JI(`',`ssh.auth.agentfwd')";
956 return "JI(`',`ssh.auth.changeuser')";
958 return "JI(`',`ssh.auth.tis')";
960 return "JI(`',`ssh.auth.ki')";
965 return "JI(`',`selection.buttons')";
966 case IDC_MOUSEOVERRIDE:
967 return "JI(`',`selection.shiftdrag')";
968 case IDC_SELTYPESTATIC:
970 case IDC_SELTYPERECT:
971 return "JI(`',`selection.rect')";
977 return "JI(`',`selection.charclasses')";
979 return "JI(`',`selection.linedraw')";
981 return "JI(`',`selection.rtf')";
984 return "JI(`',`colours.bold')";
986 return "JI(`',`colours.logpal')";
987 case IDC_COLOURSTATIC:
996 return "JI(`',`colours.config')";
998 case IDC_CODEPAGESTATIC:
1000 return "JI(`',`translation.codepage')";
1001 case IDC_CAPSLOCKCYR:
1002 return "JI(`',`translation.cyrillic')";
1004 case IDC_VTXWINDOWS:
1009 return "JI(`',`translation.linedraw')";
1011 case IDC_X11_FORWARD:
1012 case IDC_X11_DISPSTATIC:
1013 case IDC_X11_DISPLAY:
1014 return "JI(`',`ssh.tunnels.x11')";
1015 case IDC_PFWDSTATIC:
1016 case IDC_PFWDSTATIC2:
1017 case IDC_PFWDREMOVE:
1020 case IDC_SPORTSTATIC:
1022 case IDC_DPORTSTATIC:
1025 case IDC_PFWDREMOTE:
1026 return "JI(`',`ssh.tunnels.portfwd')";
1029 return "JI(`',`ssh.tunnels.portfwd.localhost')";
1031 case IDC_BUGS_IGNORE1:
1032 case IDC_BUGD_IGNORE1:
1033 return "JI(`',`ssh.bugs.ignore1')";
1034 case IDC_BUGS_PLAINPW1:
1035 case IDC_BUGD_PLAINPW1:
1036 return "JI(`',`ssh.bugs.plainpw1')";
1039 return "JI(`',`ssh.bugs.rsa1')";
1040 case IDC_BUGS_HMAC2:
1041 case IDC_BUGD_HMAC2:
1042 return "JI(`',`ssh.bugs.hmac2')";
1043 case IDC_BUGS_DERIVEKEY2:
1044 case IDC_BUGD_DERIVEKEY2:
1045 return "JI(`',`ssh.bugs.derivekey2')";
1046 case IDC_BUGS_RSAPAD2:
1047 case IDC_BUGD_RSAPAD2:
1048 return "JI(`',`ssh.bugs.rsapad2')";
1049 case IDC_BUGS_DHGEX2:
1050 case IDC_BUGD_DHGEX2:
1051 return "JI(`',`ssh.bugs.dhgex2')";
1058 /* 2nd arg: NZ => don't redraw session list (use when loading
1060 static void init_dlg_ctrls(HWND hwnd, int keepsess)
1063 char fontstatic[256];
1065 SetDlgItemText(hwnd, IDC_HOST, cfg.host);
1066 SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
1069 n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
1070 for (i = n; i-- > 0;)
1071 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_DELETESTRING, i, 0);
1072 for (i = 0; i < nsessions; i++)
1073 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_ADDSTRING,
1074 0, (LPARAM) (sessions[i]));
1076 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
1077 CheckRadioButton(hwnd, IDC_PROTRAW, IDC_PROTSSH,
1078 cfg.protocol == PROT_SSH ? IDC_PROTSSH :
1079 cfg.protocol == PROT_TELNET ? IDC_PROTTELNET :
1081 PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW);
1082 SetDlgItemInt(hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
1083 CheckDlgButton(hwnd, IDC_NODELAY, cfg.tcp_nodelay);
1085 CheckRadioButton(hwnd, IDC_DEL008, IDC_DEL127,
1086 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
1087 CheckRadioButton(hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
1088 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
1089 CheckRadioButton(hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
1090 cfg.funky_type == 0 ? IDC_FUNCTILDE :
1091 cfg.funky_type == 1 ? IDC_FUNCLINUX :
1092 cfg.funky_type == 2 ? IDC_FUNCXTERM :
1093 cfg.funky_type == 3 ? IDC_FUNCVT400 :
1094 cfg.funky_type == 4 ? IDC_FUNCVT100P :
1095 cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE);
1096 CheckDlgButton(hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
1097 CheckDlgButton(hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
1098 CheckDlgButton(hwnd, IDC_NOMOUSEREP, cfg.no_mouse_rep);
1099 CheckDlgButton(hwnd, IDC_NORESIZE, cfg.no_remote_resize);
1100 CheckDlgButton(hwnd, IDC_NOALTSCREEN, cfg.no_alt_screen);
1101 CheckDlgButton(hwnd, IDC_NOWINTITLE, cfg.no_remote_wintitle);
1102 CheckDlgButton(hwnd, IDC_NODBACKSPACE, cfg.no_dbackspace);
1103 CheckDlgButton(hwnd, IDC_NOCHARSET, cfg.no_remote_charset);
1104 CheckRadioButton(hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
1105 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
1106 CheckRadioButton(hwnd, IDC_KPNORMAL, IDC_KPNH,
1107 cfg.nethack_keypad ? IDC_KPNH :
1108 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
1109 CheckDlgButton(hwnd, IDC_ALTF4, cfg.alt_f4);
1110 CheckDlgButton(hwnd, IDC_ALTSPACE, cfg.alt_space);
1111 CheckDlgButton(hwnd, IDC_ALTONLY, cfg.alt_only);
1112 CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
1113 CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
1114 CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
1115 CheckDlgButton(hwnd, IDC_TELNETRET, cfg.telnet_newline);
1116 CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
1117 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
1118 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
1119 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
1120 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND :
1121 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
1122 SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
1123 CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
1124 CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
1125 CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
1126 CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
1128 CheckDlgButton(hwnd, IDC_WRAPMODE, cfg.wrap_mode);
1129 CheckDlgButton(hwnd, IDC_DECOM, cfg.dec_om);
1130 CheckDlgButton(hwnd, IDC_LFHASCR, cfg.lfhascr);
1131 SetDlgItemInt(hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
1132 SetDlgItemInt(hwnd, IDC_COLSEDIT, cfg.width, FALSE);
1133 SetDlgItemInt(hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
1134 fmtfont(fontstatic);
1135 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
1136 CheckRadioButton(hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
1137 cfg.beep == BELL_DISABLED ? IDC_BELL_DISABLED :
1138 cfg.beep == BELL_DEFAULT ? IDC_BELL_DEFAULT :
1139 cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
1141 BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
1142 CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
1144 B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
1145 B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
1146 B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
1147 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
1148 CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
1149 SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
1150 MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
1151 MySetDlgItemFlt(hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
1153 CheckDlgButton(hwnd, IDC_BCE, cfg.bce);
1154 CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
1156 SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
1157 CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
1158 CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
1159 CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
1160 SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
1161 CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
1162 cfg.cursor_type == 0 ? IDC_CURBLOCK :
1163 cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
1164 CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
1165 CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
1166 CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
1167 CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZEEITHER,
1168 cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
1169 cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
1170 cfg.resize_action == RESIZE_EITHER ? IDC_RESIZEEITHER :
1172 CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
1173 cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
1174 cfg.close_on_exit ==
1175 COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
1176 CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
1178 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1179 SetDlgItemText(hwnd, IDC_TSEDIT, cfg.termspeed);
1180 SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
1181 SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
1182 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1183 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
1184 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATPACKET,
1185 cfg.logtype == LGTYP_NONE ? IDC_LSTATOFF :
1186 cfg.logtype == LGTYP_ASCII ? IDC_LSTATASCII :
1187 cfg.logtype == LGTYP_DEBUG ? IDC_LSTATRAW :
1189 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
1190 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
1191 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
1194 char *p = cfg.environmt;
1195 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
1197 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
1203 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0,
1208 CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC,
1209 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
1210 CheckRadioButton(hwnd, IDC_TPASSIVE, IDC_TACTIVE,
1211 cfg.passive_telnet ? IDC_TPASSIVE : IDC_TACTIVE);
1213 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1214 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1215 CheckDlgButton(hwnd, IDC_NOPTY, cfg.nopty);
1216 CheckDlgButton(hwnd, IDC_COMPRESS, cfg.compression);
1217 CheckDlgButton(hwnd, IDC_SSH2DES, cfg.ssh2_des_cbc);
1218 CheckDlgButton(hwnd, IDC_AGENTFWD, cfg.agentfwd);
1219 CheckDlgButton(hwnd, IDC_CHANGEUSER, cfg.change_username);
1220 CheckRadioButton(hwnd, IDC_SSHPROT1ONLY, IDC_SSHPROT2ONLY,
1221 cfg.sshprot == 1 ? IDC_SSHPROT1 :
1222 cfg.sshprot == 2 ? IDC_SSHPROT2 :
1223 cfg.sshprot == 3 ? IDC_SSHPROT2ONLY : IDC_SSHPROT1ONLY);
1224 CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
1225 CheckDlgButton(hwnd, IDC_AUTHKI, cfg.try_ki_auth);
1226 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
1227 SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
1231 static const struct { char *s; int c; } ciphers[] = {
1232 { "3DES", CIPHER_3DES },
1233 { "Blowfish", CIPHER_BLOWFISH },
1234 { "DES", CIPHER_DES },
1235 { "AES (SSH 2 only)", CIPHER_AES },
1236 { "-- warn below here --", CIPHER_WARN }
1239 /* Set up the "selected ciphers" box. */
1240 /* (cipherlist assumed to contain all ciphers) */
1241 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_RESETCONTENT, 0, 0);
1242 for (i = 0; i < CIPHER_MAX; i++) {
1243 int c = cfg.ssh_cipherlist[i];
1246 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
1247 if (ciphers[j].c == c) {
1248 cstr = ciphers[j].s;
1252 pos = SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_ADDSTRING,
1254 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_SETITEMDATA,
1260 CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
1261 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
1262 CheckRadioButton(hwnd, IDC_SELTYPELEX, IDC_SELTYPERECT,
1263 cfg.rect_select == 0 ? IDC_SELTYPELEX : IDC_SELTYPERECT);
1264 CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
1265 CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
1266 CheckDlgButton(hwnd, IDC_RTFPASTE, cfg.rtf_paste);
1268 static int tabs[4] = { 25, 61, 96, 128 };
1269 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
1272 for (i = 0; i < 128; i++) {
1274 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
1275 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg.wordness[i]);
1276 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
1280 CheckDlgButton(hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
1281 CheckDlgButton(hwnd, IDC_PALETTE, cfg.try_palette);
1284 n = SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
1285 for (i = n; i-- > 0;)
1286 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
1287 LB_DELETESTRING, i, 0);
1288 for (i = 0; i < 22; i++)
1289 if (cfg.bold_colour || permcolour[i])
1290 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
1291 (LPARAM) colours[i]);
1293 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
1294 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
1295 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
1296 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
1301 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
1302 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
1303 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
1304 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
1305 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
1308 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
1314 pe = printer_start_enum(&nprinters);
1315 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_RESETCONTENT, 0, 0);
1316 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1317 0, (LPARAM) PRINTER_DISABLED_STRING);
1318 for (i = 0; i < nprinters; i++) {
1319 char *printer_name = printer_get_name(pe, i);
1320 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1321 0, (LPARAM) printer_name);
1323 printer_finish_enum(pe);
1324 SetDlgItemText(hwnd, IDC_PRINTER,
1325 *cfg.printer ? cfg.printer : PRINTER_DISABLED_STRING);
1328 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
1329 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
1330 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
1331 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
1332 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
1335 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
1336 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
1338 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
1339 CheckDlgButton(hwnd, IDC_RPORT_ALL, cfg.rport_acceptall);
1340 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
1343 CheckRadioButton(hwnd, IDC_PROXYTYPENONE, IDC_PROXYTYPETELNET,
1344 cfg.proxy_type == PROXY_HTTP ? IDC_PROXYTYPEHTTP :
1345 cfg.proxy_type == PROXY_SOCKS ? IDC_PROXYTYPESOCKS :
1346 cfg.proxy_type == PROXY_TELNET ? IDC_PROXYTYPETELNET : IDC_PROXYTYPENONE);
1347 SetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host);
1348 SetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, cfg.proxy_port, FALSE);
1349 SetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT, cfg.proxy_exclude_list);
1350 SetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT, cfg.proxy_telnet_command);
1351 SetDlgItemText(hwnd, IDC_PROXYUSEREDIT, cfg.proxy_username);
1352 SetDlgItemText(hwnd, IDC_PROXYPASSEDIT, cfg.proxy_password);
1353 CheckRadioButton(hwnd, IDC_PROXYSOCKSVER5, IDC_PROXYSOCKSVER4,
1354 cfg.proxy_socks_version == 4 ? IDC_PROXYSOCKSVER4 : IDC_PROXYSOCKSVER5);
1356 /* SSH bugs config */
1357 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_RESETCONTENT, 0, 0);
1358 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1359 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"Off");
1360 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"On");
1361 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_SETCURSEL,
1362 cfg.sshbug_ignore1 == BUG_ON ? 2 :
1363 cfg.sshbug_ignore1 == BUG_OFF ? 1 : 0, 0);
1364 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_RESETCONTENT, 0, 0);
1365 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1366 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Off");
1367 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"On");
1368 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_SETCURSEL,
1369 cfg.sshbug_plainpw1 == BUG_ON ? 2 :
1370 cfg.sshbug_plainpw1 == BUG_OFF ? 1 : 0, 0);
1371 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_RESETCONTENT, 0, 0);
1372 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1373 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Off");
1374 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"On");
1375 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_SETCURSEL,
1376 cfg.sshbug_rsa1 == BUG_ON ? 2 :
1377 cfg.sshbug_rsa1 == BUG_OFF ? 1 : 0, 0);
1378 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_RESETCONTENT, 0, 0);
1379 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1380 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Off");
1381 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"On");
1382 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_SETCURSEL,
1383 cfg.sshbug_hmac2 == BUG_ON ? 2 :
1384 cfg.sshbug_hmac2 == BUG_OFF ? 1 : 0, 0);
1385 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_RESETCONTENT, 0, 0);
1386 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1387 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Off");
1388 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"On");
1389 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_SETCURSEL,
1390 cfg.sshbug_derivekey2 == BUG_ON ? 2 :
1391 cfg.sshbug_derivekey2 == BUG_OFF ? 1 : 0, 0);
1392 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_RESETCONTENT, 0, 0);
1393 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1394 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Off");
1395 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"On");
1396 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_SETCURSEL,
1397 cfg.sshbug_rsapad2 == BUG_ON ? 2 :
1398 cfg.sshbug_rsapad2 == BUG_OFF ? 1 : 0, 0);
1399 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_RESETCONTENT, 0, 0);
1400 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1401 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"Off");
1402 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"On");
1403 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_SETCURSEL,
1404 cfg.sshbug_dhgex2 == BUG_ON ? 2 :
1405 cfg.sshbug_dhgex2 == BUG_OFF ? 1 : 0, 0);
1408 struct treeview_faff {
1410 HTREEITEM lastat[4];
1413 static HTREEITEM treeview_insert(struct treeview_faff *faff,
1414 int level, char *text)
1419 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
1420 ins.hInsertAfter = faff->lastat[level];
1421 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1422 #define INSITEM DUMMYUNIONNAME.item
1424 #define INSITEM item
1426 ins.INSITEM.mask = TVIF_TEXT;
1427 ins.INSITEM.pszText = text;
1428 newitem = TreeView_InsertItem(faff->treeview, &ins);
1430 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
1432 faff->lastat[level] = newitem;
1433 for (i = level + 1; i < 4; i++)
1434 faff->lastat[i] = NULL;
1439 * Create the panelfuls of controls in the configuration box.
1441 static void create_controls(HWND hwnd, int dlgtype, int panel)
1443 if (panel == sessionpanelstart) {
1444 /* The Session panel. Accelerators used: [acgoh] nprtis elvd w */
1446 ctlposinit(&cp, hwnd, 80, 3, 13);
1447 bartitle(&cp, "Basic options for your PuTTY session",
1450 beginbox(&cp, "Specify your connection by host name or IP address",
1453 "Host &Name (or IP address)",
1454 IDC_HOSTSTATIC, IDC_HOST, 75,
1455 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
1456 if (backends[3].backend == NULL) {
1457 /* this is PuTTYtel, so only three protocols available */
1458 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
1459 "&Raw", IDC_PROTRAW,
1460 "&Telnet", IDC_PROTTELNET,
1461 "Rlog&in", IDC_PROTRLOGIN, NULL);
1463 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
1464 "&Raw", IDC_PROTRAW,
1465 "&Telnet", IDC_PROTTELNET,
1466 "Rlog&in", IDC_PROTRLOGIN,
1475 beginbox(&cp, "Load, save or delete a stored session",
1477 sesssaver(&cp, "Sav&ed Sessions",
1478 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
1479 "&Load", IDC_SESSLOAD,
1480 "Sa&ve", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
1483 beginbox(&cp, NULL, IDC_BOX_SESSION3);
1484 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
1485 "Always", IDC_COEALWAYS,
1486 "Never", IDC_COENEVER,
1487 "Only on clean exit", IDC_COENORMAL, NULL);
1491 if (panel == loggingpanelstart) {
1492 /* The Logging panel. Accelerators used: [acgoh] tplsfwe */
1494 ctlposinit(&cp, hwnd, 80, 3, 13);
1495 bartitle(&cp, "Options controlling session logging",
1497 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
1499 "Session logging:", IDC_LSTATSTATIC,
1500 "Logging &turned off completely", IDC_LSTATOFF,
1501 "Log &printable output only", IDC_LSTATASCII,
1502 "&Log all session output", IDC_LSTATRAW,
1503 "Log &SSH packet data", IDC_LSTATPACKET,
1505 editbutton(&cp, "Log &file name:",
1506 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
1508 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
1509 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
1511 "What to do if the log file already &exists:",
1512 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
1513 "Always append to the end of it", IDC_LSTATXAPN,
1514 "Ask the user every time", IDC_LSTATXASK, NULL);
1518 if (panel == terminalpanelstart) {
1519 /* The Terminal panel. Accelerators used: [acgoh] wdren lts p */
1521 ctlposinit(&cp, hwnd, 80, 3, 13);
1522 bartitle(&cp, "Options controlling the terminal emulation",
1523 IDC_TITLE_TERMINAL);
1524 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
1525 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
1526 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
1527 checkbox(&cp, "Implicit C&R in every LF", IDC_LFHASCR);
1528 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
1529 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
1531 "An&swerback to ^E:", IDC_ANSWERBACK,
1532 IDC_ANSWEREDIT, 100, NULL);
1535 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
1536 radioline(&cp, "&Local echo:", IDC_ECHOSTATIC, 3,
1537 "Auto", IDC_ECHOBACKEND,
1538 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
1539 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
1540 "Auto", IDC_EDITBACKEND,
1541 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
1544 beginbox(&cp, "Remote-controlled printing", IDC_BOX_TERMINAL3);
1545 combobox(&cp, "&Printer to send ANSI printer output to:",
1546 IDC_PRINTERSTATIC, IDC_PRINTER);
1550 if (panel == featurespanelstart) {
1551 /* The Features panel. Accelerators used: [acgoh] ukswtbrx */
1553 ctlposinit(&cp, hwnd, 80, 3, 13);
1554 bartitle(&cp, "Enabling and disabling advanced terminal features ",
1555 IDC_TITLE_FEATURES);
1556 beginbox(&cp, NULL, IDC_BOX_FEATURES1);
1557 checkbox(&cp, "Disable application c&ursor keys mode", IDC_NOAPPLICC);
1558 checkbox(&cp, "Disable application &keypad mode", IDC_NOAPPLICK);
1559 checkbox(&cp, "Disable &xterm-style mouse reporting", IDC_NOMOUSEREP);
1560 checkbox(&cp, "Disable remote-controlled terminal re&sizing",
1562 checkbox(&cp, "Disable s&witching to alternate terminal screen",
1564 checkbox(&cp, "Disable remote-controlled window &title changing",
1566 checkbox(&cp, "Disable destructive &backspace on server sending ^?",
1568 checkbox(&cp, "Disable remote-controlled cha&racter set configuration",
1573 if (panel == bellpanelstart) {
1574 /* The Bell panel. Accelerators used: [acgoh] bdsm wit */
1576 ctlposinit(&cp, hwnd, 80, 3, 13);
1577 bartitle(&cp, "Options controlling the terminal bell",
1579 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
1581 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
1582 "None (bell disabled)", IDC_BELL_DISABLED,
1583 "Play Windows Default Sound", IDC_BELL_DEFAULT,
1584 "Play a custom sound file", IDC_BELL_WAVEFILE,
1585 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
1586 editbutton(&cp, "Custom sound file to play as a bell:",
1587 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
1588 "Bro&wse...", IDC_BELL_WAVEBROWSE);
1589 radioline(&cp, "Taskbar/caption &indication on bell:",
1590 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
1591 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
1594 beginbox(&cp, "Control the bell overload behaviour",
1596 checkbox(&cp, "Bell is temporarily &disabled when over-used",
1598 staticedit(&cp, "Over-use means this &many bells...",
1599 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
1600 staticedit(&cp, "... in &this many seconds",
1601 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
1603 "The bell is re-enabled after a few seconds of silence.",
1604 1, IDC_BELLOVLEXPLAIN);
1605 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1610 if (panel == keyboardpanelstart) {
1611 /* The Keyboard panel. Accelerators used: [acgoh] bef rntd */
1613 ctlposinit(&cp, hwnd, 80, 3, 13);
1614 bartitle(&cp, "Options controlling the effects of keys",
1615 IDC_TITLE_KEYBOARD);
1616 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1617 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1618 "Control-H", IDC_DEL008,
1619 "Control-? (127)", IDC_DEL127, NULL);
1620 radioline(&cp, "The Home and &End keys", IDC_HOMESTATIC, 2,
1621 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1622 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1623 "ESC[n~", IDC_FUNCTILDE,
1624 "Linux", IDC_FUNCLINUX,
1625 "Xterm R6", IDC_FUNCXTERM,
1626 "VT400", IDC_FUNCVT400,
1627 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1629 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1630 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1631 "Normal", IDC_CURNORMAL,
1632 "Application", IDC_CURAPPLIC, NULL);
1633 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1634 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1635 "NetHack", IDC_KPNH, NULL);
1637 beginbox(&cp, "Enable extra keyboard features:",
1639 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1640 checkbox(&cp, "Control-Alt is &different from AltGr",
1645 if (panel == windowpanelstart) {
1646 /* The Window panel. Accelerators used: [acgoh] rmz sdikp */
1648 ctlposinit(&cp, hwnd, 80, 3, 13);
1649 bartitle(&cp, "Options controlling PuTTY's window",
1651 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1653 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1654 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
1655 radiobig(&cp, "When window is resi&zed:", IDC_RESIZESTATIC,
1656 "Change the number of rows and columns", IDC_RESIZETERM,
1657 "Change the size of the font", IDC_RESIZEFONT,
1658 "Change font size only when maximised", IDC_RESIZEEITHER,
1659 "Forbid resizing completely", IDC_RESIZENONE, NULL);
1661 beginbox(&cp, "Control the scrollback in the window",
1663 staticedit(&cp, "Lines of &scrollback",
1664 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1665 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
1666 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
1667 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1668 checkbox(&cp, "Reset scrollback on dis&play activity",
1673 if (panel == appearancepanelstart) {
1674 /* The Appearance panel. Accelerators used: [acgoh] luvb n ti p s */
1676 ctlposinit(&cp, hwnd, 80, 3, 13);
1677 bartitle(&cp, "Configure the appearance of PuTTY's window",
1678 IDC_TITLE_APPEARANCE);
1679 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1680 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1681 "B&lock", IDC_CURBLOCK,
1682 "&Underline", IDC_CURUNDER,
1683 "&Vertical line", IDC_CURVERT, NULL);
1684 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1686 beginbox(&cp, "Set the font used in the terminal window",
1687 IDC_BOX_APPEARANCE2);
1688 staticbtn(&cp, "", IDC_FONTSTATIC, "Cha&nge...", IDC_CHOOSEFONT);
1690 beginbox(&cp, "Adjust the use of the window title",
1691 IDC_BOX_APPEARANCE3);
1693 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1694 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
1696 beginbox(&cp, "Adjust the use of the mouse pointer",
1697 IDC_BOX_APPEARANCE4);
1698 checkbox(&cp, "Hide mouse &pointer when typing in window",
1701 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1702 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1704 staticedit(&cp, "Gap between text and window edge",
1705 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
1709 if (panel == behaviourpanelstart) {
1710 /* The Behaviour panel. Accelerators used: [acgoh] w4yltf */
1712 ctlposinit(&cp, hwnd, 80, 3, 13);
1713 bartitle(&cp, "Configure the behaviour of PuTTY's window",
1715 beginbox(&cp, NULL, IDC_BOX_BEHAVIOUR1);
1716 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1717 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1718 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1719 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
1720 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1721 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1725 if (panel == translationpanelstart) {
1726 /* The Translation panel. Accelerators used: [acgoh] rxbepus */
1728 ctlposinit(&cp, hwnd, 80, 3, 13);
1729 bartitle(&cp, "Options controlling character set translation",
1730 IDC_TITLE_TRANSLATION);
1731 beginbox(&cp, "Character set translation on received data",
1732 IDC_BOX_TRANSLATION1);
1733 combobox(&cp, "&Received data assumed to be in which character set:",
1734 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1736 beginbox(&cp, "Enable character set translation on input data",
1737 IDC_BOX_TRANSLATION2);
1738 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
1741 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
1742 IDC_BOX_TRANSLATION3);
1744 "Handling of line drawing characters:", IDC_VTSTATIC,
1745 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1746 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1747 "Use font in O&EM mode only", IDC_VTOEMONLY,
1748 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1749 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
1753 if (panel == selectionpanelstart) {
1754 /* The Selection panel. Accelerators used: [acgoh] df wxp est nr */
1756 ctlposinit(&cp, hwnd, 80, 3, 13);
1757 bartitle(&cp, "Options controlling copy and paste",
1758 IDC_TITLE_SELECTION);
1759 beginbox(&cp, "Translation of pasted characters",
1760 IDC_BOX_SELECTION1);
1762 "&Don't translate line drawing chars into +, - and |",
1765 "Paste to clipboard in RT&F as well as plain text",
1768 beginbox(&cp, "Control which mouse button does which thing",
1769 IDC_BOX_SELECTION2);
1770 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1771 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1772 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1775 "Shift overrides a&pplication's use of mouse",
1778 "Default selection mode (Alt+drag does the other one):",
1779 IDC_SELTYPESTATIC, 2,
1780 "&Normal", IDC_SELTYPELEX,
1781 "&Rectangular block", IDC_SELTYPERECT, NULL);
1783 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1784 IDC_BOX_SELECTION3);
1785 charclass(&cp, "Charact&er classes:", IDC_CCSTATIC, IDC_CCLIST,
1786 "&Set", IDC_CCSET, IDC_CCEDIT,
1787 "&to class", IDC_CCSTATIC2);
1791 if (panel == colourspanelstart) {
1792 /* The Colours panel. Accelerators used: [acgoh] blum */
1794 ctlposinit(&cp, hwnd, 80, 3, 13);
1795 bartitle(&cp, "Options controlling use of colours",
1797 beginbox(&cp, "General options for colour usage",
1799 checkbox(&cp, "&Bolded text is a different colour",
1801 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1803 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1805 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1806 IDC_COLOURSTATIC, IDC_COLOURLIST,
1807 "&Modify...", IDC_CHANGE,
1808 "Red:", IDC_RSTATIC, IDC_RVALUE,
1809 "Green:", IDC_GSTATIC, IDC_GVALUE,
1810 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1814 if (panel == connectionpanelstart) {
1815 /* The Connection panel. Accelerators used: [acgoh] tukn */
1817 ctlposinit(&cp, hwnd, 80, 3, 13);
1818 bartitle(&cp, "Options controlling the connection",
1819 IDC_TITLE_CONNECTION);
1821 beginbox(&cp, "Data to send to the server",
1822 IDC_BOX_CONNECTION1);
1823 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1825 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1829 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1830 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1832 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1836 beginbox(&cp, "Sending of null packets to keep session active",
1837 IDC_BOX_CONNECTION2);
1838 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1839 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1842 beginbox(&cp, "Low-level TCP connection options",
1843 IDC_BOX_CONNECTION3);
1844 checkbox(&cp, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1850 if (panel == proxypanelstart) {
1851 /* The Proxy panel. Accelerators used: [acgoh] ntslypeuwmv */
1853 ctlposinit(&cp, hwnd, 80, 3, 13);
1855 bartitle(&cp, "Options controlling proxy usage",
1857 beginbox(&cp, "Proxy basics", IDC_BOX_PROXY1);
1858 radioline(&cp, "Proxy type:", IDC_PROXYTYPESTATIC, 4,
1859 "&None", IDC_PROXYTYPENONE,
1860 "H&TTP", IDC_PROXYTYPEHTTP,
1861 "&SOCKS", IDC_PROXYTYPESOCKS,
1862 "Te&lnet", IDC_PROXYTYPETELNET, NULL);
1864 "Prox&y Host", IDC_PROXYHOSTSTATIC, IDC_PROXYHOSTEDIT, 80,
1865 "&Port", IDC_PROXYPORTSTATIC, IDC_PROXYPORTEDIT, 20, NULL);
1867 "&Exclude Hosts/IPs", IDC_PROXYEXCLUDESTATIC,
1868 IDC_PROXYEXCLUDEEDIT, 100, NULL);
1869 staticedit(&cp, "&Username", IDC_PROXYUSERSTATIC,
1870 IDC_PROXYUSEREDIT, 60);
1871 staticpassedit(&cp, "Pass&word", IDC_PROXYPASSSTATIC,
1872 IDC_PROXYPASSEDIT, 60);
1874 beginbox(&cp, "Misc. proxy settings", IDC_BOX_PROXY2);
1876 "Telnet co&mmand", IDC_PROXYTELNETCMDSTATIC,
1877 IDC_PROXYTELNETCMDEDIT, 100, NULL);
1878 radioline(&cp, "SOCKS &Version", IDC_PROXYSOCKSVERSTATIC,
1879 2, "Version 5", IDC_PROXYSOCKSVER5, "Version 4",
1880 IDC_PROXYSOCKSVER4, NULL);
1885 if (panel == telnetpanelstart) {
1886 /* The Telnet panel. Accelerators used: [acgoh] svldr bftk */
1888 ctlposinit(&cp, hwnd, 80, 3, 13);
1890 bartitle(&cp, "Options controlling Telnet connections",
1892 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1893 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1895 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1896 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1897 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1898 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1900 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1901 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1902 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1903 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1904 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1905 "Passive", IDC_TPASSIVE, "Active",
1907 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1909 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1915 if (panel == rloginpanelstart) {
1916 /* The Rlogin panel. Accelerators used: [acgoh] sl */
1918 ctlposinit(&cp, hwnd, 80, 3, 13);
1920 bartitle(&cp, "Options controlling Rlogin connections",
1922 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1923 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1925 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1926 IDC_RLLUSEREDIT, 50);
1931 if (panel == sshpanelstart) {
1932 /* The SSH panel. Accelerators used: [acgoh] r pe12ni sd */
1934 ctlposinit(&cp, hwnd, 80, 3, 13);
1936 bartitle(&cp, "Options controlling SSH connections",
1938 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1940 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1943 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
1944 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1945 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1946 radioline(&cp, "Preferred SSH protocol version:",
1947 IDC_SSHPROTSTATIC, 4,
1948 "1 on&ly", IDC_SSHPROT1ONLY,
1949 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2,
1950 "2 o&nly", IDC_SSHPROT2ONLY, NULL);
1952 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1953 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1954 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1956 checkbox(&cp, "Enable non-standard use of single-&DES in SSH 2",
1962 if (panel == sshauthpanelstart) {
1963 /* The SSH authentication panel. Accelerators used: [acgoh] m fkiuw */
1965 ctlposinit(&cp, hwnd, 80, 3, 13);
1967 bartitle(&cp, "Options controlling SSH authentication",
1969 beginbox(&cp, "Authentication methods",
1971 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
1973 checkbox(&cp, "Attempt \"keyboard-&interactive\" authentication"
1974 " (SSH2)", IDC_AUTHKI);
1976 beginbox(&cp, "Authentication parameters",
1978 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
1979 checkbox(&cp, "Allow attempted changes of &username in SSH2",
1981 editbutton(&cp, "Private &key file for authentication:",
1982 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
1988 if (panel == sshbugspanelstart) {
1989 /* The SSH bugs panel. Accelerators used: [acgoh] isrmep */
1991 ctlposinit(&cp, hwnd, 80, 3, 13);
1993 bartitle(&cp, "Workarounds for SSH server bugs",
1995 beginbox(&cp, "Detection of known bugs in SSH servers",
1997 staticddl(&cp, "Chokes on SSH1 &ignore messages",
1998 IDC_BUGS_IGNORE1, IDC_BUGD_IGNORE1, 20);
1999 staticddl(&cp, "Refuses all SSH1 pa&ssword camouflage",
2000 IDC_BUGS_PLAINPW1, IDC_BUGD_PLAINPW1, 20);
2001 staticddl(&cp, "Chokes on SSH1 &RSA authentication",
2002 IDC_BUGS_RSA1, IDC_BUGD_RSA1, 20);
2003 staticddl(&cp, "Miscomputes SSH2 H&MAC keys",
2004 IDC_BUGS_HMAC2, IDC_BUGD_HMAC2, 20);
2005 staticddl(&cp, "Miscomputes SSH2 &encryption keys",
2006 IDC_BUGS_DERIVEKEY2, IDC_BUGD_DERIVEKEY2, 20);
2007 staticddl(&cp, "Requires &padding on SSH2 RSA signatures",
2008 IDC_BUGS_RSAPAD2, IDC_BUGD_RSAPAD2, 20);
2009 staticddl(&cp, "Chokes on &Diffie-Hellman group exchange",
2010 IDC_BUGS_DHGEX2, IDC_BUGD_DHGEX2, 20);
2015 if (panel == tunnelspanelstart) {
2016 /* The Tunnels panel. Accelerators used: [acgoh] deilmrstxp */
2018 ctlposinit(&cp, hwnd, 80, 3, 13);
2020 bartitle(&cp, "Options controlling SSH tunnelling",
2022 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
2023 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
2024 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
2025 IDC_X11_DISPLAY, 50, NULL);
2027 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
2028 checkbox(&cp, "Local ports accept connections from o&ther hosts",
2030 checkbox(&cp, "Remote &ports do the same (SSH v2 only)",
2032 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
2033 "&Remove", IDC_PFWDREMOVE);
2034 fwdsetter(&cp, IDC_PFWDLIST,
2035 "Add new forwarded port:", IDC_PFWDSTATIC2,
2036 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
2037 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
2038 "A&dd", IDC_PFWDADD);
2039 bareradioline(&cp, 2,
2040 "&Local", IDC_PFWDLOCAL,
2041 "Re&mote", IDC_PFWDREMOTE, NULL);
2049 * Helper function to load the session selected in SESSLIST
2050 * if any, as this is done in more than one place in
2051 * GenericMainDlgProc(). 0 => failure.
2053 static int load_selected_session(HWND hwnd)
2055 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2056 LB_GETCURSEL, 0, 0);
2062 isdef = !strcmp(sessions[n], "Default Settings");
2063 load_settings(sessions[n], !isdef, &cfg);
2064 init_dlg_ctrls(hwnd, TRUE);
2066 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
2068 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
2069 /* Restore the selection, which will have been clobbered by
2070 * SESSEDIT handling. */
2071 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
2076 * This function is the configuration box.
2078 static int GenericMainDlgProc(HWND hwnd, UINT msg,
2079 WPARAM wParam, LPARAM lParam, int dlgtype)
2082 struct treeview_faff tvfaff;
2085 char filename[sizeof(cfg.keyfile)];
2088 char fontstatic[256];
2090 struct servent *service;
2092 static UINT draglistmsg = WM_NULL;
2097 SetWindowLong(hwnd, GWL_USERDATA, 0);
2099 SetWindowLong(hwnd, GWL_EXSTYLE,
2100 GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
2102 HWND item = GetDlgItem(hwnd, IDC_HELPBTN);
2104 DestroyWindow(item);
2106 requested_help = FALSE;
2107 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
2108 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
2110 * Centre the window.
2112 { /* centre the window */
2115 hw = GetDesktopWindow();
2116 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
2118 (rs.right + rs.left + rd.left - rd.right) / 2,
2119 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
2120 rd.right - rd.left, rd.bottom - rd.top, TRUE);
2124 * Create the tree view.
2132 r.right = r.left + 75;
2134 r.bottom = r.top + 10;
2135 MapDialogRect(hwnd, &r);
2136 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
2137 WS_CHILD | WS_VISIBLE,
2139 r.right - r.left, r.bottom - r.top,
2140 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
2142 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
2143 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2146 r.right = r.left + 75;
2148 r.bottom = r.top + 219;
2149 MapDialogRect(hwnd, &r);
2150 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
2151 WS_CHILD | WS_VISIBLE |
2152 WS_TABSTOP | TVS_HASLINES |
2153 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
2155 TVS_SHOWSELALWAYS, r.left, r.top,
2156 r.right - r.left, r.bottom - r.top,
2157 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
2159 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
2160 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2161 tvfaff.treeview = treeview;
2162 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
2166 * Set up the tree view contents.
2168 hsession = treeview_insert(&tvfaff, 0, "Session");
2169 treeview_insert(&tvfaff, 1, "Logging");
2170 treeview_insert(&tvfaff, 0, "Terminal");
2171 treeview_insert(&tvfaff, 1, "Keyboard");
2172 treeview_insert(&tvfaff, 1, "Bell");
2173 treeview_insert(&tvfaff, 1, "Features");
2174 treeview_insert(&tvfaff, 0, "Window");
2175 treeview_insert(&tvfaff, 1, "Appearance");
2176 treeview_insert(&tvfaff, 1, "Behaviour");
2177 treeview_insert(&tvfaff, 1, "Translation");
2178 treeview_insert(&tvfaff, 1, "Selection");
2179 treeview_insert(&tvfaff, 1, "Colours");
2180 treeview_insert(&tvfaff, 0, "Connection");
2182 treeview_insert(&tvfaff, 1, "Proxy");
2183 treeview_insert(&tvfaff, 1, "Telnet");
2184 treeview_insert(&tvfaff, 1, "Rlogin");
2185 if (backends[3].backend != NULL) {
2186 treeview_insert(&tvfaff, 1, "SSH");
2187 /* XXX long name is ugly */
2188 /* XXX make it closed by default? */
2189 treeview_insert(&tvfaff, 2, "Auth");
2190 treeview_insert(&tvfaff, 2, "Tunnels");
2191 treeview_insert(&tvfaff, 2, "Bugs");
2196 * Put the treeview selection on to the Session panel. This
2197 * should also cause creation of the relevant controls.
2199 TreeView_SelectItem(treeview, hsession);
2202 * Set focus into the first available control.
2206 ctl = GetDlgItem(hwnd, IDC_HOST);
2208 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
2212 SetWindowLong(hwnd, GWL_USERDATA, 1);
2213 sesslist_has_focus = 0;
2217 * Button release should trigger WM_OK if there was a
2218 * previous double click on the session list.
2222 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
2225 if (LOWORD(wParam) == IDCX_TREEVIEW &&
2226 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
2228 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
2233 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
2236 item.pszText = buffer;
2237 item.cchTextMax = sizeof(buffer);
2238 item.mask = TVIF_TEXT;
2239 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
2240 for (j = controlstartvalue; j < controlendvalue; j++) {
2241 HWND item = GetDlgItem(hwnd, j);
2243 DestroyWindow(item);
2245 if (!strcmp(buffer, "Session"))
2246 create_controls(hwnd, dlgtype, sessionpanelstart);
2247 if (!strcmp(buffer, "Logging"))
2248 create_controls(hwnd, dlgtype, loggingpanelstart);
2249 if (!strcmp(buffer, "Keyboard"))
2250 create_controls(hwnd, dlgtype, keyboardpanelstart);
2251 if (!strcmp(buffer, "Terminal"))
2252 create_controls(hwnd, dlgtype, terminalpanelstart);
2253 if (!strcmp(buffer, "Bell"))
2254 create_controls(hwnd, dlgtype, bellpanelstart);
2255 if (!strcmp(buffer, "Features"))
2256 create_controls(hwnd, dlgtype, featurespanelstart);
2257 if (!strcmp(buffer, "Window"))
2258 create_controls(hwnd, dlgtype, windowpanelstart);
2259 if (!strcmp(buffer, "Appearance"))
2260 create_controls(hwnd, dlgtype, appearancepanelstart);
2261 if (!strcmp(buffer, "Behaviour"))
2262 create_controls(hwnd, dlgtype, behaviourpanelstart);
2263 if (!strcmp(buffer, "Tunnels"))
2264 create_controls(hwnd, dlgtype, tunnelspanelstart);
2265 if (!strcmp(buffer, "Connection"))
2266 create_controls(hwnd, dlgtype, connectionpanelstart);
2267 if (!strcmp(buffer, "Proxy"))
2268 create_controls(hwnd, dlgtype, proxypanelstart);
2269 if (!strcmp(buffer, "Telnet"))
2270 create_controls(hwnd, dlgtype, telnetpanelstart);
2271 if (!strcmp(buffer, "Rlogin"))
2272 create_controls(hwnd, dlgtype, rloginpanelstart);
2273 if (!strcmp(buffer, "SSH"))
2274 create_controls(hwnd, dlgtype, sshpanelstart);
2275 if (!strcmp(buffer, "Auth"))
2276 create_controls(hwnd, dlgtype, sshauthpanelstart);
2277 if (!strcmp(buffer, "Bugs"))
2278 create_controls(hwnd, dlgtype, sshbugspanelstart);
2279 if (!strcmp(buffer, "Selection"))
2280 create_controls(hwnd, dlgtype, selectionpanelstart);
2281 if (!strcmp(buffer, "Colours"))
2282 create_controls(hwnd, dlgtype, colourspanelstart);
2283 if (!strcmp(buffer, "Translation"))
2284 create_controls(hwnd, dlgtype, translationpanelstart);
2286 init_dlg_ctrls(hwnd, FALSE);
2288 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
2289 InvalidateRect (hwnd, NULL, TRUE);
2291 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
2297 * Only process WM_COMMAND once the dialog is fully formed.
2299 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
2300 switch (LOWORD(wParam)) {
2302 /* Behaviour of the "Open" button is different if the
2303 * session list has focus, *unless* the user just
2304 * double-clicked... */
2305 if (sesslist_has_focus && !readytogo) {
2306 if (!load_selected_session(hwnd)) {
2311 /* If at this point we have a valid session, go! */
2313 if (requested_help) {
2314 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2315 requested_help = FALSE;
2322 if (HIWORD(wParam) == BN_CLICKED ||
2323 HIWORD(wParam) == BN_DOUBLECLICKED) {
2325 WinHelp(hwnd, help_path,
2326 help_has_contents ? HELP_FINDER : HELP_CONTENTS,
2328 requested_help = TRUE;
2333 if (requested_help) {
2334 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2335 requested_help = FALSE;
2339 case IDC_PROTTELNET:
2340 case IDC_PROTRLOGIN:
2343 if (HIWORD(wParam) == BN_CLICKED ||
2344 HIWORD(wParam) == BN_DOUBLECLICKED) {
2345 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
2346 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
2347 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
2349 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
2352 * When switching using the arrow keys, we
2353 * appear to get two of these messages, both
2354 * mentioning the target button in
2355 * LOWORD(wParam), but one of them called while
2356 * the previous button is still checked. This
2357 * causes an unnecessary reset of the port
2358 * number field, which we fix by ensuring here
2359 * that the button selected is indeed the one
2362 if (IsDlgButtonChecked(hwnd, LOWORD(wParam)) &&
2363 ((cfg.protocol == PROT_SSH && cfg.port != 22)
2364 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
2365 || (cfg.protocol == PROT_RLOGIN
2366 && cfg.port != 513))) {
2367 cfg.port = i ? 22 : j ? 23 : 513;
2368 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
2373 if (HIWORD(wParam) == EN_CHANGE)
2374 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
2375 sizeof(cfg.host) - 1);
2378 if (HIWORD(wParam) == EN_CHANGE) {
2379 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
2380 if (isdigit(portname[0]))
2381 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
2383 service = getservbyname(portname, NULL);
2385 cfg.port = ntohs(service->s_port);
2392 if (HIWORD(wParam) == EN_CHANGE) {
2393 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2395 GetDlgItemText(hwnd, IDC_SESSEDIT,
2396 savedsession, sizeof(savedsession) - 1);
2397 savedsession[sizeof(savedsession) - 1] = '\0';
2401 if (HIWORD(wParam) == BN_CLICKED ||
2402 HIWORD(wParam) == BN_DOUBLECLICKED) {
2407 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
2410 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2411 LB_GETCURSEL, 0, 0);
2416 strcpy(str, sessions[n]);
2418 save_settings(str, !!strcmp(str, "Default Settings"),
2420 get_sesslist(FALSE);
2422 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2424 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2426 for (i = 0; i < nsessions; i++)
2427 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2429 (LPARAM) (sessions[i]));
2430 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2432 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2434 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2440 if (LOWORD(wParam) == IDC_SESSLIST) {
2441 if (HIWORD(wParam) == LBN_SETFOCUS)
2442 sesslist_has_focus = 1;
2443 else if (HIWORD(wParam) == LBN_KILLFOCUS)
2444 sesslist_has_focus = 0;
2446 if (LOWORD(wParam) == IDC_SESSLOAD &&
2447 HIWORD(wParam) != BN_CLICKED &&
2448 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2449 if (LOWORD(wParam) == IDC_SESSLIST &&
2450 HIWORD(wParam) != LBN_DBLCLK) break;
2451 /* Load the session selected in SESSLIST. */
2452 if (load_selected_session(hwnd) &&
2453 LOWORD(wParam) == IDC_SESSLIST) {
2455 * A double-click on a saved session should
2456 * actually start the session, not just load it.
2457 * Unless it's Default Settings or some other
2458 * host-less set of saved settings.
2467 if (HIWORD(wParam) == BN_CLICKED ||
2468 HIWORD(wParam) == BN_DOUBLECLICKED) {
2469 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2470 LB_GETCURSEL, 0, 0);
2471 if (n == LB_ERR || n == 0) {
2475 del_settings(sessions[n]);
2476 get_sesslist(FALSE);
2478 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2480 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2482 for (i = 0; i < nsessions; i++)
2483 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2485 (LPARAM) (sessions[i]));
2486 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2488 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2490 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2494 if (HIWORD(wParam) == EN_CHANGE)
2495 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
2496 &cfg.ping_interval);
2499 if (HIWORD(wParam) == BN_CLICKED ||
2500 HIWORD(wParam) == BN_DOUBLECLICKED)
2502 IsDlgButtonChecked(hwnd, IDC_NODELAY);
2506 if (HIWORD(wParam) == BN_CLICKED ||
2507 HIWORD(wParam) == BN_DOUBLECLICKED)
2508 cfg.bksp_is_delete =
2509 IsDlgButtonChecked(hwnd, IDC_DEL127);
2513 if (HIWORD(wParam) == BN_CLICKED ||
2514 HIWORD(wParam) == BN_DOUBLECLICKED)
2516 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
2522 case IDC_FUNCVT100P:
2524 if (HIWORD(wParam) == BN_CLICKED ||
2525 HIWORD(wParam) == BN_DOUBLECLICKED)
2526 switch (LOWORD(wParam)) {
2539 case IDC_FUNCVT100P:
2549 if (HIWORD(wParam) == BN_CLICKED ||
2550 HIWORD(wParam) == BN_DOUBLECLICKED) {
2552 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
2553 cfg.nethack_keypad = FALSE;
2557 if (HIWORD(wParam) == BN_CLICKED ||
2558 HIWORD(wParam) == BN_DOUBLECLICKED) {
2559 cfg.app_keypad = FALSE;
2560 cfg.nethack_keypad = TRUE;
2565 if (HIWORD(wParam) == BN_CLICKED ||
2566 HIWORD(wParam) == BN_DOUBLECLICKED)
2568 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
2571 if (HIWORD(wParam) == BN_CLICKED ||
2572 HIWORD(wParam) == BN_DOUBLECLICKED)
2574 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
2577 if (HIWORD(wParam) == BN_CLICKED ||
2578 HIWORD(wParam) == BN_DOUBLECLICKED)
2580 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
2582 case IDC_NOMOUSEREP:
2583 if (HIWORD(wParam) == BN_CLICKED ||
2584 HIWORD(wParam) == BN_DOUBLECLICKED)
2586 IsDlgButtonChecked(hwnd, IDC_NOMOUSEREP);
2589 if (HIWORD(wParam) == BN_CLICKED ||
2590 HIWORD(wParam) == BN_DOUBLECLICKED)
2591 cfg.no_remote_resize =
2592 IsDlgButtonChecked(hwnd, IDC_NORESIZE);
2594 case IDC_NOALTSCREEN:
2595 if (HIWORD(wParam) == BN_CLICKED ||
2596 HIWORD(wParam) == BN_DOUBLECLICKED)
2598 IsDlgButtonChecked(hwnd, IDC_NOALTSCREEN);
2600 case IDC_NOWINTITLE:
2601 if (HIWORD(wParam) == BN_CLICKED ||
2602 HIWORD(wParam) == BN_DOUBLECLICKED)
2603 cfg.no_remote_wintitle =
2604 IsDlgButtonChecked(hwnd, IDC_NOWINTITLE);
2606 case IDC_NODBACKSPACE:
2607 if (HIWORD(wParam) == BN_CLICKED ||
2608 HIWORD(wParam) == BN_DOUBLECLICKED)
2610 IsDlgButtonChecked(hwnd, IDC_NODBACKSPACE);
2613 if (HIWORD(wParam) == BN_CLICKED ||
2614 HIWORD(wParam) == BN_DOUBLECLICKED)
2615 cfg.no_remote_charset =
2616 IsDlgButtonChecked(hwnd, IDC_NOCHARSET);
2619 if (HIWORD(wParam) == BN_CLICKED ||
2620 HIWORD(wParam) == BN_DOUBLECLICKED)
2621 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
2624 if (HIWORD(wParam) == BN_CLICKED ||
2625 HIWORD(wParam) == BN_DOUBLECLICKED)
2627 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
2630 if (HIWORD(wParam) == BN_CLICKED ||
2631 HIWORD(wParam) == BN_DOUBLECLICKED)
2633 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
2635 case IDC_ECHOBACKEND:
2638 if (HIWORD(wParam) == BN_CLICKED ||
2639 HIWORD(wParam) == BN_DOUBLECLICKED) {
2640 if (LOWORD(wParam) == IDC_ECHOBACKEND)
2641 cfg.localecho = LD_BACKEND;
2642 if (LOWORD(wParam) == IDC_ECHOYES)
2643 cfg.localecho = LD_YES;
2644 if (LOWORD(wParam) == IDC_ECHONO)
2645 cfg.localecho = LD_NO;
2648 case IDC_EDITBACKEND:
2651 if (HIWORD(wParam) == BN_CLICKED ||
2652 HIWORD(wParam) == BN_DOUBLECLICKED) {
2653 if (LOWORD(wParam) == IDC_EDITBACKEND)
2654 cfg.localedit = LD_BACKEND;
2655 if (LOWORD(wParam) == IDC_EDITYES)
2656 cfg.localedit = LD_YES;
2657 if (LOWORD(wParam) == IDC_EDITNO)
2658 cfg.localedit = LD_NO;
2661 case IDC_ANSWEREDIT:
2662 if (HIWORD(wParam) == EN_CHANGE)
2663 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
2664 sizeof(cfg.answerback) - 1);
2666 case IDC_ALWAYSONTOP:
2667 if (HIWORD(wParam) == BN_CLICKED ||
2668 HIWORD(wParam) == BN_DOUBLECLICKED)
2670 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
2672 case IDC_FULLSCREENONALTENTER:
2673 if (HIWORD(wParam) == BN_CLICKED ||
2674 HIWORD(wParam) == BN_DOUBLECLICKED)
2675 cfg.fullscreenonaltenter =
2676 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
2679 if (HIWORD(wParam) == BN_CLICKED ||
2680 HIWORD(wParam) == BN_DOUBLECLICKED)
2682 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
2684 case IDC_SCROLLDISP:
2685 if (HIWORD(wParam) == BN_CLICKED ||
2686 HIWORD(wParam) == BN_DOUBLECLICKED)
2687 cfg.scroll_on_disp =
2688 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
2690 case IDC_COMPOSEKEY:
2691 if (HIWORD(wParam) == BN_CLICKED ||
2692 HIWORD(wParam) == BN_DOUBLECLICKED)
2694 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
2696 case IDC_CTRLALTKEYS:
2697 if (HIWORD(wParam) == BN_CLICKED ||
2698 HIWORD(wParam) == BN_DOUBLECLICKED)
2700 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
2703 if (HIWORD(wParam) == BN_CLICKED ||
2704 HIWORD(wParam) == BN_DOUBLECLICKED)
2705 cfg.telnet_keyboard =
2706 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
2709 if (HIWORD(wParam) == BN_CLICKED ||
2710 HIWORD(wParam) == BN_DOUBLECLICKED)
2711 cfg.telnet_newline =
2712 IsDlgButtonChecked(hwnd, IDC_TELNETRET);
2715 if (HIWORD(wParam) == BN_CLICKED ||
2716 HIWORD(wParam) == BN_DOUBLECLICKED)
2718 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
2721 if (HIWORD(wParam) == BN_CLICKED ||
2722 HIWORD(wParam) == BN_DOUBLECLICKED)
2723 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
2726 if (HIWORD(wParam) == BN_CLICKED ||
2727 HIWORD(wParam) == BN_DOUBLECLICKED)
2729 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
2732 if (HIWORD(wParam) == EN_CHANGE)
2733 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
2736 if (HIWORD(wParam) == EN_CHANGE)
2737 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
2740 if (HIWORD(wParam) == EN_CHANGE)
2741 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
2743 case IDC_CHOOSEFONT:
2746 lf.lfHeight = -MulDiv(cfg.fontheight,
2747 GetDeviceCaps(hdc, LOGPIXELSY),
2751 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
2752 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
2753 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
2754 lf.lfCharSet = cfg.fontcharset;
2755 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
2756 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
2757 lf.lfQuality = DEFAULT_QUALITY;
2758 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
2759 strncpy(lf.lfFaceName, cfg.font,
2760 sizeof(lf.lfFaceName) - 1);
2761 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
2763 cf.lStructSize = sizeof(cf);
2764 cf.hwndOwner = hwnd;
2766 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
2767 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
2769 if (ChooseFont(&cf)) {
2770 strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
2771 cfg.font[sizeof(cfg.font) - 1] = '\0';
2772 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
2773 cfg.fontcharset = lf.lfCharSet;
2774 cfg.fontheight = cf.iPointSize / 10;
2775 fmtfont(fontstatic);
2776 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
2779 case IDC_BELL_DISABLED:
2780 case IDC_BELL_DEFAULT:
2781 case IDC_BELL_WAVEFILE:
2782 case IDC_BELL_VISUAL:
2783 if (HIWORD(wParam) == BN_CLICKED ||
2784 HIWORD(wParam) == BN_DOUBLECLICKED) {
2785 if (LOWORD(wParam) == IDC_BELL_DISABLED)
2786 cfg.beep = BELL_DISABLED;
2787 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
2788 cfg.beep = BELL_DEFAULT;
2789 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
2790 cfg.beep = BELL_WAVEFILE;
2791 if (LOWORD(wParam) == IDC_BELL_VISUAL)
2792 cfg.beep = BELL_VISUAL;
2795 case IDC_B_IND_DISABLED:
2796 case IDC_B_IND_FLASH:
2797 case IDC_B_IND_STEADY:
2798 if (HIWORD(wParam) == BN_CLICKED ||
2799 HIWORD(wParam) == BN_DOUBLECLICKED) {
2800 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2801 cfg.beep_ind = B_IND_DISABLED;
2802 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2803 cfg.beep_ind = B_IND_FLASH;
2804 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2805 cfg.beep_ind = B_IND_STEADY;
2808 case IDC_BELL_WAVEBROWSE:
2809 memset(&of, 0, sizeof(of));
2810 #ifdef OPENFILENAME_SIZE_VERSION_400
2811 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2813 of.lStructSize = sizeof(of);
2815 of.hwndOwner = hwnd;
2816 of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2817 of.lpstrCustomFilter = NULL;
2818 of.nFilterIndex = 1;
2819 of.lpstrFile = filename;
2820 strcpy(filename, cfg.bell_wavefile);
2821 of.nMaxFile = sizeof(filename);
2822 of.lpstrFileTitle = NULL;
2823 of.lpstrInitialDir = NULL;
2824 of.lpstrTitle = "Select Bell Sound File";
2826 if (GetOpenFileName(&of)) {
2827 strcpy(cfg.bell_wavefile, filename);
2828 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2832 case IDC_BELL_WAVEEDIT:
2833 if (HIWORD(wParam) == EN_CHANGE)
2834 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2836 sizeof(cfg.bell_wavefile) - 1);
2839 if (HIWORD(wParam) == BN_CLICKED ||
2840 HIWORD(wParam) == BN_DOUBLECLICKED)
2842 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2845 if (HIWORD(wParam) == EN_CHANGE)
2846 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2849 if (HIWORD(wParam) == EN_CHANGE)
2850 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2854 if (HIWORD(wParam) == EN_CHANGE)
2855 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2859 if (HIWORD(wParam) == BN_CLICKED ||
2860 HIWORD(wParam) == BN_DOUBLECLICKED)
2862 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2865 if (HIWORD(wParam) == BN_CLICKED ||
2866 HIWORD(wParam) == BN_DOUBLECLICKED)
2867 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2870 if (HIWORD(wParam) == BN_CLICKED ||
2871 HIWORD(wParam) == BN_DOUBLECLICKED)
2872 cfg.win_name_always =
2873 IsDlgButtonChecked(hwnd, IDC_WINNAME);
2876 if (HIWORD(wParam) == BN_CLICKED ||
2877 HIWORD(wParam) == BN_DOUBLECLICKED)
2879 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2881 case IDC_SUNKENEDGE:
2882 if (HIWORD(wParam) == BN_CLICKED ||
2883 HIWORD(wParam) == BN_DOUBLECLICKED)
2885 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2888 if (HIWORD(wParam) == EN_CHANGE)
2889 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2890 &cfg.window_border);
2891 if (cfg.window_border > 32)
2892 cfg.window_border = 32;
2895 if (HIWORD(wParam) == BN_CLICKED ||
2896 HIWORD(wParam) == BN_DOUBLECLICKED)
2897 cfg.cursor_type = 0;
2900 if (HIWORD(wParam) == BN_CLICKED ||
2901 HIWORD(wParam) == BN_DOUBLECLICKED)
2902 cfg.cursor_type = 1;
2905 if (HIWORD(wParam) == BN_CLICKED ||
2906 HIWORD(wParam) == BN_DOUBLECLICKED)
2907 cfg.cursor_type = 2;
2910 if (HIWORD(wParam) == BN_CLICKED ||
2911 HIWORD(wParam) == BN_DOUBLECLICKED)
2913 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2916 if (HIWORD(wParam) == BN_CLICKED ||
2917 HIWORD(wParam) == BN_DOUBLECLICKED)
2919 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2921 case IDC_SCROLLBARFULLSCREEN:
2922 if (HIWORD(wParam) == BN_CLICKED ||
2923 HIWORD(wParam) == BN_DOUBLECLICKED)
2924 cfg.scrollbar_in_fullscreen =
2925 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2927 case IDC_RESIZETERM:
2928 case IDC_RESIZEFONT:
2929 case IDC_RESIZENONE:
2930 case IDC_RESIZEEITHER:
2931 if (HIWORD(wParam) == BN_CLICKED ||
2932 HIWORD(wParam) == BN_DOUBLECLICKED) {
2934 IsDlgButtonChecked(hwnd,
2935 IDC_RESIZETERM) ? RESIZE_TERM :
2936 IsDlgButtonChecked(hwnd,
2937 IDC_RESIZEFONT) ? RESIZE_FONT :
2938 IsDlgButtonChecked(hwnd,
2939 IDC_RESIZEEITHER) ? RESIZE_EITHER :
2944 if (HIWORD(wParam) == EN_CHANGE)
2945 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2946 sizeof(cfg.wintitle) - 1);
2951 if (HIWORD(wParam) == BN_CLICKED ||
2952 HIWORD(wParam) == BN_DOUBLECLICKED) {
2954 IsDlgButtonChecked(hwnd,
2955 IDC_COEALWAYS) ? COE_ALWAYS :
2956 IsDlgButtonChecked(hwnd,
2957 IDC_COENEVER) ? COE_NEVER :
2962 if (HIWORD(wParam) == BN_CLICKED ||
2963 HIWORD(wParam) == BN_DOUBLECLICKED)
2965 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
2968 if (HIWORD(wParam) == EN_CHANGE)
2969 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
2970 sizeof(cfg.termtype) - 1);
2974 case IDC_PROXYHOSTEDIT:
2975 if (HIWORD(wParam) == EN_CHANGE)
2976 GetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host,
2977 sizeof(cfg.proxy_host) - 1);
2979 case IDC_PROXYPORTEDIT:
2980 if (HIWORD(wParam) == EN_CHANGE) {
2981 GetDlgItemText(hwnd, IDC_PROXYPORTEDIT, portname, 31);
2982 if (isdigit(portname[0]))
2983 MyGetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, &cfg.proxy_port);
2985 service = getservbyname(portname, NULL);
2987 cfg.proxy_port = ntohs(service->s_port);
2993 case IDC_PROXYEXCLUDEEDIT:
2994 if (HIWORD(wParam) == EN_CHANGE)
2995 GetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT,
2996 cfg.proxy_exclude_list,
2997 sizeof(cfg.proxy_exclude_list) - 1);
2999 case IDC_PROXYUSEREDIT:
3000 if (HIWORD(wParam) == EN_CHANGE)
3001 GetDlgItemText(hwnd, IDC_PROXYUSEREDIT,
3003 sizeof(cfg.proxy_username) - 1);
3005 case IDC_PROXYPASSEDIT:
3006 if (HIWORD(wParam) == EN_CHANGE)
3007 GetDlgItemText(hwnd, IDC_PROXYPASSEDIT,
3009 sizeof(cfg.proxy_password) - 1);
3011 case IDC_PROXYTELNETCMDEDIT:
3012 if (HIWORD(wParam) == EN_CHANGE)
3013 GetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT,
3014 cfg.proxy_telnet_command,
3015 sizeof(cfg.proxy_telnet_command) - 1);
3017 case IDC_PROXYSOCKSVER5:
3018 case IDC_PROXYSOCKSVER4:
3019 if (HIWORD(wParam) == BN_CLICKED ||
3020 HIWORD(wParam) == BN_DOUBLECLICKED) {
3021 cfg.proxy_socks_version =
3022 IsDlgButtonChecked(hwnd, IDC_PROXYSOCKSVER4) ? 4 : 5;
3025 case IDC_PROXYTYPENONE:
3026 case IDC_PROXYTYPEHTTP:
3027 case IDC_PROXYTYPESOCKS:
3028 case IDC_PROXYTYPETELNET:
3029 if (HIWORD(wParam) == BN_CLICKED ||
3030 HIWORD(wParam) == BN_DOUBLECLICKED) {
3032 IsDlgButtonChecked(hwnd, IDC_PROXYTYPEHTTP) ? PROXY_HTTP :
3033 IsDlgButtonChecked(hwnd, IDC_PROXYTYPESOCKS) ? PROXY_SOCKS :
3034 IsDlgButtonChecked(hwnd, IDC_PROXYTYPETELNET) ? PROXY_TELNET :
3040 if (HIWORD(wParam) == EN_CHANGE)
3041 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
3042 sizeof(cfg.logfilename) - 1);
3045 memset(&of, 0, sizeof(of));
3046 #ifdef OPENFILENAME_SIZE_VERSION_400
3047 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3049 of.lStructSize = sizeof(of);
3051 of.hwndOwner = hwnd;
3052 of.lpstrFilter = "All Files\0*\0\0\0";
3053 of.lpstrCustomFilter = NULL;
3054 of.nFilterIndex = 1;
3055 of.lpstrFile = filename;
3056 strcpy(filename, cfg.logfilename);
3057 of.nMaxFile = sizeof(filename);
3058 of.lpstrFileTitle = NULL;
3059 of.lpstrInitialDir = NULL;
3060 of.lpstrTitle = "Select session log file";
3062 if (GetSaveFileName(&of)) {
3063 strcpy(cfg.logfilename, filename);
3064 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
3068 case IDC_LSTATASCII:
3070 case IDC_LSTATPACKET:
3071 if (HIWORD(wParam) == BN_CLICKED ||
3072 HIWORD(wParam) == BN_DOUBLECLICKED) {
3073 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
3074 cfg.logtype = LGTYP_NONE;
3075 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
3076 cfg.logtype = LGTYP_ASCII;
3077 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
3078 cfg.logtype = LGTYP_DEBUG;
3079 if (IsDlgButtonChecked(hwnd, IDC_LSTATPACKET))
3080 cfg.logtype = LGTYP_PACKETS;
3086 if (HIWORD(wParam) == BN_CLICKED ||
3087 HIWORD(wParam) == BN_DOUBLECLICKED) {
3088 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
3089 cfg.logxfovr = LGXF_ASK;
3090 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
3091 cfg.logxfovr = LGXF_APN;
3092 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
3093 cfg.logxfovr = LGXF_OVR;
3098 if (HIWORD(wParam) == EN_CHANGE)
3099 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
3100 sizeof(cfg.termspeed) - 1);
3103 if (HIWORD(wParam) == EN_CHANGE)
3104 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
3105 sizeof(cfg.username) - 1);
3107 case IDC_RLLUSEREDIT:
3108 if (HIWORD(wParam) == EN_CHANGE)
3109 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
3111 sizeof(cfg.localusername) - 1);
3115 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
3119 cfg.passive_telnet =
3120 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
3123 if (HIWORD(wParam) == BN_CLICKED ||
3124 HIWORD(wParam) == BN_DOUBLECLICKED) {
3125 char str[sizeof(cfg.environmt)];
3127 GetDlgItemText(hwnd, IDC_VAREDIT, str,
3133 p = str + strlen(str);
3135 GetDlgItemText(hwnd, IDC_VALEDIT, p,
3136 sizeof(str) - 1 - (p - str));
3147 if ((p - cfg.environmt) + strlen(str) + 2 <
3148 sizeof(cfg.environmt)) {
3150 p[strlen(str) + 1] = '\0';
3151 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
3153 SetDlgItemText(hwnd, IDC_VAREDIT, "");
3154 SetDlgItemText(hwnd, IDC_VALEDIT, "");
3156 MessageBox(hwnd, "Environment too big",
3157 "PuTTY Error", MB_OK | MB_ICONERROR);
3162 if (HIWORD(wParam) != BN_CLICKED &&
3163 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3165 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
3172 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
3199 if (HIWORD(wParam) == BN_CLICKED ||
3200 HIWORD(wParam) == BN_DOUBLECLICKED)
3201 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
3204 if (HIWORD(wParam) == BN_CLICKED ||
3205 HIWORD(wParam) == BN_DOUBLECLICKED)
3207 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
3210 if (HIWORD(wParam) == BN_CLICKED ||
3211 HIWORD(wParam) == BN_DOUBLECLICKED)
3213 IsDlgButtonChecked(hwnd, IDC_SSH2DES);
3216 if (HIWORD(wParam) == BN_CLICKED ||
3217 HIWORD(wParam) == BN_DOUBLECLICKED)
3219 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
3221 case IDC_CHANGEUSER:
3222 if (HIWORD(wParam) == BN_CLICKED ||
3223 HIWORD(wParam) == BN_DOUBLECLICKED)
3224 cfg.change_username =
3225 IsDlgButtonChecked(hwnd, IDC_CHANGEUSER);
3227 case IDC_CIPHERLIST:
3230 handle_prefslist(&cipherlist,
3231 cfg.ssh_cipherlist, CIPHER_MAX,
3232 0, hwnd, wParam, lParam);
3234 case IDC_SSHPROT1ONLY:
3237 case IDC_SSHPROT2ONLY:
3238 if (HIWORD(wParam) == BN_CLICKED ||
3239 HIWORD(wParam) == BN_DOUBLECLICKED) {
3240 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1ONLY))
3242 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
3244 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
3246 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2ONLY))
3251 if (HIWORD(wParam) == BN_CLICKED ||
3252 HIWORD(wParam) == BN_DOUBLECLICKED)
3254 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
3257 if (HIWORD(wParam) == BN_CLICKED ||
3258 HIWORD(wParam) == BN_DOUBLECLICKED)
3260 IsDlgButtonChecked(hwnd, IDC_AUTHKI);
3263 if (HIWORD(wParam) == EN_CHANGE)
3264 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
3265 sizeof(cfg.keyfile) - 1);
3268 if (HIWORD(wParam) == EN_CHANGE)
3269 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
3270 sizeof(cfg.remote_cmd) - 1);
3273 memset(&of, 0, sizeof(of));
3274 #ifdef OPENFILENAME_SIZE_VERSION_400
3275 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3277 of.lStructSize = sizeof(of);
3279 of.hwndOwner = hwnd;
3280 of.lpstrFilter = "PuTTY Private Key Files\0*.PPK\0"
3281 "AllFiles\0*\0\0\0";
3282 of.lpstrCustomFilter = NULL;
3283 of.nFilterIndex = 1;
3284 of.lpstrFile = filename;
3285 strcpy(filename, cfg.keyfile);
3286 of.nMaxFile = sizeof(filename);
3287 of.lpstrFileTitle = NULL;
3288 of.lpstrInitialDir = NULL;
3289 of.lpstrTitle = "Select Private Key File";
3291 if (GetOpenFileName(&of)) {
3292 strcpy(cfg.keyfile, filename);
3293 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
3297 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
3300 cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
3304 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
3306 case IDC_SELTYPELEX:
3307 case IDC_SELTYPERECT:
3308 cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
3310 case IDC_MOUSEOVERRIDE:
3311 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
3317 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
3322 for (i = 0; i < 128; i++)
3323 if (SendDlgItemMessage
3324 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
3326 cfg.wordness[i] = n;
3327 SendDlgItemMessage(hwnd, IDC_CCLIST,
3328 LB_DELETESTRING, i, 0);
3329 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
3330 (i >= 0x21 && i != 0x7F) ? i : ' ',
3332 SendDlgItemMessage(hwnd, IDC_CCLIST,
3339 case IDC_BOLDCOLOUR:
3340 if (HIWORD(wParam) == BN_CLICKED ||
3341 HIWORD(wParam) == BN_DOUBLECLICKED) {
3344 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
3345 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
3348 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3350 if (n != 12 + 10 * cfg.bold_colour) {
3351 for (i = n; i-- > 0;)
3352 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3353 LB_DELETESTRING, i, 0);
3354 for (i = 0; i < 22; i++)
3355 if (cfg.bold_colour || permcolour[i])
3356 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3358 (LPARAM) colours[i]);
3360 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
3362 InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
3367 if (HIWORD(wParam) == BN_CLICKED ||
3368 HIWORD(wParam) == BN_DOUBLECLICKED)
3370 IsDlgButtonChecked(hwnd, IDC_PALETTE);
3372 case IDC_COLOURLIST:
3373 if (HIWORD(wParam) == LBN_DBLCLK ||
3374 HIWORD(wParam) == LBN_SELCHANGE) {
3376 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3379 if (!cfg.bold_colour)
3380 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3381 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3383 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3385 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3390 if (HIWORD(wParam) == BN_CLICKED ||
3391 HIWORD(wParam) == BN_DOUBLECLICKED) {
3392 static CHOOSECOLOR cc;
3393 static DWORD custom[16] = { 0 }; /* zero initialisers */
3395 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3398 if (!cfg.bold_colour)
3399 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3400 cc.lStructSize = sizeof(cc);
3401 cc.hwndOwner = hwnd;
3402 cc.hInstance = (HWND) hinst;
3403 cc.lpCustColors = custom;
3405 RGB(cfg.colours[i][0], cfg.colours[i][1],
3407 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
3408 if (ChooseColor(&cc)) {
3410 (unsigned char) (cc.rgbResult & 0xFF);
3412 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
3414 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
3415 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3417 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3419 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3425 if (HIWORD(wParam) == CBN_SELCHANGE) {
3426 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
3427 CB_GETCURSEL, 0, 0);
3428 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
3429 index, (LPARAM)cfg.line_codepage);
3430 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3431 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
3432 sizeof(cfg.line_codepage) - 1);
3433 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
3434 strcpy(cfg.line_codepage,
3435 cp_name(decode_codepage(cfg.line_codepage)));
3436 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
3440 if (HIWORD(wParam) == CBN_SELCHANGE) {
3441 int index = SendDlgItemMessage(hwnd, IDC_PRINTER,
3442 CB_GETCURSEL, 0, 0);
3443 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_GETLBTEXT,
3444 index, (LPARAM)cfg.printer);
3445 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3446 GetDlgItemText(hwnd, IDC_PRINTER, cfg.printer,
3447 sizeof(cfg.printer) - 1);
3449 if (!strcmp(cfg.printer, PRINTER_DISABLED_STRING))
3450 *cfg.printer = '\0';
3452 case IDC_CAPSLOCKCYR:
3453 if (HIWORD(wParam) == BN_CLICKED ||
3454 HIWORD(wParam) == BN_DOUBLECLICKED) {
3455 cfg.xlat_capslockcyr =
3456 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
3459 case IDC_VTXWINDOWS:
3465 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
3466 : IsDlgButtonChecked(hwnd,
3467 IDC_VTOEMANSI) ? VT_OEMANSI :
3468 IsDlgButtonChecked(hwnd,
3469 IDC_VTOEMONLY) ? VT_OEMONLY :
3470 IsDlgButtonChecked(hwnd,
3471 IDC_VTUNICODE) ? VT_UNICODE :
3474 case IDC_X11_FORWARD:
3475 if (HIWORD(wParam) == BN_CLICKED ||
3476 HIWORD(wParam) == BN_DOUBLECLICKED)
3478 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
3481 if (HIWORD(wParam) == BN_CLICKED ||
3482 HIWORD(wParam) == BN_DOUBLECLICKED)
3483 cfg.lport_acceptall =
3484 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
3487 if (HIWORD(wParam) == BN_CLICKED ||
3488 HIWORD(wParam) == BN_DOUBLECLICKED)
3489 cfg.rport_acceptall =
3490 IsDlgButtonChecked(hwnd, IDC_RPORT_ALL);
3492 case IDC_X11_DISPLAY:
3493 if (HIWORD(wParam) == EN_CHANGE)
3494 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
3495 sizeof(cfg.x11_display) - 1);
3498 if (HIWORD(wParam) == BN_CLICKED ||
3499 HIWORD(wParam) == BN_DOUBLECLICKED) {
3500 char str[sizeof(cfg.portfwd)];
3502 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
3506 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
3510 "You need to specify a source port number",
3511 "PuTTY Error", MB_OK | MB_ICONERROR);
3514 p = str + strlen(str);
3516 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
3517 sizeof(str) - 1 - (p - str));
3518 if (!*p || !strchr(p, ':')) {
3520 "You need to specify a destination address\n"
3521 "in the form \"host.name:port\"",
3522 "PuTTY Error", MB_OK | MB_ICONERROR);
3531 if ((p - cfg.portfwd) + strlen(str) + 2 <
3532 sizeof(cfg.portfwd)) {
3534 p[strlen(str) + 1] = '\0';
3535 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
3537 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
3538 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
3540 MessageBox(hwnd, "Too many forwardings",
3541 "PuTTY Error", MB_OK | MB_ICONERROR);
3545 case IDC_PFWDREMOVE:
3546 if (HIWORD(wParam) != BN_CLICKED &&
3547 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3548 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
3549 LB_GETCURSEL, 0, 0);
3555 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
3581 case IDC_BUGD_IGNORE1:
3582 if (HIWORD(wParam) == CBN_SELCHANGE) {
3583 int index = SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1,
3584 CB_GETCURSEL, 0, 0);
3585 cfg.sshbug_ignore1 = (index == 0 ? BUG_AUTO :
3586 index == 1 ? BUG_OFF : BUG_ON);
3589 case IDC_BUGD_PLAINPW1:
3590 if (HIWORD(wParam) == CBN_SELCHANGE) {
3591 int index = SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1,
3592 CB_GETCURSEL, 0, 0);
3593 cfg.sshbug_plainpw1 = (index == 0 ? BUG_AUTO :
3594 index == 1 ? BUG_OFF : BUG_ON);
3598 if (HIWORD(wParam) == CBN_SELCHANGE) {
3599 int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSA1,
3600 CB_GETCURSEL, 0, 0);
3601 cfg.sshbug_rsa1 = (index == 0 ? BUG_AUTO :
3602 index == 1 ? BUG_OFF : BUG_ON);
3605 case IDC_BUGD_HMAC2:
3606 if (HIWORD(wParam) == CBN_SELCHANGE) {
3607 int index = SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2,
3608 CB_GETCURSEL, 0, 0);
3609 cfg.sshbug_hmac2 = (index == 0 ? BUG_AUTO :
3610 index == 1 ? BUG_OFF : BUG_ON);
3613 case IDC_BUGD_DERIVEKEY2:
3614 if (HIWORD(wParam) == CBN_SELCHANGE) {
3615 int index = SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2,
3616 CB_GETCURSEL, 0, 0);
3617 cfg.sshbug_derivekey2 = (index == 0 ? BUG_AUTO :
3618 index == 1 ? BUG_OFF : BUG_ON);
3621 case IDC_BUGD_RSAPAD2:
3622 if (HIWORD(wParam) == CBN_SELCHANGE) {
3623 int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2,
3624 CB_GETCURSEL, 0, 0);
3625 cfg.sshbug_rsapad2 = (index == 0 ? BUG_AUTO :
3626 index == 1 ? BUG_OFF : BUG_ON);
3629 case IDC_BUGD_DHGEX2:
3630 if (HIWORD(wParam) == CBN_SELCHANGE) {
3631 int index = SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2,
3632 CB_GETCURSEL, 0, 0);
3633 cfg.sshbug_dhgex2 = (index == 0 ? BUG_AUTO :
3634 index == 1 ? BUG_OFF : BUG_ON);
3641 int id = ((LPHELPINFO)lParam)->iCtrlId;
3642 char *cmd = help_context_cmd(id);
3644 WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
3645 requested_help = TRUE;
3652 if (requested_help) {
3653 WinHelp(hwnd, help_path, HELP_QUIT, 0);
3654 requested_help = FALSE;
3659 /* Grrr Explorer will maximize Dialogs! */
3661 if (wParam == SIZE_MAXIMIZED)
3667 * Handle application-defined messages eg. DragListBox
3669 /* First find out what the number is (once). */
3670 if (draglistmsg == WM_NULL)
3671 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
3673 if (msg == draglistmsg) {
3674 /* Only process once dialog is fully formed. */
3675 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
3676 case IDC_CIPHERLIST:
3677 return handle_prefslist(&cipherlist,
3678 cfg.ssh_cipherlist, CIPHER_MAX,
3679 1, hwnd, wParam, lParam);
3688 static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
3689 WPARAM wParam, LPARAM lParam)
3691 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
3693 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
3694 EnableWindow(hwnd, 0);
3695 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3696 EnableWindow(hwnd, 1);
3697 SetActiveWindow(hwnd);
3699 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
3702 static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
3703 WPARAM wParam, LPARAM lParam)
3705 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
3708 void defuse_showwindow(void)
3711 * Work around the fact that the app's first call to ShowWindow
3712 * will ignore the default in favour of the shell-provided
3717 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
3719 ShowWindow(hwnd, SW_HIDE);
3720 SetActiveWindow(hwnd);
3721 DestroyWindow(hwnd);
3730 savedsession[0] = '\0';
3732 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
3733 get_sesslist(FALSE);
3738 int do_reconfig(HWND hwnd)
3743 backup_cfg = cfg; /* structure copy */
3745 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
3747 cfg = backup_cfg; /* structure copy */
3752 void logevent(char *string)
3757 log_eventlog(string);
3759 if (nevents >= negsize) {
3761 events = srealloc(events, negsize * sizeof(*events));
3765 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
3768 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
3769 strcpy(events[nevents], timebuf);
3770 strcat(events[nevents], string);
3773 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
3774 0, (LPARAM) events[nevents]);
3775 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
3776 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
3781 void showeventlog(HWND hwnd)
3784 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
3786 ShowWindow(logbox, SW_SHOWNORMAL);
3788 SetActiveWindow(logbox);
3791 void showabout(HWND hwnd)
3793 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3796 void verify_ssh_host_key(char *host, int port, char *keytype,
3797 char *keystr, char *fingerprint)
3801 static const char absentmsg[] =
3802 "The server's host key is not cached in the registry. You\n"
3803 "have no guarantee that the server is the computer you\n"
3805 "The server's key fingerprint is:\n"
3807 "If you trust this host, hit Yes to add the key to\n"
3808 "PuTTY's cache and carry on connecting.\n"
3809 "If you want to carry on connecting just once, without\n"
3810 "adding the key to the cache, hit No.\n"
3811 "If you do not trust this host, hit Cancel to abandon the\n"
3814 static const char wrongmsg[] =
3815 "WARNING - POTENTIAL SECURITY BREACH!\n"
3817 "The server's host key does not match the one PuTTY has\n"
3818 "cached in the registry. This means that either the\n"
3819 "server administrator has changed the host key, or you\n"
3820 "have actually connected to another computer pretending\n"
3821 "to be the server.\n"
3822 "The new key fingerprint is:\n"
3824 "If you were expecting this change and trust the new key,\n"
3825 "hit Yes to update PuTTY's cache and continue connecting.\n"
3826 "If you want to carry on connecting but without updating\n"
3827 "the cache, hit No.\n"
3828 "If you want to abandon the connection completely, hit\n"
3829 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3831 static const char mbtitle[] = "PuTTY Security Alert";
3834 /* sensible fingerprint max size */
3835 (sizeof(absentmsg) > sizeof(wrongmsg) ?
3836 sizeof(absentmsg) : sizeof(wrongmsg))];
3839 * Verify the key against the registry.
3841 ret = verify_host_key(host, port, keytype, keystr);
3843 if (ret == 0) /* success - key matched OK */
3845 if (ret == 2) { /* key was different */
3847 sprintf(message, wrongmsg, fingerprint);
3848 mbret = MessageBox(NULL, message, mbtitle,
3849 MB_ICONWARNING | MB_YESNOCANCEL);
3851 store_host_key(host, port, keytype, keystr);
3852 if (mbret == IDCANCEL)
3855 if (ret == 1) { /* key was absent */
3857 sprintf(message, absentmsg, fingerprint);
3858 mbret = MessageBox(NULL, message, mbtitle,
3859 MB_ICONWARNING | MB_YESNOCANCEL);
3861 store_host_key(host, port, keytype, keystr);
3862 if (mbret == IDCANCEL)
3868 * Ask whether the selected cipher is acceptable (since it was
3869 * below the configured 'warn' threshold).
3870 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3872 void askcipher(char *ciphername, int cs)
3874 static const char mbtitle[] = "PuTTY Security Alert";
3875 static const char msg[] =
3876 "The first %.35scipher supported by the server\n"
3877 "is %.64s, which is below the configured\n"
3878 "warning threshold.\n"
3879 "Do you want to continue with this connection?\n";
3880 /* guessed cipher name + type max length */
3881 char message[100 + sizeof(msg)];
3884 sprintf(message, msg,
3886 (cs == 1) ? "client-to-server " :
3887 "server-to-client ",
3889 mbret = MessageBox(NULL, message, mbtitle,
3890 MB_ICONWARNING | MB_YESNO);
3898 * Ask whether to wipe a session log file before writing to it.
3899 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3901 int askappend(char *filename)
3903 static const char mbtitle[] = "PuTTY Log to File";
3904 static const char msgtemplate[] =
3905 "The session log file \"%.*s\" already exists.\n"
3906 "You can overwrite it with a new session log,\n"
3907 "append your session log to the end of it,\n"
3908 "or disable session logging for this session.\n"
3909 "Hit Yes to wipe the file, No to append to it,\n"
3910 "or Cancel to disable logging.";
3911 char message[sizeof(msgtemplate) + FILENAME_MAX];
3913 if (cfg.logxfovr != LGXF_ASK) {
3914 return ((cfg.logxfovr == LGXF_OVR) ? 2 : 1);
3916 sprintf(message, msgtemplate, FILENAME_MAX, filename);
3918 mbret = MessageBox(NULL, message, mbtitle,
3919 MB_ICONQUESTION | MB_YESNOCANCEL);
3922 else if (mbret == IDNO)
3929 * Warn about the obsolescent key file format.
3931 void old_keyfile_warning(void)
3933 static const char mbtitle[] = "PuTTY Key File Warning";
3934 static const char message[] =
3935 "You are loading an SSH 2 private key which has an\n"
3936 "old version of the file format. This means your key\n"
3937 "file is not fully tamperproof. Future versions of\n"
3938 "PuTTY may stop supporting this private key format,\n"
3939 "so we recommend you convert your key to the new\n"
3942 "You can perform this conversion by loading the key\n"
3943 "into PuTTYgen and then saving it again.";
3945 MessageBox(NULL, message, mbtitle, MB_OK);