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 extern Config cfg; /* defined in window.c */
32 struct sesslist sesslist; /* exported to window.c */
34 #define PRINTER_DISABLED_STRING "None (printing disabled)"
36 void force_normal(HWND hwnd)
38 static int recurse = 0;
46 wp.length = sizeof(wp);
47 if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) {
48 wp.showCmd = SW_SHOWNORMAL;
49 SetWindowPlacement(hwnd, &wp);
54 static void MyGetDlgItemInt(HWND hwnd, int id, int *result)
58 n = GetDlgItemInt(hwnd, id, &ok, FALSE);
63 static void MyGetDlgItemFlt(HWND hwnd, int id, int *result, int scale)
67 ok = GetDlgItemText(hwnd, id, text, sizeof(text) - 1);
69 *result = (int) (scale * atof(text));
72 static void MySetDlgItemFlt(HWND hwnd, int id, double value)
75 sprintf(text, "%g", value);
76 SetDlgItemText(hwnd, id, text);
79 static int CALLBACK LogProc(HWND hwnd, UINT msg,
80 WPARAM wParam, LPARAM lParam)
87 static int tabs[4] = { 78, 108 };
88 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
91 for (i = 0; i < nevents; i++)
92 SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
93 0, (LPARAM) events[i]);
96 switch (LOWORD(wParam)) {
100 SetActiveWindow(GetParent(hwnd));
104 if (HIWORD(wParam) == BN_CLICKED ||
105 HIWORD(wParam) == BN_DOUBLECLICKED) {
108 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
109 LB_GETSELCOUNT, 0, 0);
110 if (selcount == 0) { /* don't even try to copy zero items */
115 selitems = smalloc(selcount * sizeof(int));
117 int count = SendDlgItemMessage(hwnd, IDN_LIST,
124 static unsigned char sel_nl[] = SEL_NL;
126 if (count == 0) { /* can't copy zero stuff */
132 for (i = 0; i < count; i++)
134 strlen(events[selitems[i]]) + sizeof(sel_nl);
136 clipdata = smalloc(size);
139 for (i = 0; i < count; i++) {
140 char *q = events[selitems[i]];
141 int qlen = strlen(q);
144 memcpy(p, sel_nl, sizeof(sel_nl));
147 write_aclip(NULL, clipdata, size, TRUE);
152 for (i = 0; i < nevents; i++)
153 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
162 SetActiveWindow(GetParent(hwnd));
169 static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
170 WPARAM wParam, LPARAM lParam)
176 switch (LOWORD(wParam)) {
189 static int CALLBACK AboutProc(HWND hwnd, UINT msg,
190 WPARAM wParam, LPARAM lParam)
194 SetDlgItemText(hwnd, IDA_VERSION, ver);
197 switch (LOWORD(wParam)) {
200 EndDialog(hwnd, TRUE);
203 EnableWindow(hwnd, 0);
204 DialogBox(hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
206 EnableWindow(hwnd, 1);
207 SetActiveWindow(hwnd);
211 /* Load web browser */
212 ShellExecute(hwnd, "open",
213 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
214 0, 0, SW_SHOWDEFAULT);
219 EndDialog(hwnd, TRUE);
226 * Null dialog procedure.
228 static int CALLBACK NullDlgProc(HWND hwnd, UINT msg,
229 WPARAM wParam, LPARAM lParam)
234 static char savedsession[2048];
237 IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
390 IDC_SCROLLBARFULLSCREEN,
405 IDC_FULLSCREENONALTENTER,
408 appearancepanelstart,
409 IDC_TITLE_APPEARANCE,
431 connectionpanelstart,
432 IDC_TITLE_CONNECTION,
457 IDC_PROXYEXCLUDESTATIC,
458 IDC_PROXYEXCLUDEEDIT,
469 IDC_PROXYTELNETCMDSTATIC,
470 IDC_PROXYTELNETCMDEDIT,
471 IDC_PROXYSOCKSVERSTATIC,
602 translationpanelstart,
603 IDC_TITLE_TRANSLATION,
604 IDC_BOX_TRANSLATION1,
605 IDC_BOX_TRANSLATION2,
606 IDC_BOX_TRANSLATION3,
647 static const char *const colours[] = {
648 "Default Foreground", "Default Bold Foreground",
649 "Default Background", "Default Bold Background",
650 "Cursor Text", "Cursor Colour",
651 "ANSI Black", "ANSI Black Bold",
652 "ANSI Red", "ANSI Red Bold",
653 "ANSI Green", "ANSI Green Bold",
654 "ANSI Yellow", "ANSI Yellow Bold",
655 "ANSI Blue", "ANSI Blue Bold",
656 "ANSI Magenta", "ANSI Magenta Bold",
657 "ANSI Cyan", "ANSI Cyan Bold",
658 "ANSI White", "ANSI White Bold"
660 static const int permcolour[] = {
661 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
662 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
663 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
666 static void fmtfont(char *buf)
668 sprintf(buf, "Font: %s, ", cfg.font);
670 strcat(buf, "bold, ");
671 if (cfg.fontheight == 0)
672 strcat(buf, "default height");
674 sprintf(buf + strlen(buf), "%d-point",
675 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
678 char *help_context_cmd(int id)
690 return "JI(`',`session.hostname')";
697 return "JI(`',`session.saved')";
702 return "JI(`',`session.coe')";
703 case IDC_LSTATSTATIC:
707 case IDC_LSTATPACKET:
708 return "JI(`',`logging.main')";
713 return "JI(`',`logging.filename')";
718 return "JI(`',`logging.exists')";
723 return "JI(`',`keyboard.backspace')";
727 return "JI(`',`keyboard.homeend')";
735 return "JI(`',`keyboard.funkeys')";
739 return "JI(`',`keyboard.appkeypad')";
743 return "JI(`',`keyboard.appcursor')";
745 return "JI(`',`keyboard.nethack')";
747 return "JI(`',`keyboard.compose')";
748 case IDC_CTRLALTKEYS:
749 return "JI(`',`keyboard.ctrlalt')";
753 return "JI(`',`features.application')";
755 return "JI(`',`features.mouse')";
757 return "JI(`',`features.resize')";
758 case IDC_NOALTSCREEN:
759 return "JI(`',`features.altscreen')";
761 return "JI(`',`features.retitle')";
762 case IDC_NODBACKSPACE:
763 return "JI(`',`features.dbackspace')";
765 return "JI(`',`features.charset')";
768 return "JI(`',`terminal.autowrap')";
770 return "JI(`',`terminal.decom')";
772 return "JI(`',`terminal.lfhascr')";
774 return "JI(`',`terminal.bce')";
776 return "JI(`',`terminal.blink')";
779 return "JI(`',`terminal.answerback')";
781 case IDC_ECHOBACKEND:
784 return "JI(`',`terminal.localecho')";
786 case IDC_EDITBACKEND:
789 return "JI(`',`terminal.localedit')";
790 case IDC_PRINTERSTATIC:
792 return "JI(`',`terminal.printing')";
795 case IDC_BELL_DISABLED:
796 case IDC_BELL_DEFAULT:
797 case IDC_BELL_WAVEFILE:
798 case IDC_BELL_VISUAL:
799 case IDC_BELL_WAVESTATIC:
800 case IDC_BELL_WAVEEDIT:
801 case IDC_BELL_WAVEBROWSE:
802 return "JI(`',`bell.style')";
803 case IDC_B_IND_STATIC:
804 case IDC_B_IND_DISABLED:
805 case IDC_B_IND_FLASH:
806 case IDC_B_IND_STEADY:
807 return "JI(`',`bell.taskbar')";
809 case IDC_BELLOVLNSTATIC:
811 case IDC_BELLOVLTSTATIC:
813 case IDC_BELLOVLEXPLAIN:
814 case IDC_BELLOVLSSTATIC:
816 return "JI(`',`bell.overload')";
822 return "JI(`',`window.size')";
823 case IDC_RESIZESTATIC:
827 case IDC_RESIZEEITHER:
828 return "JI(`',`window.resize')";
830 case IDC_SCROLLBARFULLSCREEN:
835 return "JI(`',`window.scrollback')";
838 return "JI(`',`behaviour.closewarn')";
840 return "JI(`',`behaviour.altf4')";
842 return "JI(`',`behaviour.altspace')";
844 return "JI(`',`behaviour.altonly')";
845 case IDC_ALWAYSONTOP:
846 return "JI(`',`behaviour.alwaysontop')";
847 case IDC_FULLSCREENONALTENTER:
848 return "JI(`',`behaviour.altenter')";
850 case IDC_CURSORSTATIC:
855 return "JI(`',`appearance.cursor')";
858 return "JI(`',`appearance.font')";
862 return "JI(`',`appearance.title')";
864 return "JI(`',`appearance.hidemouse')";
868 return "JI(`',`appearance.border')";
872 return "JI(`',`connection.termtype')";
875 return "JI(`',`connection.username')";
878 return "JI(`',`connection.keepalive')";
880 return "JI(`',`connection.nodelay')";
882 case IDC_PROXYTYPESTATIC:
883 case IDC_PROXYTYPENONE:
884 case IDC_PROXYTYPEHTTP:
885 case IDC_PROXYTYPESOCKS:
886 case IDC_PROXYTYPETELNET:
887 return "JI(`',`proxy.type')";
888 case IDC_PROXYHOSTSTATIC:
889 case IDC_PROXYHOSTEDIT:
890 case IDC_PROXYPORTSTATIC:
891 case IDC_PROXYPORTEDIT:
892 return "JI(`',`proxy.main')";
893 case IDC_PROXYEXCLUDESTATIC:
894 case IDC_PROXYEXCLUDEEDIT:
895 case IDC_PROXYLOCALHOST:
896 return "JI(`',`proxy.exclude')";
897 case IDC_PROXYDNSSTATIC:
899 case IDC_PROXYDNSAUTO:
900 case IDC_PROXYDNSYES:
901 return "JI(`',`proxy.dns')";
902 case IDC_PROXYUSERSTATIC:
903 case IDC_PROXYUSEREDIT:
904 case IDC_PROXYPASSSTATIC:
905 case IDC_PROXYPASSEDIT:
906 return "JI(`',`proxy.auth')";
907 case IDC_PROXYTELNETCMDSTATIC:
908 case IDC_PROXYTELNETCMDEDIT:
909 return "JI(`',`proxy.command')";
910 case IDC_PROXYSOCKSVERSTATIC:
911 case IDC_PROXYSOCKSVER5:
912 case IDC_PROXYSOCKSVER4:
913 return "JI(`',`proxy.socksver')";
917 return "JI(`',`telnet.termspeed')";
926 return "JI(`',`telnet.environ')";
930 return "JI(`',`telnet.oldenviron')";
934 return "JI(`',`telnet.passive')";
936 return "JI(`',`telnet.specialkeys')";
938 return "JI(`',`telnet.newline')";
942 return "JI(`',`rlogin.termspeed')";
943 case IDC_RLLUSERSTATIC:
944 case IDC_RLLUSEREDIT:
945 return "JI(`',`rlogin.localuser')";
948 return "JI(`',`ssh.nopty')";
949 case IDC_CIPHERSTATIC2:
954 return "JI(`',`ssh.ciphers')";
955 case IDC_SSHPROTSTATIC:
956 case IDC_SSHPROT1ONLY:
959 case IDC_SSHPROT2ONLY:
960 return "JI(`',`ssh.protocol')";
963 return "JI(`',`ssh.command')";
965 return "JI(`',`ssh.compress')";
970 return "JI(`',`ssh.auth.privkey')";
972 return "JI(`',`ssh.auth.agentfwd')";
974 return "JI(`',`ssh.auth.changeuser')";
976 return "JI(`',`ssh.auth.tis')";
978 return "JI(`',`ssh.auth.ki')";
983 return "JI(`',`selection.buttons')";
984 case IDC_MOUSEOVERRIDE:
985 return "JI(`',`selection.shiftdrag')";
986 case IDC_SELTYPESTATIC:
988 case IDC_SELTYPERECT:
989 return "JI(`',`selection.rect')";
995 return "JI(`',`selection.charclasses')";
997 return "JI(`',`selection.linedraw')";
999 return "JI(`',`selection.rtf')";
1001 case IDC_BOLDCOLOUR:
1002 return "JI(`',`colours.bold')";
1004 return "JI(`',`colours.logpal')";
1005 case IDC_COLOURSTATIC:
1006 case IDC_COLOURLIST:
1014 return "JI(`',`colours.config')";
1016 case IDC_CODEPAGESTATIC:
1018 return "JI(`',`translation.codepage')";
1019 case IDC_CAPSLOCKCYR:
1020 return "JI(`',`translation.cyrillic')";
1022 case IDC_VTXWINDOWS:
1027 return "JI(`',`translation.linedraw')";
1029 case IDC_X11_FORWARD:
1030 case IDC_X11_DISPSTATIC:
1031 case IDC_X11_DISPLAY:
1032 return "JI(`',`ssh.tunnels.x11')";
1033 case IDC_X11AUTHSTATIC:
1036 return "JI(`',`ssh.tunnels.x11auth')";
1037 case IDC_PFWDSTATIC:
1038 case IDC_PFWDSTATIC2:
1039 case IDC_PFWDREMOVE:
1042 case IDC_SPORTSTATIC:
1044 case IDC_DPORTSTATIC:
1047 case IDC_PFWDREMOTE:
1048 return "JI(`',`ssh.tunnels.portfwd')";
1051 return "JI(`',`ssh.tunnels.portfwd.localhost')";
1053 case IDC_BUGS_IGNORE1:
1054 case IDC_BUGD_IGNORE1:
1055 return "JI(`',`ssh.bugs.ignore1')";
1056 case IDC_BUGS_PLAINPW1:
1057 case IDC_BUGD_PLAINPW1:
1058 return "JI(`',`ssh.bugs.plainpw1')";
1061 return "JI(`',`ssh.bugs.rsa1')";
1062 case IDC_BUGS_HMAC2:
1063 case IDC_BUGD_HMAC2:
1064 return "JI(`',`ssh.bugs.hmac2')";
1065 case IDC_BUGS_DERIVEKEY2:
1066 case IDC_BUGD_DERIVEKEY2:
1067 return "JI(`',`ssh.bugs.derivekey2')";
1068 case IDC_BUGS_RSAPAD2:
1069 case IDC_BUGD_RSAPAD2:
1070 return "JI(`',`ssh.bugs.rsapad2')";
1071 case IDC_BUGS_DHGEX2:
1072 case IDC_BUGD_DHGEX2:
1073 return "JI(`',`ssh.bugs.dhgex2')";
1080 /* 2nd arg: NZ => don't redraw session list (use when loading
1082 static void init_dlg_ctrls(HWND hwnd, int keepsess)
1085 char fontstatic[256];
1087 SetDlgItemText(hwnd, IDC_HOST, cfg.host);
1088 SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
1091 n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
1092 for (i = n; i-- > 0;)
1093 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_DELETESTRING, i, 0);
1094 for (i = 0; i < sesslist.nsessions; i++)
1095 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_ADDSTRING,
1096 0, (LPARAM) (sesslist.sessions[i]));
1098 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
1099 CheckRadioButton(hwnd, IDC_PROTRAW, IDC_PROTSSH,
1100 cfg.protocol == PROT_SSH ? IDC_PROTSSH :
1101 cfg.protocol == PROT_TELNET ? IDC_PROTTELNET :
1103 PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW);
1104 SetDlgItemInt(hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
1105 CheckDlgButton(hwnd, IDC_NODELAY, cfg.tcp_nodelay);
1107 CheckRadioButton(hwnd, IDC_DEL008, IDC_DEL127,
1108 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
1109 CheckRadioButton(hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
1110 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
1111 CheckRadioButton(hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
1112 cfg.funky_type == 0 ? IDC_FUNCTILDE :
1113 cfg.funky_type == 1 ? IDC_FUNCLINUX :
1114 cfg.funky_type == 2 ? IDC_FUNCXTERM :
1115 cfg.funky_type == 3 ? IDC_FUNCVT400 :
1116 cfg.funky_type == 4 ? IDC_FUNCVT100P :
1117 cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE);
1118 CheckDlgButton(hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
1119 CheckDlgButton(hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
1120 CheckDlgButton(hwnd, IDC_NOMOUSEREP, cfg.no_mouse_rep);
1121 CheckDlgButton(hwnd, IDC_NORESIZE, cfg.no_remote_resize);
1122 CheckDlgButton(hwnd, IDC_NOALTSCREEN, cfg.no_alt_screen);
1123 CheckDlgButton(hwnd, IDC_NOWINTITLE, cfg.no_remote_wintitle);
1124 CheckDlgButton(hwnd, IDC_NODBACKSPACE, cfg.no_dbackspace);
1125 CheckDlgButton(hwnd, IDC_NOCHARSET, cfg.no_remote_charset);
1126 CheckRadioButton(hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
1127 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
1128 CheckRadioButton(hwnd, IDC_KPNORMAL, IDC_KPNH,
1129 cfg.nethack_keypad ? IDC_KPNH :
1130 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
1131 CheckDlgButton(hwnd, IDC_ALTF4, cfg.alt_f4);
1132 CheckDlgButton(hwnd, IDC_ALTSPACE, cfg.alt_space);
1133 CheckDlgButton(hwnd, IDC_ALTONLY, cfg.alt_only);
1134 CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
1135 CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
1136 CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
1137 CheckDlgButton(hwnd, IDC_TELNETRET, cfg.telnet_newline);
1138 CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
1139 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
1140 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
1141 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
1142 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND :
1143 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
1144 SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
1145 CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
1146 CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
1147 CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
1148 CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
1150 CheckDlgButton(hwnd, IDC_WRAPMODE, cfg.wrap_mode);
1151 CheckDlgButton(hwnd, IDC_DECOM, cfg.dec_om);
1152 CheckDlgButton(hwnd, IDC_LFHASCR, cfg.lfhascr);
1153 SetDlgItemInt(hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
1154 SetDlgItemInt(hwnd, IDC_COLSEDIT, cfg.width, FALSE);
1155 SetDlgItemInt(hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
1156 fmtfont(fontstatic);
1157 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
1158 CheckRadioButton(hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
1159 cfg.beep == BELL_DISABLED ? IDC_BELL_DISABLED :
1160 cfg.beep == BELL_DEFAULT ? IDC_BELL_DEFAULT :
1161 cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
1163 BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
1164 CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
1166 B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
1167 B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
1168 B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
1169 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
1170 CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
1171 SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
1172 MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
1173 MySetDlgItemFlt(hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
1175 CheckDlgButton(hwnd, IDC_BCE, cfg.bce);
1176 CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
1178 SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
1179 CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
1180 CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
1181 CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
1182 SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
1183 CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
1184 cfg.cursor_type == 0 ? IDC_CURBLOCK :
1185 cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
1186 CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
1187 CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
1188 CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
1189 CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZEEITHER,
1190 cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
1191 cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
1192 cfg.resize_action == RESIZE_EITHER ? IDC_RESIZEEITHER :
1194 CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
1195 cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
1196 cfg.close_on_exit ==
1197 COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
1198 CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
1200 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1201 SetDlgItemText(hwnd, IDC_TSEDIT, cfg.termspeed);
1202 SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
1203 SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
1204 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1205 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
1206 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATPACKET,
1207 cfg.logtype == LGTYP_NONE ? IDC_LSTATOFF :
1208 cfg.logtype == LGTYP_ASCII ? IDC_LSTATASCII :
1209 cfg.logtype == LGTYP_DEBUG ? IDC_LSTATRAW :
1211 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
1212 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
1213 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
1216 char *p = cfg.environmt;
1217 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
1219 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
1225 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0,
1230 CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC,
1231 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
1232 CheckRadioButton(hwnd, IDC_TPASSIVE, IDC_TACTIVE,
1233 cfg.passive_telnet ? IDC_TPASSIVE : IDC_TACTIVE);
1235 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1236 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1237 CheckDlgButton(hwnd, IDC_NOPTY, cfg.nopty);
1238 CheckDlgButton(hwnd, IDC_COMPRESS, cfg.compression);
1239 CheckDlgButton(hwnd, IDC_SSH2DES, cfg.ssh2_des_cbc);
1240 CheckDlgButton(hwnd, IDC_AGENTFWD, cfg.agentfwd);
1241 CheckDlgButton(hwnd, IDC_CHANGEUSER, cfg.change_username);
1242 CheckRadioButton(hwnd, IDC_SSHPROT1ONLY, IDC_SSHPROT2ONLY,
1243 cfg.sshprot == 1 ? IDC_SSHPROT1 :
1244 cfg.sshprot == 2 ? IDC_SSHPROT2 :
1245 cfg.sshprot == 3 ? IDC_SSHPROT2ONLY : IDC_SSHPROT1ONLY);
1246 CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
1247 CheckDlgButton(hwnd, IDC_AUTHKI, cfg.try_ki_auth);
1248 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
1249 SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
1253 static const struct { char *s; int c; } ciphers[] = {
1254 { "3DES", CIPHER_3DES },
1255 { "Blowfish", CIPHER_BLOWFISH },
1256 { "DES", CIPHER_DES },
1257 { "AES (SSH 2 only)", CIPHER_AES },
1258 { "-- warn below here --", CIPHER_WARN }
1261 /* Set up the "selected ciphers" box. */
1262 /* (cipherlist assumed to contain all ciphers) */
1263 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_RESETCONTENT, 0, 0);
1264 for (i = 0; i < CIPHER_MAX; i++) {
1265 int c = cfg.ssh_cipherlist[i];
1268 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
1269 if (ciphers[j].c == c) {
1270 cstr = ciphers[j].s;
1274 pos = SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_ADDSTRING,
1276 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_SETITEMDATA,
1282 CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
1283 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
1284 CheckRadioButton(hwnd, IDC_SELTYPELEX, IDC_SELTYPERECT,
1285 cfg.rect_select == 0 ? IDC_SELTYPELEX : IDC_SELTYPERECT);
1286 CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
1287 CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
1288 CheckDlgButton(hwnd, IDC_RTFPASTE, cfg.rtf_paste);
1290 static int tabs[4] = { 25, 61, 96, 128 };
1291 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
1294 for (i = 0; i < 128; i++) {
1296 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
1297 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg.wordness[i]);
1298 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
1302 CheckDlgButton(hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
1303 CheckDlgButton(hwnd, IDC_PALETTE, cfg.try_palette);
1306 n = SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
1307 for (i = n; i-- > 0;)
1308 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
1309 LB_DELETESTRING, i, 0);
1310 for (i = 0; i < 22; i++)
1311 if (cfg.bold_colour || permcolour[i])
1312 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
1313 (LPARAM) colours[i]);
1315 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
1316 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
1317 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
1318 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
1323 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
1324 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
1325 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
1326 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
1327 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
1330 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
1336 pe = printer_start_enum(&nprinters);
1337 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_RESETCONTENT, 0, 0);
1338 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1339 0, (LPARAM) PRINTER_DISABLED_STRING);
1340 for (i = 0; i < nprinters; i++) {
1341 char *printer_name = printer_get_name(pe, i);
1342 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1343 0, (LPARAM) printer_name);
1345 printer_finish_enum(pe);
1346 SetDlgItemText(hwnd, IDC_PRINTER,
1347 *cfg.printer ? cfg.printer : PRINTER_DISABLED_STRING);
1350 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
1351 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
1352 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
1353 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
1354 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
1357 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
1358 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
1359 CheckRadioButton(hwnd, IDC_X11MIT, IDC_X11XDM,
1360 cfg.x11_auth == X11_MIT ? IDC_X11MIT : IDC_X11XDM);
1362 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
1363 CheckDlgButton(hwnd, IDC_RPORT_ALL, cfg.rport_acceptall);
1364 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
1367 CheckRadioButton(hwnd, IDC_PROXYTYPENONE, IDC_PROXYTYPETELNET,
1368 cfg.proxy_type == PROXY_HTTP ? IDC_PROXYTYPEHTTP :
1369 cfg.proxy_type == PROXY_SOCKS ? IDC_PROXYTYPESOCKS :
1370 cfg.proxy_type == PROXY_TELNET ? IDC_PROXYTYPETELNET : IDC_PROXYTYPENONE);
1371 SetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host);
1372 SetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, cfg.proxy_port, FALSE);
1373 SetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT, cfg.proxy_exclude_list);
1374 CheckDlgButton(hwnd, IDC_PROXYLOCALHOST, cfg.even_proxy_localhost);
1375 CheckRadioButton(hwnd, IDC_PROXYDNSNO, IDC_PROXYDNSYES,
1376 cfg.proxy_dns == PROXYDNS_NO ? IDC_PROXYDNSNO :
1377 cfg.proxy_dns == PROXYDNS_YES ? IDC_PROXYDNSYES :
1379 SetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT, cfg.proxy_telnet_command);
1380 SetDlgItemText(hwnd, IDC_PROXYUSEREDIT, cfg.proxy_username);
1381 SetDlgItemText(hwnd, IDC_PROXYPASSEDIT, cfg.proxy_password);
1382 CheckRadioButton(hwnd, IDC_PROXYSOCKSVER5, IDC_PROXYSOCKSVER4,
1383 cfg.proxy_socks_version == 4 ? IDC_PROXYSOCKSVER4 : IDC_PROXYSOCKSVER5);
1385 /* SSH bugs config */
1386 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_RESETCONTENT, 0, 0);
1387 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1388 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"Off");
1389 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"On");
1390 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_SETCURSEL,
1391 cfg.sshbug_ignore1 == BUG_ON ? 2 :
1392 cfg.sshbug_ignore1 == BUG_OFF ? 1 : 0, 0);
1393 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_RESETCONTENT, 0, 0);
1394 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1395 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Off");
1396 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"On");
1397 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_SETCURSEL,
1398 cfg.sshbug_plainpw1 == BUG_ON ? 2 :
1399 cfg.sshbug_plainpw1 == BUG_OFF ? 1 : 0, 0);
1400 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_RESETCONTENT, 0, 0);
1401 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1402 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Off");
1403 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"On");
1404 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_SETCURSEL,
1405 cfg.sshbug_rsa1 == BUG_ON ? 2 :
1406 cfg.sshbug_rsa1 == BUG_OFF ? 1 : 0, 0);
1407 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_RESETCONTENT, 0, 0);
1408 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1409 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Off");
1410 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"On");
1411 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_SETCURSEL,
1412 cfg.sshbug_hmac2 == BUG_ON ? 2 :
1413 cfg.sshbug_hmac2 == BUG_OFF ? 1 : 0, 0);
1414 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_RESETCONTENT, 0, 0);
1415 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1416 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Off");
1417 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"On");
1418 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_SETCURSEL,
1419 cfg.sshbug_derivekey2 == BUG_ON ? 2 :
1420 cfg.sshbug_derivekey2 == BUG_OFF ? 1 : 0, 0);
1421 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_RESETCONTENT, 0, 0);
1422 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1423 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Off");
1424 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"On");
1425 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_SETCURSEL,
1426 cfg.sshbug_rsapad2 == BUG_ON ? 2 :
1427 cfg.sshbug_rsapad2 == BUG_OFF ? 1 : 0, 0);
1428 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_RESETCONTENT, 0, 0);
1429 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1430 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"Off");
1431 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"On");
1432 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_SETCURSEL,
1433 cfg.sshbug_dhgex2 == BUG_ON ? 2 :
1434 cfg.sshbug_dhgex2 == BUG_OFF ? 1 : 0, 0);
1437 struct treeview_faff {
1439 HTREEITEM lastat[4];
1442 static HTREEITEM treeview_insert(struct treeview_faff *faff,
1443 int level, char *text)
1448 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
1449 ins.hInsertAfter = faff->lastat[level];
1450 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1451 #define INSITEM DUMMYUNIONNAME.item
1453 #define INSITEM item
1455 ins.INSITEM.mask = TVIF_TEXT;
1456 ins.INSITEM.pszText = text;
1457 newitem = TreeView_InsertItem(faff->treeview, &ins);
1459 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
1461 faff->lastat[level] = newitem;
1462 for (i = level + 1; i < 4; i++)
1463 faff->lastat[i] = NULL;
1468 * Create the panelfuls of controls in the configuration box.
1470 static void create_controls(HWND hwnd, int dlgtype, int panel)
1472 if (panel == sessionpanelstart) {
1473 /* The Session panel. Accelerators used: [acgoh] nprtis elvd w */
1475 ctlposinit(&cp, hwnd, 80, 3, 13);
1476 bartitle(&cp, "Basic options for your PuTTY session",
1479 beginbox(&cp, "Specify your connection by host name or IP address",
1482 "Host &Name (or IP address)",
1483 IDC_HOSTSTATIC, IDC_HOST, 75,
1484 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
1485 if (backends[3].backend == NULL) {
1486 /* this is PuTTYtel, so only three protocols available */
1487 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
1488 "&Raw", IDC_PROTRAW,
1489 "&Telnet", IDC_PROTTELNET,
1490 "Rlog&in", IDC_PROTRLOGIN, NULL);
1492 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
1493 "&Raw", IDC_PROTRAW,
1494 "&Telnet", IDC_PROTTELNET,
1495 "Rlog&in", IDC_PROTRLOGIN,
1504 beginbox(&cp, "Load, save or delete a stored session",
1506 sesssaver(&cp, "Sav&ed Sessions",
1507 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
1508 "&Load", IDC_SESSLOAD,
1509 "Sa&ve", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
1512 beginbox(&cp, NULL, IDC_BOX_SESSION3);
1513 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
1514 "Always", IDC_COEALWAYS,
1515 "Never", IDC_COENEVER,
1516 "Only on clean exit", IDC_COENORMAL, NULL);
1520 if (panel == loggingpanelstart) {
1521 /* The Logging panel. Accelerators used: [acgoh] tplsfwe */
1523 ctlposinit(&cp, hwnd, 80, 3, 13);
1524 bartitle(&cp, "Options controlling session logging",
1526 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
1528 "Session logging:", IDC_LSTATSTATIC,
1529 "Logging &turned off completely", IDC_LSTATOFF,
1530 "Log &printable output only", IDC_LSTATASCII,
1531 "&Log all session output", IDC_LSTATRAW,
1532 "Log &SSH packet data", IDC_LSTATPACKET,
1534 editbutton(&cp, "Log &file name:",
1535 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
1537 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
1538 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
1540 "What to do if the log file already &exists:",
1541 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
1542 "Always append to the end of it", IDC_LSTATXAPN,
1543 "Ask the user every time", IDC_LSTATXASK, NULL);
1547 if (panel == terminalpanelstart) {
1548 /* The Terminal panel. Accelerators used: [acgoh] wdren lts p */
1550 ctlposinit(&cp, hwnd, 80, 3, 13);
1551 bartitle(&cp, "Options controlling the terminal emulation",
1552 IDC_TITLE_TERMINAL);
1553 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
1554 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
1555 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
1556 checkbox(&cp, "Implicit C&R in every LF", IDC_LFHASCR);
1557 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
1558 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
1560 "An&swerback to ^E:", IDC_ANSWERBACK,
1561 IDC_ANSWEREDIT, 100, NULL);
1564 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
1565 radioline(&cp, "&Local echo:", IDC_ECHOSTATIC, 3,
1566 "Auto", IDC_ECHOBACKEND,
1567 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
1568 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
1569 "Auto", IDC_EDITBACKEND,
1570 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
1573 beginbox(&cp, "Remote-controlled printing", IDC_BOX_TERMINAL3);
1574 combobox(&cp, "&Printer to send ANSI printer output to:",
1575 IDC_PRINTERSTATIC, IDC_PRINTER);
1579 if (panel == featurespanelstart) {
1580 /* The Features panel. Accelerators used: [acgoh] ukswtbrx */
1582 ctlposinit(&cp, hwnd, 80, 3, 13);
1583 bartitle(&cp, "Enabling and disabling advanced terminal features ",
1584 IDC_TITLE_FEATURES);
1585 beginbox(&cp, NULL, IDC_BOX_FEATURES1);
1586 checkbox(&cp, "Disable application c&ursor keys mode", IDC_NOAPPLICC);
1587 checkbox(&cp, "Disable application &keypad mode", IDC_NOAPPLICK);
1588 checkbox(&cp, "Disable &xterm-style mouse reporting", IDC_NOMOUSEREP);
1589 checkbox(&cp, "Disable remote-controlled terminal re&sizing",
1591 checkbox(&cp, "Disable s&witching to alternate terminal screen",
1593 checkbox(&cp, "Disable remote-controlled window &title changing",
1595 checkbox(&cp, "Disable destructive &backspace on server sending ^?",
1597 checkbox(&cp, "Disable remote-controlled cha&racter set configuration",
1602 if (panel == bellpanelstart) {
1603 /* The Bell panel. Accelerators used: [acgoh] bdsm wit */
1605 ctlposinit(&cp, hwnd, 80, 3, 13);
1606 bartitle(&cp, "Options controlling the terminal bell",
1608 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
1610 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
1611 "None (bell disabled)", IDC_BELL_DISABLED,
1612 "Play Windows Default Sound", IDC_BELL_DEFAULT,
1613 "Play a custom sound file", IDC_BELL_WAVEFILE,
1614 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
1615 editbutton(&cp, "Custom sound file to play as a bell:",
1616 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
1617 "Bro&wse...", IDC_BELL_WAVEBROWSE);
1618 radioline(&cp, "Taskbar/caption &indication on bell:",
1619 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
1620 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
1623 beginbox(&cp, "Control the bell overload behaviour",
1625 checkbox(&cp, "Bell is temporarily &disabled when over-used",
1627 staticedit(&cp, "Over-use means this &many bells...",
1628 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
1629 staticedit(&cp, "... in &this many seconds",
1630 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
1632 "The bell is re-enabled after a few seconds of silence.",
1633 1, IDC_BELLOVLEXPLAIN);
1634 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1639 if (panel == keyboardpanelstart) {
1640 /* The Keyboard panel. Accelerators used: [acgoh] bef rntd */
1642 ctlposinit(&cp, hwnd, 80, 3, 13);
1643 bartitle(&cp, "Options controlling the effects of keys",
1644 IDC_TITLE_KEYBOARD);
1645 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1646 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1647 "Control-H", IDC_DEL008,
1648 "Control-? (127)", IDC_DEL127, NULL);
1649 radioline(&cp, "The Home and &End keys", IDC_HOMESTATIC, 2,
1650 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1651 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1652 "ESC[n~", IDC_FUNCTILDE,
1653 "Linux", IDC_FUNCLINUX,
1654 "Xterm R6", IDC_FUNCXTERM,
1655 "VT400", IDC_FUNCVT400,
1656 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1658 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1659 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1660 "Normal", IDC_CURNORMAL,
1661 "Application", IDC_CURAPPLIC, NULL);
1662 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1663 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1664 "NetHack", IDC_KPNH, NULL);
1666 beginbox(&cp, "Enable extra keyboard features:",
1668 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1669 checkbox(&cp, "Control-Alt is &different from AltGr",
1674 if (panel == windowpanelstart) {
1675 /* The Window panel. Accelerators used: [acgoh] rmz sdikp */
1677 ctlposinit(&cp, hwnd, 80, 3, 13);
1678 bartitle(&cp, "Options controlling PuTTY's window",
1680 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1682 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1683 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
1684 radiobig(&cp, "When window is resi&zed:", IDC_RESIZESTATIC,
1685 "Change the number of rows and columns", IDC_RESIZETERM,
1686 "Change the size of the font", IDC_RESIZEFONT,
1687 "Change font size only when maximised", IDC_RESIZEEITHER,
1688 "Forbid resizing completely", IDC_RESIZENONE, NULL);
1690 beginbox(&cp, "Control the scrollback in the window",
1692 staticedit(&cp, "Lines of &scrollback",
1693 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1694 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
1695 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
1696 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1697 checkbox(&cp, "Reset scrollback on dis&play activity",
1702 if (panel == appearancepanelstart) {
1703 /* The Appearance panel. Accelerators used: [acgoh] luvb n ti p s */
1705 ctlposinit(&cp, hwnd, 80, 3, 13);
1706 bartitle(&cp, "Configure the appearance of PuTTY's window",
1707 IDC_TITLE_APPEARANCE);
1708 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1709 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1710 "B&lock", IDC_CURBLOCK,
1711 "&Underline", IDC_CURUNDER,
1712 "&Vertical line", IDC_CURVERT, NULL);
1713 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1715 beginbox(&cp, "Set the font used in the terminal window",
1716 IDC_BOX_APPEARANCE2);
1717 staticbtn(&cp, "", IDC_FONTSTATIC, "Cha&nge...", IDC_CHOOSEFONT);
1719 beginbox(&cp, "Adjust the use of the window title",
1720 IDC_BOX_APPEARANCE3);
1722 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1723 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
1725 beginbox(&cp, "Adjust the use of the mouse pointer",
1726 IDC_BOX_APPEARANCE4);
1727 checkbox(&cp, "Hide mouse &pointer when typing in window",
1730 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1731 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1733 staticedit(&cp, "Gap between text and window edge",
1734 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
1738 if (panel == behaviourpanelstart) {
1739 /* The Behaviour panel. Accelerators used: [acgoh] w4yltf */
1741 ctlposinit(&cp, hwnd, 80, 3, 13);
1742 bartitle(&cp, "Configure the behaviour of PuTTY's window",
1744 beginbox(&cp, NULL, IDC_BOX_BEHAVIOUR1);
1745 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1746 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1747 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1748 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
1749 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1750 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1754 if (panel == translationpanelstart) {
1755 /* The Translation panel. Accelerators used: [acgoh] rxbepus */
1757 ctlposinit(&cp, hwnd, 80, 3, 13);
1758 bartitle(&cp, "Options controlling character set translation",
1759 IDC_TITLE_TRANSLATION);
1760 beginbox(&cp, "Character set translation on received data",
1761 IDC_BOX_TRANSLATION1);
1762 combobox(&cp, "&Received data assumed to be in which character set:",
1763 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1765 beginbox(&cp, "Enable character set translation on input data",
1766 IDC_BOX_TRANSLATION2);
1767 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
1770 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
1771 IDC_BOX_TRANSLATION3);
1773 "Handling of line drawing characters:", IDC_VTSTATIC,
1774 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1775 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1776 "Use font in O&EM mode only", IDC_VTOEMONLY,
1777 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1778 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
1782 if (panel == selectionpanelstart) {
1783 /* The Selection panel. Accelerators used: [acgoh] df wxp est nr */
1785 ctlposinit(&cp, hwnd, 80, 3, 13);
1786 bartitle(&cp, "Options controlling copy and paste",
1787 IDC_TITLE_SELECTION);
1788 beginbox(&cp, "Translation of pasted characters",
1789 IDC_BOX_SELECTION1);
1791 "&Don't translate line drawing chars into +, - and |",
1794 "Paste to clipboard in RT&F as well as plain text",
1797 beginbox(&cp, "Control which mouse button does which thing",
1798 IDC_BOX_SELECTION2);
1799 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1800 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1801 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1804 "Shift overrides a&pplication's use of mouse",
1807 "Default selection mode (Alt+drag does the other one):",
1808 IDC_SELTYPESTATIC, 2,
1809 "&Normal", IDC_SELTYPELEX,
1810 "&Rectangular block", IDC_SELTYPERECT, NULL);
1812 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1813 IDC_BOX_SELECTION3);
1814 charclass(&cp, "Charact&er classes:", IDC_CCSTATIC, IDC_CCLIST,
1815 "&Set", IDC_CCSET, IDC_CCEDIT,
1816 "&to class", IDC_CCSTATIC2);
1820 if (panel == colourspanelstart) {
1821 /* The Colours panel. Accelerators used: [acgoh] blum */
1823 ctlposinit(&cp, hwnd, 80, 3, 13);
1824 bartitle(&cp, "Options controlling use of colours",
1826 beginbox(&cp, "General options for colour usage",
1828 checkbox(&cp, "&Bolded text is a different colour",
1830 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1832 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1834 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1835 IDC_COLOURSTATIC, IDC_COLOURLIST,
1836 "&Modify...", IDC_CHANGE,
1837 "Red:", IDC_RSTATIC, IDC_RVALUE,
1838 "Green:", IDC_GSTATIC, IDC_GVALUE,
1839 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1843 if (panel == connectionpanelstart) {
1844 /* The Connection panel. Accelerators used: [acgoh] tukn */
1846 ctlposinit(&cp, hwnd, 80, 3, 13);
1847 bartitle(&cp, "Options controlling the connection",
1848 IDC_TITLE_CONNECTION);
1850 beginbox(&cp, "Data to send to the server",
1851 IDC_BOX_CONNECTION1);
1852 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1854 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1858 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1859 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1861 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1865 beginbox(&cp, "Sending of null packets to keep session active",
1866 IDC_BOX_CONNECTION2);
1867 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1868 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1871 beginbox(&cp, "Low-level TCP connection options",
1872 IDC_BOX_CONNECTION3);
1873 checkbox(&cp, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1879 if (panel == proxypanelstart) {
1880 /* The Proxy panel. Accelerators used: [acgoh] ntslypeuwmvxd */
1882 ctlposinit(&cp, hwnd, 80, 3, 13);
1884 bartitle(&cp, "Options controlling proxy usage",
1886 beginbox(&cp, "Proxy basics", IDC_BOX_PROXY1);
1887 radioline(&cp, "Proxy type:", IDC_PROXYTYPESTATIC, 4,
1888 "&None", IDC_PROXYTYPENONE,
1889 "H&TTP", IDC_PROXYTYPEHTTP,
1890 "&SOCKS", IDC_PROXYTYPESOCKS,
1891 "Te&lnet", IDC_PROXYTYPETELNET, NULL);
1893 "Prox&y Host", IDC_PROXYHOSTSTATIC, IDC_PROXYHOSTEDIT, 80,
1894 "&Port", IDC_PROXYPORTSTATIC, IDC_PROXYPORTEDIT, 20, NULL);
1896 "&Exclude Hosts/IPs", IDC_PROXYEXCLUDESTATIC,
1897 IDC_PROXYEXCLUDEEDIT, 100, NULL);
1898 checkbox(&cp, "Consider pro&xying local host connections",
1899 IDC_PROXYLOCALHOST);
1900 radioline(&cp, "Do &DNS name lookup at proxy end:",
1901 IDC_PROXYDNSSTATIC, 3,
1902 "No", IDC_PROXYDNSNO,
1903 "Auto", IDC_PROXYDNSAUTO,
1904 "Yes", IDC_PROXYDNSYES, NULL);
1905 staticedit(&cp, "&Username", IDC_PROXYUSERSTATIC,
1906 IDC_PROXYUSEREDIT, 60);
1907 staticpassedit(&cp, "Pass&word", IDC_PROXYPASSSTATIC,
1908 IDC_PROXYPASSEDIT, 60);
1910 beginbox(&cp, "Misc. proxy settings", IDC_BOX_PROXY2);
1912 "Telnet co&mmand", IDC_PROXYTELNETCMDSTATIC,
1913 IDC_PROXYTELNETCMDEDIT, 100, NULL);
1914 radioline(&cp, "SOCKS &Version", IDC_PROXYSOCKSVERSTATIC,
1915 2, "Version 5", IDC_PROXYSOCKSVER5, "Version 4",
1916 IDC_PROXYSOCKSVER4, NULL);
1921 if (panel == telnetpanelstart) {
1922 /* The Telnet panel. Accelerators used: [acgoh] svldr bftk */
1924 ctlposinit(&cp, hwnd, 80, 3, 13);
1926 bartitle(&cp, "Options controlling Telnet connections",
1928 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1929 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1931 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1932 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1933 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1934 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1936 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1937 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1938 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1939 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1940 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1941 "Passive", IDC_TPASSIVE, "Active",
1943 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1945 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1951 if (panel == rloginpanelstart) {
1952 /* The Rlogin panel. Accelerators used: [acgoh] sl */
1954 ctlposinit(&cp, hwnd, 80, 3, 13);
1956 bartitle(&cp, "Options controlling Rlogin connections",
1958 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1959 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1961 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1962 IDC_RLLUSEREDIT, 50);
1967 if (panel == sshpanelstart) {
1968 /* The SSH panel. Accelerators used: [acgoh] r pel12n sud i */
1970 ctlposinit(&cp, hwnd, 80, 3, 13);
1972 bartitle(&cp, "Options controlling SSH connections",
1974 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1976 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1979 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
1980 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1981 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1982 radioline(&cp, "Preferred SSH protocol version:",
1983 IDC_SSHPROTSTATIC, 4,
1984 "1 on&ly", IDC_SSHPROT1ONLY,
1985 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2,
1986 "2 o&nly", IDC_SSHPROT2ONLY, NULL);
1988 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1989 /* Adds accelerators: ud */
1990 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1991 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1993 checkbox(&cp, "Enable non-standard use of s&ingle-DES in SSH 2",
1999 if (panel == sshauthpanelstart) {
2000 /* The SSH authentication panel. Accelerators used: [acgoh] m fkiuw */
2002 ctlposinit(&cp, hwnd, 80, 3, 13);
2004 bartitle(&cp, "Options controlling SSH authentication",
2006 beginbox(&cp, "Authentication methods",
2008 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
2010 checkbox(&cp, "Attempt \"keyboard-&interactive\" authentication"
2011 " (SSH2)", IDC_AUTHKI);
2013 beginbox(&cp, "Authentication parameters",
2015 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
2016 checkbox(&cp, "Allow attempted changes of &username in SSH2",
2018 editbutton(&cp, "Private &key file for authentication:",
2019 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
2025 if (panel == sshbugspanelstart) {
2026 /* The SSH bugs panel. Accelerators used: [acgoh] isrmepd */
2028 ctlposinit(&cp, hwnd, 80, 3, 13);
2030 bartitle(&cp, "Workarounds for SSH server bugs",
2032 beginbox(&cp, "Detection of known bugs in SSH servers",
2034 staticddl(&cp, "Chokes on SSH1 &ignore messages",
2035 IDC_BUGS_IGNORE1, IDC_BUGD_IGNORE1, 20);
2036 staticddl(&cp, "Refuses all SSH1 pa&ssword camouflage",
2037 IDC_BUGS_PLAINPW1, IDC_BUGD_PLAINPW1, 20);
2038 staticddl(&cp, "Chokes on SSH1 &RSA authentication",
2039 IDC_BUGS_RSA1, IDC_BUGD_RSA1, 20);
2040 staticddl(&cp, "Miscomputes SSH2 H&MAC keys",
2041 IDC_BUGS_HMAC2, IDC_BUGD_HMAC2, 20);
2042 staticddl(&cp, "Miscomputes SSH2 &encryption keys",
2043 IDC_BUGS_DERIVEKEY2, IDC_BUGD_DERIVEKEY2, 20);
2044 staticddl(&cp, "Requires &padding on SSH2 RSA signatures",
2045 IDC_BUGS_RSAPAD2, IDC_BUGD_RSAPAD2, 20);
2046 staticddl(&cp, "Chokes on &Diffie-Hellman group exchange",
2047 IDC_BUGS_DHGEX2, IDC_BUGD_DHGEX2, 20);
2052 if (panel == tunnelspanelstart) {
2053 /* The Tunnels panel. Accelerators used: [acgoh] exu tprsdilm */
2055 ctlposinit(&cp, hwnd, 80, 3, 13);
2057 bartitle(&cp, "Options controlling SSH tunnelling",
2059 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
2060 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
2061 staticedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
2062 IDC_X11_DISPLAY, 50);
2063 radioline(&cp, "Remote X11 a&uthentication protocol",
2064 IDC_X11AUTHSTATIC, 2,
2065 "MIT-Magic-Cookie-1", IDC_X11MIT,
2066 "XDM-Authorization-1", IDC_X11XDM, NULL);
2068 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
2069 checkbox(&cp, "Local ports accept connections from o&ther hosts",
2071 checkbox(&cp, "Remote &ports do the same (SSH v2 only)",
2073 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
2074 "&Remove", IDC_PFWDREMOVE);
2075 fwdsetter(&cp, IDC_PFWDLIST,
2076 "Add new forwarded port:", IDC_PFWDSTATIC2,
2077 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
2078 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
2079 "A&dd", IDC_PFWDADD,
2080 "&Local", IDC_PFWDLOCAL,
2081 "Re&mote", IDC_PFWDREMOTE);
2089 * Helper function to load the session selected in SESSLIST
2090 * if any, as this is done in more than one place in
2091 * GenericMainDlgProc(). 0 => failure.
2093 static int load_selected_session(HWND hwnd)
2095 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2096 LB_GETCURSEL, 0, 0);
2102 isdef = !strcmp(sesslist.sessions[n], "Default Settings");
2103 load_settings(sesslist.sessions[n], !isdef, &cfg);
2104 init_dlg_ctrls(hwnd, TRUE);
2106 SetDlgItemText(hwnd, IDC_SESSEDIT, sesslist.sessions[n]);
2108 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
2109 /* Restore the selection, which will have been clobbered by
2110 * SESSEDIT handling. */
2111 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
2116 * This function is the configuration box.
2118 static int GenericMainDlgProc(HWND hwnd, UINT msg,
2119 WPARAM wParam, LPARAM lParam, int dlgtype)
2122 struct treeview_faff tvfaff;
2125 char filename[sizeof(cfg.keyfile)];
2128 char fontstatic[256];
2130 struct servent *service;
2132 static UINT draglistmsg = WM_NULL;
2137 SetWindowLong(hwnd, GWL_USERDATA, 0);
2139 SetWindowLong(hwnd, GWL_EXSTYLE,
2140 GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
2142 HWND item = GetDlgItem(hwnd, IDC_HELPBTN);
2144 DestroyWindow(item);
2146 requested_help = FALSE;
2147 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
2148 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
2150 * Centre the window.
2152 { /* centre the window */
2155 hw = GetDesktopWindow();
2156 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
2158 (rs.right + rs.left + rd.left - rd.right) / 2,
2159 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
2160 rd.right - rd.left, rd.bottom - rd.top, TRUE);
2164 * Create the tree view.
2172 r.right = r.left + 75;
2174 r.bottom = r.top + 10;
2175 MapDialogRect(hwnd, &r);
2176 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
2177 WS_CHILD | WS_VISIBLE,
2179 r.right - r.left, r.bottom - r.top,
2180 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
2182 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
2183 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2186 r.right = r.left + 75;
2188 r.bottom = r.top + 219;
2189 MapDialogRect(hwnd, &r);
2190 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
2191 WS_CHILD | WS_VISIBLE |
2192 WS_TABSTOP | TVS_HASLINES |
2193 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
2195 TVS_SHOWSELALWAYS, r.left, r.top,
2196 r.right - r.left, r.bottom - r.top,
2197 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
2199 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
2200 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2201 tvfaff.treeview = treeview;
2202 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
2206 * Set up the tree view contents.
2208 hsession = treeview_insert(&tvfaff, 0, "Session");
2209 treeview_insert(&tvfaff, 1, "Logging");
2210 treeview_insert(&tvfaff, 0, "Terminal");
2211 treeview_insert(&tvfaff, 1, "Keyboard");
2212 treeview_insert(&tvfaff, 1, "Bell");
2213 treeview_insert(&tvfaff, 1, "Features");
2214 treeview_insert(&tvfaff, 0, "Window");
2215 treeview_insert(&tvfaff, 1, "Appearance");
2216 treeview_insert(&tvfaff, 1, "Behaviour");
2217 treeview_insert(&tvfaff, 1, "Translation");
2218 treeview_insert(&tvfaff, 1, "Selection");
2219 treeview_insert(&tvfaff, 1, "Colours");
2220 treeview_insert(&tvfaff, 0, "Connection");
2222 treeview_insert(&tvfaff, 1, "Proxy");
2223 treeview_insert(&tvfaff, 1, "Telnet");
2224 treeview_insert(&tvfaff, 1, "Rlogin");
2225 if (backends[3].backend != NULL) {
2226 treeview_insert(&tvfaff, 1, "SSH");
2227 /* XXX long name is ugly */
2228 /* XXX make it closed by default? */
2229 treeview_insert(&tvfaff, 2, "Auth");
2230 treeview_insert(&tvfaff, 2, "Tunnels");
2231 treeview_insert(&tvfaff, 2, "Bugs");
2236 * Put the treeview selection on to the Session panel. This
2237 * should also cause creation of the relevant controls.
2239 TreeView_SelectItem(treeview, hsession);
2242 * Set focus into the first available control.
2246 ctl = GetDlgItem(hwnd, IDC_HOST);
2248 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
2252 SetWindowLong(hwnd, GWL_USERDATA, 1);
2253 sesslist_has_focus = 0;
2257 * Button release should trigger WM_OK if there was a
2258 * previous double click on the session list.
2262 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
2265 if (LOWORD(wParam) == IDCX_TREEVIEW &&
2266 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
2268 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
2273 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
2276 item.pszText = buffer;
2277 item.cchTextMax = sizeof(buffer);
2278 item.mask = TVIF_TEXT;
2279 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
2280 for (j = controlstartvalue; j < controlendvalue; j++) {
2281 HWND item = GetDlgItem(hwnd, j);
2283 DestroyWindow(item);
2285 if (!strcmp(buffer, "Session"))
2286 create_controls(hwnd, dlgtype, sessionpanelstart);
2287 if (!strcmp(buffer, "Logging"))
2288 create_controls(hwnd, dlgtype, loggingpanelstart);
2289 if (!strcmp(buffer, "Keyboard"))
2290 create_controls(hwnd, dlgtype, keyboardpanelstart);
2291 if (!strcmp(buffer, "Terminal"))
2292 create_controls(hwnd, dlgtype, terminalpanelstart);
2293 if (!strcmp(buffer, "Bell"))
2294 create_controls(hwnd, dlgtype, bellpanelstart);
2295 if (!strcmp(buffer, "Features"))
2296 create_controls(hwnd, dlgtype, featurespanelstart);
2297 if (!strcmp(buffer, "Window"))
2298 create_controls(hwnd, dlgtype, windowpanelstart);
2299 if (!strcmp(buffer, "Appearance"))
2300 create_controls(hwnd, dlgtype, appearancepanelstart);
2301 if (!strcmp(buffer, "Behaviour"))
2302 create_controls(hwnd, dlgtype, behaviourpanelstart);
2303 if (!strcmp(buffer, "Tunnels"))
2304 create_controls(hwnd, dlgtype, tunnelspanelstart);
2305 if (!strcmp(buffer, "Connection"))
2306 create_controls(hwnd, dlgtype, connectionpanelstart);
2307 if (!strcmp(buffer, "Proxy"))
2308 create_controls(hwnd, dlgtype, proxypanelstart);
2309 if (!strcmp(buffer, "Telnet"))
2310 create_controls(hwnd, dlgtype, telnetpanelstart);
2311 if (!strcmp(buffer, "Rlogin"))
2312 create_controls(hwnd, dlgtype, rloginpanelstart);
2313 if (!strcmp(buffer, "SSH"))
2314 create_controls(hwnd, dlgtype, sshpanelstart);
2315 if (!strcmp(buffer, "Auth"))
2316 create_controls(hwnd, dlgtype, sshauthpanelstart);
2317 if (!strcmp(buffer, "Bugs"))
2318 create_controls(hwnd, dlgtype, sshbugspanelstart);
2319 if (!strcmp(buffer, "Selection"))
2320 create_controls(hwnd, dlgtype, selectionpanelstart);
2321 if (!strcmp(buffer, "Colours"))
2322 create_controls(hwnd, dlgtype, colourspanelstart);
2323 if (!strcmp(buffer, "Translation"))
2324 create_controls(hwnd, dlgtype, translationpanelstart);
2326 init_dlg_ctrls(hwnd, FALSE);
2328 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
2329 InvalidateRect (hwnd, NULL, TRUE);
2331 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
2337 * Only process WM_COMMAND once the dialog is fully formed.
2339 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
2340 switch (LOWORD(wParam)) {
2342 /* Behaviour of the "Open" button is different if the
2343 * session list has focus, *unless* the user just
2344 * double-clicked... */
2345 if (sesslist_has_focus && !readytogo) {
2346 if (!load_selected_session(hwnd)) {
2351 /* If at this point we have a valid session, go! */
2353 if (requested_help) {
2354 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2355 requested_help = FALSE;
2362 if (HIWORD(wParam) == BN_CLICKED ||
2363 HIWORD(wParam) == BN_DOUBLECLICKED) {
2365 WinHelp(hwnd, help_path,
2366 help_has_contents ? HELP_FINDER : HELP_CONTENTS,
2368 requested_help = TRUE;
2373 if (requested_help) {
2374 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2375 requested_help = FALSE;
2379 case IDC_PROTTELNET:
2380 case IDC_PROTRLOGIN:
2383 if (HIWORD(wParam) == BN_CLICKED ||
2384 HIWORD(wParam) == BN_DOUBLECLICKED) {
2385 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
2386 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
2387 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
2389 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
2392 * When switching using the arrow keys, we
2393 * appear to get two of these messages, both
2394 * mentioning the target button in
2395 * LOWORD(wParam), but one of them called while
2396 * the previous button is still checked. This
2397 * causes an unnecessary reset of the port
2398 * number field, which we fix by ensuring here
2399 * that the button selected is indeed the one
2402 if (IsDlgButtonChecked(hwnd, LOWORD(wParam)) &&
2403 ((cfg.protocol == PROT_SSH && cfg.port != 22)
2404 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
2405 || (cfg.protocol == PROT_RLOGIN
2406 && cfg.port != 513))) {
2407 cfg.port = i ? 22 : j ? 23 : 513;
2408 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
2413 if (HIWORD(wParam) == EN_CHANGE)
2414 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
2415 sizeof(cfg.host) - 1);
2418 if (HIWORD(wParam) == EN_CHANGE) {
2419 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
2420 if (isdigit(portname[0]))
2421 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
2423 service = getservbyname(portname, NULL);
2425 cfg.port = ntohs(service->s_port);
2432 if (HIWORD(wParam) == EN_CHANGE) {
2433 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2435 GetDlgItemText(hwnd, IDC_SESSEDIT,
2436 savedsession, sizeof(savedsession) - 1);
2437 savedsession[sizeof(savedsession) - 1] = '\0';
2441 if (HIWORD(wParam) == BN_CLICKED ||
2442 HIWORD(wParam) == BN_DOUBLECLICKED) {
2447 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
2450 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2451 LB_GETCURSEL, 0, 0);
2456 strcpy(str, sesslist.sessions[n]);
2458 save_settings(str, !!strcmp(str, "Default Settings"),
2460 get_sesslist(&sesslist, FALSE);
2461 get_sesslist(&sesslist, TRUE);
2462 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2464 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2466 for (i = 0; i < sesslist.nsessions; i++)
2467 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2469 (LPARAM) (sesslist.sessions[i]));
2470 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2472 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2474 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2480 if (LOWORD(wParam) == IDC_SESSLIST) {
2481 if (HIWORD(wParam) == LBN_SETFOCUS)
2482 sesslist_has_focus = 1;
2483 else if (HIWORD(wParam) == LBN_KILLFOCUS)
2484 sesslist_has_focus = 0;
2486 if (LOWORD(wParam) == IDC_SESSLOAD &&
2487 HIWORD(wParam) != BN_CLICKED &&
2488 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2489 if (LOWORD(wParam) == IDC_SESSLIST &&
2490 HIWORD(wParam) != LBN_DBLCLK) break;
2491 /* Load the session selected in SESSLIST. */
2492 if (load_selected_session(hwnd) &&
2493 LOWORD(wParam) == IDC_SESSLIST) {
2495 * A double-click on a saved session should
2496 * actually start the session, not just load it.
2497 * Unless it's Default Settings or some other
2498 * host-less set of saved settings.
2507 if (HIWORD(wParam) == BN_CLICKED ||
2508 HIWORD(wParam) == BN_DOUBLECLICKED) {
2509 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2510 LB_GETCURSEL, 0, 0);
2511 if (n == LB_ERR || n == 0) {
2515 del_settings(sesslist.sessions[n]);
2516 get_sesslist(&sesslist, FALSE);
2517 get_sesslist(&sesslist, TRUE);
2518 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2520 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2522 for (i = 0; i < sesslist.nsessions; i++)
2523 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2525 (LPARAM) (sesslist.sessions[i]));
2526 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2528 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2530 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2534 if (HIWORD(wParam) == EN_CHANGE)
2535 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
2536 &cfg.ping_interval);
2539 if (HIWORD(wParam) == BN_CLICKED ||
2540 HIWORD(wParam) == BN_DOUBLECLICKED)
2542 IsDlgButtonChecked(hwnd, IDC_NODELAY);
2546 if (HIWORD(wParam) == BN_CLICKED ||
2547 HIWORD(wParam) == BN_DOUBLECLICKED)
2548 cfg.bksp_is_delete =
2549 IsDlgButtonChecked(hwnd, IDC_DEL127);
2553 if (HIWORD(wParam) == BN_CLICKED ||
2554 HIWORD(wParam) == BN_DOUBLECLICKED)
2556 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
2562 case IDC_FUNCVT100P:
2564 if (HIWORD(wParam) == BN_CLICKED ||
2565 HIWORD(wParam) == BN_DOUBLECLICKED)
2566 switch (LOWORD(wParam)) {
2579 case IDC_FUNCVT100P:
2589 if (HIWORD(wParam) == BN_CLICKED ||
2590 HIWORD(wParam) == BN_DOUBLECLICKED) {
2592 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
2593 cfg.nethack_keypad = FALSE;
2597 if (HIWORD(wParam) == BN_CLICKED ||
2598 HIWORD(wParam) == BN_DOUBLECLICKED) {
2599 cfg.app_keypad = FALSE;
2600 cfg.nethack_keypad = TRUE;
2605 if (HIWORD(wParam) == BN_CLICKED ||
2606 HIWORD(wParam) == BN_DOUBLECLICKED)
2608 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
2611 if (HIWORD(wParam) == BN_CLICKED ||
2612 HIWORD(wParam) == BN_DOUBLECLICKED)
2614 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
2617 if (HIWORD(wParam) == BN_CLICKED ||
2618 HIWORD(wParam) == BN_DOUBLECLICKED)
2620 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
2622 case IDC_NOMOUSEREP:
2623 if (HIWORD(wParam) == BN_CLICKED ||
2624 HIWORD(wParam) == BN_DOUBLECLICKED)
2626 IsDlgButtonChecked(hwnd, IDC_NOMOUSEREP);
2629 if (HIWORD(wParam) == BN_CLICKED ||
2630 HIWORD(wParam) == BN_DOUBLECLICKED)
2631 cfg.no_remote_resize =
2632 IsDlgButtonChecked(hwnd, IDC_NORESIZE);
2634 case IDC_NOALTSCREEN:
2635 if (HIWORD(wParam) == BN_CLICKED ||
2636 HIWORD(wParam) == BN_DOUBLECLICKED)
2638 IsDlgButtonChecked(hwnd, IDC_NOALTSCREEN);
2640 case IDC_NOWINTITLE:
2641 if (HIWORD(wParam) == BN_CLICKED ||
2642 HIWORD(wParam) == BN_DOUBLECLICKED)
2643 cfg.no_remote_wintitle =
2644 IsDlgButtonChecked(hwnd, IDC_NOWINTITLE);
2646 case IDC_NODBACKSPACE:
2647 if (HIWORD(wParam) == BN_CLICKED ||
2648 HIWORD(wParam) == BN_DOUBLECLICKED)
2650 IsDlgButtonChecked(hwnd, IDC_NODBACKSPACE);
2653 if (HIWORD(wParam) == BN_CLICKED ||
2654 HIWORD(wParam) == BN_DOUBLECLICKED)
2655 cfg.no_remote_charset =
2656 IsDlgButtonChecked(hwnd, IDC_NOCHARSET);
2659 if (HIWORD(wParam) == BN_CLICKED ||
2660 HIWORD(wParam) == BN_DOUBLECLICKED)
2661 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
2664 if (HIWORD(wParam) == BN_CLICKED ||
2665 HIWORD(wParam) == BN_DOUBLECLICKED)
2667 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
2670 if (HIWORD(wParam) == BN_CLICKED ||
2671 HIWORD(wParam) == BN_DOUBLECLICKED)
2673 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
2675 case IDC_ECHOBACKEND:
2678 if (HIWORD(wParam) == BN_CLICKED ||
2679 HIWORD(wParam) == BN_DOUBLECLICKED) {
2680 if (LOWORD(wParam) == IDC_ECHOBACKEND)
2681 cfg.localecho = LD_BACKEND;
2682 if (LOWORD(wParam) == IDC_ECHOYES)
2683 cfg.localecho = LD_YES;
2684 if (LOWORD(wParam) == IDC_ECHONO)
2685 cfg.localecho = LD_NO;
2688 case IDC_EDITBACKEND:
2691 if (HIWORD(wParam) == BN_CLICKED ||
2692 HIWORD(wParam) == BN_DOUBLECLICKED) {
2693 if (LOWORD(wParam) == IDC_EDITBACKEND)
2694 cfg.localedit = LD_BACKEND;
2695 if (LOWORD(wParam) == IDC_EDITYES)
2696 cfg.localedit = LD_YES;
2697 if (LOWORD(wParam) == IDC_EDITNO)
2698 cfg.localedit = LD_NO;
2701 case IDC_ANSWEREDIT:
2702 if (HIWORD(wParam) == EN_CHANGE)
2703 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
2704 sizeof(cfg.answerback) - 1);
2706 case IDC_ALWAYSONTOP:
2707 if (HIWORD(wParam) == BN_CLICKED ||
2708 HIWORD(wParam) == BN_DOUBLECLICKED)
2710 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
2712 case IDC_FULLSCREENONALTENTER:
2713 if (HIWORD(wParam) == BN_CLICKED ||
2714 HIWORD(wParam) == BN_DOUBLECLICKED)
2715 cfg.fullscreenonaltenter =
2716 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
2719 if (HIWORD(wParam) == BN_CLICKED ||
2720 HIWORD(wParam) == BN_DOUBLECLICKED)
2722 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
2724 case IDC_SCROLLDISP:
2725 if (HIWORD(wParam) == BN_CLICKED ||
2726 HIWORD(wParam) == BN_DOUBLECLICKED)
2727 cfg.scroll_on_disp =
2728 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
2730 case IDC_COMPOSEKEY:
2731 if (HIWORD(wParam) == BN_CLICKED ||
2732 HIWORD(wParam) == BN_DOUBLECLICKED)
2734 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
2736 case IDC_CTRLALTKEYS:
2737 if (HIWORD(wParam) == BN_CLICKED ||
2738 HIWORD(wParam) == BN_DOUBLECLICKED)
2740 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
2743 if (HIWORD(wParam) == BN_CLICKED ||
2744 HIWORD(wParam) == BN_DOUBLECLICKED)
2745 cfg.telnet_keyboard =
2746 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
2749 if (HIWORD(wParam) == BN_CLICKED ||
2750 HIWORD(wParam) == BN_DOUBLECLICKED)
2751 cfg.telnet_newline =
2752 IsDlgButtonChecked(hwnd, IDC_TELNETRET);
2755 if (HIWORD(wParam) == BN_CLICKED ||
2756 HIWORD(wParam) == BN_DOUBLECLICKED)
2758 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
2761 if (HIWORD(wParam) == BN_CLICKED ||
2762 HIWORD(wParam) == BN_DOUBLECLICKED)
2763 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
2766 if (HIWORD(wParam) == BN_CLICKED ||
2767 HIWORD(wParam) == BN_DOUBLECLICKED)
2769 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
2772 if (HIWORD(wParam) == EN_CHANGE)
2773 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
2776 if (HIWORD(wParam) == EN_CHANGE)
2777 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
2780 if (HIWORD(wParam) == EN_CHANGE)
2781 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
2783 case IDC_CHOOSEFONT:
2786 lf.lfHeight = -MulDiv(cfg.fontheight,
2787 GetDeviceCaps(hdc, LOGPIXELSY),
2791 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
2792 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
2793 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
2794 lf.lfCharSet = cfg.fontcharset;
2795 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
2796 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
2797 lf.lfQuality = DEFAULT_QUALITY;
2798 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
2799 strncpy(lf.lfFaceName, cfg.font,
2800 sizeof(lf.lfFaceName) - 1);
2801 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
2803 cf.lStructSize = sizeof(cf);
2804 cf.hwndOwner = hwnd;
2806 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
2807 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
2809 if (ChooseFont(&cf)) {
2810 strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
2811 cfg.font[sizeof(cfg.font) - 1] = '\0';
2812 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
2813 cfg.fontcharset = lf.lfCharSet;
2814 cfg.fontheight = cf.iPointSize / 10;
2815 fmtfont(fontstatic);
2816 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
2819 case IDC_BELL_DISABLED:
2820 case IDC_BELL_DEFAULT:
2821 case IDC_BELL_WAVEFILE:
2822 case IDC_BELL_VISUAL:
2823 if (HIWORD(wParam) == BN_CLICKED ||
2824 HIWORD(wParam) == BN_DOUBLECLICKED) {
2825 if (LOWORD(wParam) == IDC_BELL_DISABLED)
2826 cfg.beep = BELL_DISABLED;
2827 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
2828 cfg.beep = BELL_DEFAULT;
2829 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
2830 cfg.beep = BELL_WAVEFILE;
2831 if (LOWORD(wParam) == IDC_BELL_VISUAL)
2832 cfg.beep = BELL_VISUAL;
2835 case IDC_B_IND_DISABLED:
2836 case IDC_B_IND_FLASH:
2837 case IDC_B_IND_STEADY:
2838 if (HIWORD(wParam) == BN_CLICKED ||
2839 HIWORD(wParam) == BN_DOUBLECLICKED) {
2840 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2841 cfg.beep_ind = B_IND_DISABLED;
2842 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2843 cfg.beep_ind = B_IND_FLASH;
2844 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2845 cfg.beep_ind = B_IND_STEADY;
2848 case IDC_BELL_WAVEBROWSE:
2849 memset(&of, 0, sizeof(of));
2850 #ifdef OPENFILENAME_SIZE_VERSION_400
2851 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2853 of.lStructSize = sizeof(of);
2855 of.hwndOwner = hwnd;
2856 of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2857 of.lpstrCustomFilter = NULL;
2858 of.nFilterIndex = 1;
2859 of.lpstrFile = filename;
2860 strcpy(filename, cfg.bell_wavefile);
2861 of.nMaxFile = sizeof(filename);
2862 of.lpstrFileTitle = NULL;
2863 of.lpstrInitialDir = NULL;
2864 of.lpstrTitle = "Select Bell Sound File";
2866 if (GetOpenFileName(&of)) {
2867 strcpy(cfg.bell_wavefile, filename);
2868 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2872 case IDC_BELL_WAVEEDIT:
2873 if (HIWORD(wParam) == EN_CHANGE)
2874 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2876 sizeof(cfg.bell_wavefile) - 1);
2879 if (HIWORD(wParam) == BN_CLICKED ||
2880 HIWORD(wParam) == BN_DOUBLECLICKED)
2882 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2885 if (HIWORD(wParam) == EN_CHANGE)
2886 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2889 if (HIWORD(wParam) == EN_CHANGE)
2890 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2894 if (HIWORD(wParam) == EN_CHANGE)
2895 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2899 if (HIWORD(wParam) == BN_CLICKED ||
2900 HIWORD(wParam) == BN_DOUBLECLICKED)
2902 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2905 if (HIWORD(wParam) == BN_CLICKED ||
2906 HIWORD(wParam) == BN_DOUBLECLICKED)
2907 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2910 if (HIWORD(wParam) == BN_CLICKED ||
2911 HIWORD(wParam) == BN_DOUBLECLICKED)
2912 cfg.win_name_always =
2913 IsDlgButtonChecked(hwnd, IDC_WINNAME);
2916 if (HIWORD(wParam) == BN_CLICKED ||
2917 HIWORD(wParam) == BN_DOUBLECLICKED)
2919 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2921 case IDC_SUNKENEDGE:
2922 if (HIWORD(wParam) == BN_CLICKED ||
2923 HIWORD(wParam) == BN_DOUBLECLICKED)
2925 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2928 if (HIWORD(wParam) == EN_CHANGE)
2929 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2930 &cfg.window_border);
2931 if (cfg.window_border > 32)
2932 cfg.window_border = 32;
2935 if (HIWORD(wParam) == BN_CLICKED ||
2936 HIWORD(wParam) == BN_DOUBLECLICKED)
2937 cfg.cursor_type = 0;
2940 if (HIWORD(wParam) == BN_CLICKED ||
2941 HIWORD(wParam) == BN_DOUBLECLICKED)
2942 cfg.cursor_type = 1;
2945 if (HIWORD(wParam) == BN_CLICKED ||
2946 HIWORD(wParam) == BN_DOUBLECLICKED)
2947 cfg.cursor_type = 2;
2950 if (HIWORD(wParam) == BN_CLICKED ||
2951 HIWORD(wParam) == BN_DOUBLECLICKED)
2953 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2956 if (HIWORD(wParam) == BN_CLICKED ||
2957 HIWORD(wParam) == BN_DOUBLECLICKED)
2959 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2961 case IDC_SCROLLBARFULLSCREEN:
2962 if (HIWORD(wParam) == BN_CLICKED ||
2963 HIWORD(wParam) == BN_DOUBLECLICKED)
2964 cfg.scrollbar_in_fullscreen =
2965 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2967 case IDC_RESIZETERM:
2968 case IDC_RESIZEFONT:
2969 case IDC_RESIZENONE:
2970 case IDC_RESIZEEITHER:
2971 if (HIWORD(wParam) == BN_CLICKED ||
2972 HIWORD(wParam) == BN_DOUBLECLICKED) {
2974 IsDlgButtonChecked(hwnd,
2975 IDC_RESIZETERM) ? RESIZE_TERM :
2976 IsDlgButtonChecked(hwnd,
2977 IDC_RESIZEFONT) ? RESIZE_FONT :
2978 IsDlgButtonChecked(hwnd,
2979 IDC_RESIZEEITHER) ? RESIZE_EITHER :
2984 if (HIWORD(wParam) == EN_CHANGE)
2985 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2986 sizeof(cfg.wintitle) - 1);
2991 if (HIWORD(wParam) == BN_CLICKED ||
2992 HIWORD(wParam) == BN_DOUBLECLICKED) {
2994 IsDlgButtonChecked(hwnd,
2995 IDC_COEALWAYS) ? COE_ALWAYS :
2996 IsDlgButtonChecked(hwnd,
2997 IDC_COENEVER) ? COE_NEVER :
3002 if (HIWORD(wParam) == BN_CLICKED ||
3003 HIWORD(wParam) == BN_DOUBLECLICKED)
3005 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
3008 if (HIWORD(wParam) == EN_CHANGE)
3009 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
3010 sizeof(cfg.termtype) - 1);
3014 case IDC_PROXYHOSTEDIT:
3015 if (HIWORD(wParam) == EN_CHANGE)
3016 GetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host,
3017 sizeof(cfg.proxy_host) - 1);
3019 case IDC_PROXYPORTEDIT:
3020 if (HIWORD(wParam) == EN_CHANGE) {
3021 GetDlgItemText(hwnd, IDC_PROXYPORTEDIT, portname, 31);
3022 if (isdigit(portname[0]))
3023 MyGetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, &cfg.proxy_port);
3025 service = getservbyname(portname, NULL);
3027 cfg.proxy_port = ntohs(service->s_port);
3033 case IDC_PROXYEXCLUDEEDIT:
3034 if (HIWORD(wParam) == EN_CHANGE)
3035 GetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT,
3036 cfg.proxy_exclude_list,
3037 sizeof(cfg.proxy_exclude_list) - 1);
3039 case IDC_PROXYUSEREDIT:
3040 if (HIWORD(wParam) == EN_CHANGE)
3041 GetDlgItemText(hwnd, IDC_PROXYUSEREDIT,
3043 sizeof(cfg.proxy_username) - 1);
3045 case IDC_PROXYPASSEDIT:
3046 if (HIWORD(wParam) == EN_CHANGE)
3047 GetDlgItemText(hwnd, IDC_PROXYPASSEDIT,
3049 sizeof(cfg.proxy_password) - 1);
3051 case IDC_PROXYTELNETCMDEDIT:
3052 if (HIWORD(wParam) == EN_CHANGE)
3053 GetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT,
3054 cfg.proxy_telnet_command,
3055 sizeof(cfg.proxy_telnet_command) - 1);
3057 case IDC_PROXYSOCKSVER5:
3058 case IDC_PROXYSOCKSVER4:
3059 if (HIWORD(wParam) == BN_CLICKED ||
3060 HIWORD(wParam) == BN_DOUBLECLICKED) {
3061 cfg.proxy_socks_version =
3062 IsDlgButtonChecked(hwnd, IDC_PROXYSOCKSVER4) ? 4 : 5;
3065 case IDC_PROXYLOCALHOST:
3066 if (HIWORD(wParam) == BN_CLICKED ||
3067 HIWORD(wParam) == BN_DOUBLECLICKED)
3068 cfg.even_proxy_localhost =
3069 IsDlgButtonChecked(hwnd, IDC_PROXYLOCALHOST);
3071 case IDC_PROXYDNSNO:
3072 case IDC_PROXYDNSAUTO:
3073 case IDC_PROXYDNSYES:
3074 if (HIWORD(wParam) == BN_CLICKED ||
3075 HIWORD(wParam) == BN_DOUBLECLICKED) {
3077 IsDlgButtonChecked(hwnd, IDC_PROXYDNSNO) ? PROXYDNS_NO :
3078 IsDlgButtonChecked(hwnd, IDC_PROXYDNSYES) ? PROXYDNS_YES :
3082 case IDC_PROXYTYPENONE:
3083 case IDC_PROXYTYPEHTTP:
3084 case IDC_PROXYTYPESOCKS:
3085 case IDC_PROXYTYPETELNET:
3086 if (HIWORD(wParam) == BN_CLICKED ||
3087 HIWORD(wParam) == BN_DOUBLECLICKED) {
3089 IsDlgButtonChecked(hwnd, IDC_PROXYTYPEHTTP) ? PROXY_HTTP :
3090 IsDlgButtonChecked(hwnd, IDC_PROXYTYPESOCKS) ? PROXY_SOCKS :
3091 IsDlgButtonChecked(hwnd, IDC_PROXYTYPETELNET) ? PROXY_TELNET :
3097 if (HIWORD(wParam) == EN_CHANGE)
3098 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
3099 sizeof(cfg.logfilename) - 1);
3102 memset(&of, 0, sizeof(of));
3103 #ifdef OPENFILENAME_SIZE_VERSION_400
3104 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3106 of.lStructSize = sizeof(of);
3108 of.hwndOwner = hwnd;
3109 of.lpstrFilter = "All Files\0*\0\0\0";
3110 of.lpstrCustomFilter = NULL;
3111 of.nFilterIndex = 1;
3112 of.lpstrFile = filename;
3113 strcpy(filename, cfg.logfilename);
3114 of.nMaxFile = sizeof(filename);
3115 of.lpstrFileTitle = NULL;
3116 of.lpstrInitialDir = NULL;
3117 of.lpstrTitle = "Select session log file";
3119 if (GetSaveFileName(&of)) {
3120 strcpy(cfg.logfilename, filename);
3121 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
3125 case IDC_LSTATASCII:
3127 case IDC_LSTATPACKET:
3128 if (HIWORD(wParam) == BN_CLICKED ||
3129 HIWORD(wParam) == BN_DOUBLECLICKED) {
3130 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
3131 cfg.logtype = LGTYP_NONE;
3132 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
3133 cfg.logtype = LGTYP_ASCII;
3134 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
3135 cfg.logtype = LGTYP_DEBUG;
3136 if (IsDlgButtonChecked(hwnd, IDC_LSTATPACKET))
3137 cfg.logtype = LGTYP_PACKETS;
3143 if (HIWORD(wParam) == BN_CLICKED ||
3144 HIWORD(wParam) == BN_DOUBLECLICKED) {
3145 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
3146 cfg.logxfovr = LGXF_ASK;
3147 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
3148 cfg.logxfovr = LGXF_APN;
3149 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
3150 cfg.logxfovr = LGXF_OVR;
3155 if (HIWORD(wParam) == EN_CHANGE)
3156 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
3157 sizeof(cfg.termspeed) - 1);
3160 if (HIWORD(wParam) == EN_CHANGE)
3161 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
3162 sizeof(cfg.username) - 1);
3164 case IDC_RLLUSEREDIT:
3165 if (HIWORD(wParam) == EN_CHANGE)
3166 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
3168 sizeof(cfg.localusername) - 1);
3172 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
3176 cfg.passive_telnet =
3177 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
3180 if (HIWORD(wParam) == BN_CLICKED ||
3181 HIWORD(wParam) == BN_DOUBLECLICKED) {
3182 char str[sizeof(cfg.environmt)];
3184 GetDlgItemText(hwnd, IDC_VAREDIT, str,
3190 p = str + strlen(str);
3192 GetDlgItemText(hwnd, IDC_VALEDIT, p,
3193 sizeof(str) - 1 - (p - str));
3204 if ((p - cfg.environmt) + strlen(str) + 2 <
3205 sizeof(cfg.environmt)) {
3207 p[strlen(str) + 1] = '\0';
3208 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
3210 SetDlgItemText(hwnd, IDC_VAREDIT, "");
3211 SetDlgItemText(hwnd, IDC_VALEDIT, "");
3213 MessageBox(hwnd, "Environment too big",
3214 "PuTTY Error", MB_OK | MB_ICONERROR);
3219 if (HIWORD(wParam) != BN_CLICKED &&
3220 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3222 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
3229 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
3256 if (HIWORD(wParam) == BN_CLICKED ||
3257 HIWORD(wParam) == BN_DOUBLECLICKED)
3258 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
3261 if (HIWORD(wParam) == BN_CLICKED ||
3262 HIWORD(wParam) == BN_DOUBLECLICKED)
3264 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
3267 if (HIWORD(wParam) == BN_CLICKED ||
3268 HIWORD(wParam) == BN_DOUBLECLICKED)
3270 IsDlgButtonChecked(hwnd, IDC_SSH2DES);
3273 if (HIWORD(wParam) == BN_CLICKED ||
3274 HIWORD(wParam) == BN_DOUBLECLICKED)
3276 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
3278 case IDC_CHANGEUSER:
3279 if (HIWORD(wParam) == BN_CLICKED ||
3280 HIWORD(wParam) == BN_DOUBLECLICKED)
3281 cfg.change_username =
3282 IsDlgButtonChecked(hwnd, IDC_CHANGEUSER);
3284 case IDC_CIPHERLIST:
3287 handle_prefslist(&cipherlist,
3288 cfg.ssh_cipherlist, CIPHER_MAX,
3289 0, hwnd, wParam, lParam);
3291 case IDC_SSHPROT1ONLY:
3294 case IDC_SSHPROT2ONLY:
3295 if (HIWORD(wParam) == BN_CLICKED ||
3296 HIWORD(wParam) == BN_DOUBLECLICKED) {
3297 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1ONLY))
3299 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
3301 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
3303 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2ONLY))
3308 if (HIWORD(wParam) == BN_CLICKED ||
3309 HIWORD(wParam) == BN_DOUBLECLICKED)
3311 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
3314 if (HIWORD(wParam) == BN_CLICKED ||
3315 HIWORD(wParam) == BN_DOUBLECLICKED)
3317 IsDlgButtonChecked(hwnd, IDC_AUTHKI);
3320 if (HIWORD(wParam) == EN_CHANGE)
3321 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
3322 sizeof(cfg.keyfile) - 1);
3325 if (HIWORD(wParam) == EN_CHANGE)
3326 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
3327 sizeof(cfg.remote_cmd) - 1);
3330 memset(&of, 0, sizeof(of));
3331 #ifdef OPENFILENAME_SIZE_VERSION_400
3332 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3334 of.lStructSize = sizeof(of);
3336 of.hwndOwner = hwnd;
3337 of.lpstrFilter = "PuTTY Private Key Files (*.ppk)\0*.PPK\0"
3338 "AllFiles\0*\0\0\0";
3339 of.lpstrCustomFilter = NULL;
3340 of.nFilterIndex = 1;
3341 of.lpstrFile = filename;
3342 strcpy(filename, cfg.keyfile);
3343 of.nMaxFile = sizeof(filename);
3344 of.lpstrFileTitle = NULL;
3345 of.lpstrInitialDir = NULL;
3346 of.lpstrTitle = "Select Private Key File";
3348 if (GetOpenFileName(&of)) {
3349 strcpy(cfg.keyfile, filename);
3350 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
3354 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
3357 cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
3361 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
3363 case IDC_SELTYPELEX:
3364 case IDC_SELTYPERECT:
3365 cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
3367 case IDC_MOUSEOVERRIDE:
3368 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
3374 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
3379 for (i = 0; i < 128; i++)
3380 if (SendDlgItemMessage
3381 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
3383 cfg.wordness[i] = n;
3384 SendDlgItemMessage(hwnd, IDC_CCLIST,
3385 LB_DELETESTRING, i, 0);
3386 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
3387 (i >= 0x21 && i != 0x7F) ? i : ' ',
3389 SendDlgItemMessage(hwnd, IDC_CCLIST,
3396 case IDC_BOLDCOLOUR:
3397 if (HIWORD(wParam) == BN_CLICKED ||
3398 HIWORD(wParam) == BN_DOUBLECLICKED) {
3401 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
3402 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
3405 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3407 if (n != 12 + 10 * cfg.bold_colour) {
3408 for (i = n; i-- > 0;)
3409 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3410 LB_DELETESTRING, i, 0);
3411 for (i = 0; i < 22; i++)
3412 if (cfg.bold_colour || permcolour[i])
3413 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3415 (LPARAM) colours[i]);
3417 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
3419 InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
3424 if (HIWORD(wParam) == BN_CLICKED ||
3425 HIWORD(wParam) == BN_DOUBLECLICKED)
3427 IsDlgButtonChecked(hwnd, IDC_PALETTE);
3429 case IDC_COLOURLIST:
3430 if (HIWORD(wParam) == LBN_DBLCLK ||
3431 HIWORD(wParam) == LBN_SELCHANGE) {
3433 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3436 if (!cfg.bold_colour)
3437 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3438 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3440 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3442 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3447 if (HIWORD(wParam) == BN_CLICKED ||
3448 HIWORD(wParam) == BN_DOUBLECLICKED) {
3449 static CHOOSECOLOR cc;
3450 static DWORD custom[16] = { 0 }; /* zero initialisers */
3452 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3455 if (!cfg.bold_colour)
3456 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3457 cc.lStructSize = sizeof(cc);
3458 cc.hwndOwner = hwnd;
3459 cc.hInstance = (HWND) hinst;
3460 cc.lpCustColors = custom;
3462 RGB(cfg.colours[i][0], cfg.colours[i][1],
3464 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
3465 if (ChooseColor(&cc)) {
3467 (unsigned char) (cc.rgbResult & 0xFF);
3469 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
3471 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
3472 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3474 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3476 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3482 if (HIWORD(wParam) == CBN_SELCHANGE) {
3483 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
3484 CB_GETCURSEL, 0, 0);
3485 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
3486 index, (LPARAM)cfg.line_codepage);
3487 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3488 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
3489 sizeof(cfg.line_codepage) - 1);
3490 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
3491 strcpy(cfg.line_codepage,
3492 cp_name(decode_codepage(cfg.line_codepage)));
3493 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
3497 if (HIWORD(wParam) == CBN_SELCHANGE) {
3498 int index = SendDlgItemMessage(hwnd, IDC_PRINTER,
3499 CB_GETCURSEL, 0, 0);
3500 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_GETLBTEXT,
3501 index, (LPARAM)cfg.printer);
3502 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3503 GetDlgItemText(hwnd, IDC_PRINTER, cfg.printer,
3504 sizeof(cfg.printer) - 1);
3506 if (!strcmp(cfg.printer, PRINTER_DISABLED_STRING))
3507 *cfg.printer = '\0';
3509 case IDC_CAPSLOCKCYR:
3510 if (HIWORD(wParam) == BN_CLICKED ||
3511 HIWORD(wParam) == BN_DOUBLECLICKED) {
3512 cfg.xlat_capslockcyr =
3513 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
3516 case IDC_VTXWINDOWS:
3522 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
3523 : IsDlgButtonChecked(hwnd,
3524 IDC_VTOEMANSI) ? VT_OEMANSI :
3525 IsDlgButtonChecked(hwnd,
3526 IDC_VTOEMONLY) ? VT_OEMONLY :
3527 IsDlgButtonChecked(hwnd,
3528 IDC_VTUNICODE) ? VT_UNICODE :
3531 case IDC_X11_FORWARD:
3532 if (HIWORD(wParam) == BN_CLICKED ||
3533 HIWORD(wParam) == BN_DOUBLECLICKED)
3535 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
3538 if (HIWORD(wParam) == BN_CLICKED ||
3539 HIWORD(wParam) == BN_DOUBLECLICKED)
3540 cfg.lport_acceptall =
3541 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
3544 if (HIWORD(wParam) == BN_CLICKED ||
3545 HIWORD(wParam) == BN_DOUBLECLICKED)
3546 cfg.rport_acceptall =
3547 IsDlgButtonChecked(hwnd, IDC_RPORT_ALL);
3549 case IDC_X11_DISPLAY:
3550 if (HIWORD(wParam) == EN_CHANGE)
3551 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
3552 sizeof(cfg.x11_display) - 1);
3556 if (HIWORD(wParam) == BN_CLICKED ||
3557 HIWORD(wParam) == BN_DOUBLECLICKED) {
3558 if (IsDlgButtonChecked(hwnd, IDC_X11MIT))
3559 cfg.x11_auth = X11_MIT;
3560 else if (IsDlgButtonChecked(hwnd, IDC_X11XDM))
3561 cfg.x11_auth = X11_XDM;
3565 if (HIWORD(wParam) == BN_CLICKED ||
3566 HIWORD(wParam) == BN_DOUBLECLICKED) {
3567 char str[sizeof(cfg.portfwd)];
3569 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
3573 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
3577 "You need to specify a source port number",
3578 "PuTTY Error", MB_OK | MB_ICONERROR);
3581 p = str + strlen(str);
3583 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
3584 sizeof(str) - 1 - (p - str));
3585 if (!*p || !strchr(p, ':')) {
3587 "You need to specify a destination address\n"
3588 "in the form \"host.name:port\"",
3589 "PuTTY Error", MB_OK | MB_ICONERROR);
3598 if ((p - cfg.portfwd) + strlen(str) + 2 <
3599 sizeof(cfg.portfwd)) {
3601 p[strlen(str) + 1] = '\0';
3602 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
3604 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
3605 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
3607 MessageBox(hwnd, "Too many forwardings",
3608 "PuTTY Error", MB_OK | MB_ICONERROR);
3612 case IDC_PFWDREMOVE:
3613 if (HIWORD(wParam) != BN_CLICKED &&
3614 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3615 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
3616 LB_GETCURSEL, 0, 0);
3622 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
3648 case IDC_BUGD_IGNORE1:
3649 if (HIWORD(wParam) == CBN_SELCHANGE) {
3650 int index = SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1,
3651 CB_GETCURSEL, 0, 0);
3652 cfg.sshbug_ignore1 = (index == 0 ? BUG_AUTO :
3653 index == 1 ? BUG_OFF : BUG_ON);
3656 case IDC_BUGD_PLAINPW1:
3657 if (HIWORD(wParam) == CBN_SELCHANGE) {
3658 int index = SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1,
3659 CB_GETCURSEL, 0, 0);
3660 cfg.sshbug_plainpw1 = (index == 0 ? BUG_AUTO :
3661 index == 1 ? BUG_OFF : BUG_ON);
3665 if (HIWORD(wParam) == CBN_SELCHANGE) {
3666 int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSA1,
3667 CB_GETCURSEL, 0, 0);
3668 cfg.sshbug_rsa1 = (index == 0 ? BUG_AUTO :
3669 index == 1 ? BUG_OFF : BUG_ON);
3672 case IDC_BUGD_HMAC2:
3673 if (HIWORD(wParam) == CBN_SELCHANGE) {
3674 int index = SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2,
3675 CB_GETCURSEL, 0, 0);
3676 cfg.sshbug_hmac2 = (index == 0 ? BUG_AUTO :
3677 index == 1 ? BUG_OFF : BUG_ON);
3680 case IDC_BUGD_DERIVEKEY2:
3681 if (HIWORD(wParam) == CBN_SELCHANGE) {
3682 int index = SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2,
3683 CB_GETCURSEL, 0, 0);
3684 cfg.sshbug_derivekey2 = (index == 0 ? BUG_AUTO :
3685 index == 1 ? BUG_OFF : BUG_ON);
3688 case IDC_BUGD_RSAPAD2:
3689 if (HIWORD(wParam) == CBN_SELCHANGE) {
3690 int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2,
3691 CB_GETCURSEL, 0, 0);
3692 cfg.sshbug_rsapad2 = (index == 0 ? BUG_AUTO :
3693 index == 1 ? BUG_OFF : BUG_ON);
3696 case IDC_BUGD_DHGEX2:
3697 if (HIWORD(wParam) == CBN_SELCHANGE) {
3698 int index = SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2,
3699 CB_GETCURSEL, 0, 0);
3700 cfg.sshbug_dhgex2 = (index == 0 ? BUG_AUTO :
3701 index == 1 ? BUG_OFF : BUG_ON);
3708 int id = ((LPHELPINFO)lParam)->iCtrlId;
3709 char *cmd = help_context_cmd(id);
3711 WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
3712 requested_help = TRUE;
3719 if (requested_help) {
3720 WinHelp(hwnd, help_path, HELP_QUIT, 0);
3721 requested_help = FALSE;
3726 /* Grrr Explorer will maximize Dialogs! */
3728 if (wParam == SIZE_MAXIMIZED)
3734 * Handle application-defined messages eg. DragListBox
3736 /* First find out what the number is (once). */
3737 if (draglistmsg == WM_NULL)
3738 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
3740 if (msg == draglistmsg) {
3741 /* Only process once dialog is fully formed. */
3742 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
3743 case IDC_CIPHERLIST:
3744 return handle_prefslist(&cipherlist,
3745 cfg.ssh_cipherlist, CIPHER_MAX,
3746 1, hwnd, wParam, lParam);
3755 static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
3756 WPARAM wParam, LPARAM lParam)
3758 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
3760 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
3761 EnableWindow(hwnd, 0);
3762 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3763 EnableWindow(hwnd, 1);
3764 SetActiveWindow(hwnd);
3766 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
3769 static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
3770 WPARAM wParam, LPARAM lParam)
3772 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
3775 void defuse_showwindow(void)
3778 * Work around the fact that the app's first call to ShowWindow
3779 * will ignore the default in favour of the shell-provided
3784 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
3786 ShowWindow(hwnd, SW_HIDE);
3787 SetActiveWindow(hwnd);
3788 DestroyWindow(hwnd);
3796 get_sesslist(&sesslist, TRUE);
3797 savedsession[0] = '\0';
3799 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
3800 get_sesslist(&sesslist, FALSE);
3805 int do_reconfig(HWND hwnd)
3810 backup_cfg = cfg; /* structure copy */
3812 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
3814 cfg = backup_cfg; /* structure copy */
3819 void logevent(void *frontend, char *string)
3824 log_eventlog(logctx, string);
3826 if (nevents >= negsize) {
3828 events = srealloc(events, negsize * sizeof(*events));
3832 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
3835 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
3836 strcpy(events[nevents], timebuf);
3837 strcat(events[nevents], string);
3840 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
3841 0, (LPARAM) events[nevents]);
3842 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
3843 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
3848 void showeventlog(HWND hwnd)
3851 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
3853 ShowWindow(logbox, SW_SHOWNORMAL);
3855 SetActiveWindow(logbox);
3858 void showabout(HWND hwnd)
3860 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3863 void verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,
3864 char *keystr, char *fingerprint)
3868 static const char absentmsg[] =
3869 "The server's host key is not cached in the registry. You\n"
3870 "have no guarantee that the server is the computer you\n"
3872 "The server's key fingerprint is:\n"
3874 "If you trust this host, hit Yes to add the key to\n"
3875 "PuTTY's cache and carry on connecting.\n"
3876 "If you want to carry on connecting just once, without\n"
3877 "adding the key to the cache, hit No.\n"
3878 "If you do not trust this host, hit Cancel to abandon the\n"
3881 static const char wrongmsg[] =
3882 "WARNING - POTENTIAL SECURITY BREACH!\n"
3884 "The server's host key does not match the one PuTTY has\n"
3885 "cached in the registry. This means that either the\n"
3886 "server administrator has changed the host key, or you\n"
3887 "have actually connected to another computer pretending\n"
3888 "to be the server.\n"
3889 "The new key fingerprint is:\n"
3891 "If you were expecting this change and trust the new key,\n"
3892 "hit Yes to update PuTTY's cache and continue connecting.\n"
3893 "If you want to carry on connecting but without updating\n"
3894 "the cache, hit No.\n"
3895 "If you want to abandon the connection completely, hit\n"
3896 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3898 static const char mbtitle[] = "PuTTY Security Alert";
3901 /* sensible fingerprint max size */
3902 (sizeof(absentmsg) > sizeof(wrongmsg) ?
3903 sizeof(absentmsg) : sizeof(wrongmsg))];
3906 * Verify the key against the registry.
3908 ret = verify_host_key(host, port, keytype, keystr);
3910 if (ret == 0) /* success - key matched OK */
3912 if (ret == 2) { /* key was different */
3914 sprintf(message, wrongmsg, fingerprint);
3915 mbret = MessageBox(NULL, message, mbtitle,
3916 MB_ICONWARNING | MB_YESNOCANCEL);
3918 store_host_key(host, port, keytype, keystr);
3919 if (mbret == IDCANCEL)
3922 if (ret == 1) { /* key was absent */
3924 sprintf(message, absentmsg, fingerprint);
3925 mbret = MessageBox(NULL, message, mbtitle,
3926 MB_ICONWARNING | MB_YESNOCANCEL);
3928 store_host_key(host, port, keytype, keystr);
3929 if (mbret == IDCANCEL)
3935 * Ask whether the selected cipher is acceptable (since it was
3936 * below the configured 'warn' threshold).
3937 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3939 void askcipher(void *frontend, char *ciphername, int cs)
3941 static const char mbtitle[] = "PuTTY Security Alert";
3942 static const char msg[] =
3943 "The first %.35scipher supported by the server\n"
3944 "is %.64s, which is below the configured\n"
3945 "warning threshold.\n"
3946 "Do you want to continue with this connection?\n";
3947 /* guessed cipher name + type max length */
3948 char message[100 + sizeof(msg)];
3951 sprintf(message, msg,
3953 (cs == 1) ? "client-to-server " :
3954 "server-to-client ",
3956 mbret = MessageBox(NULL, message, mbtitle,
3957 MB_ICONWARNING | MB_YESNO);
3965 * Ask whether to wipe a session log file before writing to it.
3966 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3968 int askappend(void *frontend, char *filename)
3970 static const char mbtitle[] = "PuTTY Log to File";
3971 static const char msgtemplate[] =
3972 "The session log file \"%.*s\" already exists.\n"
3973 "You can overwrite it with a new session log,\n"
3974 "append your session log to the end of it,\n"
3975 "or disable session logging for this session.\n"
3976 "Hit Yes to wipe the file, No to append to it,\n"
3977 "or Cancel to disable logging.";
3978 char message[sizeof(msgtemplate) + FILENAME_MAX];
3981 sprintf(message, msgtemplate, FILENAME_MAX, filename);
3983 mbret = MessageBox(NULL, message, mbtitle,
3984 MB_ICONQUESTION | MB_YESNOCANCEL);
3987 else if (mbret == IDNO)
3994 * Warn about the obsolescent key file format.
3996 * Uniquely among these functions, this one does _not_ expect a
3997 * frontend handle. This means that if PuTTY is ported to a
3998 * platform which requires frontend handles, this function will be
3999 * an anomaly. Fortunately, the problem it addresses will not have
4000 * been present on that platform, so it can plausibly be
4001 * implemented as an empty function.
4003 void old_keyfile_warning(void)
4005 static const char mbtitle[] = "PuTTY Key File Warning";
4006 static const char message[] =
4007 "You are loading an SSH 2 private key which has an\n"
4008 "old version of the file format. This means your key\n"
4009 "file is not fully tamperproof. Future versions of\n"
4010 "PuTTY may stop supporting this private key format,\n"
4011 "so we recommend you convert your key to the new\n"
4014 "You can perform this conversion by loading the key\n"
4015 "into PuTTYgen and then saving it again.";
4017 MessageBox(NULL, message, mbtitle, MB_OK);