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,
604 translationpanelstart,
605 IDC_TITLE_TRANSLATION,
606 IDC_BOX_TRANSLATION1,
607 IDC_BOX_TRANSLATION2,
608 IDC_BOX_TRANSLATION3,
649 static const char *const colours[] = {
650 "Default Foreground", "Default Bold Foreground",
651 "Default Background", "Default Bold Background",
652 "Cursor Text", "Cursor Colour",
653 "ANSI Black", "ANSI Black Bold",
654 "ANSI Red", "ANSI Red Bold",
655 "ANSI Green", "ANSI Green Bold",
656 "ANSI Yellow", "ANSI Yellow Bold",
657 "ANSI Blue", "ANSI Blue Bold",
658 "ANSI Magenta", "ANSI Magenta Bold",
659 "ANSI Cyan", "ANSI Cyan Bold",
660 "ANSI White", "ANSI White Bold"
663 static void fmtfont(char *buf)
665 sprintf(buf, "Font: %s, ", cfg.font.name);
667 strcat(buf, "bold, ");
668 if (cfg.font.height == 0)
669 strcat(buf, "default height");
671 sprintf(buf + strlen(buf), "%d-point",
672 (cfg.font.height < 0 ? -cfg.font.height : cfg.font.height));
675 char *help_context_cmd(int id)
687 return "JI(`',`session.hostname')";
694 return "JI(`',`session.saved')";
699 return "JI(`',`session.coe')";
700 case IDC_LSTATSTATIC:
704 case IDC_LSTATPACKET:
705 return "JI(`',`logging.main')";
710 return "JI(`',`logging.filename')";
715 return "JI(`',`logging.exists')";
720 return "JI(`',`keyboard.backspace')";
724 return "JI(`',`keyboard.homeend')";
732 return "JI(`',`keyboard.funkeys')";
736 return "JI(`',`keyboard.appkeypad')";
740 return "JI(`',`keyboard.appcursor')";
742 return "JI(`',`keyboard.nethack')";
744 return "JI(`',`keyboard.compose')";
745 case IDC_CTRLALTKEYS:
746 return "JI(`',`keyboard.ctrlalt')";
750 return "JI(`',`features.application')";
752 return "JI(`',`features.mouse')";
754 return "JI(`',`features.resize')";
755 case IDC_NOALTSCREEN:
756 return "JI(`',`features.altscreen')";
758 return "JI(`',`features.retitle')";
759 case IDC_NODBACKSPACE:
760 return "JI(`',`features.dbackspace')";
762 return "JI(`',`features.charset')";
765 return "JI(`',`terminal.autowrap')";
767 return "JI(`',`terminal.decom')";
769 return "JI(`',`terminal.lfhascr')";
771 return "JI(`',`terminal.bce')";
773 return "JI(`',`terminal.blink')";
776 return "JI(`',`terminal.answerback')";
778 case IDC_ECHOBACKEND:
781 return "JI(`',`terminal.localecho')";
783 case IDC_EDITBACKEND:
786 return "JI(`',`terminal.localedit')";
787 case IDC_PRINTERSTATIC:
789 return "JI(`',`terminal.printing')";
792 case IDC_BELL_DISABLED:
793 case IDC_BELL_DEFAULT:
794 case IDC_BELL_WAVEFILE:
795 case IDC_BELL_VISUAL:
796 case IDC_BELL_WAVESTATIC:
797 case IDC_BELL_WAVEEDIT:
798 case IDC_BELL_WAVEBROWSE:
799 return "JI(`',`bell.style')";
800 case IDC_B_IND_STATIC:
801 case IDC_B_IND_DISABLED:
802 case IDC_B_IND_FLASH:
803 case IDC_B_IND_STEADY:
804 return "JI(`',`bell.taskbar')";
806 case IDC_BELLOVLNSTATIC:
808 case IDC_BELLOVLTSTATIC:
810 case IDC_BELLOVLEXPLAIN:
811 case IDC_BELLOVLSSTATIC:
813 return "JI(`',`bell.overload')";
819 return "JI(`',`window.size')";
820 case IDC_RESIZESTATIC:
824 case IDC_RESIZEEITHER:
825 return "JI(`',`window.resize')";
827 case IDC_SCROLLBARFULLSCREEN:
832 return "JI(`',`window.scrollback')";
835 return "JI(`',`behaviour.closewarn')";
837 return "JI(`',`behaviour.altf4')";
839 return "JI(`',`behaviour.altspace')";
841 return "JI(`',`behaviour.altonly')";
842 case IDC_ALWAYSONTOP:
843 return "JI(`',`behaviour.alwaysontop')";
844 case IDC_FULLSCREENONALTENTER:
845 return "JI(`',`behaviour.altenter')";
847 case IDC_CURSORSTATIC:
852 return "JI(`',`appearance.cursor')";
855 return "JI(`',`appearance.font')";
859 return "JI(`',`appearance.title')";
861 return "JI(`',`appearance.hidemouse')";
865 return "JI(`',`appearance.border')";
869 return "JI(`',`connection.termtype')";
872 return "JI(`',`connection.username')";
875 return "JI(`',`connection.keepalive')";
877 return "JI(`',`connection.nodelay')";
879 case IDC_PROXYTYPESTATIC:
880 case IDC_PROXYTYPENONE:
881 case IDC_PROXYTYPEHTTP:
882 case IDC_PROXYTYPESOCKS:
883 case IDC_PROXYTYPETELNET:
884 return "JI(`',`proxy.type')";
885 case IDC_PROXYHOSTSTATIC:
886 case IDC_PROXYHOSTEDIT:
887 case IDC_PROXYPORTSTATIC:
888 case IDC_PROXYPORTEDIT:
889 return "JI(`',`proxy.main')";
890 case IDC_PROXYEXCLUDESTATIC:
891 case IDC_PROXYEXCLUDEEDIT:
892 case IDC_PROXYLOCALHOST:
893 return "JI(`',`proxy.exclude')";
894 case IDC_PROXYDNSSTATIC:
896 case IDC_PROXYDNSAUTO:
897 case IDC_PROXYDNSYES:
898 return "JI(`',`proxy.dns')";
899 case IDC_PROXYUSERSTATIC:
900 case IDC_PROXYUSEREDIT:
901 case IDC_PROXYPASSSTATIC:
902 case IDC_PROXYPASSEDIT:
903 return "JI(`',`proxy.auth')";
904 case IDC_PROXYTELNETCMDSTATIC:
905 case IDC_PROXYTELNETCMDEDIT:
906 return "JI(`',`proxy.command')";
907 case IDC_PROXYSOCKSVERSTATIC:
908 case IDC_PROXYSOCKSVER5:
909 case IDC_PROXYSOCKSVER4:
910 return "JI(`',`proxy.socksver')";
914 return "JI(`',`telnet.termspeed')";
923 return "JI(`',`telnet.environ')";
927 return "JI(`',`telnet.oldenviron')";
931 return "JI(`',`telnet.passive')";
933 return "JI(`',`telnet.specialkeys')";
935 return "JI(`',`telnet.newline')";
939 return "JI(`',`rlogin.termspeed')";
940 case IDC_RLLUSERSTATIC:
941 case IDC_RLLUSEREDIT:
942 return "JI(`',`rlogin.localuser')";
945 return "JI(`',`ssh.nopty')";
946 case IDC_CIPHERSTATIC2:
951 return "JI(`',`ssh.ciphers')";
952 case IDC_SSHPROTSTATIC:
953 case IDC_SSHPROT1ONLY:
956 case IDC_SSHPROT2ONLY:
957 return "JI(`',`ssh.protocol')";
960 return "JI(`',`ssh.command')";
962 return "JI(`',`ssh.compress')";
967 return "JI(`',`ssh.auth.privkey')";
969 return "JI(`',`ssh.auth.agentfwd')";
971 return "JI(`',`ssh.auth.changeuser')";
973 return "JI(`',`ssh.auth.tis')";
975 return "JI(`',`ssh.auth.ki')";
980 return "JI(`',`selection.buttons')";
981 case IDC_MOUSEOVERRIDE:
982 return "JI(`',`selection.shiftdrag')";
983 case IDC_SELTYPESTATIC:
985 case IDC_SELTYPERECT:
986 return "JI(`',`selection.rect')";
992 return "JI(`',`selection.charclasses')";
994 return "JI(`',`selection.linedraw')";
996 return "JI(`',`selection.rtf')";
999 return "JI(`',`colours.bold')";
1001 return "JI(`',`colours.logpal')";
1002 case IDC_COLOURSTATIC:
1003 case IDC_COLOURLIST:
1011 return "JI(`',`colours.config')";
1013 case IDC_CODEPAGESTATIC:
1015 return "JI(`',`translation.codepage')";
1016 case IDC_CAPSLOCKCYR:
1017 return "JI(`',`translation.cyrillic')";
1019 case IDC_VTXWINDOWS:
1024 return "JI(`',`translation.linedraw')";
1026 case IDC_X11_FORWARD:
1027 case IDC_X11_DISPSTATIC:
1028 case IDC_X11_DISPLAY:
1029 return "JI(`',`ssh.tunnels.x11')";
1030 case IDC_X11AUTHSTATIC:
1033 return "JI(`',`ssh.tunnels.x11auth')";
1034 case IDC_PFWDSTATIC:
1035 case IDC_PFWDSTATIC2:
1036 case IDC_PFWDREMOVE:
1039 case IDC_SPORTSTATIC:
1041 case IDC_DPORTSTATIC:
1044 case IDC_PFWDREMOTE:
1045 return "JI(`',`ssh.tunnels.portfwd')";
1048 return "JI(`',`ssh.tunnels.portfwd.localhost')";
1050 case IDC_BUGS_IGNORE1:
1051 case IDC_BUGD_IGNORE1:
1052 return "JI(`',`ssh.bugs.ignore1')";
1053 case IDC_BUGS_PLAINPW1:
1054 case IDC_BUGD_PLAINPW1:
1055 return "JI(`',`ssh.bugs.plainpw1')";
1058 return "JI(`',`ssh.bugs.rsa1')";
1059 case IDC_BUGS_HMAC2:
1060 case IDC_BUGD_HMAC2:
1061 return "JI(`',`ssh.bugs.hmac2')";
1062 case IDC_BUGS_DERIVEKEY2:
1063 case IDC_BUGD_DERIVEKEY2:
1064 return "JI(`',`ssh.bugs.derivekey2')";
1065 case IDC_BUGS_RSAPAD2:
1066 case IDC_BUGD_RSAPAD2:
1067 return "JI(`',`ssh.bugs.rsapad2')";
1068 case IDC_BUGS_DHGEX2:
1069 case IDC_BUGD_DHGEX2:
1070 return "JI(`',`ssh.bugs.dhgex2')";
1071 case IDC_BUGS_PKSESSID2:
1072 case IDC_BUGD_PKSESSID2:
1073 return "JI(`',`ssh.bugs.pksessid2')";
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 == AUTO ? IDC_ECHOBACKEND :
1140 cfg.localecho == FORCE_ON ? IDC_ECHOYES : IDC_ECHONO);
1141 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
1142 cfg.localedit == AUTO ? IDC_EDITBACKEND :
1143 cfg.localedit == FORCE_ON ? 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.path);
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 == AUTO ? IDC_COENORMAL :
1196 cfg.close_on_exit ==
1197 FORCE_OFF ? 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.path);
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.path);
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 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
1312 (LPARAM) colours[i]);
1314 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
1315 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
1316 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
1317 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
1322 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
1323 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
1324 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
1325 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
1326 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
1329 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
1335 pe = printer_start_enum(&nprinters);
1336 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_RESETCONTENT, 0, 0);
1337 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1338 0, (LPARAM) PRINTER_DISABLED_STRING);
1339 for (i = 0; i < nprinters; i++) {
1340 char *printer_name = printer_get_name(pe, i);
1341 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1342 0, (LPARAM) printer_name);
1344 printer_finish_enum(pe);
1345 SetDlgItemText(hwnd, IDC_PRINTER,
1346 *cfg.printer ? cfg.printer : PRINTER_DISABLED_STRING);
1349 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
1350 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
1351 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
1352 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
1353 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
1356 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
1357 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
1358 CheckRadioButton(hwnd, IDC_X11MIT, IDC_X11XDM,
1359 cfg.x11_auth == X11_MIT ? IDC_X11MIT : IDC_X11XDM);
1361 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
1362 CheckDlgButton(hwnd, IDC_RPORT_ALL, cfg.rport_acceptall);
1363 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
1366 CheckRadioButton(hwnd, IDC_PROXYTYPENONE, IDC_PROXYTYPETELNET,
1367 cfg.proxy_type == PROXY_HTTP ? IDC_PROXYTYPEHTTP :
1368 cfg.proxy_type == PROXY_SOCKS ? IDC_PROXYTYPESOCKS :
1369 cfg.proxy_type == PROXY_TELNET ? IDC_PROXYTYPETELNET : IDC_PROXYTYPENONE);
1370 SetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host);
1371 SetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, cfg.proxy_port, FALSE);
1372 SetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT, cfg.proxy_exclude_list);
1373 CheckDlgButton(hwnd, IDC_PROXYLOCALHOST, cfg.even_proxy_localhost);
1374 CheckRadioButton(hwnd, IDC_PROXYDNSNO, IDC_PROXYDNSYES,
1375 cfg.proxy_dns == FORCE_OFF ? IDC_PROXYDNSNO :
1376 cfg.proxy_dns == FORCE_ON ? IDC_PROXYDNSYES :
1378 SetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT, cfg.proxy_telnet_command);
1379 SetDlgItemText(hwnd, IDC_PROXYUSEREDIT, cfg.proxy_username);
1380 SetDlgItemText(hwnd, IDC_PROXYPASSEDIT, cfg.proxy_password);
1381 CheckRadioButton(hwnd, IDC_PROXYSOCKSVER5, IDC_PROXYSOCKSVER4,
1382 cfg.proxy_socks_version == 4 ? IDC_PROXYSOCKSVER4 : IDC_PROXYSOCKSVER5);
1384 /* SSH bugs config */
1385 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_RESETCONTENT, 0, 0);
1386 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1387 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"Off");
1388 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"On");
1389 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_SETCURSEL,
1390 cfg.sshbug_ignore1 == FORCE_ON ? 2 :
1391 cfg.sshbug_ignore1 == FORCE_OFF ? 1 : 0, 0);
1392 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_RESETCONTENT, 0, 0);
1393 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1394 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Off");
1395 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"On");
1396 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_SETCURSEL,
1397 cfg.sshbug_plainpw1 == FORCE_ON ? 2 :
1398 cfg.sshbug_plainpw1 == FORCE_OFF ? 1 : 0, 0);
1399 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_RESETCONTENT, 0, 0);
1400 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1401 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Off");
1402 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"On");
1403 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_SETCURSEL,
1404 cfg.sshbug_rsa1 == FORCE_ON ? 2 :
1405 cfg.sshbug_rsa1 == FORCE_OFF ? 1 : 0, 0);
1406 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_RESETCONTENT, 0, 0);
1407 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1408 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Off");
1409 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"On");
1410 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_SETCURSEL,
1411 cfg.sshbug_hmac2 == FORCE_ON ? 2 :
1412 cfg.sshbug_hmac2 == FORCE_OFF ? 1 : 0, 0);
1413 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_RESETCONTENT, 0, 0);
1414 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1415 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Off");
1416 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"On");
1417 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_SETCURSEL,
1418 cfg.sshbug_derivekey2 == FORCE_ON ? 2 :
1419 cfg.sshbug_derivekey2 == FORCE_OFF ? 1 : 0, 0);
1420 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_RESETCONTENT, 0, 0);
1421 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1422 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Off");
1423 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"On");
1424 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_SETCURSEL,
1425 cfg.sshbug_rsapad2 == FORCE_ON ? 2 :
1426 cfg.sshbug_rsapad2 == FORCE_OFF ? 1 : 0, 0);
1427 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_RESETCONTENT, 0, 0);
1428 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1429 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"Off");
1430 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"On");
1431 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_SETCURSEL,
1432 cfg.sshbug_dhgex2 == FORCE_ON ? 2 :
1433 cfg.sshbug_dhgex2 == FORCE_OFF ? 1 : 0, 0);
1434 SendDlgItemMessage(hwnd, IDC_BUGD_PKSESSID2, CB_RESETCONTENT, 0, 0);
1435 SendDlgItemMessage(hwnd, IDC_BUGD_PKSESSID2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1436 SendDlgItemMessage(hwnd, IDC_BUGD_PKSESSID2, CB_ADDSTRING, 0, (LPARAM)"Off");
1437 SendDlgItemMessage(hwnd, IDC_BUGD_PKSESSID2, CB_ADDSTRING, 0, (LPARAM)"On");
1438 SendDlgItemMessage(hwnd, IDC_BUGD_PKSESSID2, CB_SETCURSEL,
1439 cfg.sshbug_pksessid2 == FORCE_ON ? 2 :
1440 cfg.sshbug_pksessid2 == FORCE_OFF ? 1 : 0, 0);
1443 struct treeview_faff {
1445 HTREEITEM lastat[4];
1448 static HTREEITEM treeview_insert(struct treeview_faff *faff,
1449 int level, char *text)
1454 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
1455 ins.hInsertAfter = faff->lastat[level];
1456 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1457 #define INSITEM DUMMYUNIONNAME.item
1459 #define INSITEM item
1461 ins.INSITEM.mask = TVIF_TEXT;
1462 ins.INSITEM.pszText = text;
1463 newitem = TreeView_InsertItem(faff->treeview, &ins);
1465 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
1467 faff->lastat[level] = newitem;
1468 for (i = level + 1; i < 4; i++)
1469 faff->lastat[i] = NULL;
1474 * Create the panelfuls of controls in the configuration box.
1476 static void create_controls(HWND hwnd, int dlgtype, int panel)
1478 if (panel == sessionpanelstart) {
1479 /* The Session panel. Accelerators used: [acgoh] nprtis elvd w */
1481 ctlposinit(&cp, hwnd, 80, 3, 13);
1482 bartitle(&cp, "Basic options for your PuTTY session",
1485 beginbox(&cp, "Specify your connection by host name or IP address",
1488 "Host &Name (or IP address)",
1489 IDC_HOSTSTATIC, IDC_HOST, 75,
1490 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
1491 if (backends[3].backend == NULL) {
1492 /* this is PuTTYtel, so only three protocols available */
1493 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
1494 "&Raw", IDC_PROTRAW,
1495 "&Telnet", IDC_PROTTELNET,
1496 "Rlog&in", IDC_PROTRLOGIN, NULL);
1498 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
1499 "&Raw", IDC_PROTRAW,
1500 "&Telnet", IDC_PROTTELNET,
1501 "Rlog&in", IDC_PROTRLOGIN,
1510 beginbox(&cp, "Load, save or delete a stored session",
1512 sesssaver(&cp, "Sav&ed Sessions",
1513 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
1514 "&Load", IDC_SESSLOAD,
1515 "Sa&ve", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
1518 beginbox(&cp, NULL, IDC_BOX_SESSION3);
1519 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
1520 "Always", IDC_COEALWAYS,
1521 "Never", IDC_COENEVER,
1522 "Only on clean exit", IDC_COENORMAL, NULL);
1526 if (panel == loggingpanelstart) {
1527 /* The Logging panel. Accelerators used: [acgoh] tplsfwe */
1529 ctlposinit(&cp, hwnd, 80, 3, 13);
1530 bartitle(&cp, "Options controlling session logging",
1532 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
1534 "Session logging:", IDC_LSTATSTATIC,
1535 "Logging &turned off completely", IDC_LSTATOFF,
1536 "Log &printable output only", IDC_LSTATASCII,
1537 "&Log all session output", IDC_LSTATRAW,
1538 "Log &SSH packet data", IDC_LSTATPACKET,
1540 editbutton(&cp, "Log &file name:",
1541 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
1543 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
1544 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
1546 "What to do if the log file already &exists:",
1547 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
1548 "Always append to the end of it", IDC_LSTATXAPN,
1549 "Ask the user every time", IDC_LSTATXASK, NULL);
1553 if (panel == terminalpanelstart) {
1554 /* The Terminal panel. Accelerators used: [acgoh] wdren lts p */
1556 ctlposinit(&cp, hwnd, 80, 3, 13);
1557 bartitle(&cp, "Options controlling the terminal emulation",
1558 IDC_TITLE_TERMINAL);
1559 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
1560 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
1561 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
1562 checkbox(&cp, "Implicit C&R in every LF", IDC_LFHASCR);
1563 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
1564 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
1566 "An&swerback to ^E:", IDC_ANSWERBACK,
1567 IDC_ANSWEREDIT, 100, NULL);
1570 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
1571 radioline(&cp, "&Local echo:", IDC_ECHOSTATIC, 3,
1572 "Auto", IDC_ECHOBACKEND,
1573 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
1574 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
1575 "Auto", IDC_EDITBACKEND,
1576 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
1579 beginbox(&cp, "Remote-controlled printing", IDC_BOX_TERMINAL3);
1580 combobox(&cp, "&Printer to send ANSI printer output to:",
1581 IDC_PRINTERSTATIC, IDC_PRINTER);
1585 if (panel == featurespanelstart) {
1586 /* The Features panel. Accelerators used: [acgoh] ukswtbrx */
1588 ctlposinit(&cp, hwnd, 80, 3, 13);
1589 bartitle(&cp, "Enabling and disabling advanced terminal features ",
1590 IDC_TITLE_FEATURES);
1591 beginbox(&cp, NULL, IDC_BOX_FEATURES1);
1592 checkbox(&cp, "Disable application c&ursor keys mode", IDC_NOAPPLICC);
1593 checkbox(&cp, "Disable application &keypad mode", IDC_NOAPPLICK);
1594 checkbox(&cp, "Disable &xterm-style mouse reporting", IDC_NOMOUSEREP);
1595 checkbox(&cp, "Disable remote-controlled terminal re&sizing",
1597 checkbox(&cp, "Disable s&witching to alternate terminal screen",
1599 checkbox(&cp, "Disable remote-controlled window &title changing",
1601 checkbox(&cp, "Disable destructive &backspace on server sending ^?",
1603 checkbox(&cp, "Disable remote-controlled cha&racter set configuration",
1608 if (panel == bellpanelstart) {
1609 /* The Bell panel. Accelerators used: [acgoh] bdsm wit */
1611 ctlposinit(&cp, hwnd, 80, 3, 13);
1612 bartitle(&cp, "Options controlling the terminal bell",
1614 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
1616 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
1617 "None (bell disabled)", IDC_BELL_DISABLED,
1618 "Play Windows Default Sound", IDC_BELL_DEFAULT,
1619 "Play a custom sound file", IDC_BELL_WAVEFILE,
1620 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
1621 editbutton(&cp, "Custom sound file to play as a bell:",
1622 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
1623 "Bro&wse...", IDC_BELL_WAVEBROWSE);
1624 radioline(&cp, "Taskbar/caption &indication on bell:",
1625 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
1626 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
1629 beginbox(&cp, "Control the bell overload behaviour",
1631 checkbox(&cp, "Bell is temporarily &disabled when over-used",
1633 staticedit(&cp, "Over-use means this &many bells...",
1634 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
1635 staticedit(&cp, "... in &this many seconds",
1636 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
1638 "The bell is re-enabled after a few seconds of silence.",
1639 1, IDC_BELLOVLEXPLAIN);
1640 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1645 if (panel == keyboardpanelstart) {
1646 /* The Keyboard panel. Accelerators used: [acgoh] bef rntd */
1648 ctlposinit(&cp, hwnd, 80, 3, 13);
1649 bartitle(&cp, "Options controlling the effects of keys",
1650 IDC_TITLE_KEYBOARD);
1651 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1652 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1653 "Control-H", IDC_DEL008,
1654 "Control-? (127)", IDC_DEL127, NULL);
1655 radioline(&cp, "The Home and &End keys", IDC_HOMESTATIC, 2,
1656 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1657 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1658 "ESC[n~", IDC_FUNCTILDE,
1659 "Linux", IDC_FUNCLINUX,
1660 "Xterm R6", IDC_FUNCXTERM,
1661 "VT400", IDC_FUNCVT400,
1662 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1664 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1665 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1666 "Normal", IDC_CURNORMAL,
1667 "Application", IDC_CURAPPLIC, NULL);
1668 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1669 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1670 "NetHack", IDC_KPNH, NULL);
1672 beginbox(&cp, "Enable extra keyboard features:",
1674 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1675 checkbox(&cp, "Control-Alt is &different from AltGr",
1680 if (panel == windowpanelstart) {
1681 /* The Window panel. Accelerators used: [acgoh] rmz sdikp */
1683 ctlposinit(&cp, hwnd, 80, 3, 13);
1684 bartitle(&cp, "Options controlling PuTTY's window",
1686 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1688 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1689 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
1690 radiobig(&cp, "When window is resi&zed:", IDC_RESIZESTATIC,
1691 "Change the number of rows and columns", IDC_RESIZETERM,
1692 "Change the size of the font", IDC_RESIZEFONT,
1693 "Change font size only when maximised", IDC_RESIZEEITHER,
1694 "Forbid resizing completely", IDC_RESIZENONE, NULL);
1696 beginbox(&cp, "Control the scrollback in the window",
1698 staticedit(&cp, "Lines of &scrollback",
1699 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1700 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
1701 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
1702 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1703 checkbox(&cp, "Reset scrollback on dis&play activity",
1708 if (panel == appearancepanelstart) {
1709 /* The Appearance panel. Accelerators used: [acgoh] luvb n ti p s */
1711 ctlposinit(&cp, hwnd, 80, 3, 13);
1712 bartitle(&cp, "Configure the appearance of PuTTY's window",
1713 IDC_TITLE_APPEARANCE);
1714 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1715 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1716 "B&lock", IDC_CURBLOCK,
1717 "&Underline", IDC_CURUNDER,
1718 "&Vertical line", IDC_CURVERT, NULL);
1719 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1721 beginbox(&cp, "Set the font used in the terminal window",
1722 IDC_BOX_APPEARANCE2);
1723 staticbtn(&cp, "", IDC_FONTSTATIC, "Cha&nge...", IDC_CHOOSEFONT);
1725 beginbox(&cp, "Adjust the use of the window title",
1726 IDC_BOX_APPEARANCE3);
1728 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1729 checkbox(&cp, "Separate window and &icon titles", IDC_WINNAME);
1731 beginbox(&cp, "Adjust the use of the mouse pointer",
1732 IDC_BOX_APPEARANCE4);
1733 checkbox(&cp, "Hide mouse &pointer when typing in window",
1736 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1737 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1739 staticedit(&cp, "Gap between text and window edge",
1740 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
1744 if (panel == behaviourpanelstart) {
1745 /* The Behaviour panel. Accelerators used: [acgoh] w4yltf */
1747 ctlposinit(&cp, hwnd, 80, 3, 13);
1748 bartitle(&cp, "Configure the behaviour of PuTTY's window",
1750 beginbox(&cp, NULL, IDC_BOX_BEHAVIOUR1);
1751 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1752 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1753 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1754 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
1755 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1756 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1760 if (panel == translationpanelstart) {
1761 /* The Translation panel. Accelerators used: [acgoh] rxbepus */
1763 ctlposinit(&cp, hwnd, 80, 3, 13);
1764 bartitle(&cp, "Options controlling character set translation",
1765 IDC_TITLE_TRANSLATION);
1766 beginbox(&cp, "Character set translation on received data",
1767 IDC_BOX_TRANSLATION1);
1768 combobox(&cp, "&Received data assumed to be in which character set:",
1769 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1771 beginbox(&cp, "Enable character set translation on input data",
1772 IDC_BOX_TRANSLATION2);
1773 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
1776 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
1777 IDC_BOX_TRANSLATION3);
1779 "Handling of line drawing characters:", IDC_VTSTATIC,
1780 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1781 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1782 "Use font in O&EM mode only", IDC_VTOEMONLY,
1783 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1784 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
1788 if (panel == selectionpanelstart) {
1789 /* The Selection panel. Accelerators used: [acgoh] df wxp est nr */
1791 ctlposinit(&cp, hwnd, 80, 3, 13);
1792 bartitle(&cp, "Options controlling copy and paste",
1793 IDC_TITLE_SELECTION);
1794 beginbox(&cp, "Translation of pasted characters",
1795 IDC_BOX_SELECTION1);
1797 "&Don't translate line drawing chars into +, - and |",
1800 "Paste to clipboard in RT&F as well as plain text",
1803 beginbox(&cp, "Control which mouse button does which thing",
1804 IDC_BOX_SELECTION2);
1805 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1806 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1807 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1810 "Shift overrides a&pplication's use of mouse",
1813 "Default selection mode (Alt+drag does the other one):",
1814 IDC_SELTYPESTATIC, 2,
1815 "&Normal", IDC_SELTYPELEX,
1816 "&Rectangular block", IDC_SELTYPERECT, NULL);
1818 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1819 IDC_BOX_SELECTION3);
1820 charclass(&cp, "Charact&er classes:", IDC_CCSTATIC, IDC_CCLIST,
1821 "&Set", IDC_CCSET, IDC_CCEDIT,
1822 "&to class", IDC_CCSTATIC2);
1826 if (panel == colourspanelstart) {
1827 /* The Colours panel. Accelerators used: [acgoh] blum */
1829 ctlposinit(&cp, hwnd, 80, 3, 13);
1830 bartitle(&cp, "Options controlling use of colours",
1832 beginbox(&cp, "General options for colour usage",
1834 checkbox(&cp, "&Bolded text is a different colour",
1836 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1838 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1840 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1841 IDC_COLOURSTATIC, IDC_COLOURLIST,
1842 "&Modify...", IDC_CHANGE,
1843 "Red:", IDC_RSTATIC, IDC_RVALUE,
1844 "Green:", IDC_GSTATIC, IDC_GVALUE,
1845 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1849 if (panel == connectionpanelstart) {
1850 /* The Connection panel. Accelerators used: [acgoh] tukn */
1852 ctlposinit(&cp, hwnd, 80, 3, 13);
1853 bartitle(&cp, "Options controlling the connection",
1854 IDC_TITLE_CONNECTION);
1856 beginbox(&cp, "Data to send to the server",
1857 IDC_BOX_CONNECTION1);
1858 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1860 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1864 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1865 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1867 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1871 beginbox(&cp, "Sending of null packets to keep session active",
1872 IDC_BOX_CONNECTION2);
1873 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1874 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1877 beginbox(&cp, "Low-level TCP connection options",
1878 IDC_BOX_CONNECTION3);
1879 checkbox(&cp, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1885 if (panel == proxypanelstart) {
1886 /* The Proxy panel. Accelerators used: [acgoh] ntslypeuwmvxd */
1888 ctlposinit(&cp, hwnd, 80, 3, 13);
1890 bartitle(&cp, "Options controlling proxy usage",
1892 beginbox(&cp, "Proxy basics", IDC_BOX_PROXY1);
1893 radioline(&cp, "Proxy type:", IDC_PROXYTYPESTATIC, 4,
1894 "&None", IDC_PROXYTYPENONE,
1895 "H&TTP", IDC_PROXYTYPEHTTP,
1896 "&SOCKS", IDC_PROXYTYPESOCKS,
1897 "Te&lnet", IDC_PROXYTYPETELNET, NULL);
1899 "Prox&y Host", IDC_PROXYHOSTSTATIC, IDC_PROXYHOSTEDIT, 80,
1900 "&Port", IDC_PROXYPORTSTATIC, IDC_PROXYPORTEDIT, 20, NULL);
1902 "&Exclude Hosts/IPs", IDC_PROXYEXCLUDESTATIC,
1903 IDC_PROXYEXCLUDEEDIT, 100, NULL);
1904 checkbox(&cp, "Consider pro&xying local host connections",
1905 IDC_PROXYLOCALHOST);
1906 radioline(&cp, "Do &DNS name lookup at proxy end:",
1907 IDC_PROXYDNSSTATIC, 3,
1908 "No", IDC_PROXYDNSNO,
1909 "Auto", IDC_PROXYDNSAUTO,
1910 "Yes", IDC_PROXYDNSYES, NULL);
1911 staticedit(&cp, "&Username", IDC_PROXYUSERSTATIC,
1912 IDC_PROXYUSEREDIT, 60);
1913 staticpassedit(&cp, "Pass&word", IDC_PROXYPASSSTATIC,
1914 IDC_PROXYPASSEDIT, 60);
1916 beginbox(&cp, "Misc. proxy settings", IDC_BOX_PROXY2);
1918 "Telnet co&mmand", IDC_PROXYTELNETCMDSTATIC,
1919 IDC_PROXYTELNETCMDEDIT, 100, NULL);
1920 radioline(&cp, "SOCKS &Version", IDC_PROXYSOCKSVERSTATIC,
1921 2, "Version 5", IDC_PROXYSOCKSVER5, "Version 4",
1922 IDC_PROXYSOCKSVER4, NULL);
1927 if (panel == telnetpanelstart) {
1928 /* The Telnet panel. Accelerators used: [acgoh] svldr bftk */
1930 ctlposinit(&cp, hwnd, 80, 3, 13);
1932 bartitle(&cp, "Options controlling Telnet connections",
1934 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1935 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1937 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1938 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1939 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1940 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1942 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1943 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1944 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1945 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1946 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1947 "Passive", IDC_TPASSIVE, "Active",
1949 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1951 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1957 if (panel == rloginpanelstart) {
1958 /* The Rlogin panel. Accelerators used: [acgoh] sl */
1960 ctlposinit(&cp, hwnd, 80, 3, 13);
1962 bartitle(&cp, "Options controlling Rlogin connections",
1964 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1965 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1967 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1968 IDC_RLLUSEREDIT, 50);
1973 if (panel == sshpanelstart) {
1974 /* The SSH panel. Accelerators used: [acgoh] r pel12n sud i */
1976 ctlposinit(&cp, hwnd, 80, 3, 13);
1978 bartitle(&cp, "Options controlling SSH connections",
1980 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1982 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1985 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
1986 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1987 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1988 radioline(&cp, "Preferred SSH protocol version:",
1989 IDC_SSHPROTSTATIC, 4,
1990 "1 on&ly", IDC_SSHPROT1ONLY,
1991 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2,
1992 "2 o&nly", IDC_SSHPROT2ONLY, NULL);
1994 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1995 /* Adds accelerators: ud */
1996 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1997 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1999 checkbox(&cp, "Enable non-standard use of s&ingle-DES in SSH 2",
2005 if (panel == sshauthpanelstart) {
2006 /* The SSH authentication panel. Accelerators used: [acgoh] m fkiuw */
2008 ctlposinit(&cp, hwnd, 80, 3, 13);
2010 bartitle(&cp, "Options controlling SSH authentication",
2012 beginbox(&cp, "Authentication methods",
2014 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
2016 checkbox(&cp, "Attempt \"keyboard-&interactive\" authentication"
2017 " (SSH2)", IDC_AUTHKI);
2019 beginbox(&cp, "Authentication parameters",
2021 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
2022 checkbox(&cp, "Allow attempted changes of &username in SSH2",
2024 editbutton(&cp, "Private &key file for authentication:",
2025 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
2031 if (panel == sshbugspanelstart) {
2032 /* The SSH bugs panel. Accelerators used: [acgoh] isrmepd */
2034 ctlposinit(&cp, hwnd, 80, 3, 13);
2036 bartitle(&cp, "Workarounds for SSH server bugs",
2038 beginbox(&cp, "Detection of known bugs in SSH servers",
2040 staticddl(&cp, "Chokes on SSH1 &ignore messages",
2041 IDC_BUGS_IGNORE1, IDC_BUGD_IGNORE1, 20);
2042 staticddl(&cp, "Refuses all SSH1 pa&ssword camouflage",
2043 IDC_BUGS_PLAINPW1, IDC_BUGD_PLAINPW1, 20);
2044 staticddl(&cp, "Chokes on SSH1 &RSA authentication",
2045 IDC_BUGS_RSA1, IDC_BUGD_RSA1, 20);
2046 staticddl(&cp, "Miscomputes SSH2 H&MAC keys",
2047 IDC_BUGS_HMAC2, IDC_BUGD_HMAC2, 20);
2048 staticddl(&cp, "Miscomputes SSH2 &encryption keys",
2049 IDC_BUGS_DERIVEKEY2, IDC_BUGD_DERIVEKEY2, 20);
2050 staticddl(&cp, "Requires &padding on SSH2 RSA signatures",
2051 IDC_BUGS_RSAPAD2, IDC_BUGD_RSAPAD2, 20);
2052 staticddl(&cp, "Chokes on &Diffie-Hellman group exchange",
2053 IDC_BUGS_DHGEX2, IDC_BUGD_DHGEX2, 20);
2054 staticddl(&cp, "Misuses the sessio&n ID in PK auth",
2055 IDC_BUGS_PKSESSID2, IDC_BUGD_PKSESSID2, 20);
2060 if (panel == tunnelspanelstart) {
2061 /* The Tunnels panel. Accelerators used: [acgoh] exu tprsdilm */
2063 ctlposinit(&cp, hwnd, 80, 3, 13);
2065 bartitle(&cp, "Options controlling SSH tunnelling",
2067 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
2068 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
2069 staticedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
2070 IDC_X11_DISPLAY, 50);
2071 radioline(&cp, "Remote X11 a&uthentication protocol",
2072 IDC_X11AUTHSTATIC, 2,
2073 "MIT-Magic-Cookie-1", IDC_X11MIT,
2074 "XDM-Authorization-1", IDC_X11XDM, NULL);
2076 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
2077 checkbox(&cp, "Local ports accept connections from o&ther hosts",
2079 checkbox(&cp, "Remote &ports do the same (SSH v2 only)",
2081 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
2082 "&Remove", IDC_PFWDREMOVE);
2083 fwdsetter(&cp, IDC_PFWDLIST,
2084 "Add new forwarded port:", IDC_PFWDSTATIC2,
2085 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
2086 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
2087 "A&dd", IDC_PFWDADD,
2088 "&Local", IDC_PFWDLOCAL,
2089 "Re&mote", IDC_PFWDREMOTE);
2097 * Helper function to load the session selected in SESSLIST
2098 * if any, as this is done in more than one place in
2099 * GenericMainDlgProc(). 0 => failure.
2101 static int load_selected_session(HWND hwnd)
2103 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2104 LB_GETCURSEL, 0, 0);
2110 isdef = !strcmp(sesslist.sessions[n], "Default Settings");
2111 load_settings(sesslist.sessions[n], !isdef, &cfg);
2112 init_dlg_ctrls(hwnd, TRUE);
2114 SetDlgItemText(hwnd, IDC_SESSEDIT, sesslist.sessions[n]);
2116 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
2117 /* Restore the selection, which will have been clobbered by
2118 * SESSEDIT handling. */
2119 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
2124 * This function is the configuration box.
2126 static int GenericMainDlgProc(HWND hwnd, UINT msg,
2127 WPARAM wParam, LPARAM lParam, int dlgtype)
2130 struct treeview_faff tvfaff;
2133 char filename[sizeof(cfg.keyfile.path)];
2136 char fontstatic[256];
2138 struct servent *service;
2140 static UINT draglistmsg = WM_NULL;
2145 SetWindowLong(hwnd, GWL_USERDATA, 0);
2147 SetWindowLong(hwnd, GWL_EXSTYLE,
2148 GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
2150 HWND item = GetDlgItem(hwnd, IDC_HELPBTN);
2152 DestroyWindow(item);
2154 requested_help = FALSE;
2155 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
2156 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
2158 * Centre the window.
2160 { /* centre the window */
2163 hw = GetDesktopWindow();
2164 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
2166 (rs.right + rs.left + rd.left - rd.right) / 2,
2167 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
2168 rd.right - rd.left, rd.bottom - rd.top, TRUE);
2172 * Create the tree view.
2180 r.right = r.left + 75;
2182 r.bottom = r.top + 10;
2183 MapDialogRect(hwnd, &r);
2184 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
2185 WS_CHILD | WS_VISIBLE,
2187 r.right - r.left, r.bottom - r.top,
2188 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
2190 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
2191 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2194 r.right = r.left + 75;
2196 r.bottom = r.top + 219;
2197 MapDialogRect(hwnd, &r);
2198 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
2199 WS_CHILD | WS_VISIBLE |
2200 WS_TABSTOP | TVS_HASLINES |
2201 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
2203 TVS_SHOWSELALWAYS, r.left, r.top,
2204 r.right - r.left, r.bottom - r.top,
2205 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
2207 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
2208 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2209 tvfaff.treeview = treeview;
2210 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
2214 * Set up the tree view contents.
2216 hsession = treeview_insert(&tvfaff, 0, "Session");
2217 treeview_insert(&tvfaff, 1, "Logging");
2218 treeview_insert(&tvfaff, 0, "Terminal");
2219 treeview_insert(&tvfaff, 1, "Keyboard");
2220 treeview_insert(&tvfaff, 1, "Bell");
2221 treeview_insert(&tvfaff, 1, "Features");
2222 treeview_insert(&tvfaff, 0, "Window");
2223 treeview_insert(&tvfaff, 1, "Appearance");
2224 treeview_insert(&tvfaff, 1, "Behaviour");
2225 treeview_insert(&tvfaff, 1, "Translation");
2226 treeview_insert(&tvfaff, 1, "Selection");
2227 treeview_insert(&tvfaff, 1, "Colours");
2228 treeview_insert(&tvfaff, 0, "Connection");
2230 treeview_insert(&tvfaff, 1, "Proxy");
2231 treeview_insert(&tvfaff, 1, "Telnet");
2232 treeview_insert(&tvfaff, 1, "Rlogin");
2233 if (backends[3].backend != NULL) {
2234 treeview_insert(&tvfaff, 1, "SSH");
2235 /* XXX long name is ugly */
2236 /* XXX make it closed by default? */
2237 treeview_insert(&tvfaff, 2, "Auth");
2238 treeview_insert(&tvfaff, 2, "Tunnels");
2239 treeview_insert(&tvfaff, 2, "Bugs");
2244 * Put the treeview selection on to the Session panel. This
2245 * should also cause creation of the relevant controls.
2247 TreeView_SelectItem(treeview, hsession);
2250 * Set focus into the first available control.
2254 ctl = GetDlgItem(hwnd, IDC_HOST);
2256 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
2260 SetWindowLong(hwnd, GWL_USERDATA, 1);
2261 sesslist_has_focus = 0;
2265 * Button release should trigger WM_OK if there was a
2266 * previous double click on the session list.
2270 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
2273 if (LOWORD(wParam) == IDCX_TREEVIEW &&
2274 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
2276 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
2281 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
2284 item.pszText = buffer;
2285 item.cchTextMax = sizeof(buffer);
2286 item.mask = TVIF_TEXT;
2287 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
2288 for (j = controlstartvalue; j < controlendvalue; j++) {
2289 HWND item = GetDlgItem(hwnd, j);
2291 DestroyWindow(item);
2293 if (!strcmp(buffer, "Session"))
2294 create_controls(hwnd, dlgtype, sessionpanelstart);
2295 if (!strcmp(buffer, "Logging"))
2296 create_controls(hwnd, dlgtype, loggingpanelstart);
2297 if (!strcmp(buffer, "Keyboard"))
2298 create_controls(hwnd, dlgtype, keyboardpanelstart);
2299 if (!strcmp(buffer, "Terminal"))
2300 create_controls(hwnd, dlgtype, terminalpanelstart);
2301 if (!strcmp(buffer, "Bell"))
2302 create_controls(hwnd, dlgtype, bellpanelstart);
2303 if (!strcmp(buffer, "Features"))
2304 create_controls(hwnd, dlgtype, featurespanelstart);
2305 if (!strcmp(buffer, "Window"))
2306 create_controls(hwnd, dlgtype, windowpanelstart);
2307 if (!strcmp(buffer, "Appearance"))
2308 create_controls(hwnd, dlgtype, appearancepanelstart);
2309 if (!strcmp(buffer, "Behaviour"))
2310 create_controls(hwnd, dlgtype, behaviourpanelstart);
2311 if (!strcmp(buffer, "Tunnels"))
2312 create_controls(hwnd, dlgtype, tunnelspanelstart);
2313 if (!strcmp(buffer, "Connection"))
2314 create_controls(hwnd, dlgtype, connectionpanelstart);
2315 if (!strcmp(buffer, "Proxy"))
2316 create_controls(hwnd, dlgtype, proxypanelstart);
2317 if (!strcmp(buffer, "Telnet"))
2318 create_controls(hwnd, dlgtype, telnetpanelstart);
2319 if (!strcmp(buffer, "Rlogin"))
2320 create_controls(hwnd, dlgtype, rloginpanelstart);
2321 if (!strcmp(buffer, "SSH"))
2322 create_controls(hwnd, dlgtype, sshpanelstart);
2323 if (!strcmp(buffer, "Auth"))
2324 create_controls(hwnd, dlgtype, sshauthpanelstart);
2325 if (!strcmp(buffer, "Bugs"))
2326 create_controls(hwnd, dlgtype, sshbugspanelstart);
2327 if (!strcmp(buffer, "Selection"))
2328 create_controls(hwnd, dlgtype, selectionpanelstart);
2329 if (!strcmp(buffer, "Colours"))
2330 create_controls(hwnd, dlgtype, colourspanelstart);
2331 if (!strcmp(buffer, "Translation"))
2332 create_controls(hwnd, dlgtype, translationpanelstart);
2334 init_dlg_ctrls(hwnd, FALSE);
2336 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
2337 InvalidateRect (hwnd, NULL, TRUE);
2339 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
2345 * Only process WM_COMMAND once the dialog is fully formed.
2347 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
2348 switch (LOWORD(wParam)) {
2350 /* Behaviour of the "Open" button is different if the
2351 * session list has focus, *unless* the user just
2352 * double-clicked... */
2353 if (sesslist_has_focus && !readytogo) {
2354 if (!load_selected_session(hwnd)) {
2359 /* If at this point we have a valid session, go! */
2361 if (requested_help) {
2362 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2363 requested_help = FALSE;
2370 if (HIWORD(wParam) == BN_CLICKED ||
2371 HIWORD(wParam) == BN_DOUBLECLICKED) {
2373 WinHelp(hwnd, help_path,
2374 help_has_contents ? HELP_FINDER : HELP_CONTENTS,
2376 requested_help = TRUE;
2381 if (requested_help) {
2382 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2383 requested_help = FALSE;
2387 case IDC_PROTTELNET:
2388 case IDC_PROTRLOGIN:
2391 if (HIWORD(wParam) == BN_CLICKED ||
2392 HIWORD(wParam) == BN_DOUBLECLICKED) {
2393 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
2394 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
2395 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
2397 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
2400 * When switching using the arrow keys, we
2401 * appear to get two of these messages, both
2402 * mentioning the target button in
2403 * LOWORD(wParam), but one of them called while
2404 * the previous button is still checked. This
2405 * causes an unnecessary reset of the port
2406 * number field, which we fix by ensuring here
2407 * that the button selected is indeed the one
2410 if (IsDlgButtonChecked(hwnd, LOWORD(wParam)) &&
2411 ((cfg.protocol == PROT_SSH && cfg.port != 22)
2412 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
2413 || (cfg.protocol == PROT_RLOGIN
2414 && cfg.port != 513))) {
2415 cfg.port = i ? 22 : j ? 23 : 513;
2416 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
2421 if (HIWORD(wParam) == EN_CHANGE)
2422 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
2423 sizeof(cfg.host) - 1);
2426 if (HIWORD(wParam) == EN_CHANGE) {
2427 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
2428 if (isdigit(portname[0]))
2429 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
2431 service = getservbyname(portname, NULL);
2433 cfg.port = ntohs(service->s_port);
2440 if (HIWORD(wParam) == EN_CHANGE) {
2441 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2443 GetDlgItemText(hwnd, IDC_SESSEDIT,
2444 savedsession, sizeof(savedsession) - 1);
2445 savedsession[sizeof(savedsession) - 1] = '\0';
2449 if (HIWORD(wParam) == BN_CLICKED ||
2450 HIWORD(wParam) == BN_DOUBLECLICKED) {
2455 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
2458 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2459 LB_GETCURSEL, 0, 0);
2464 strcpy(str, sesslist.sessions[n]);
2466 save_settings(str, !!strcmp(str, "Default Settings"),
2468 get_sesslist(&sesslist, FALSE);
2469 get_sesslist(&sesslist, TRUE);
2470 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2472 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2474 for (i = 0; i < sesslist.nsessions; i++)
2475 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2477 (LPARAM) (sesslist.sessions[i]));
2478 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2480 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2482 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2488 if (LOWORD(wParam) == IDC_SESSLIST) {
2489 if (HIWORD(wParam) == LBN_SETFOCUS)
2490 sesslist_has_focus = 1;
2491 else if (HIWORD(wParam) == LBN_KILLFOCUS)
2492 sesslist_has_focus = 0;
2494 if (LOWORD(wParam) == IDC_SESSLOAD &&
2495 HIWORD(wParam) != BN_CLICKED &&
2496 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2497 if (LOWORD(wParam) == IDC_SESSLIST &&
2498 HIWORD(wParam) != LBN_DBLCLK) break;
2499 /* Load the session selected in SESSLIST. */
2500 if (load_selected_session(hwnd) &&
2501 LOWORD(wParam) == IDC_SESSLIST) {
2503 * A double-click on a saved session should
2504 * actually start the session, not just load it.
2505 * Unless it's Default Settings or some other
2506 * host-less set of saved settings.
2515 if (HIWORD(wParam) == BN_CLICKED ||
2516 HIWORD(wParam) == BN_DOUBLECLICKED) {
2517 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2518 LB_GETCURSEL, 0, 0);
2519 if (n == LB_ERR || n == 0) {
2523 del_settings(sesslist.sessions[n]);
2524 get_sesslist(&sesslist, FALSE);
2525 get_sesslist(&sesslist, TRUE);
2526 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2528 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2530 for (i = 0; i < sesslist.nsessions; i++)
2531 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2533 (LPARAM) (sesslist.sessions[i]));
2534 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2536 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2538 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2542 if (HIWORD(wParam) == EN_CHANGE)
2543 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
2544 &cfg.ping_interval);
2547 if (HIWORD(wParam) == BN_CLICKED ||
2548 HIWORD(wParam) == BN_DOUBLECLICKED)
2550 IsDlgButtonChecked(hwnd, IDC_NODELAY);
2554 if (HIWORD(wParam) == BN_CLICKED ||
2555 HIWORD(wParam) == BN_DOUBLECLICKED)
2556 cfg.bksp_is_delete =
2557 IsDlgButtonChecked(hwnd, IDC_DEL127);
2561 if (HIWORD(wParam) == BN_CLICKED ||
2562 HIWORD(wParam) == BN_DOUBLECLICKED)
2564 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
2570 case IDC_FUNCVT100P:
2572 if (HIWORD(wParam) == BN_CLICKED ||
2573 HIWORD(wParam) == BN_DOUBLECLICKED)
2574 switch (LOWORD(wParam)) {
2587 case IDC_FUNCVT100P:
2597 if (HIWORD(wParam) == BN_CLICKED ||
2598 HIWORD(wParam) == BN_DOUBLECLICKED) {
2600 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
2601 cfg.nethack_keypad = FALSE;
2605 if (HIWORD(wParam) == BN_CLICKED ||
2606 HIWORD(wParam) == BN_DOUBLECLICKED) {
2607 cfg.app_keypad = FALSE;
2608 cfg.nethack_keypad = TRUE;
2613 if (HIWORD(wParam) == BN_CLICKED ||
2614 HIWORD(wParam) == BN_DOUBLECLICKED)
2616 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
2619 if (HIWORD(wParam) == BN_CLICKED ||
2620 HIWORD(wParam) == BN_DOUBLECLICKED)
2622 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
2625 if (HIWORD(wParam) == BN_CLICKED ||
2626 HIWORD(wParam) == BN_DOUBLECLICKED)
2628 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
2630 case IDC_NOMOUSEREP:
2631 if (HIWORD(wParam) == BN_CLICKED ||
2632 HIWORD(wParam) == BN_DOUBLECLICKED)
2634 IsDlgButtonChecked(hwnd, IDC_NOMOUSEREP);
2637 if (HIWORD(wParam) == BN_CLICKED ||
2638 HIWORD(wParam) == BN_DOUBLECLICKED)
2639 cfg.no_remote_resize =
2640 IsDlgButtonChecked(hwnd, IDC_NORESIZE);
2642 case IDC_NOALTSCREEN:
2643 if (HIWORD(wParam) == BN_CLICKED ||
2644 HIWORD(wParam) == BN_DOUBLECLICKED)
2646 IsDlgButtonChecked(hwnd, IDC_NOALTSCREEN);
2648 case IDC_NOWINTITLE:
2649 if (HIWORD(wParam) == BN_CLICKED ||
2650 HIWORD(wParam) == BN_DOUBLECLICKED)
2651 cfg.no_remote_wintitle =
2652 IsDlgButtonChecked(hwnd, IDC_NOWINTITLE);
2654 case IDC_NODBACKSPACE:
2655 if (HIWORD(wParam) == BN_CLICKED ||
2656 HIWORD(wParam) == BN_DOUBLECLICKED)
2658 IsDlgButtonChecked(hwnd, IDC_NODBACKSPACE);
2661 if (HIWORD(wParam) == BN_CLICKED ||
2662 HIWORD(wParam) == BN_DOUBLECLICKED)
2663 cfg.no_remote_charset =
2664 IsDlgButtonChecked(hwnd, IDC_NOCHARSET);
2667 if (HIWORD(wParam) == BN_CLICKED ||
2668 HIWORD(wParam) == BN_DOUBLECLICKED)
2669 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
2672 if (HIWORD(wParam) == BN_CLICKED ||
2673 HIWORD(wParam) == BN_DOUBLECLICKED)
2675 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
2678 if (HIWORD(wParam) == BN_CLICKED ||
2679 HIWORD(wParam) == BN_DOUBLECLICKED)
2681 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
2683 case IDC_ECHOBACKEND:
2686 if (HIWORD(wParam) == BN_CLICKED ||
2687 HIWORD(wParam) == BN_DOUBLECLICKED) {
2688 if (LOWORD(wParam) == IDC_ECHOBACKEND)
2689 cfg.localecho = AUTO;
2690 if (LOWORD(wParam) == IDC_ECHOYES)
2691 cfg.localecho = FORCE_ON;
2692 if (LOWORD(wParam) == IDC_ECHONO)
2693 cfg.localecho = FORCE_OFF;
2696 case IDC_EDITBACKEND:
2699 if (HIWORD(wParam) == BN_CLICKED ||
2700 HIWORD(wParam) == BN_DOUBLECLICKED) {
2701 if (LOWORD(wParam) == IDC_EDITBACKEND)
2702 cfg.localedit = AUTO;
2703 if (LOWORD(wParam) == IDC_EDITYES)
2704 cfg.localedit = FORCE_ON;
2705 if (LOWORD(wParam) == IDC_EDITNO)
2706 cfg.localedit = FORCE_OFF;
2709 case IDC_ANSWEREDIT:
2710 if (HIWORD(wParam) == EN_CHANGE)
2711 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
2712 sizeof(cfg.answerback) - 1);
2714 case IDC_ALWAYSONTOP:
2715 if (HIWORD(wParam) == BN_CLICKED ||
2716 HIWORD(wParam) == BN_DOUBLECLICKED)
2718 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
2720 case IDC_FULLSCREENONALTENTER:
2721 if (HIWORD(wParam) == BN_CLICKED ||
2722 HIWORD(wParam) == BN_DOUBLECLICKED)
2723 cfg.fullscreenonaltenter =
2724 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
2727 if (HIWORD(wParam) == BN_CLICKED ||
2728 HIWORD(wParam) == BN_DOUBLECLICKED)
2730 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
2732 case IDC_SCROLLDISP:
2733 if (HIWORD(wParam) == BN_CLICKED ||
2734 HIWORD(wParam) == BN_DOUBLECLICKED)
2735 cfg.scroll_on_disp =
2736 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
2738 case IDC_COMPOSEKEY:
2739 if (HIWORD(wParam) == BN_CLICKED ||
2740 HIWORD(wParam) == BN_DOUBLECLICKED)
2742 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
2744 case IDC_CTRLALTKEYS:
2745 if (HIWORD(wParam) == BN_CLICKED ||
2746 HIWORD(wParam) == BN_DOUBLECLICKED)
2748 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
2751 if (HIWORD(wParam) == BN_CLICKED ||
2752 HIWORD(wParam) == BN_DOUBLECLICKED)
2753 cfg.telnet_keyboard =
2754 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
2757 if (HIWORD(wParam) == BN_CLICKED ||
2758 HIWORD(wParam) == BN_DOUBLECLICKED)
2759 cfg.telnet_newline =
2760 IsDlgButtonChecked(hwnd, IDC_TELNETRET);
2763 if (HIWORD(wParam) == BN_CLICKED ||
2764 HIWORD(wParam) == BN_DOUBLECLICKED)
2766 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
2769 if (HIWORD(wParam) == BN_CLICKED ||
2770 HIWORD(wParam) == BN_DOUBLECLICKED)
2771 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
2774 if (HIWORD(wParam) == BN_CLICKED ||
2775 HIWORD(wParam) == BN_DOUBLECLICKED)
2777 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
2780 if (HIWORD(wParam) == EN_CHANGE)
2781 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
2784 if (HIWORD(wParam) == EN_CHANGE)
2785 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
2788 if (HIWORD(wParam) == EN_CHANGE)
2789 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
2791 case IDC_CHOOSEFONT:
2794 lf.lfHeight = -MulDiv(cfg.font.height,
2795 GetDeviceCaps(hdc, LOGPIXELSY),
2799 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
2800 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
2801 lf.lfWeight = (cfg.font.isbold ? FW_BOLD : 0);
2802 lf.lfCharSet = cfg.font.charset;
2803 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
2804 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
2805 lf.lfQuality = DEFAULT_QUALITY;
2806 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
2807 strncpy(lf.lfFaceName, cfg.font.name,
2808 sizeof(lf.lfFaceName) - 1);
2809 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
2811 cf.lStructSize = sizeof(cf);
2812 cf.hwndOwner = hwnd;
2814 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
2815 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
2817 if (ChooseFont(&cf)) {
2818 strncpy(cfg.font.name, lf.lfFaceName,
2819 sizeof(cfg.font.name) - 1);
2820 cfg.font.name[sizeof(cfg.font.name) - 1] = '\0';
2821 cfg.font.isbold = (lf.lfWeight == FW_BOLD);
2822 cfg.font.charset = lf.lfCharSet;
2823 cfg.font.height = cf.iPointSize / 10;
2824 fmtfont(fontstatic);
2825 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
2828 case IDC_BELL_DISABLED:
2829 case IDC_BELL_DEFAULT:
2830 case IDC_BELL_WAVEFILE:
2831 case IDC_BELL_VISUAL:
2832 if (HIWORD(wParam) == BN_CLICKED ||
2833 HIWORD(wParam) == BN_DOUBLECLICKED) {
2834 if (LOWORD(wParam) == IDC_BELL_DISABLED)
2835 cfg.beep = BELL_DISABLED;
2836 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
2837 cfg.beep = BELL_DEFAULT;
2838 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
2839 cfg.beep = BELL_WAVEFILE;
2840 if (LOWORD(wParam) == IDC_BELL_VISUAL)
2841 cfg.beep = BELL_VISUAL;
2844 case IDC_B_IND_DISABLED:
2845 case IDC_B_IND_FLASH:
2846 case IDC_B_IND_STEADY:
2847 if (HIWORD(wParam) == BN_CLICKED ||
2848 HIWORD(wParam) == BN_DOUBLECLICKED) {
2849 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2850 cfg.beep_ind = B_IND_DISABLED;
2851 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2852 cfg.beep_ind = B_IND_FLASH;
2853 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2854 cfg.beep_ind = B_IND_STEADY;
2857 case IDC_BELL_WAVEBROWSE:
2858 memset(&of, 0, sizeof(of));
2859 #ifdef OPENFILENAME_SIZE_VERSION_400
2860 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2862 of.lStructSize = sizeof(of);
2864 of.hwndOwner = hwnd;
2865 of.lpstrFilter = "Wave Files (*.wav)\0*.WAV\0"
2866 "All Files (*.*)\0*\0\0\0";
2867 of.lpstrCustomFilter = NULL;
2868 of.nFilterIndex = 1;
2869 of.lpstrFile = filename;
2870 strcpy(filename, cfg.bell_wavefile.path);
2871 of.nMaxFile = sizeof(filename);
2872 of.lpstrFileTitle = NULL;
2873 of.lpstrInitialDir = NULL;
2874 of.lpstrTitle = "Select Bell Sound File";
2876 if (GetOpenFileName(&of)) {
2877 strcpy(cfg.bell_wavefile.path, filename);
2878 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2879 cfg.bell_wavefile.path);
2882 case IDC_BELL_WAVEEDIT:
2883 if (HIWORD(wParam) == EN_CHANGE)
2884 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2885 cfg.bell_wavefile.path,
2886 sizeof(cfg.bell_wavefile.path) - 1);
2889 if (HIWORD(wParam) == BN_CLICKED ||
2890 HIWORD(wParam) == BN_DOUBLECLICKED)
2892 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2895 if (HIWORD(wParam) == EN_CHANGE)
2896 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2899 if (HIWORD(wParam) == EN_CHANGE)
2900 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2904 if (HIWORD(wParam) == EN_CHANGE)
2905 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2909 if (HIWORD(wParam) == BN_CLICKED ||
2910 HIWORD(wParam) == BN_DOUBLECLICKED)
2912 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2915 if (HIWORD(wParam) == BN_CLICKED ||
2916 HIWORD(wParam) == BN_DOUBLECLICKED)
2917 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2920 if (HIWORD(wParam) == BN_CLICKED ||
2921 HIWORD(wParam) == BN_DOUBLECLICKED)
2922 cfg.win_name_always =
2923 !IsDlgButtonChecked(hwnd, IDC_WINNAME);
2926 if (HIWORD(wParam) == BN_CLICKED ||
2927 HIWORD(wParam) == BN_DOUBLECLICKED)
2929 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2931 case IDC_SUNKENEDGE:
2932 if (HIWORD(wParam) == BN_CLICKED ||
2933 HIWORD(wParam) == BN_DOUBLECLICKED)
2935 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2938 if (HIWORD(wParam) == EN_CHANGE)
2939 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2940 &cfg.window_border);
2941 if (cfg.window_border > 32)
2942 cfg.window_border = 32;
2945 if (HIWORD(wParam) == BN_CLICKED ||
2946 HIWORD(wParam) == BN_DOUBLECLICKED)
2947 cfg.cursor_type = 0;
2950 if (HIWORD(wParam) == BN_CLICKED ||
2951 HIWORD(wParam) == BN_DOUBLECLICKED)
2952 cfg.cursor_type = 1;
2955 if (HIWORD(wParam) == BN_CLICKED ||
2956 HIWORD(wParam) == BN_DOUBLECLICKED)
2957 cfg.cursor_type = 2;
2960 if (HIWORD(wParam) == BN_CLICKED ||
2961 HIWORD(wParam) == BN_DOUBLECLICKED)
2963 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2966 if (HIWORD(wParam) == BN_CLICKED ||
2967 HIWORD(wParam) == BN_DOUBLECLICKED)
2969 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2971 case IDC_SCROLLBARFULLSCREEN:
2972 if (HIWORD(wParam) == BN_CLICKED ||
2973 HIWORD(wParam) == BN_DOUBLECLICKED)
2974 cfg.scrollbar_in_fullscreen =
2975 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2977 case IDC_RESIZETERM:
2978 case IDC_RESIZEFONT:
2979 case IDC_RESIZENONE:
2980 case IDC_RESIZEEITHER:
2981 if (HIWORD(wParam) == BN_CLICKED ||
2982 HIWORD(wParam) == BN_DOUBLECLICKED) {
2984 IsDlgButtonChecked(hwnd,
2985 IDC_RESIZETERM) ? RESIZE_TERM :
2986 IsDlgButtonChecked(hwnd,
2987 IDC_RESIZEFONT) ? RESIZE_FONT :
2988 IsDlgButtonChecked(hwnd,
2989 IDC_RESIZEEITHER) ? RESIZE_EITHER :
2994 if (HIWORD(wParam) == EN_CHANGE)
2995 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2996 sizeof(cfg.wintitle) - 1);
3001 if (HIWORD(wParam) == BN_CLICKED ||
3002 HIWORD(wParam) == BN_DOUBLECLICKED) {
3004 IsDlgButtonChecked(hwnd,
3005 IDC_COEALWAYS) ? FORCE_ON :
3006 IsDlgButtonChecked(hwnd,
3007 IDC_COENEVER) ? FORCE_OFF :
3012 if (HIWORD(wParam) == BN_CLICKED ||
3013 HIWORD(wParam) == BN_DOUBLECLICKED)
3015 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
3018 if (HIWORD(wParam) == EN_CHANGE)
3019 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
3020 sizeof(cfg.termtype) - 1);
3024 case IDC_PROXYHOSTEDIT:
3025 if (HIWORD(wParam) == EN_CHANGE)
3026 GetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host,
3027 sizeof(cfg.proxy_host) - 1);
3029 case IDC_PROXYPORTEDIT:
3030 if (HIWORD(wParam) == EN_CHANGE) {
3031 GetDlgItemText(hwnd, IDC_PROXYPORTEDIT, portname, 31);
3032 if (isdigit(portname[0]))
3033 MyGetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, &cfg.proxy_port);
3035 service = getservbyname(portname, NULL);
3037 cfg.proxy_port = ntohs(service->s_port);
3043 case IDC_PROXYEXCLUDEEDIT:
3044 if (HIWORD(wParam) == EN_CHANGE)
3045 GetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT,
3046 cfg.proxy_exclude_list,
3047 sizeof(cfg.proxy_exclude_list) - 1);
3049 case IDC_PROXYUSEREDIT:
3050 if (HIWORD(wParam) == EN_CHANGE)
3051 GetDlgItemText(hwnd, IDC_PROXYUSEREDIT,
3053 sizeof(cfg.proxy_username) - 1);
3055 case IDC_PROXYPASSEDIT:
3056 if (HIWORD(wParam) == EN_CHANGE)
3057 GetDlgItemText(hwnd, IDC_PROXYPASSEDIT,
3059 sizeof(cfg.proxy_password) - 1);
3061 case IDC_PROXYTELNETCMDEDIT:
3062 if (HIWORD(wParam) == EN_CHANGE)
3063 GetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT,
3064 cfg.proxy_telnet_command,
3065 sizeof(cfg.proxy_telnet_command) - 1);
3067 case IDC_PROXYSOCKSVER5:
3068 case IDC_PROXYSOCKSVER4:
3069 if (HIWORD(wParam) == BN_CLICKED ||
3070 HIWORD(wParam) == BN_DOUBLECLICKED) {
3071 cfg.proxy_socks_version =
3072 IsDlgButtonChecked(hwnd, IDC_PROXYSOCKSVER4) ? 4 : 5;
3075 case IDC_PROXYLOCALHOST:
3076 if (HIWORD(wParam) == BN_CLICKED ||
3077 HIWORD(wParam) == BN_DOUBLECLICKED)
3078 cfg.even_proxy_localhost =
3079 IsDlgButtonChecked(hwnd, IDC_PROXYLOCALHOST);
3081 case IDC_PROXYDNSNO:
3082 case IDC_PROXYDNSAUTO:
3083 case IDC_PROXYDNSYES:
3084 if (HIWORD(wParam) == BN_CLICKED ||
3085 HIWORD(wParam) == BN_DOUBLECLICKED) {
3087 IsDlgButtonChecked(hwnd, IDC_PROXYDNSNO) ? FORCE_OFF :
3088 IsDlgButtonChecked(hwnd, IDC_PROXYDNSYES) ? FORCE_ON :
3092 case IDC_PROXYTYPENONE:
3093 case IDC_PROXYTYPEHTTP:
3094 case IDC_PROXYTYPESOCKS:
3095 case IDC_PROXYTYPETELNET:
3096 if (HIWORD(wParam) == BN_CLICKED ||
3097 HIWORD(wParam) == BN_DOUBLECLICKED) {
3099 IsDlgButtonChecked(hwnd, IDC_PROXYTYPEHTTP) ? PROXY_HTTP :
3100 IsDlgButtonChecked(hwnd, IDC_PROXYTYPESOCKS) ? PROXY_SOCKS :
3101 IsDlgButtonChecked(hwnd, IDC_PROXYTYPETELNET) ? PROXY_TELNET :
3107 if (HIWORD(wParam) == EN_CHANGE)
3108 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename.path,
3109 sizeof(cfg.logfilename.path) - 1);
3112 memset(&of, 0, sizeof(of));
3113 #ifdef OPENFILENAME_SIZE_VERSION_400
3114 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3116 of.lStructSize = sizeof(of);
3118 of.hwndOwner = hwnd;
3119 of.lpstrFilter = "All Files (*.*)\0*\0\0\0";
3120 of.lpstrCustomFilter = NULL;
3121 of.nFilterIndex = 1;
3122 of.lpstrFile = filename;
3123 strcpy(filename, cfg.logfilename.path);
3124 of.nMaxFile = sizeof(filename);
3125 of.lpstrFileTitle = NULL;
3126 of.lpstrInitialDir = NULL;
3127 of.lpstrTitle = "Select session log file";
3129 if (GetSaveFileName(&of)) {
3130 strcpy(cfg.logfilename.path, filename);
3131 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename.path);
3135 case IDC_LSTATASCII:
3137 case IDC_LSTATPACKET:
3138 if (HIWORD(wParam) == BN_CLICKED ||
3139 HIWORD(wParam) == BN_DOUBLECLICKED) {
3140 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
3141 cfg.logtype = LGTYP_NONE;
3142 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
3143 cfg.logtype = LGTYP_ASCII;
3144 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
3145 cfg.logtype = LGTYP_DEBUG;
3146 if (IsDlgButtonChecked(hwnd, IDC_LSTATPACKET))
3147 cfg.logtype = LGTYP_PACKETS;
3153 if (HIWORD(wParam) == BN_CLICKED ||
3154 HIWORD(wParam) == BN_DOUBLECLICKED) {
3155 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
3156 cfg.logxfovr = LGXF_ASK;
3157 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
3158 cfg.logxfovr = LGXF_APN;
3159 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
3160 cfg.logxfovr = LGXF_OVR;
3165 if (HIWORD(wParam) == EN_CHANGE)
3166 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
3167 sizeof(cfg.termspeed) - 1);
3170 if (HIWORD(wParam) == EN_CHANGE)
3171 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
3172 sizeof(cfg.username) - 1);
3174 case IDC_RLLUSEREDIT:
3175 if (HIWORD(wParam) == EN_CHANGE)
3176 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
3178 sizeof(cfg.localusername) - 1);
3182 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
3186 cfg.passive_telnet =
3187 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
3190 if (HIWORD(wParam) == BN_CLICKED ||
3191 HIWORD(wParam) == BN_DOUBLECLICKED) {
3192 char str[sizeof(cfg.environmt)];
3194 GetDlgItemText(hwnd, IDC_VAREDIT, str,
3200 p = str + strlen(str);
3202 GetDlgItemText(hwnd, IDC_VALEDIT, p,
3203 sizeof(str) - 1 - (p - str));
3214 if ((p - cfg.environmt) + strlen(str) + 2 <
3215 sizeof(cfg.environmt)) {
3217 p[strlen(str) + 1] = '\0';
3218 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
3220 SetDlgItemText(hwnd, IDC_VAREDIT, "");
3221 SetDlgItemText(hwnd, IDC_VALEDIT, "");
3223 MessageBox(hwnd, "Environment too big",
3224 "PuTTY Error", MB_OK | MB_ICONERROR);
3229 if (HIWORD(wParam) != BN_CLICKED &&
3230 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3232 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
3239 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
3266 if (HIWORD(wParam) == BN_CLICKED ||
3267 HIWORD(wParam) == BN_DOUBLECLICKED)
3268 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
3271 if (HIWORD(wParam) == BN_CLICKED ||
3272 HIWORD(wParam) == BN_DOUBLECLICKED)
3274 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
3277 if (HIWORD(wParam) == BN_CLICKED ||
3278 HIWORD(wParam) == BN_DOUBLECLICKED)
3280 IsDlgButtonChecked(hwnd, IDC_SSH2DES);
3283 if (HIWORD(wParam) == BN_CLICKED ||
3284 HIWORD(wParam) == BN_DOUBLECLICKED)
3286 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
3288 case IDC_CHANGEUSER:
3289 if (HIWORD(wParam) == BN_CLICKED ||
3290 HIWORD(wParam) == BN_DOUBLECLICKED)
3291 cfg.change_username =
3292 IsDlgButtonChecked(hwnd, IDC_CHANGEUSER);
3294 case IDC_CIPHERLIST:
3297 handle_prefslist(&cipherlist,
3298 cfg.ssh_cipherlist, CIPHER_MAX,
3299 0, hwnd, wParam, lParam);
3301 case IDC_SSHPROT1ONLY:
3304 case IDC_SSHPROT2ONLY:
3305 if (HIWORD(wParam) == BN_CLICKED ||
3306 HIWORD(wParam) == BN_DOUBLECLICKED) {
3307 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1ONLY))
3309 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
3311 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
3313 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2ONLY))
3318 if (HIWORD(wParam) == BN_CLICKED ||
3319 HIWORD(wParam) == BN_DOUBLECLICKED)
3321 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
3324 if (HIWORD(wParam) == BN_CLICKED ||
3325 HIWORD(wParam) == BN_DOUBLECLICKED)
3327 IsDlgButtonChecked(hwnd, IDC_AUTHKI);
3330 if (HIWORD(wParam) == EN_CHANGE)
3331 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile.path,
3332 sizeof(cfg.keyfile.path) - 1);
3335 if (HIWORD(wParam) == EN_CHANGE)
3336 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
3337 sizeof(cfg.remote_cmd) - 1);
3340 memset(&of, 0, sizeof(of));
3341 #ifdef OPENFILENAME_SIZE_VERSION_400
3342 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3344 of.lStructSize = sizeof(of);
3346 of.hwndOwner = hwnd;
3347 of.lpstrFilter = "PuTTY Private Key Files (*.ppk)\0*.ppk\0"
3348 "All Files (*.*)\0*\0\0\0";
3349 of.lpstrCustomFilter = NULL;
3350 of.nFilterIndex = 1;
3351 of.lpstrFile = filename;
3352 strcpy(filename, cfg.keyfile.path);
3353 of.nMaxFile = sizeof(filename);
3354 of.lpstrFileTitle = NULL;
3355 of.lpstrInitialDir = NULL;
3356 of.lpstrTitle = "Select Private Key File";
3358 if (GetOpenFileName(&of)) {
3359 strcpy(cfg.keyfile.path, filename);
3360 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile.path);
3364 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
3367 cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
3371 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
3373 case IDC_SELTYPELEX:
3374 case IDC_SELTYPERECT:
3375 cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
3377 case IDC_MOUSEOVERRIDE:
3378 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
3384 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
3389 for (i = 0; i < 128; i++)
3390 if (SendDlgItemMessage
3391 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
3393 cfg.wordness[i] = n;
3394 SendDlgItemMessage(hwnd, IDC_CCLIST,
3395 LB_DELETESTRING, i, 0);
3396 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
3397 (i >= 0x21 && i != 0x7F) ? i : ' ',
3399 SendDlgItemMessage(hwnd, IDC_CCLIST,
3406 case IDC_BOLDCOLOUR:
3407 if (HIWORD(wParam) == BN_CLICKED ||
3408 HIWORD(wParam) == BN_DOUBLECLICKED) {
3411 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
3415 if (HIWORD(wParam) == BN_CLICKED ||
3416 HIWORD(wParam) == BN_DOUBLECLICKED)
3418 IsDlgButtonChecked(hwnd, IDC_PALETTE);
3420 case IDC_COLOURLIST:
3421 if (HIWORD(wParam) == LBN_DBLCLK ||
3422 HIWORD(wParam) == LBN_SELCHANGE) {
3424 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3427 if (!cfg.bold_colour)
3428 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3429 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3431 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3433 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3438 if (HIWORD(wParam) == BN_CLICKED ||
3439 HIWORD(wParam) == BN_DOUBLECLICKED) {
3440 static CHOOSECOLOR cc;
3441 static DWORD custom[16] = { 0 }; /* zero initialisers */
3443 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3446 if (!cfg.bold_colour)
3447 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3448 cc.lStructSize = sizeof(cc);
3449 cc.hwndOwner = hwnd;
3450 cc.hInstance = (HWND) hinst;
3451 cc.lpCustColors = custom;
3453 RGB(cfg.colours[i][0], cfg.colours[i][1],
3455 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
3456 if (ChooseColor(&cc)) {
3458 (unsigned char) (cc.rgbResult & 0xFF);
3460 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
3462 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
3463 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3465 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3467 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3473 if (HIWORD(wParam) == CBN_SELCHANGE) {
3474 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
3475 CB_GETCURSEL, 0, 0);
3476 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
3477 index, (LPARAM)cfg.line_codepage);
3478 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3479 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
3480 sizeof(cfg.line_codepage) - 1);
3481 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
3482 strcpy(cfg.line_codepage,
3483 cp_name(decode_codepage(cfg.line_codepage)));
3484 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
3488 if (HIWORD(wParam) == CBN_SELCHANGE) {
3489 int index = SendDlgItemMessage(hwnd, IDC_PRINTER,
3490 CB_GETCURSEL, 0, 0);
3491 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_GETLBTEXT,
3492 index, (LPARAM)cfg.printer);
3493 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3494 GetDlgItemText(hwnd, IDC_PRINTER, cfg.printer,
3495 sizeof(cfg.printer) - 1);
3497 if (!strcmp(cfg.printer, PRINTER_DISABLED_STRING))
3498 *cfg.printer = '\0';
3500 case IDC_CAPSLOCKCYR:
3501 if (HIWORD(wParam) == BN_CLICKED ||
3502 HIWORD(wParam) == BN_DOUBLECLICKED) {
3503 cfg.xlat_capslockcyr =
3504 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
3507 case IDC_VTXWINDOWS:
3513 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
3514 : IsDlgButtonChecked(hwnd,
3515 IDC_VTOEMANSI) ? VT_OEMANSI :
3516 IsDlgButtonChecked(hwnd,
3517 IDC_VTOEMONLY) ? VT_OEMONLY :
3518 IsDlgButtonChecked(hwnd,
3519 IDC_VTUNICODE) ? VT_UNICODE :
3522 case IDC_X11_FORWARD:
3523 if (HIWORD(wParam) == BN_CLICKED ||
3524 HIWORD(wParam) == BN_DOUBLECLICKED)
3526 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
3529 if (HIWORD(wParam) == BN_CLICKED ||
3530 HIWORD(wParam) == BN_DOUBLECLICKED)
3531 cfg.lport_acceptall =
3532 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
3535 if (HIWORD(wParam) == BN_CLICKED ||
3536 HIWORD(wParam) == BN_DOUBLECLICKED)
3537 cfg.rport_acceptall =
3538 IsDlgButtonChecked(hwnd, IDC_RPORT_ALL);
3540 case IDC_X11_DISPLAY:
3541 if (HIWORD(wParam) == EN_CHANGE)
3542 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
3543 sizeof(cfg.x11_display) - 1);
3547 if (HIWORD(wParam) == BN_CLICKED ||
3548 HIWORD(wParam) == BN_DOUBLECLICKED) {
3549 if (IsDlgButtonChecked(hwnd, IDC_X11MIT))
3550 cfg.x11_auth = X11_MIT;
3551 else if (IsDlgButtonChecked(hwnd, IDC_X11XDM))
3552 cfg.x11_auth = X11_XDM;
3556 if (HIWORD(wParam) == BN_CLICKED ||
3557 HIWORD(wParam) == BN_DOUBLECLICKED) {
3558 char str[sizeof(cfg.portfwd)];
3560 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
3564 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
3568 "You need to specify a source port number",
3569 "PuTTY Error", MB_OK | MB_ICONERROR);
3572 p = str + strlen(str);
3574 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
3575 sizeof(str) - 1 - (p - str));
3576 if (!*p || !strchr(p, ':')) {
3578 "You need to specify a destination address\n"
3579 "in the form \"host.name:port\"",
3580 "PuTTY Error", MB_OK | MB_ICONERROR);
3589 if ((p - cfg.portfwd) + strlen(str) + 2 <
3590 sizeof(cfg.portfwd)) {
3592 p[strlen(str) + 1] = '\0';
3593 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
3595 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
3596 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
3598 MessageBox(hwnd, "Too many forwardings",
3599 "PuTTY Error", MB_OK | MB_ICONERROR);
3603 case IDC_PFWDREMOVE:
3604 if (HIWORD(wParam) != BN_CLICKED &&
3605 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3606 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
3607 LB_GETCURSEL, 0, 0);
3613 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
3639 case IDC_BUGD_IGNORE1:
3640 if (HIWORD(wParam) == CBN_SELCHANGE) {
3641 int index = SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1,
3642 CB_GETCURSEL, 0, 0);
3643 cfg.sshbug_ignore1 = (index == 0 ? AUTO :
3644 index == 1 ? FORCE_OFF : FORCE_ON);
3647 case IDC_BUGD_PLAINPW1:
3648 if (HIWORD(wParam) == CBN_SELCHANGE) {
3649 int index = SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1,
3650 CB_GETCURSEL, 0, 0);
3651 cfg.sshbug_plainpw1 = (index == 0 ? AUTO :
3652 index == 1 ? FORCE_OFF : FORCE_ON);
3656 if (HIWORD(wParam) == CBN_SELCHANGE) {
3657 int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSA1,
3658 CB_GETCURSEL, 0, 0);
3659 cfg.sshbug_rsa1 = (index == 0 ? AUTO :
3660 index == 1 ? FORCE_OFF : FORCE_ON);
3663 case IDC_BUGD_HMAC2:
3664 if (HIWORD(wParam) == CBN_SELCHANGE) {
3665 int index = SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2,
3666 CB_GETCURSEL, 0, 0);
3667 cfg.sshbug_hmac2 = (index == 0 ? AUTO :
3668 index == 1 ? FORCE_OFF : FORCE_ON);
3671 case IDC_BUGD_DERIVEKEY2:
3672 if (HIWORD(wParam) == CBN_SELCHANGE) {
3673 int index = SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2,
3674 CB_GETCURSEL, 0, 0);
3675 cfg.sshbug_derivekey2 = (index == 0 ? AUTO :
3676 index == 1 ? FORCE_OFF:FORCE_ON);
3679 case IDC_BUGD_RSAPAD2:
3680 if (HIWORD(wParam) == CBN_SELCHANGE) {
3681 int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2,
3682 CB_GETCURSEL, 0, 0);
3683 cfg.sshbug_rsapad2 = (index == 0 ? AUTO :
3684 index == 1 ? FORCE_OFF : FORCE_ON);
3687 case IDC_BUGD_DHGEX2:
3688 if (HIWORD(wParam) == CBN_SELCHANGE) {
3689 int index = SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2,
3690 CB_GETCURSEL, 0, 0);
3691 cfg.sshbug_dhgex2 = (index == 0 ? AUTO :
3692 index == 1 ? FORCE_OFF : FORCE_ON);
3695 case IDC_BUGD_PKSESSID2:
3696 if (HIWORD(wParam) == CBN_SELCHANGE) {
3697 int index = SendDlgItemMessage(hwnd, IDC_BUGD_PKSESSID2,
3698 CB_GETCURSEL, 0, 0);
3699 cfg.sshbug_pksessid2 = (index == 0 ? AUTO :
3700 index == 1 ? FORCE_OFF : FORCE_ON);
3707 int id = ((LPHELPINFO)lParam)->iCtrlId;
3708 char *cmd = help_context_cmd(id);
3710 WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
3711 requested_help = TRUE;
3718 if (requested_help) {
3719 WinHelp(hwnd, help_path, HELP_QUIT, 0);
3720 requested_help = FALSE;
3725 /* Grrr Explorer will maximize Dialogs! */
3727 if (wParam == SIZE_MAXIMIZED)
3733 * Handle application-defined messages eg. DragListBox
3735 /* First find out what the number is (once). */
3736 if (draglistmsg == WM_NULL)
3737 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
3739 if (msg == draglistmsg) {
3740 /* Only process once dialog is fully formed. */
3741 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
3742 case IDC_CIPHERLIST:
3743 return handle_prefslist(&cipherlist,
3744 cfg.ssh_cipherlist, CIPHER_MAX,
3745 1, hwnd, wParam, lParam);
3754 static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
3755 WPARAM wParam, LPARAM lParam)
3757 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
3759 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
3760 EnableWindow(hwnd, 0);
3761 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3762 EnableWindow(hwnd, 1);
3763 SetActiveWindow(hwnd);
3765 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
3768 static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
3769 WPARAM wParam, LPARAM lParam)
3771 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
3774 void defuse_showwindow(void)
3777 * Work around the fact that the app's first call to ShowWindow
3778 * will ignore the default in favour of the shell-provided
3783 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
3785 ShowWindow(hwnd, SW_HIDE);
3786 SetActiveWindow(hwnd);
3787 DestroyWindow(hwnd);
3795 get_sesslist(&sesslist, TRUE);
3796 savedsession[0] = '\0';
3798 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
3799 get_sesslist(&sesslist, FALSE);
3804 int do_reconfig(HWND hwnd)
3809 backup_cfg = cfg; /* structure copy */
3811 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
3813 cfg = backup_cfg; /* structure copy */
3818 void logevent(void *frontend, char *string)
3823 log_eventlog(logctx, string);
3825 if (nevents >= negsize) {
3827 events = srealloc(events, negsize * sizeof(*events));
3831 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
3834 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
3835 strcpy(events[nevents], timebuf);
3836 strcat(events[nevents], string);
3839 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
3840 0, (LPARAM) events[nevents]);
3841 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
3842 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
3847 void showeventlog(HWND hwnd)
3850 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
3852 ShowWindow(logbox, SW_SHOWNORMAL);
3854 SetActiveWindow(logbox);
3857 void showabout(HWND hwnd)
3859 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3862 void verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,
3863 char *keystr, char *fingerprint)
3867 static const char absentmsg[] =
3868 "The server's host key is not cached in the registry. You\n"
3869 "have no guarantee that the server is the computer you\n"
3871 "The server's key fingerprint is:\n"
3873 "If you trust this host, hit Yes to add the key to\n"
3874 "PuTTY's cache and carry on connecting.\n"
3875 "If you want to carry on connecting just once, without\n"
3876 "adding the key to the cache, hit No.\n"
3877 "If you do not trust this host, hit Cancel to abandon the\n"
3880 static const char wrongmsg[] =
3881 "WARNING - POTENTIAL SECURITY BREACH!\n"
3883 "The server's host key does not match the one PuTTY has\n"
3884 "cached in the registry. This means that either the\n"
3885 "server administrator has changed the host key, or you\n"
3886 "have actually connected to another computer pretending\n"
3887 "to be the server.\n"
3888 "The new key fingerprint is:\n"
3890 "If you were expecting this change and trust the new key,\n"
3891 "hit Yes to update PuTTY's cache and continue connecting.\n"
3892 "If you want to carry on connecting but without updating\n"
3893 "the cache, hit No.\n"
3894 "If you want to abandon the connection completely, hit\n"
3895 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3897 static const char mbtitle[] = "PuTTY Security Alert";
3900 /* sensible fingerprint max size */
3901 (sizeof(absentmsg) > sizeof(wrongmsg) ?
3902 sizeof(absentmsg) : sizeof(wrongmsg))];
3905 * Verify the key against the registry.
3907 ret = verify_host_key(host, port, keytype, keystr);
3909 if (ret == 0) /* success - key matched OK */
3911 if (ret == 2) { /* key was different */
3913 sprintf(message, wrongmsg, fingerprint);
3914 mbret = MessageBox(NULL, message, mbtitle,
3915 MB_ICONWARNING | MB_YESNOCANCEL);
3917 store_host_key(host, port, keytype, keystr);
3918 if (mbret == IDCANCEL)
3921 if (ret == 1) { /* key was absent */
3923 sprintf(message, absentmsg, fingerprint);
3924 mbret = MessageBox(NULL, message, mbtitle,
3925 MB_ICONWARNING | MB_YESNOCANCEL);
3927 store_host_key(host, port, keytype, keystr);
3928 if (mbret == IDCANCEL)
3934 * Ask whether the selected cipher is acceptable (since it was
3935 * below the configured 'warn' threshold).
3936 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3938 void askcipher(void *frontend, char *ciphername, int cs)
3940 static const char mbtitle[] = "PuTTY Security Alert";
3941 static const char msg[] =
3942 "The first %.35scipher supported by the server\n"
3943 "is %.64s, which is below the configured\n"
3944 "warning threshold.\n"
3945 "Do you want to continue with this connection?\n";
3946 /* guessed cipher name + type max length */
3947 char message[100 + sizeof(msg)];
3950 sprintf(message, msg,
3952 (cs == 1) ? "client-to-server " :
3953 "server-to-client ",
3955 mbret = MessageBox(NULL, message, mbtitle,
3956 MB_ICONWARNING | MB_YESNO);
3964 * Ask whether to wipe a session log file before writing to it.
3965 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3967 int askappend(void *frontend, Filename filename)
3969 static const char mbtitle[] = "PuTTY Log to File";
3970 static const char msgtemplate[] =
3971 "The session log file \"%.*s\" already exists.\n"
3972 "You can overwrite it with a new session log,\n"
3973 "append your session log to the end of it,\n"
3974 "or disable session logging for this session.\n"
3975 "Hit Yes to wipe the file, No to append to it,\n"
3976 "or Cancel to disable logging.";
3977 char message[sizeof(msgtemplate) + FILENAME_MAX];
3980 sprintf(message, msgtemplate, FILENAME_MAX, filename.path);
3982 mbret = MessageBox(NULL, message, mbtitle,
3983 MB_ICONQUESTION | MB_YESNOCANCEL);
3986 else if (mbret == IDNO)
3993 * Warn about the obsolescent key file format.
3995 * Uniquely among these functions, this one does _not_ expect a
3996 * frontend handle. This means that if PuTTY is ported to a
3997 * platform which requires frontend handles, this function will be
3998 * an anomaly. Fortunately, the problem it addresses will not have
3999 * been present on that platform, so it can plausibly be
4000 * implemented as an empty function.
4002 void old_keyfile_warning(void)
4004 static const char mbtitle[] = "PuTTY Key File Warning";
4005 static const char message[] =
4006 "You are loading an SSH 2 private key which has an\n"
4007 "old version of the file format. This means your key\n"
4008 "file is not fully tamperproof. Future versions of\n"
4009 "PuTTY may stop supporting this private key format,\n"
4010 "so we recommend you convert your key to the new\n"
4013 "You can perform this conversion by loading the key\n"
4014 "into PuTTYgen and then saving it again.";
4016 MessageBox(NULL, message, mbtitle, MB_OK);