16 #define TVINSERTSTRUCT TV_INSERTSTRUCT
17 #define TVITEM TV_ITEM
21 static char **events = NULL;
22 static int nevents = 0, negsize = 0;
25 static int sesslist_has_focus;
26 static int requested_help;
28 static struct prefslist cipherlist;
30 extern Config cfg; /* defined in window.c */
32 struct sesslist sesslist; /* exported to window.c */
34 #define PRINTER_DISABLED_STRING "None (printing disabled)"
36 void force_normal(HWND hwnd)
38 static int recurse = 0;
46 wp.length = sizeof(wp);
47 if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) {
48 wp.showCmd = SW_SHOWNORMAL;
49 SetWindowPlacement(hwnd, &wp);
54 static void MyGetDlgItemInt(HWND hwnd, int id, int *result)
58 n = GetDlgItemInt(hwnd, id, &ok, FALSE);
63 static void MyGetDlgItemFlt(HWND hwnd, int id, int *result, int scale)
67 ok = GetDlgItemText(hwnd, id, text, sizeof(text) - 1);
69 *result = (int) (scale * atof(text));
72 static void MySetDlgItemFlt(HWND hwnd, int id, double value)
75 sprintf(text, "%g", value);
76 SetDlgItemText(hwnd, id, text);
79 static int CALLBACK LogProc(HWND hwnd, UINT msg,
80 WPARAM wParam, LPARAM lParam)
87 static int tabs[4] = { 78, 108 };
88 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
91 for (i = 0; i < nevents; i++)
92 SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
93 0, (LPARAM) events[i]);
96 switch (LOWORD(wParam)) {
100 SetActiveWindow(GetParent(hwnd));
104 if (HIWORD(wParam) == BN_CLICKED ||
105 HIWORD(wParam) == BN_DOUBLECLICKED) {
108 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
109 LB_GETSELCOUNT, 0, 0);
110 if (selcount == 0) { /* don't even try to copy zero items */
115 selitems = smalloc(selcount * sizeof(int));
117 int count = SendDlgItemMessage(hwnd, IDN_LIST,
124 static unsigned char sel_nl[] = SEL_NL;
126 if (count == 0) { /* can't copy zero stuff */
132 for (i = 0; i < count; i++)
134 strlen(events[selitems[i]]) + sizeof(sel_nl);
136 clipdata = smalloc(size);
139 for (i = 0; i < count; i++) {
140 char *q = events[selitems[i]];
141 int qlen = strlen(q);
144 memcpy(p, sel_nl, sizeof(sel_nl));
147 write_aclip(NULL, clipdata, size, TRUE);
152 for (i = 0; i < nevents; i++)
153 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
162 SetActiveWindow(GetParent(hwnd));
169 static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
170 WPARAM wParam, LPARAM lParam)
176 switch (LOWORD(wParam)) {
189 static int CALLBACK AboutProc(HWND hwnd, UINT msg,
190 WPARAM wParam, LPARAM lParam)
194 SetDlgItemText(hwnd, IDA_VERSION, ver);
197 switch (LOWORD(wParam)) {
200 EndDialog(hwnd, TRUE);
203 EnableWindow(hwnd, 0);
204 DialogBox(hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
206 EnableWindow(hwnd, 1);
207 SetActiveWindow(hwnd);
211 /* Load web browser */
212 ShellExecute(hwnd, "open",
213 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
214 0, 0, SW_SHOWDEFAULT);
219 EndDialog(hwnd, TRUE);
226 * Null dialog procedure.
228 static int CALLBACK NullDlgProc(HWND hwnd, UINT msg,
229 WPARAM wParam, LPARAM lParam)
234 static char savedsession[2048];
237 IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
390 IDC_SCROLLBARFULLSCREEN,
405 IDC_FULLSCREENONALTENTER,
408 appearancepanelstart,
409 IDC_TITLE_APPEARANCE,
431 connectionpanelstart,
432 IDC_TITLE_CONNECTION,
457 IDC_PROXYEXCLUDESTATIC,
458 IDC_PROXYEXCLUDEEDIT,
469 IDC_PROXYTELNETCMDSTATIC,
470 IDC_PROXYTELNETCMDEDIT,
471 IDC_PROXYSOCKSVERSTATIC,
602 translationpanelstart,
603 IDC_TITLE_TRANSLATION,
604 IDC_BOX_TRANSLATION1,
605 IDC_BOX_TRANSLATION2,
606 IDC_BOX_TRANSLATION3,
647 static const char *const colours[] = {
648 "Default Foreground", "Default Bold Foreground",
649 "Default Background", "Default Bold Background",
650 "Cursor Text", "Cursor Colour",
651 "ANSI Black", "ANSI Black Bold",
652 "ANSI Red", "ANSI Red Bold",
653 "ANSI Green", "ANSI Green Bold",
654 "ANSI Yellow", "ANSI Yellow Bold",
655 "ANSI Blue", "ANSI Blue Bold",
656 "ANSI Magenta", "ANSI Magenta Bold",
657 "ANSI Cyan", "ANSI Cyan Bold",
658 "ANSI White", "ANSI White Bold"
661 static void fmtfont(char *buf)
663 sprintf(buf, "Font: %s, ", cfg.font);
665 strcat(buf, "bold, ");
666 if (cfg.fontheight == 0)
667 strcat(buf, "default height");
669 sprintf(buf + strlen(buf), "%d-point",
670 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
673 char *help_context_cmd(int id)
685 return "JI(`',`session.hostname')";
692 return "JI(`',`session.saved')";
697 return "JI(`',`session.coe')";
698 case IDC_LSTATSTATIC:
702 case IDC_LSTATPACKET:
703 return "JI(`',`logging.main')";
708 return "JI(`',`logging.filename')";
713 return "JI(`',`logging.exists')";
718 return "JI(`',`keyboard.backspace')";
722 return "JI(`',`keyboard.homeend')";
730 return "JI(`',`keyboard.funkeys')";
734 return "JI(`',`keyboard.appkeypad')";
738 return "JI(`',`keyboard.appcursor')";
740 return "JI(`',`keyboard.nethack')";
742 return "JI(`',`keyboard.compose')";
743 case IDC_CTRLALTKEYS:
744 return "JI(`',`keyboard.ctrlalt')";
748 return "JI(`',`features.application')";
750 return "JI(`',`features.mouse')";
752 return "JI(`',`features.resize')";
753 case IDC_NOALTSCREEN:
754 return "JI(`',`features.altscreen')";
756 return "JI(`',`features.retitle')";
757 case IDC_NODBACKSPACE:
758 return "JI(`',`features.dbackspace')";
760 return "JI(`',`features.charset')";
763 return "JI(`',`terminal.autowrap')";
765 return "JI(`',`terminal.decom')";
767 return "JI(`',`terminal.lfhascr')";
769 return "JI(`',`terminal.bce')";
771 return "JI(`',`terminal.blink')";
774 return "JI(`',`terminal.answerback')";
776 case IDC_ECHOBACKEND:
779 return "JI(`',`terminal.localecho')";
781 case IDC_EDITBACKEND:
784 return "JI(`',`terminal.localedit')";
785 case IDC_PRINTERSTATIC:
787 return "JI(`',`terminal.printing')";
790 case IDC_BELL_DISABLED:
791 case IDC_BELL_DEFAULT:
792 case IDC_BELL_WAVEFILE:
793 case IDC_BELL_VISUAL:
794 case IDC_BELL_WAVESTATIC:
795 case IDC_BELL_WAVEEDIT:
796 case IDC_BELL_WAVEBROWSE:
797 return "JI(`',`bell.style')";
798 case IDC_B_IND_STATIC:
799 case IDC_B_IND_DISABLED:
800 case IDC_B_IND_FLASH:
801 case IDC_B_IND_STEADY:
802 return "JI(`',`bell.taskbar')";
804 case IDC_BELLOVLNSTATIC:
806 case IDC_BELLOVLTSTATIC:
808 case IDC_BELLOVLEXPLAIN:
809 case IDC_BELLOVLSSTATIC:
811 return "JI(`',`bell.overload')";
817 return "JI(`',`window.size')";
818 case IDC_RESIZESTATIC:
822 case IDC_RESIZEEITHER:
823 return "JI(`',`window.resize')";
825 case IDC_SCROLLBARFULLSCREEN:
830 return "JI(`',`window.scrollback')";
833 return "JI(`',`behaviour.closewarn')";
835 return "JI(`',`behaviour.altf4')";
837 return "JI(`',`behaviour.altspace')";
839 return "JI(`',`behaviour.altonly')";
840 case IDC_ALWAYSONTOP:
841 return "JI(`',`behaviour.alwaysontop')";
842 case IDC_FULLSCREENONALTENTER:
843 return "JI(`',`behaviour.altenter')";
845 case IDC_CURSORSTATIC:
850 return "JI(`',`appearance.cursor')";
853 return "JI(`',`appearance.font')";
857 return "JI(`',`appearance.title')";
859 return "JI(`',`appearance.hidemouse')";
863 return "JI(`',`appearance.border')";
867 return "JI(`',`connection.termtype')";
870 return "JI(`',`connection.username')";
873 return "JI(`',`connection.keepalive')";
875 return "JI(`',`connection.nodelay')";
877 case IDC_PROXYTYPESTATIC:
878 case IDC_PROXYTYPENONE:
879 case IDC_PROXYTYPEHTTP:
880 case IDC_PROXYTYPESOCKS:
881 case IDC_PROXYTYPETELNET:
882 return "JI(`',`proxy.type')";
883 case IDC_PROXYHOSTSTATIC:
884 case IDC_PROXYHOSTEDIT:
885 case IDC_PROXYPORTSTATIC:
886 case IDC_PROXYPORTEDIT:
887 return "JI(`',`proxy.main')";
888 case IDC_PROXYEXCLUDESTATIC:
889 case IDC_PROXYEXCLUDEEDIT:
890 case IDC_PROXYLOCALHOST:
891 return "JI(`',`proxy.exclude')";
892 case IDC_PROXYDNSSTATIC:
894 case IDC_PROXYDNSAUTO:
895 case IDC_PROXYDNSYES:
896 return "JI(`',`proxy.dns')";
897 case IDC_PROXYUSERSTATIC:
898 case IDC_PROXYUSEREDIT:
899 case IDC_PROXYPASSSTATIC:
900 case IDC_PROXYPASSEDIT:
901 return "JI(`',`proxy.auth')";
902 case IDC_PROXYTELNETCMDSTATIC:
903 case IDC_PROXYTELNETCMDEDIT:
904 return "JI(`',`proxy.command')";
905 case IDC_PROXYSOCKSVERSTATIC:
906 case IDC_PROXYSOCKSVER5:
907 case IDC_PROXYSOCKSVER4:
908 return "JI(`',`proxy.socksver')";
912 return "JI(`',`telnet.termspeed')";
921 return "JI(`',`telnet.environ')";
925 return "JI(`',`telnet.oldenviron')";
929 return "JI(`',`telnet.passive')";
931 return "JI(`',`telnet.specialkeys')";
933 return "JI(`',`telnet.newline')";
937 return "JI(`',`rlogin.termspeed')";
938 case IDC_RLLUSERSTATIC:
939 case IDC_RLLUSEREDIT:
940 return "JI(`',`rlogin.localuser')";
943 return "JI(`',`ssh.nopty')";
944 case IDC_CIPHERSTATIC2:
949 return "JI(`',`ssh.ciphers')";
950 case IDC_SSHPROTSTATIC:
951 case IDC_SSHPROT1ONLY:
954 case IDC_SSHPROT2ONLY:
955 return "JI(`',`ssh.protocol')";
958 return "JI(`',`ssh.command')";
960 return "JI(`',`ssh.compress')";
965 return "JI(`',`ssh.auth.privkey')";
967 return "JI(`',`ssh.auth.agentfwd')";
969 return "JI(`',`ssh.auth.changeuser')";
971 return "JI(`',`ssh.auth.tis')";
973 return "JI(`',`ssh.auth.ki')";
978 return "JI(`',`selection.buttons')";
979 case IDC_MOUSEOVERRIDE:
980 return "JI(`',`selection.shiftdrag')";
981 case IDC_SELTYPESTATIC:
983 case IDC_SELTYPERECT:
984 return "JI(`',`selection.rect')";
990 return "JI(`',`selection.charclasses')";
992 return "JI(`',`selection.linedraw')";
994 return "JI(`',`selection.rtf')";
997 return "JI(`',`colours.bold')";
999 return "JI(`',`colours.logpal')";
1000 case IDC_COLOURSTATIC:
1001 case IDC_COLOURLIST:
1009 return "JI(`',`colours.config')";
1011 case IDC_CODEPAGESTATIC:
1013 return "JI(`',`translation.codepage')";
1014 case IDC_CAPSLOCKCYR:
1015 return "JI(`',`translation.cyrillic')";
1017 case IDC_VTXWINDOWS:
1022 return "JI(`',`translation.linedraw')";
1024 case IDC_X11_FORWARD:
1025 case IDC_X11_DISPSTATIC:
1026 case IDC_X11_DISPLAY:
1027 return "JI(`',`ssh.tunnels.x11')";
1028 case IDC_X11AUTHSTATIC:
1031 return "JI(`',`ssh.tunnels.x11auth')";
1032 case IDC_PFWDSTATIC:
1033 case IDC_PFWDSTATIC2:
1034 case IDC_PFWDREMOVE:
1037 case IDC_SPORTSTATIC:
1039 case IDC_DPORTSTATIC:
1042 case IDC_PFWDREMOTE:
1043 return "JI(`',`ssh.tunnels.portfwd')";
1046 return "JI(`',`ssh.tunnels.portfwd.localhost')";
1048 case IDC_BUGS_IGNORE1:
1049 case IDC_BUGD_IGNORE1:
1050 return "JI(`',`ssh.bugs.ignore1')";
1051 case IDC_BUGS_PLAINPW1:
1052 case IDC_BUGD_PLAINPW1:
1053 return "JI(`',`ssh.bugs.plainpw1')";
1056 return "JI(`',`ssh.bugs.rsa1')";
1057 case IDC_BUGS_HMAC2:
1058 case IDC_BUGD_HMAC2:
1059 return "JI(`',`ssh.bugs.hmac2')";
1060 case IDC_BUGS_DERIVEKEY2:
1061 case IDC_BUGD_DERIVEKEY2:
1062 return "JI(`',`ssh.bugs.derivekey2')";
1063 case IDC_BUGS_RSAPAD2:
1064 case IDC_BUGD_RSAPAD2:
1065 return "JI(`',`ssh.bugs.rsapad2')";
1066 case IDC_BUGS_DHGEX2:
1067 case IDC_BUGD_DHGEX2:
1068 return "JI(`',`ssh.bugs.dhgex2')";
1075 /* 2nd arg: NZ => don't redraw session list (use when loading
1077 static void init_dlg_ctrls(HWND hwnd, int keepsess)
1080 char fontstatic[256];
1082 SetDlgItemText(hwnd, IDC_HOST, cfg.host);
1083 SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
1086 n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
1087 for (i = n; i-- > 0;)
1088 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_DELETESTRING, i, 0);
1089 for (i = 0; i < sesslist.nsessions; i++)
1090 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_ADDSTRING,
1091 0, (LPARAM) (sesslist.sessions[i]));
1093 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
1094 CheckRadioButton(hwnd, IDC_PROTRAW, IDC_PROTSSH,
1095 cfg.protocol == PROT_SSH ? IDC_PROTSSH :
1096 cfg.protocol == PROT_TELNET ? IDC_PROTTELNET :
1098 PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW);
1099 SetDlgItemInt(hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
1100 CheckDlgButton(hwnd, IDC_NODELAY, cfg.tcp_nodelay);
1102 CheckRadioButton(hwnd, IDC_DEL008, IDC_DEL127,
1103 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
1104 CheckRadioButton(hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
1105 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
1106 CheckRadioButton(hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
1107 cfg.funky_type == 0 ? IDC_FUNCTILDE :
1108 cfg.funky_type == 1 ? IDC_FUNCLINUX :
1109 cfg.funky_type == 2 ? IDC_FUNCXTERM :
1110 cfg.funky_type == 3 ? IDC_FUNCVT400 :
1111 cfg.funky_type == 4 ? IDC_FUNCVT100P :
1112 cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE);
1113 CheckDlgButton(hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
1114 CheckDlgButton(hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
1115 CheckDlgButton(hwnd, IDC_NOMOUSEREP, cfg.no_mouse_rep);
1116 CheckDlgButton(hwnd, IDC_NORESIZE, cfg.no_remote_resize);
1117 CheckDlgButton(hwnd, IDC_NOALTSCREEN, cfg.no_alt_screen);
1118 CheckDlgButton(hwnd, IDC_NOWINTITLE, cfg.no_remote_wintitle);
1119 CheckDlgButton(hwnd, IDC_NODBACKSPACE, cfg.no_dbackspace);
1120 CheckDlgButton(hwnd, IDC_NOCHARSET, cfg.no_remote_charset);
1121 CheckRadioButton(hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
1122 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
1123 CheckRadioButton(hwnd, IDC_KPNORMAL, IDC_KPNH,
1124 cfg.nethack_keypad ? IDC_KPNH :
1125 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
1126 CheckDlgButton(hwnd, IDC_ALTF4, cfg.alt_f4);
1127 CheckDlgButton(hwnd, IDC_ALTSPACE, cfg.alt_space);
1128 CheckDlgButton(hwnd, IDC_ALTONLY, cfg.alt_only);
1129 CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
1130 CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
1131 CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
1132 CheckDlgButton(hwnd, IDC_TELNETRET, cfg.telnet_newline);
1133 CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
1134 cfg.localecho == AUTO ? IDC_ECHOBACKEND :
1135 cfg.localecho == FORCE_ON ? IDC_ECHOYES : IDC_ECHONO);
1136 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
1137 cfg.localedit == AUTO ? IDC_EDITBACKEND :
1138 cfg.localedit == FORCE_ON ? IDC_EDITYES : IDC_EDITNO);
1139 SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
1140 CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
1141 CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
1142 CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
1143 CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
1145 CheckDlgButton(hwnd, IDC_WRAPMODE, cfg.wrap_mode);
1146 CheckDlgButton(hwnd, IDC_DECOM, cfg.dec_om);
1147 CheckDlgButton(hwnd, IDC_LFHASCR, cfg.lfhascr);
1148 SetDlgItemInt(hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
1149 SetDlgItemInt(hwnd, IDC_COLSEDIT, cfg.width, FALSE);
1150 SetDlgItemInt(hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
1151 fmtfont(fontstatic);
1152 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
1153 CheckRadioButton(hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
1154 cfg.beep == BELL_DISABLED ? IDC_BELL_DISABLED :
1155 cfg.beep == BELL_DEFAULT ? IDC_BELL_DEFAULT :
1156 cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
1158 BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
1159 CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
1161 B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
1162 B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
1163 B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
1164 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
1165 CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
1166 SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
1167 MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
1168 MySetDlgItemFlt(hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
1170 CheckDlgButton(hwnd, IDC_BCE, cfg.bce);
1171 CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
1173 SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
1174 CheckDlgButton(hwnd, IDC_WINNAME, !cfg.win_name_always);
1175 CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
1176 CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
1177 SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
1178 CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
1179 cfg.cursor_type == 0 ? IDC_CURBLOCK :
1180 cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
1181 CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
1182 CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
1183 CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
1184 CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZEEITHER,
1185 cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
1186 cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
1187 cfg.resize_action == RESIZE_EITHER ? IDC_RESIZEEITHER :
1189 CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
1190 cfg.close_on_exit == AUTO ? IDC_COENORMAL :
1191 cfg.close_on_exit ==
1192 FORCE_OFF ? IDC_COENEVER : IDC_COEALWAYS);
1193 CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
1195 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1196 SetDlgItemText(hwnd, IDC_TSEDIT, cfg.termspeed);
1197 SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
1198 SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
1199 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1200 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
1201 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATPACKET,
1202 cfg.logtype == LGTYP_NONE ? IDC_LSTATOFF :
1203 cfg.logtype == LGTYP_ASCII ? IDC_LSTATASCII :
1204 cfg.logtype == LGTYP_DEBUG ? IDC_LSTATRAW :
1206 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
1207 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
1208 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
1211 char *p = cfg.environmt;
1212 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
1214 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
1220 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0,
1225 CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC,
1226 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
1227 CheckRadioButton(hwnd, IDC_TPASSIVE, IDC_TACTIVE,
1228 cfg.passive_telnet ? IDC_TPASSIVE : IDC_TACTIVE);
1230 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1231 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1232 CheckDlgButton(hwnd, IDC_NOPTY, cfg.nopty);
1233 CheckDlgButton(hwnd, IDC_COMPRESS, cfg.compression);
1234 CheckDlgButton(hwnd, IDC_SSH2DES, cfg.ssh2_des_cbc);
1235 CheckDlgButton(hwnd, IDC_AGENTFWD, cfg.agentfwd);
1236 CheckDlgButton(hwnd, IDC_CHANGEUSER, cfg.change_username);
1237 CheckRadioButton(hwnd, IDC_SSHPROT1ONLY, IDC_SSHPROT2ONLY,
1238 cfg.sshprot == 1 ? IDC_SSHPROT1 :
1239 cfg.sshprot == 2 ? IDC_SSHPROT2 :
1240 cfg.sshprot == 3 ? IDC_SSHPROT2ONLY : IDC_SSHPROT1ONLY);
1241 CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
1242 CheckDlgButton(hwnd, IDC_AUTHKI, cfg.try_ki_auth);
1243 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
1244 SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
1248 static const struct { char *s; int c; } ciphers[] = {
1249 { "3DES", CIPHER_3DES },
1250 { "Blowfish", CIPHER_BLOWFISH },
1251 { "DES", CIPHER_DES },
1252 { "AES (SSH 2 only)", CIPHER_AES },
1253 { "-- warn below here --", CIPHER_WARN }
1256 /* Set up the "selected ciphers" box. */
1257 /* (cipherlist assumed to contain all ciphers) */
1258 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_RESETCONTENT, 0, 0);
1259 for (i = 0; i < CIPHER_MAX; i++) {
1260 int c = cfg.ssh_cipherlist[i];
1263 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
1264 if (ciphers[j].c == c) {
1265 cstr = ciphers[j].s;
1269 pos = SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_ADDSTRING,
1271 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_SETITEMDATA,
1277 CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
1278 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
1279 CheckRadioButton(hwnd, IDC_SELTYPELEX, IDC_SELTYPERECT,
1280 cfg.rect_select == 0 ? IDC_SELTYPELEX : IDC_SELTYPERECT);
1281 CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
1282 CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
1283 CheckDlgButton(hwnd, IDC_RTFPASTE, cfg.rtf_paste);
1285 static int tabs[4] = { 25, 61, 96, 128 };
1286 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
1289 for (i = 0; i < 128; i++) {
1291 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
1292 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg.wordness[i]);
1293 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
1297 CheckDlgButton(hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
1298 CheckDlgButton(hwnd, IDC_PALETTE, cfg.try_palette);
1301 n = SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
1302 for (i = n; i-- > 0;)
1303 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
1304 LB_DELETESTRING, i, 0);
1305 for (i = 0; i < 22; i++)
1306 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
1307 (LPARAM) colours[i]);
1309 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
1310 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
1311 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
1312 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
1317 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
1318 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
1319 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
1320 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
1321 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
1324 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
1330 pe = printer_start_enum(&nprinters);
1331 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_RESETCONTENT, 0, 0);
1332 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1333 0, (LPARAM) PRINTER_DISABLED_STRING);
1334 for (i = 0; i < nprinters; i++) {
1335 char *printer_name = printer_get_name(pe, i);
1336 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_ADDSTRING,
1337 0, (LPARAM) printer_name);
1339 printer_finish_enum(pe);
1340 SetDlgItemText(hwnd, IDC_PRINTER,
1341 *cfg.printer ? cfg.printer : PRINTER_DISABLED_STRING);
1344 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
1345 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
1346 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
1347 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
1348 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
1351 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
1352 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
1353 CheckRadioButton(hwnd, IDC_X11MIT, IDC_X11XDM,
1354 cfg.x11_auth == X11_MIT ? IDC_X11MIT : IDC_X11XDM);
1356 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
1357 CheckDlgButton(hwnd, IDC_RPORT_ALL, cfg.rport_acceptall);
1358 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
1361 CheckRadioButton(hwnd, IDC_PROXYTYPENONE, IDC_PROXYTYPETELNET,
1362 cfg.proxy_type == PROXY_HTTP ? IDC_PROXYTYPEHTTP :
1363 cfg.proxy_type == PROXY_SOCKS ? IDC_PROXYTYPESOCKS :
1364 cfg.proxy_type == PROXY_TELNET ? IDC_PROXYTYPETELNET : IDC_PROXYTYPENONE);
1365 SetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host);
1366 SetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, cfg.proxy_port, FALSE);
1367 SetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT, cfg.proxy_exclude_list);
1368 CheckDlgButton(hwnd, IDC_PROXYLOCALHOST, cfg.even_proxy_localhost);
1369 CheckRadioButton(hwnd, IDC_PROXYDNSNO, IDC_PROXYDNSYES,
1370 cfg.proxy_dns == FORCE_OFF ? IDC_PROXYDNSNO :
1371 cfg.proxy_dns == FORCE_ON ? IDC_PROXYDNSYES :
1373 SetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT, cfg.proxy_telnet_command);
1374 SetDlgItemText(hwnd, IDC_PROXYUSEREDIT, cfg.proxy_username);
1375 SetDlgItemText(hwnd, IDC_PROXYPASSEDIT, cfg.proxy_password);
1376 CheckRadioButton(hwnd, IDC_PROXYSOCKSVER5, IDC_PROXYSOCKSVER4,
1377 cfg.proxy_socks_version == 4 ? IDC_PROXYSOCKSVER4 : IDC_PROXYSOCKSVER5);
1379 /* SSH bugs config */
1380 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_RESETCONTENT, 0, 0);
1381 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1382 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"Off");
1383 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_ADDSTRING, 0, (LPARAM)"On");
1384 SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1, CB_SETCURSEL,
1385 cfg.sshbug_ignore1 == FORCE_ON ? 2 :
1386 cfg.sshbug_ignore1 == FORCE_OFF ? 1 : 0, 0);
1387 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_RESETCONTENT, 0, 0);
1388 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1389 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"Off");
1390 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_ADDSTRING, 0, (LPARAM)"On");
1391 SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1, CB_SETCURSEL,
1392 cfg.sshbug_plainpw1 == FORCE_ON ? 2 :
1393 cfg.sshbug_plainpw1 == FORCE_OFF ? 1 : 0, 0);
1394 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_RESETCONTENT, 0, 0);
1395 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Auto");
1396 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"Off");
1397 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_ADDSTRING, 0, (LPARAM)"On");
1398 SendDlgItemMessage(hwnd, IDC_BUGD_RSA1, CB_SETCURSEL,
1399 cfg.sshbug_rsa1 == FORCE_ON ? 2 :
1400 cfg.sshbug_rsa1 == FORCE_OFF ? 1 : 0, 0);
1401 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_RESETCONTENT, 0, 0);
1402 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1403 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"Off");
1404 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_ADDSTRING, 0, (LPARAM)"On");
1405 SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2, CB_SETCURSEL,
1406 cfg.sshbug_hmac2 == FORCE_ON ? 2 :
1407 cfg.sshbug_hmac2 == FORCE_OFF ? 1 : 0, 0);
1408 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_RESETCONTENT, 0, 0);
1409 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1410 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"Off");
1411 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_ADDSTRING, 0, (LPARAM)"On");
1412 SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2, CB_SETCURSEL,
1413 cfg.sshbug_derivekey2 == FORCE_ON ? 2 :
1414 cfg.sshbug_derivekey2 == FORCE_OFF ? 1 : 0, 0);
1415 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_RESETCONTENT, 0, 0);
1416 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1417 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"Off");
1418 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_ADDSTRING, 0, (LPARAM)"On");
1419 SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2, CB_SETCURSEL,
1420 cfg.sshbug_rsapad2 == FORCE_ON ? 2 :
1421 cfg.sshbug_rsapad2 == FORCE_OFF ? 1 : 0, 0);
1422 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_RESETCONTENT, 0, 0);
1423 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"Auto");
1424 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"Off");
1425 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_ADDSTRING, 0, (LPARAM)"On");
1426 SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2, CB_SETCURSEL,
1427 cfg.sshbug_dhgex2 == FORCE_ON ? 2 :
1428 cfg.sshbug_dhgex2 == FORCE_OFF ? 1 : 0, 0);
1431 struct treeview_faff {
1433 HTREEITEM lastat[4];
1436 static HTREEITEM treeview_insert(struct treeview_faff *faff,
1437 int level, char *text)
1442 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
1443 ins.hInsertAfter = faff->lastat[level];
1444 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1445 #define INSITEM DUMMYUNIONNAME.item
1447 #define INSITEM item
1449 ins.INSITEM.mask = TVIF_TEXT;
1450 ins.INSITEM.pszText = text;
1451 newitem = TreeView_InsertItem(faff->treeview, &ins);
1453 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
1455 faff->lastat[level] = newitem;
1456 for (i = level + 1; i < 4; i++)
1457 faff->lastat[i] = NULL;
1462 * Create the panelfuls of controls in the configuration box.
1464 static void create_controls(HWND hwnd, int dlgtype, int panel)
1466 if (panel == sessionpanelstart) {
1467 /* The Session panel. Accelerators used: [acgoh] nprtis elvd w */
1469 ctlposinit(&cp, hwnd, 80, 3, 13);
1470 bartitle(&cp, "Basic options for your PuTTY session",
1473 beginbox(&cp, "Specify your connection by host name or IP address",
1476 "Host &Name (or IP address)",
1477 IDC_HOSTSTATIC, IDC_HOST, 75,
1478 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
1479 if (backends[3].backend == NULL) {
1480 /* this is PuTTYtel, so only three protocols available */
1481 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
1482 "&Raw", IDC_PROTRAW,
1483 "&Telnet", IDC_PROTTELNET,
1484 "Rlog&in", IDC_PROTRLOGIN, NULL);
1486 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
1487 "&Raw", IDC_PROTRAW,
1488 "&Telnet", IDC_PROTTELNET,
1489 "Rlog&in", IDC_PROTRLOGIN,
1498 beginbox(&cp, "Load, save or delete a stored session",
1500 sesssaver(&cp, "Sav&ed Sessions",
1501 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
1502 "&Load", IDC_SESSLOAD,
1503 "Sa&ve", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
1506 beginbox(&cp, NULL, IDC_BOX_SESSION3);
1507 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
1508 "Always", IDC_COEALWAYS,
1509 "Never", IDC_COENEVER,
1510 "Only on clean exit", IDC_COENORMAL, NULL);
1514 if (panel == loggingpanelstart) {
1515 /* The Logging panel. Accelerators used: [acgoh] tplsfwe */
1517 ctlposinit(&cp, hwnd, 80, 3, 13);
1518 bartitle(&cp, "Options controlling session logging",
1520 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
1522 "Session logging:", IDC_LSTATSTATIC,
1523 "Logging &turned off completely", IDC_LSTATOFF,
1524 "Log &printable output only", IDC_LSTATASCII,
1525 "&Log all session output", IDC_LSTATRAW,
1526 "Log &SSH packet data", IDC_LSTATPACKET,
1528 editbutton(&cp, "Log &file name:",
1529 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
1531 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
1532 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
1534 "What to do if the log file already &exists:",
1535 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
1536 "Always append to the end of it", IDC_LSTATXAPN,
1537 "Ask the user every time", IDC_LSTATXASK, NULL);
1541 if (panel == terminalpanelstart) {
1542 /* The Terminal panel. Accelerators used: [acgoh] wdren lts p */
1544 ctlposinit(&cp, hwnd, 80, 3, 13);
1545 bartitle(&cp, "Options controlling the terminal emulation",
1546 IDC_TITLE_TERMINAL);
1547 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
1548 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
1549 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
1550 checkbox(&cp, "Implicit C&R in every LF", IDC_LFHASCR);
1551 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
1552 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
1554 "An&swerback to ^E:", IDC_ANSWERBACK,
1555 IDC_ANSWEREDIT, 100, NULL);
1558 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
1559 radioline(&cp, "&Local echo:", IDC_ECHOSTATIC, 3,
1560 "Auto", IDC_ECHOBACKEND,
1561 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
1562 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
1563 "Auto", IDC_EDITBACKEND,
1564 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
1567 beginbox(&cp, "Remote-controlled printing", IDC_BOX_TERMINAL3);
1568 combobox(&cp, "&Printer to send ANSI printer output to:",
1569 IDC_PRINTERSTATIC, IDC_PRINTER);
1573 if (panel == featurespanelstart) {
1574 /* The Features panel. Accelerators used: [acgoh] ukswtbrx */
1576 ctlposinit(&cp, hwnd, 80, 3, 13);
1577 bartitle(&cp, "Enabling and disabling advanced terminal features ",
1578 IDC_TITLE_FEATURES);
1579 beginbox(&cp, NULL, IDC_BOX_FEATURES1);
1580 checkbox(&cp, "Disable application c&ursor keys mode", IDC_NOAPPLICC);
1581 checkbox(&cp, "Disable application &keypad mode", IDC_NOAPPLICK);
1582 checkbox(&cp, "Disable &xterm-style mouse reporting", IDC_NOMOUSEREP);
1583 checkbox(&cp, "Disable remote-controlled terminal re&sizing",
1585 checkbox(&cp, "Disable s&witching to alternate terminal screen",
1587 checkbox(&cp, "Disable remote-controlled window &title changing",
1589 checkbox(&cp, "Disable destructive &backspace on server sending ^?",
1591 checkbox(&cp, "Disable remote-controlled cha&racter set configuration",
1596 if (panel == bellpanelstart) {
1597 /* The Bell panel. Accelerators used: [acgoh] bdsm wit */
1599 ctlposinit(&cp, hwnd, 80, 3, 13);
1600 bartitle(&cp, "Options controlling the terminal bell",
1602 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
1604 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
1605 "None (bell disabled)", IDC_BELL_DISABLED,
1606 "Play Windows Default Sound", IDC_BELL_DEFAULT,
1607 "Play a custom sound file", IDC_BELL_WAVEFILE,
1608 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
1609 editbutton(&cp, "Custom sound file to play as a bell:",
1610 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
1611 "Bro&wse...", IDC_BELL_WAVEBROWSE);
1612 radioline(&cp, "Taskbar/caption &indication on bell:",
1613 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
1614 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
1617 beginbox(&cp, "Control the bell overload behaviour",
1619 checkbox(&cp, "Bell is temporarily &disabled when over-used",
1621 staticedit(&cp, "Over-use means this &many bells...",
1622 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
1623 staticedit(&cp, "... in &this many seconds",
1624 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
1626 "The bell is re-enabled after a few seconds of silence.",
1627 1, IDC_BELLOVLEXPLAIN);
1628 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1633 if (panel == keyboardpanelstart) {
1634 /* The Keyboard panel. Accelerators used: [acgoh] bef rntd */
1636 ctlposinit(&cp, hwnd, 80, 3, 13);
1637 bartitle(&cp, "Options controlling the effects of keys",
1638 IDC_TITLE_KEYBOARD);
1639 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1640 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1641 "Control-H", IDC_DEL008,
1642 "Control-? (127)", IDC_DEL127, NULL);
1643 radioline(&cp, "The Home and &End keys", IDC_HOMESTATIC, 2,
1644 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1645 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1646 "ESC[n~", IDC_FUNCTILDE,
1647 "Linux", IDC_FUNCLINUX,
1648 "Xterm R6", IDC_FUNCXTERM,
1649 "VT400", IDC_FUNCVT400,
1650 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1652 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1653 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1654 "Normal", IDC_CURNORMAL,
1655 "Application", IDC_CURAPPLIC, NULL);
1656 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1657 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1658 "NetHack", IDC_KPNH, NULL);
1660 beginbox(&cp, "Enable extra keyboard features:",
1662 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1663 checkbox(&cp, "Control-Alt is &different from AltGr",
1668 if (panel == windowpanelstart) {
1669 /* The Window panel. Accelerators used: [acgoh] rmz sdikp */
1671 ctlposinit(&cp, hwnd, 80, 3, 13);
1672 bartitle(&cp, "Options controlling PuTTY's window",
1674 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1676 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1677 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
1678 radiobig(&cp, "When window is resi&zed:", IDC_RESIZESTATIC,
1679 "Change the number of rows and columns", IDC_RESIZETERM,
1680 "Change the size of the font", IDC_RESIZEFONT,
1681 "Change font size only when maximised", IDC_RESIZEEITHER,
1682 "Forbid resizing completely", IDC_RESIZENONE, NULL);
1684 beginbox(&cp, "Control the scrollback in the window",
1686 staticedit(&cp, "Lines of &scrollback",
1687 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1688 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
1689 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
1690 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1691 checkbox(&cp, "Reset scrollback on dis&play activity",
1696 if (panel == appearancepanelstart) {
1697 /* The Appearance panel. Accelerators used: [acgoh] luvb n ti p s */
1699 ctlposinit(&cp, hwnd, 80, 3, 13);
1700 bartitle(&cp, "Configure the appearance of PuTTY's window",
1701 IDC_TITLE_APPEARANCE);
1702 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1703 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1704 "B&lock", IDC_CURBLOCK,
1705 "&Underline", IDC_CURUNDER,
1706 "&Vertical line", IDC_CURVERT, NULL);
1707 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1709 beginbox(&cp, "Set the font used in the terminal window",
1710 IDC_BOX_APPEARANCE2);
1711 staticbtn(&cp, "", IDC_FONTSTATIC, "Cha&nge...", IDC_CHOOSEFONT);
1713 beginbox(&cp, "Adjust the use of the window title",
1714 IDC_BOX_APPEARANCE3);
1716 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1717 checkbox(&cp, "Separate window and &icon titles", IDC_WINNAME);
1719 beginbox(&cp, "Adjust the use of the mouse pointer",
1720 IDC_BOX_APPEARANCE4);
1721 checkbox(&cp, "Hide mouse &pointer when typing in window",
1724 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1725 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1727 staticedit(&cp, "Gap between text and window edge",
1728 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
1732 if (panel == behaviourpanelstart) {
1733 /* The Behaviour panel. Accelerators used: [acgoh] w4yltf */
1735 ctlposinit(&cp, hwnd, 80, 3, 13);
1736 bartitle(&cp, "Configure the behaviour of PuTTY's window",
1738 beginbox(&cp, NULL, IDC_BOX_BEHAVIOUR1);
1739 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1740 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1741 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1742 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
1743 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1744 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1748 if (panel == translationpanelstart) {
1749 /* The Translation panel. Accelerators used: [acgoh] rxbepus */
1751 ctlposinit(&cp, hwnd, 80, 3, 13);
1752 bartitle(&cp, "Options controlling character set translation",
1753 IDC_TITLE_TRANSLATION);
1754 beginbox(&cp, "Character set translation on received data",
1755 IDC_BOX_TRANSLATION1);
1756 combobox(&cp, "&Received data assumed to be in which character set:",
1757 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1759 beginbox(&cp, "Enable character set translation on input data",
1760 IDC_BOX_TRANSLATION2);
1761 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
1764 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
1765 IDC_BOX_TRANSLATION3);
1767 "Handling of line drawing characters:", IDC_VTSTATIC,
1768 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1769 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1770 "Use font in O&EM mode only", IDC_VTOEMONLY,
1771 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1772 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
1776 if (panel == selectionpanelstart) {
1777 /* The Selection panel. Accelerators used: [acgoh] df wxp est nr */
1779 ctlposinit(&cp, hwnd, 80, 3, 13);
1780 bartitle(&cp, "Options controlling copy and paste",
1781 IDC_TITLE_SELECTION);
1782 beginbox(&cp, "Translation of pasted characters",
1783 IDC_BOX_SELECTION1);
1785 "&Don't translate line drawing chars into +, - and |",
1788 "Paste to clipboard in RT&F as well as plain text",
1791 beginbox(&cp, "Control which mouse button does which thing",
1792 IDC_BOX_SELECTION2);
1793 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1794 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1795 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1798 "Shift overrides a&pplication's use of mouse",
1801 "Default selection mode (Alt+drag does the other one):",
1802 IDC_SELTYPESTATIC, 2,
1803 "&Normal", IDC_SELTYPELEX,
1804 "&Rectangular block", IDC_SELTYPERECT, NULL);
1806 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1807 IDC_BOX_SELECTION3);
1808 charclass(&cp, "Charact&er classes:", IDC_CCSTATIC, IDC_CCLIST,
1809 "&Set", IDC_CCSET, IDC_CCEDIT,
1810 "&to class", IDC_CCSTATIC2);
1814 if (panel == colourspanelstart) {
1815 /* The Colours panel. Accelerators used: [acgoh] blum */
1817 ctlposinit(&cp, hwnd, 80, 3, 13);
1818 bartitle(&cp, "Options controlling use of colours",
1820 beginbox(&cp, "General options for colour usage",
1822 checkbox(&cp, "&Bolded text is a different colour",
1824 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1826 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1828 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1829 IDC_COLOURSTATIC, IDC_COLOURLIST,
1830 "&Modify...", IDC_CHANGE,
1831 "Red:", IDC_RSTATIC, IDC_RVALUE,
1832 "Green:", IDC_GSTATIC, IDC_GVALUE,
1833 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1837 if (panel == connectionpanelstart) {
1838 /* The Connection panel. Accelerators used: [acgoh] tukn */
1840 ctlposinit(&cp, hwnd, 80, 3, 13);
1841 bartitle(&cp, "Options controlling the connection",
1842 IDC_TITLE_CONNECTION);
1844 beginbox(&cp, "Data to send to the server",
1845 IDC_BOX_CONNECTION1);
1846 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1848 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1852 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1853 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1855 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1859 beginbox(&cp, "Sending of null packets to keep session active",
1860 IDC_BOX_CONNECTION2);
1861 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1862 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1865 beginbox(&cp, "Low-level TCP connection options",
1866 IDC_BOX_CONNECTION3);
1867 checkbox(&cp, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1873 if (panel == proxypanelstart) {
1874 /* The Proxy panel. Accelerators used: [acgoh] ntslypeuwmvxd */
1876 ctlposinit(&cp, hwnd, 80, 3, 13);
1878 bartitle(&cp, "Options controlling proxy usage",
1880 beginbox(&cp, "Proxy basics", IDC_BOX_PROXY1);
1881 radioline(&cp, "Proxy type:", IDC_PROXYTYPESTATIC, 4,
1882 "&None", IDC_PROXYTYPENONE,
1883 "H&TTP", IDC_PROXYTYPEHTTP,
1884 "&SOCKS", IDC_PROXYTYPESOCKS,
1885 "Te&lnet", IDC_PROXYTYPETELNET, NULL);
1887 "Prox&y Host", IDC_PROXYHOSTSTATIC, IDC_PROXYHOSTEDIT, 80,
1888 "&Port", IDC_PROXYPORTSTATIC, IDC_PROXYPORTEDIT, 20, NULL);
1890 "&Exclude Hosts/IPs", IDC_PROXYEXCLUDESTATIC,
1891 IDC_PROXYEXCLUDEEDIT, 100, NULL);
1892 checkbox(&cp, "Consider pro&xying local host connections",
1893 IDC_PROXYLOCALHOST);
1894 radioline(&cp, "Do &DNS name lookup at proxy end:",
1895 IDC_PROXYDNSSTATIC, 3,
1896 "No", IDC_PROXYDNSNO,
1897 "Auto", IDC_PROXYDNSAUTO,
1898 "Yes", IDC_PROXYDNSYES, NULL);
1899 staticedit(&cp, "&Username", IDC_PROXYUSERSTATIC,
1900 IDC_PROXYUSEREDIT, 60);
1901 staticpassedit(&cp, "Pass&word", IDC_PROXYPASSSTATIC,
1902 IDC_PROXYPASSEDIT, 60);
1904 beginbox(&cp, "Misc. proxy settings", IDC_BOX_PROXY2);
1906 "Telnet co&mmand", IDC_PROXYTELNETCMDSTATIC,
1907 IDC_PROXYTELNETCMDEDIT, 100, NULL);
1908 radioline(&cp, "SOCKS &Version", IDC_PROXYSOCKSVERSTATIC,
1909 2, "Version 5", IDC_PROXYSOCKSVER5, "Version 4",
1910 IDC_PROXYSOCKSVER4, NULL);
1915 if (panel == telnetpanelstart) {
1916 /* The Telnet panel. Accelerators used: [acgoh] svldr bftk */
1918 ctlposinit(&cp, hwnd, 80, 3, 13);
1920 bartitle(&cp, "Options controlling Telnet connections",
1922 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1923 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1925 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1926 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1927 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1928 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1930 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1931 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1932 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1933 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1934 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1935 "Passive", IDC_TPASSIVE, "Active",
1937 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1939 checkbox(&cp, "Return key sends telnet New Line instead of ^M",
1945 if (panel == rloginpanelstart) {
1946 /* The Rlogin panel. Accelerators used: [acgoh] sl */
1948 ctlposinit(&cp, hwnd, 80, 3, 13);
1950 bartitle(&cp, "Options controlling Rlogin connections",
1952 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1953 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1955 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1956 IDC_RLLUSEREDIT, 50);
1961 if (panel == sshpanelstart) {
1962 /* The SSH panel. Accelerators used: [acgoh] r pel12n sud i */
1964 ctlposinit(&cp, hwnd, 80, 3, 13);
1966 bartitle(&cp, "Options controlling SSH connections",
1968 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1970 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1973 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
1974 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1975 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1976 radioline(&cp, "Preferred SSH protocol version:",
1977 IDC_SSHPROTSTATIC, 4,
1978 "1 on&ly", IDC_SSHPROT1ONLY,
1979 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2,
1980 "2 o&nly", IDC_SSHPROT2ONLY, NULL);
1982 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1983 /* Adds accelerators: ud */
1984 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1985 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1987 checkbox(&cp, "Enable non-standard use of s&ingle-DES in SSH 2",
1993 if (panel == sshauthpanelstart) {
1994 /* The SSH authentication panel. Accelerators used: [acgoh] m fkiuw */
1996 ctlposinit(&cp, hwnd, 80, 3, 13);
1998 bartitle(&cp, "Options controlling SSH authentication",
2000 beginbox(&cp, "Authentication methods",
2002 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
2004 checkbox(&cp, "Attempt \"keyboard-&interactive\" authentication"
2005 " (SSH2)", IDC_AUTHKI);
2007 beginbox(&cp, "Authentication parameters",
2009 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
2010 checkbox(&cp, "Allow attempted changes of &username in SSH2",
2012 editbutton(&cp, "Private &key file for authentication:",
2013 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
2019 if (panel == sshbugspanelstart) {
2020 /* The SSH bugs panel. Accelerators used: [acgoh] isrmepd */
2022 ctlposinit(&cp, hwnd, 80, 3, 13);
2024 bartitle(&cp, "Workarounds for SSH server bugs",
2026 beginbox(&cp, "Detection of known bugs in SSH servers",
2028 staticddl(&cp, "Chokes on SSH1 &ignore messages",
2029 IDC_BUGS_IGNORE1, IDC_BUGD_IGNORE1, 20);
2030 staticddl(&cp, "Refuses all SSH1 pa&ssword camouflage",
2031 IDC_BUGS_PLAINPW1, IDC_BUGD_PLAINPW1, 20);
2032 staticddl(&cp, "Chokes on SSH1 &RSA authentication",
2033 IDC_BUGS_RSA1, IDC_BUGD_RSA1, 20);
2034 staticddl(&cp, "Miscomputes SSH2 H&MAC keys",
2035 IDC_BUGS_HMAC2, IDC_BUGD_HMAC2, 20);
2036 staticddl(&cp, "Miscomputes SSH2 &encryption keys",
2037 IDC_BUGS_DERIVEKEY2, IDC_BUGD_DERIVEKEY2, 20);
2038 staticddl(&cp, "Requires &padding on SSH2 RSA signatures",
2039 IDC_BUGS_RSAPAD2, IDC_BUGD_RSAPAD2, 20);
2040 staticddl(&cp, "Chokes on &Diffie-Hellman group exchange",
2041 IDC_BUGS_DHGEX2, IDC_BUGD_DHGEX2, 20);
2046 if (panel == tunnelspanelstart) {
2047 /* The Tunnels panel. Accelerators used: [acgoh] exu tprsdilm */
2049 ctlposinit(&cp, hwnd, 80, 3, 13);
2051 bartitle(&cp, "Options controlling SSH tunnelling",
2053 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
2054 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
2055 staticedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
2056 IDC_X11_DISPLAY, 50);
2057 radioline(&cp, "Remote X11 a&uthentication protocol",
2058 IDC_X11AUTHSTATIC, 2,
2059 "MIT-Magic-Cookie-1", IDC_X11MIT,
2060 "XDM-Authorization-1", IDC_X11XDM, NULL);
2062 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
2063 checkbox(&cp, "Local ports accept connections from o&ther hosts",
2065 checkbox(&cp, "Remote &ports do the same (SSH v2 only)",
2067 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
2068 "&Remove", IDC_PFWDREMOVE);
2069 fwdsetter(&cp, IDC_PFWDLIST,
2070 "Add new forwarded port:", IDC_PFWDSTATIC2,
2071 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
2072 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
2073 "A&dd", IDC_PFWDADD,
2074 "&Local", IDC_PFWDLOCAL,
2075 "Re&mote", IDC_PFWDREMOTE);
2083 * Helper function to load the session selected in SESSLIST
2084 * if any, as this is done in more than one place in
2085 * GenericMainDlgProc(). 0 => failure.
2087 static int load_selected_session(HWND hwnd)
2089 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2090 LB_GETCURSEL, 0, 0);
2096 isdef = !strcmp(sesslist.sessions[n], "Default Settings");
2097 load_settings(sesslist.sessions[n], !isdef, &cfg);
2098 init_dlg_ctrls(hwnd, TRUE);
2100 SetDlgItemText(hwnd, IDC_SESSEDIT, sesslist.sessions[n]);
2102 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
2103 /* Restore the selection, which will have been clobbered by
2104 * SESSEDIT handling. */
2105 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
2110 * This function is the configuration box.
2112 static int GenericMainDlgProc(HWND hwnd, UINT msg,
2113 WPARAM wParam, LPARAM lParam, int dlgtype)
2116 struct treeview_faff tvfaff;
2119 char filename[sizeof(cfg.keyfile)];
2122 char fontstatic[256];
2124 struct servent *service;
2126 static UINT draglistmsg = WM_NULL;
2131 SetWindowLong(hwnd, GWL_USERDATA, 0);
2133 SetWindowLong(hwnd, GWL_EXSTYLE,
2134 GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
2136 HWND item = GetDlgItem(hwnd, IDC_HELPBTN);
2138 DestroyWindow(item);
2140 requested_help = FALSE;
2141 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
2142 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
2144 * Centre the window.
2146 { /* centre the window */
2149 hw = GetDesktopWindow();
2150 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
2152 (rs.right + rs.left + rd.left - rd.right) / 2,
2153 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
2154 rd.right - rd.left, rd.bottom - rd.top, TRUE);
2158 * Create the tree view.
2166 r.right = r.left + 75;
2168 r.bottom = r.top + 10;
2169 MapDialogRect(hwnd, &r);
2170 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
2171 WS_CHILD | WS_VISIBLE,
2173 r.right - r.left, r.bottom - r.top,
2174 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
2176 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
2177 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2180 r.right = r.left + 75;
2182 r.bottom = r.top + 219;
2183 MapDialogRect(hwnd, &r);
2184 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
2185 WS_CHILD | WS_VISIBLE |
2186 WS_TABSTOP | TVS_HASLINES |
2187 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
2189 TVS_SHOWSELALWAYS, r.left, r.top,
2190 r.right - r.left, r.bottom - r.top,
2191 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
2193 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
2194 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
2195 tvfaff.treeview = treeview;
2196 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
2200 * Set up the tree view contents.
2202 hsession = treeview_insert(&tvfaff, 0, "Session");
2203 treeview_insert(&tvfaff, 1, "Logging");
2204 treeview_insert(&tvfaff, 0, "Terminal");
2205 treeview_insert(&tvfaff, 1, "Keyboard");
2206 treeview_insert(&tvfaff, 1, "Bell");
2207 treeview_insert(&tvfaff, 1, "Features");
2208 treeview_insert(&tvfaff, 0, "Window");
2209 treeview_insert(&tvfaff, 1, "Appearance");
2210 treeview_insert(&tvfaff, 1, "Behaviour");
2211 treeview_insert(&tvfaff, 1, "Translation");
2212 treeview_insert(&tvfaff, 1, "Selection");
2213 treeview_insert(&tvfaff, 1, "Colours");
2214 treeview_insert(&tvfaff, 0, "Connection");
2216 treeview_insert(&tvfaff, 1, "Proxy");
2217 treeview_insert(&tvfaff, 1, "Telnet");
2218 treeview_insert(&tvfaff, 1, "Rlogin");
2219 if (backends[3].backend != NULL) {
2220 treeview_insert(&tvfaff, 1, "SSH");
2221 /* XXX long name is ugly */
2222 /* XXX make it closed by default? */
2223 treeview_insert(&tvfaff, 2, "Auth");
2224 treeview_insert(&tvfaff, 2, "Tunnels");
2225 treeview_insert(&tvfaff, 2, "Bugs");
2230 * Put the treeview selection on to the Session panel. This
2231 * should also cause creation of the relevant controls.
2233 TreeView_SelectItem(treeview, hsession);
2236 * Set focus into the first available control.
2240 ctl = GetDlgItem(hwnd, IDC_HOST);
2242 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
2246 SetWindowLong(hwnd, GWL_USERDATA, 1);
2247 sesslist_has_focus = 0;
2251 * Button release should trigger WM_OK if there was a
2252 * previous double click on the session list.
2256 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
2259 if (LOWORD(wParam) == IDCX_TREEVIEW &&
2260 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
2262 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
2267 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
2270 item.pszText = buffer;
2271 item.cchTextMax = sizeof(buffer);
2272 item.mask = TVIF_TEXT;
2273 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
2274 for (j = controlstartvalue; j < controlendvalue; j++) {
2275 HWND item = GetDlgItem(hwnd, j);
2277 DestroyWindow(item);
2279 if (!strcmp(buffer, "Session"))
2280 create_controls(hwnd, dlgtype, sessionpanelstart);
2281 if (!strcmp(buffer, "Logging"))
2282 create_controls(hwnd, dlgtype, loggingpanelstart);
2283 if (!strcmp(buffer, "Keyboard"))
2284 create_controls(hwnd, dlgtype, keyboardpanelstart);
2285 if (!strcmp(buffer, "Terminal"))
2286 create_controls(hwnd, dlgtype, terminalpanelstart);
2287 if (!strcmp(buffer, "Bell"))
2288 create_controls(hwnd, dlgtype, bellpanelstart);
2289 if (!strcmp(buffer, "Features"))
2290 create_controls(hwnd, dlgtype, featurespanelstart);
2291 if (!strcmp(buffer, "Window"))
2292 create_controls(hwnd, dlgtype, windowpanelstart);
2293 if (!strcmp(buffer, "Appearance"))
2294 create_controls(hwnd, dlgtype, appearancepanelstart);
2295 if (!strcmp(buffer, "Behaviour"))
2296 create_controls(hwnd, dlgtype, behaviourpanelstart);
2297 if (!strcmp(buffer, "Tunnels"))
2298 create_controls(hwnd, dlgtype, tunnelspanelstart);
2299 if (!strcmp(buffer, "Connection"))
2300 create_controls(hwnd, dlgtype, connectionpanelstart);
2301 if (!strcmp(buffer, "Proxy"))
2302 create_controls(hwnd, dlgtype, proxypanelstart);
2303 if (!strcmp(buffer, "Telnet"))
2304 create_controls(hwnd, dlgtype, telnetpanelstart);
2305 if (!strcmp(buffer, "Rlogin"))
2306 create_controls(hwnd, dlgtype, rloginpanelstart);
2307 if (!strcmp(buffer, "SSH"))
2308 create_controls(hwnd, dlgtype, sshpanelstart);
2309 if (!strcmp(buffer, "Auth"))
2310 create_controls(hwnd, dlgtype, sshauthpanelstart);
2311 if (!strcmp(buffer, "Bugs"))
2312 create_controls(hwnd, dlgtype, sshbugspanelstart);
2313 if (!strcmp(buffer, "Selection"))
2314 create_controls(hwnd, dlgtype, selectionpanelstart);
2315 if (!strcmp(buffer, "Colours"))
2316 create_controls(hwnd, dlgtype, colourspanelstart);
2317 if (!strcmp(buffer, "Translation"))
2318 create_controls(hwnd, dlgtype, translationpanelstart);
2320 init_dlg_ctrls(hwnd, FALSE);
2322 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
2323 InvalidateRect (hwnd, NULL, TRUE);
2325 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
2331 * Only process WM_COMMAND once the dialog is fully formed.
2333 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
2334 switch (LOWORD(wParam)) {
2336 /* Behaviour of the "Open" button is different if the
2337 * session list has focus, *unless* the user just
2338 * double-clicked... */
2339 if (sesslist_has_focus && !readytogo) {
2340 if (!load_selected_session(hwnd)) {
2345 /* If at this point we have a valid session, go! */
2347 if (requested_help) {
2348 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2349 requested_help = FALSE;
2356 if (HIWORD(wParam) == BN_CLICKED ||
2357 HIWORD(wParam) == BN_DOUBLECLICKED) {
2359 WinHelp(hwnd, help_path,
2360 help_has_contents ? HELP_FINDER : HELP_CONTENTS,
2362 requested_help = TRUE;
2367 if (requested_help) {
2368 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2369 requested_help = FALSE;
2373 case IDC_PROTTELNET:
2374 case IDC_PROTRLOGIN:
2377 if (HIWORD(wParam) == BN_CLICKED ||
2378 HIWORD(wParam) == BN_DOUBLECLICKED) {
2379 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
2380 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
2381 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
2383 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
2386 * When switching using the arrow keys, we
2387 * appear to get two of these messages, both
2388 * mentioning the target button in
2389 * LOWORD(wParam), but one of them called while
2390 * the previous button is still checked. This
2391 * causes an unnecessary reset of the port
2392 * number field, which we fix by ensuring here
2393 * that the button selected is indeed the one
2396 if (IsDlgButtonChecked(hwnd, LOWORD(wParam)) &&
2397 ((cfg.protocol == PROT_SSH && cfg.port != 22)
2398 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
2399 || (cfg.protocol == PROT_RLOGIN
2400 && cfg.port != 513))) {
2401 cfg.port = i ? 22 : j ? 23 : 513;
2402 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
2407 if (HIWORD(wParam) == EN_CHANGE)
2408 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
2409 sizeof(cfg.host) - 1);
2412 if (HIWORD(wParam) == EN_CHANGE) {
2413 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
2414 if (isdigit(portname[0]))
2415 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
2417 service = getservbyname(portname, NULL);
2419 cfg.port = ntohs(service->s_port);
2426 if (HIWORD(wParam) == EN_CHANGE) {
2427 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2429 GetDlgItemText(hwnd, IDC_SESSEDIT,
2430 savedsession, sizeof(savedsession) - 1);
2431 savedsession[sizeof(savedsession) - 1] = '\0';
2435 if (HIWORD(wParam) == BN_CLICKED ||
2436 HIWORD(wParam) == BN_DOUBLECLICKED) {
2441 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
2444 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2445 LB_GETCURSEL, 0, 0);
2450 strcpy(str, sesslist.sessions[n]);
2452 save_settings(str, !!strcmp(str, "Default Settings"),
2454 get_sesslist(&sesslist, FALSE);
2455 get_sesslist(&sesslist, TRUE);
2456 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2458 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2460 for (i = 0; i < sesslist.nsessions; i++)
2461 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2463 (LPARAM) (sesslist.sessions[i]));
2464 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2466 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2468 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2474 if (LOWORD(wParam) == IDC_SESSLIST) {
2475 if (HIWORD(wParam) == LBN_SETFOCUS)
2476 sesslist_has_focus = 1;
2477 else if (HIWORD(wParam) == LBN_KILLFOCUS)
2478 sesslist_has_focus = 0;
2480 if (LOWORD(wParam) == IDC_SESSLOAD &&
2481 HIWORD(wParam) != BN_CLICKED &&
2482 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2483 if (LOWORD(wParam) == IDC_SESSLIST &&
2484 HIWORD(wParam) != LBN_DBLCLK) break;
2485 /* Load the session selected in SESSLIST. */
2486 if (load_selected_session(hwnd) &&
2487 LOWORD(wParam) == IDC_SESSLIST) {
2489 * A double-click on a saved session should
2490 * actually start the session, not just load it.
2491 * Unless it's Default Settings or some other
2492 * host-less set of saved settings.
2501 if (HIWORD(wParam) == BN_CLICKED ||
2502 HIWORD(wParam) == BN_DOUBLECLICKED) {
2503 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2504 LB_GETCURSEL, 0, 0);
2505 if (n == LB_ERR || n == 0) {
2509 del_settings(sesslist.sessions[n]);
2510 get_sesslist(&sesslist, FALSE);
2511 get_sesslist(&sesslist, TRUE);
2512 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2514 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2516 for (i = 0; i < sesslist.nsessions; i++)
2517 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2519 (LPARAM) (sesslist.sessions[i]));
2520 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2522 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2524 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2528 if (HIWORD(wParam) == EN_CHANGE)
2529 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
2530 &cfg.ping_interval);
2533 if (HIWORD(wParam) == BN_CLICKED ||
2534 HIWORD(wParam) == BN_DOUBLECLICKED)
2536 IsDlgButtonChecked(hwnd, IDC_NODELAY);
2540 if (HIWORD(wParam) == BN_CLICKED ||
2541 HIWORD(wParam) == BN_DOUBLECLICKED)
2542 cfg.bksp_is_delete =
2543 IsDlgButtonChecked(hwnd, IDC_DEL127);
2547 if (HIWORD(wParam) == BN_CLICKED ||
2548 HIWORD(wParam) == BN_DOUBLECLICKED)
2550 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
2556 case IDC_FUNCVT100P:
2558 if (HIWORD(wParam) == BN_CLICKED ||
2559 HIWORD(wParam) == BN_DOUBLECLICKED)
2560 switch (LOWORD(wParam)) {
2573 case IDC_FUNCVT100P:
2583 if (HIWORD(wParam) == BN_CLICKED ||
2584 HIWORD(wParam) == BN_DOUBLECLICKED) {
2586 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
2587 cfg.nethack_keypad = FALSE;
2591 if (HIWORD(wParam) == BN_CLICKED ||
2592 HIWORD(wParam) == BN_DOUBLECLICKED) {
2593 cfg.app_keypad = FALSE;
2594 cfg.nethack_keypad = TRUE;
2599 if (HIWORD(wParam) == BN_CLICKED ||
2600 HIWORD(wParam) == BN_DOUBLECLICKED)
2602 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
2605 if (HIWORD(wParam) == BN_CLICKED ||
2606 HIWORD(wParam) == BN_DOUBLECLICKED)
2608 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
2611 if (HIWORD(wParam) == BN_CLICKED ||
2612 HIWORD(wParam) == BN_DOUBLECLICKED)
2614 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
2616 case IDC_NOMOUSEREP:
2617 if (HIWORD(wParam) == BN_CLICKED ||
2618 HIWORD(wParam) == BN_DOUBLECLICKED)
2620 IsDlgButtonChecked(hwnd, IDC_NOMOUSEREP);
2623 if (HIWORD(wParam) == BN_CLICKED ||
2624 HIWORD(wParam) == BN_DOUBLECLICKED)
2625 cfg.no_remote_resize =
2626 IsDlgButtonChecked(hwnd, IDC_NORESIZE);
2628 case IDC_NOALTSCREEN:
2629 if (HIWORD(wParam) == BN_CLICKED ||
2630 HIWORD(wParam) == BN_DOUBLECLICKED)
2632 IsDlgButtonChecked(hwnd, IDC_NOALTSCREEN);
2634 case IDC_NOWINTITLE:
2635 if (HIWORD(wParam) == BN_CLICKED ||
2636 HIWORD(wParam) == BN_DOUBLECLICKED)
2637 cfg.no_remote_wintitle =
2638 IsDlgButtonChecked(hwnd, IDC_NOWINTITLE);
2640 case IDC_NODBACKSPACE:
2641 if (HIWORD(wParam) == BN_CLICKED ||
2642 HIWORD(wParam) == BN_DOUBLECLICKED)
2644 IsDlgButtonChecked(hwnd, IDC_NODBACKSPACE);
2647 if (HIWORD(wParam) == BN_CLICKED ||
2648 HIWORD(wParam) == BN_DOUBLECLICKED)
2649 cfg.no_remote_charset =
2650 IsDlgButtonChecked(hwnd, IDC_NOCHARSET);
2653 if (HIWORD(wParam) == BN_CLICKED ||
2654 HIWORD(wParam) == BN_DOUBLECLICKED)
2655 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
2658 if (HIWORD(wParam) == BN_CLICKED ||
2659 HIWORD(wParam) == BN_DOUBLECLICKED)
2661 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
2664 if (HIWORD(wParam) == BN_CLICKED ||
2665 HIWORD(wParam) == BN_DOUBLECLICKED)
2667 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
2669 case IDC_ECHOBACKEND:
2672 if (HIWORD(wParam) == BN_CLICKED ||
2673 HIWORD(wParam) == BN_DOUBLECLICKED) {
2674 if (LOWORD(wParam) == IDC_ECHOBACKEND)
2675 cfg.localecho = AUTO;
2676 if (LOWORD(wParam) == IDC_ECHOYES)
2677 cfg.localecho = FORCE_ON;
2678 if (LOWORD(wParam) == IDC_ECHONO)
2679 cfg.localecho = FORCE_OFF;
2682 case IDC_EDITBACKEND:
2685 if (HIWORD(wParam) == BN_CLICKED ||
2686 HIWORD(wParam) == BN_DOUBLECLICKED) {
2687 if (LOWORD(wParam) == IDC_EDITBACKEND)
2688 cfg.localedit = AUTO;
2689 if (LOWORD(wParam) == IDC_EDITYES)
2690 cfg.localedit = FORCE_ON;
2691 if (LOWORD(wParam) == IDC_EDITNO)
2692 cfg.localedit = FORCE_OFF;
2695 case IDC_ANSWEREDIT:
2696 if (HIWORD(wParam) == EN_CHANGE)
2697 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
2698 sizeof(cfg.answerback) - 1);
2700 case IDC_ALWAYSONTOP:
2701 if (HIWORD(wParam) == BN_CLICKED ||
2702 HIWORD(wParam) == BN_DOUBLECLICKED)
2704 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
2706 case IDC_FULLSCREENONALTENTER:
2707 if (HIWORD(wParam) == BN_CLICKED ||
2708 HIWORD(wParam) == BN_DOUBLECLICKED)
2709 cfg.fullscreenonaltenter =
2710 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
2713 if (HIWORD(wParam) == BN_CLICKED ||
2714 HIWORD(wParam) == BN_DOUBLECLICKED)
2716 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
2718 case IDC_SCROLLDISP:
2719 if (HIWORD(wParam) == BN_CLICKED ||
2720 HIWORD(wParam) == BN_DOUBLECLICKED)
2721 cfg.scroll_on_disp =
2722 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
2724 case IDC_COMPOSEKEY:
2725 if (HIWORD(wParam) == BN_CLICKED ||
2726 HIWORD(wParam) == BN_DOUBLECLICKED)
2728 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
2730 case IDC_CTRLALTKEYS:
2731 if (HIWORD(wParam) == BN_CLICKED ||
2732 HIWORD(wParam) == BN_DOUBLECLICKED)
2734 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
2737 if (HIWORD(wParam) == BN_CLICKED ||
2738 HIWORD(wParam) == BN_DOUBLECLICKED)
2739 cfg.telnet_keyboard =
2740 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
2743 if (HIWORD(wParam) == BN_CLICKED ||
2744 HIWORD(wParam) == BN_DOUBLECLICKED)
2745 cfg.telnet_newline =
2746 IsDlgButtonChecked(hwnd, IDC_TELNETRET);
2749 if (HIWORD(wParam) == BN_CLICKED ||
2750 HIWORD(wParam) == BN_DOUBLECLICKED)
2752 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
2755 if (HIWORD(wParam) == BN_CLICKED ||
2756 HIWORD(wParam) == BN_DOUBLECLICKED)
2757 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
2760 if (HIWORD(wParam) == BN_CLICKED ||
2761 HIWORD(wParam) == BN_DOUBLECLICKED)
2763 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
2766 if (HIWORD(wParam) == EN_CHANGE)
2767 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
2770 if (HIWORD(wParam) == EN_CHANGE)
2771 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
2774 if (HIWORD(wParam) == EN_CHANGE)
2775 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
2777 case IDC_CHOOSEFONT:
2780 lf.lfHeight = -MulDiv(cfg.fontheight,
2781 GetDeviceCaps(hdc, LOGPIXELSY),
2785 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
2786 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
2787 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
2788 lf.lfCharSet = cfg.fontcharset;
2789 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
2790 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
2791 lf.lfQuality = DEFAULT_QUALITY;
2792 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
2793 strncpy(lf.lfFaceName, cfg.font,
2794 sizeof(lf.lfFaceName) - 1);
2795 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
2797 cf.lStructSize = sizeof(cf);
2798 cf.hwndOwner = hwnd;
2800 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
2801 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
2803 if (ChooseFont(&cf)) {
2804 strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
2805 cfg.font[sizeof(cfg.font) - 1] = '\0';
2806 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
2807 cfg.fontcharset = lf.lfCharSet;
2808 cfg.fontheight = cf.iPointSize / 10;
2809 fmtfont(fontstatic);
2810 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
2813 case IDC_BELL_DISABLED:
2814 case IDC_BELL_DEFAULT:
2815 case IDC_BELL_WAVEFILE:
2816 case IDC_BELL_VISUAL:
2817 if (HIWORD(wParam) == BN_CLICKED ||
2818 HIWORD(wParam) == BN_DOUBLECLICKED) {
2819 if (LOWORD(wParam) == IDC_BELL_DISABLED)
2820 cfg.beep = BELL_DISABLED;
2821 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
2822 cfg.beep = BELL_DEFAULT;
2823 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
2824 cfg.beep = BELL_WAVEFILE;
2825 if (LOWORD(wParam) == IDC_BELL_VISUAL)
2826 cfg.beep = BELL_VISUAL;
2829 case IDC_B_IND_DISABLED:
2830 case IDC_B_IND_FLASH:
2831 case IDC_B_IND_STEADY:
2832 if (HIWORD(wParam) == BN_CLICKED ||
2833 HIWORD(wParam) == BN_DOUBLECLICKED) {
2834 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2835 cfg.beep_ind = B_IND_DISABLED;
2836 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2837 cfg.beep_ind = B_IND_FLASH;
2838 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2839 cfg.beep_ind = B_IND_STEADY;
2842 case IDC_BELL_WAVEBROWSE:
2843 memset(&of, 0, sizeof(of));
2844 #ifdef OPENFILENAME_SIZE_VERSION_400
2845 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2847 of.lStructSize = sizeof(of);
2849 of.hwndOwner = hwnd;
2850 of.lpstrFilter = "Wave Files (*.wav)\0*.WAV\0"
2851 "All Files (*.*)\0*\0\0\0";
2852 of.lpstrCustomFilter = NULL;
2853 of.nFilterIndex = 1;
2854 of.lpstrFile = filename;
2855 strcpy(filename, cfg.bell_wavefile);
2856 of.nMaxFile = sizeof(filename);
2857 of.lpstrFileTitle = NULL;
2858 of.lpstrInitialDir = NULL;
2859 of.lpstrTitle = "Select Bell Sound File";
2861 if (GetOpenFileName(&of)) {
2862 strcpy(cfg.bell_wavefile, filename);
2863 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2867 case IDC_BELL_WAVEEDIT:
2868 if (HIWORD(wParam) == EN_CHANGE)
2869 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2871 sizeof(cfg.bell_wavefile) - 1);
2874 if (HIWORD(wParam) == BN_CLICKED ||
2875 HIWORD(wParam) == BN_DOUBLECLICKED)
2877 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2880 if (HIWORD(wParam) == EN_CHANGE)
2881 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2884 if (HIWORD(wParam) == EN_CHANGE)
2885 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2889 if (HIWORD(wParam) == EN_CHANGE)
2890 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2894 if (HIWORD(wParam) == BN_CLICKED ||
2895 HIWORD(wParam) == BN_DOUBLECLICKED)
2897 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2900 if (HIWORD(wParam) == BN_CLICKED ||
2901 HIWORD(wParam) == BN_DOUBLECLICKED)
2902 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2905 if (HIWORD(wParam) == BN_CLICKED ||
2906 HIWORD(wParam) == BN_DOUBLECLICKED)
2907 cfg.win_name_always =
2908 !IsDlgButtonChecked(hwnd, IDC_WINNAME);
2911 if (HIWORD(wParam) == BN_CLICKED ||
2912 HIWORD(wParam) == BN_DOUBLECLICKED)
2914 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2916 case IDC_SUNKENEDGE:
2917 if (HIWORD(wParam) == BN_CLICKED ||
2918 HIWORD(wParam) == BN_DOUBLECLICKED)
2920 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2923 if (HIWORD(wParam) == EN_CHANGE)
2924 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2925 &cfg.window_border);
2926 if (cfg.window_border > 32)
2927 cfg.window_border = 32;
2930 if (HIWORD(wParam) == BN_CLICKED ||
2931 HIWORD(wParam) == BN_DOUBLECLICKED)
2932 cfg.cursor_type = 0;
2935 if (HIWORD(wParam) == BN_CLICKED ||
2936 HIWORD(wParam) == BN_DOUBLECLICKED)
2937 cfg.cursor_type = 1;
2940 if (HIWORD(wParam) == BN_CLICKED ||
2941 HIWORD(wParam) == BN_DOUBLECLICKED)
2942 cfg.cursor_type = 2;
2945 if (HIWORD(wParam) == BN_CLICKED ||
2946 HIWORD(wParam) == BN_DOUBLECLICKED)
2948 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2951 if (HIWORD(wParam) == BN_CLICKED ||
2952 HIWORD(wParam) == BN_DOUBLECLICKED)
2954 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2956 case IDC_SCROLLBARFULLSCREEN:
2957 if (HIWORD(wParam) == BN_CLICKED ||
2958 HIWORD(wParam) == BN_DOUBLECLICKED)
2959 cfg.scrollbar_in_fullscreen =
2960 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2962 case IDC_RESIZETERM:
2963 case IDC_RESIZEFONT:
2964 case IDC_RESIZENONE:
2965 case IDC_RESIZEEITHER:
2966 if (HIWORD(wParam) == BN_CLICKED ||
2967 HIWORD(wParam) == BN_DOUBLECLICKED) {
2969 IsDlgButtonChecked(hwnd,
2970 IDC_RESIZETERM) ? RESIZE_TERM :
2971 IsDlgButtonChecked(hwnd,
2972 IDC_RESIZEFONT) ? RESIZE_FONT :
2973 IsDlgButtonChecked(hwnd,
2974 IDC_RESIZEEITHER) ? RESIZE_EITHER :
2979 if (HIWORD(wParam) == EN_CHANGE)
2980 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2981 sizeof(cfg.wintitle) - 1);
2986 if (HIWORD(wParam) == BN_CLICKED ||
2987 HIWORD(wParam) == BN_DOUBLECLICKED) {
2989 IsDlgButtonChecked(hwnd,
2990 IDC_COEALWAYS) ? FORCE_ON :
2991 IsDlgButtonChecked(hwnd,
2992 IDC_COENEVER) ? FORCE_OFF :
2997 if (HIWORD(wParam) == BN_CLICKED ||
2998 HIWORD(wParam) == BN_DOUBLECLICKED)
3000 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
3003 if (HIWORD(wParam) == EN_CHANGE)
3004 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
3005 sizeof(cfg.termtype) - 1);
3009 case IDC_PROXYHOSTEDIT:
3010 if (HIWORD(wParam) == EN_CHANGE)
3011 GetDlgItemText(hwnd, IDC_PROXYHOSTEDIT, cfg.proxy_host,
3012 sizeof(cfg.proxy_host) - 1);
3014 case IDC_PROXYPORTEDIT:
3015 if (HIWORD(wParam) == EN_CHANGE) {
3016 GetDlgItemText(hwnd, IDC_PROXYPORTEDIT, portname, 31);
3017 if (isdigit(portname[0]))
3018 MyGetDlgItemInt(hwnd, IDC_PROXYPORTEDIT, &cfg.proxy_port);
3020 service = getservbyname(portname, NULL);
3022 cfg.proxy_port = ntohs(service->s_port);
3028 case IDC_PROXYEXCLUDEEDIT:
3029 if (HIWORD(wParam) == EN_CHANGE)
3030 GetDlgItemText(hwnd, IDC_PROXYEXCLUDEEDIT,
3031 cfg.proxy_exclude_list,
3032 sizeof(cfg.proxy_exclude_list) - 1);
3034 case IDC_PROXYUSEREDIT:
3035 if (HIWORD(wParam) == EN_CHANGE)
3036 GetDlgItemText(hwnd, IDC_PROXYUSEREDIT,
3038 sizeof(cfg.proxy_username) - 1);
3040 case IDC_PROXYPASSEDIT:
3041 if (HIWORD(wParam) == EN_CHANGE)
3042 GetDlgItemText(hwnd, IDC_PROXYPASSEDIT,
3044 sizeof(cfg.proxy_password) - 1);
3046 case IDC_PROXYTELNETCMDEDIT:
3047 if (HIWORD(wParam) == EN_CHANGE)
3048 GetDlgItemText(hwnd, IDC_PROXYTELNETCMDEDIT,
3049 cfg.proxy_telnet_command,
3050 sizeof(cfg.proxy_telnet_command) - 1);
3052 case IDC_PROXYSOCKSVER5:
3053 case IDC_PROXYSOCKSVER4:
3054 if (HIWORD(wParam) == BN_CLICKED ||
3055 HIWORD(wParam) == BN_DOUBLECLICKED) {
3056 cfg.proxy_socks_version =
3057 IsDlgButtonChecked(hwnd, IDC_PROXYSOCKSVER4) ? 4 : 5;
3060 case IDC_PROXYLOCALHOST:
3061 if (HIWORD(wParam) == BN_CLICKED ||
3062 HIWORD(wParam) == BN_DOUBLECLICKED)
3063 cfg.even_proxy_localhost =
3064 IsDlgButtonChecked(hwnd, IDC_PROXYLOCALHOST);
3066 case IDC_PROXYDNSNO:
3067 case IDC_PROXYDNSAUTO:
3068 case IDC_PROXYDNSYES:
3069 if (HIWORD(wParam) == BN_CLICKED ||
3070 HIWORD(wParam) == BN_DOUBLECLICKED) {
3072 IsDlgButtonChecked(hwnd, IDC_PROXYDNSNO) ? FORCE_OFF :
3073 IsDlgButtonChecked(hwnd, IDC_PROXYDNSYES) ? FORCE_ON :
3077 case IDC_PROXYTYPENONE:
3078 case IDC_PROXYTYPEHTTP:
3079 case IDC_PROXYTYPESOCKS:
3080 case IDC_PROXYTYPETELNET:
3081 if (HIWORD(wParam) == BN_CLICKED ||
3082 HIWORD(wParam) == BN_DOUBLECLICKED) {
3084 IsDlgButtonChecked(hwnd, IDC_PROXYTYPEHTTP) ? PROXY_HTTP :
3085 IsDlgButtonChecked(hwnd, IDC_PROXYTYPESOCKS) ? PROXY_SOCKS :
3086 IsDlgButtonChecked(hwnd, IDC_PROXYTYPETELNET) ? PROXY_TELNET :
3092 if (HIWORD(wParam) == EN_CHANGE)
3093 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
3094 sizeof(cfg.logfilename) - 1);
3097 memset(&of, 0, sizeof(of));
3098 #ifdef OPENFILENAME_SIZE_VERSION_400
3099 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3101 of.lStructSize = sizeof(of);
3103 of.hwndOwner = hwnd;
3104 of.lpstrFilter = "All Files (*.*)\0*\0\0\0";
3105 of.lpstrCustomFilter = NULL;
3106 of.nFilterIndex = 1;
3107 of.lpstrFile = filename;
3108 strcpy(filename, cfg.logfilename);
3109 of.nMaxFile = sizeof(filename);
3110 of.lpstrFileTitle = NULL;
3111 of.lpstrInitialDir = NULL;
3112 of.lpstrTitle = "Select session log file";
3114 if (GetSaveFileName(&of)) {
3115 strcpy(cfg.logfilename, filename);
3116 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
3120 case IDC_LSTATASCII:
3122 case IDC_LSTATPACKET:
3123 if (HIWORD(wParam) == BN_CLICKED ||
3124 HIWORD(wParam) == BN_DOUBLECLICKED) {
3125 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
3126 cfg.logtype = LGTYP_NONE;
3127 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
3128 cfg.logtype = LGTYP_ASCII;
3129 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
3130 cfg.logtype = LGTYP_DEBUG;
3131 if (IsDlgButtonChecked(hwnd, IDC_LSTATPACKET))
3132 cfg.logtype = LGTYP_PACKETS;
3138 if (HIWORD(wParam) == BN_CLICKED ||
3139 HIWORD(wParam) == BN_DOUBLECLICKED) {
3140 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
3141 cfg.logxfovr = LGXF_ASK;
3142 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
3143 cfg.logxfovr = LGXF_APN;
3144 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
3145 cfg.logxfovr = LGXF_OVR;
3150 if (HIWORD(wParam) == EN_CHANGE)
3151 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
3152 sizeof(cfg.termspeed) - 1);
3155 if (HIWORD(wParam) == EN_CHANGE)
3156 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
3157 sizeof(cfg.username) - 1);
3159 case IDC_RLLUSEREDIT:
3160 if (HIWORD(wParam) == EN_CHANGE)
3161 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
3163 sizeof(cfg.localusername) - 1);
3167 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
3171 cfg.passive_telnet =
3172 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
3175 if (HIWORD(wParam) == BN_CLICKED ||
3176 HIWORD(wParam) == BN_DOUBLECLICKED) {
3177 char str[sizeof(cfg.environmt)];
3179 GetDlgItemText(hwnd, IDC_VAREDIT, str,
3185 p = str + strlen(str);
3187 GetDlgItemText(hwnd, IDC_VALEDIT, p,
3188 sizeof(str) - 1 - (p - str));
3199 if ((p - cfg.environmt) + strlen(str) + 2 <
3200 sizeof(cfg.environmt)) {
3202 p[strlen(str) + 1] = '\0';
3203 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
3205 SetDlgItemText(hwnd, IDC_VAREDIT, "");
3206 SetDlgItemText(hwnd, IDC_VALEDIT, "");
3208 MessageBox(hwnd, "Environment too big",
3209 "PuTTY Error", MB_OK | MB_ICONERROR);
3214 if (HIWORD(wParam) != BN_CLICKED &&
3215 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3217 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
3224 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
3251 if (HIWORD(wParam) == BN_CLICKED ||
3252 HIWORD(wParam) == BN_DOUBLECLICKED)
3253 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
3256 if (HIWORD(wParam) == BN_CLICKED ||
3257 HIWORD(wParam) == BN_DOUBLECLICKED)
3259 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
3262 if (HIWORD(wParam) == BN_CLICKED ||
3263 HIWORD(wParam) == BN_DOUBLECLICKED)
3265 IsDlgButtonChecked(hwnd, IDC_SSH2DES);
3268 if (HIWORD(wParam) == BN_CLICKED ||
3269 HIWORD(wParam) == BN_DOUBLECLICKED)
3271 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
3273 case IDC_CHANGEUSER:
3274 if (HIWORD(wParam) == BN_CLICKED ||
3275 HIWORD(wParam) == BN_DOUBLECLICKED)
3276 cfg.change_username =
3277 IsDlgButtonChecked(hwnd, IDC_CHANGEUSER);
3279 case IDC_CIPHERLIST:
3282 handle_prefslist(&cipherlist,
3283 cfg.ssh_cipherlist, CIPHER_MAX,
3284 0, hwnd, wParam, lParam);
3286 case IDC_SSHPROT1ONLY:
3289 case IDC_SSHPROT2ONLY:
3290 if (HIWORD(wParam) == BN_CLICKED ||
3291 HIWORD(wParam) == BN_DOUBLECLICKED) {
3292 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1ONLY))
3294 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
3296 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
3298 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2ONLY))
3303 if (HIWORD(wParam) == BN_CLICKED ||
3304 HIWORD(wParam) == BN_DOUBLECLICKED)
3306 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
3309 if (HIWORD(wParam) == BN_CLICKED ||
3310 HIWORD(wParam) == BN_DOUBLECLICKED)
3312 IsDlgButtonChecked(hwnd, IDC_AUTHKI);
3315 if (HIWORD(wParam) == EN_CHANGE)
3316 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
3317 sizeof(cfg.keyfile) - 1);
3320 if (HIWORD(wParam) == EN_CHANGE)
3321 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
3322 sizeof(cfg.remote_cmd) - 1);
3325 memset(&of, 0, sizeof(of));
3326 #ifdef OPENFILENAME_SIZE_VERSION_400
3327 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
3329 of.lStructSize = sizeof(of);
3331 of.hwndOwner = hwnd;
3332 of.lpstrFilter = "PuTTY Private Key Files (*.ppk)\0*.ppk\0"
3333 "All Files (*.*)\0*\0\0\0";
3334 of.lpstrCustomFilter = NULL;
3335 of.nFilterIndex = 1;
3336 of.lpstrFile = filename;
3337 strcpy(filename, cfg.keyfile);
3338 of.nMaxFile = sizeof(filename);
3339 of.lpstrFileTitle = NULL;
3340 of.lpstrInitialDir = NULL;
3341 of.lpstrTitle = "Select Private Key File";
3343 if (GetOpenFileName(&of)) {
3344 strcpy(cfg.keyfile, filename);
3345 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
3349 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
3352 cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
3356 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
3358 case IDC_SELTYPELEX:
3359 case IDC_SELTYPERECT:
3360 cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
3362 case IDC_MOUSEOVERRIDE:
3363 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
3369 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
3374 for (i = 0; i < 128; i++)
3375 if (SendDlgItemMessage
3376 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
3378 cfg.wordness[i] = n;
3379 SendDlgItemMessage(hwnd, IDC_CCLIST,
3380 LB_DELETESTRING, i, 0);
3381 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
3382 (i >= 0x21 && i != 0x7F) ? i : ' ',
3384 SendDlgItemMessage(hwnd, IDC_CCLIST,
3391 case IDC_BOLDCOLOUR:
3392 if (HIWORD(wParam) == BN_CLICKED ||
3393 HIWORD(wParam) == BN_DOUBLECLICKED) {
3396 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
3400 if (HIWORD(wParam) == BN_CLICKED ||
3401 HIWORD(wParam) == BN_DOUBLECLICKED)
3403 IsDlgButtonChecked(hwnd, IDC_PALETTE);
3405 case IDC_COLOURLIST:
3406 if (HIWORD(wParam) == LBN_DBLCLK ||
3407 HIWORD(wParam) == LBN_SELCHANGE) {
3409 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3412 if (!cfg.bold_colour)
3413 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3414 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3416 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3418 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3423 if (HIWORD(wParam) == BN_CLICKED ||
3424 HIWORD(wParam) == BN_DOUBLECLICKED) {
3425 static CHOOSECOLOR cc;
3426 static DWORD custom[16] = { 0 }; /* zero initialisers */
3428 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
3431 if (!cfg.bold_colour)
3432 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
3433 cc.lStructSize = sizeof(cc);
3434 cc.hwndOwner = hwnd;
3435 cc.hInstance = (HWND) hinst;
3436 cc.lpCustColors = custom;
3438 RGB(cfg.colours[i][0], cfg.colours[i][1],
3440 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
3441 if (ChooseColor(&cc)) {
3443 (unsigned char) (cc.rgbResult & 0xFF);
3445 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
3447 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
3448 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
3450 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
3452 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
3458 if (HIWORD(wParam) == CBN_SELCHANGE) {
3459 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
3460 CB_GETCURSEL, 0, 0);
3461 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
3462 index, (LPARAM)cfg.line_codepage);
3463 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3464 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
3465 sizeof(cfg.line_codepage) - 1);
3466 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
3467 strcpy(cfg.line_codepage,
3468 cp_name(decode_codepage(cfg.line_codepage)));
3469 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
3473 if (HIWORD(wParam) == CBN_SELCHANGE) {
3474 int index = SendDlgItemMessage(hwnd, IDC_PRINTER,
3475 CB_GETCURSEL, 0, 0);
3476 SendDlgItemMessage(hwnd, IDC_PRINTER, CB_GETLBTEXT,
3477 index, (LPARAM)cfg.printer);
3478 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
3479 GetDlgItemText(hwnd, IDC_PRINTER, cfg.printer,
3480 sizeof(cfg.printer) - 1);
3482 if (!strcmp(cfg.printer, PRINTER_DISABLED_STRING))
3483 *cfg.printer = '\0';
3485 case IDC_CAPSLOCKCYR:
3486 if (HIWORD(wParam) == BN_CLICKED ||
3487 HIWORD(wParam) == BN_DOUBLECLICKED) {
3488 cfg.xlat_capslockcyr =
3489 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
3492 case IDC_VTXWINDOWS:
3498 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
3499 : IsDlgButtonChecked(hwnd,
3500 IDC_VTOEMANSI) ? VT_OEMANSI :
3501 IsDlgButtonChecked(hwnd,
3502 IDC_VTOEMONLY) ? VT_OEMONLY :
3503 IsDlgButtonChecked(hwnd,
3504 IDC_VTUNICODE) ? VT_UNICODE :
3507 case IDC_X11_FORWARD:
3508 if (HIWORD(wParam) == BN_CLICKED ||
3509 HIWORD(wParam) == BN_DOUBLECLICKED)
3511 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
3514 if (HIWORD(wParam) == BN_CLICKED ||
3515 HIWORD(wParam) == BN_DOUBLECLICKED)
3516 cfg.lport_acceptall =
3517 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
3520 if (HIWORD(wParam) == BN_CLICKED ||
3521 HIWORD(wParam) == BN_DOUBLECLICKED)
3522 cfg.rport_acceptall =
3523 IsDlgButtonChecked(hwnd, IDC_RPORT_ALL);
3525 case IDC_X11_DISPLAY:
3526 if (HIWORD(wParam) == EN_CHANGE)
3527 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
3528 sizeof(cfg.x11_display) - 1);
3532 if (HIWORD(wParam) == BN_CLICKED ||
3533 HIWORD(wParam) == BN_DOUBLECLICKED) {
3534 if (IsDlgButtonChecked(hwnd, IDC_X11MIT))
3535 cfg.x11_auth = X11_MIT;
3536 else if (IsDlgButtonChecked(hwnd, IDC_X11XDM))
3537 cfg.x11_auth = X11_XDM;
3541 if (HIWORD(wParam) == BN_CLICKED ||
3542 HIWORD(wParam) == BN_DOUBLECLICKED) {
3543 char str[sizeof(cfg.portfwd)];
3545 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
3549 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
3553 "You need to specify a source port number",
3554 "PuTTY Error", MB_OK | MB_ICONERROR);
3557 p = str + strlen(str);
3559 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
3560 sizeof(str) - 1 - (p - str));
3561 if (!*p || !strchr(p, ':')) {
3563 "You need to specify a destination address\n"
3564 "in the form \"host.name:port\"",
3565 "PuTTY Error", MB_OK | MB_ICONERROR);
3574 if ((p - cfg.portfwd) + strlen(str) + 2 <
3575 sizeof(cfg.portfwd)) {
3577 p[strlen(str) + 1] = '\0';
3578 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
3580 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
3581 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
3583 MessageBox(hwnd, "Too many forwardings",
3584 "PuTTY Error", MB_OK | MB_ICONERROR);
3588 case IDC_PFWDREMOVE:
3589 if (HIWORD(wParam) != BN_CLICKED &&
3590 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3591 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
3592 LB_GETCURSEL, 0, 0);
3598 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
3624 case IDC_BUGD_IGNORE1:
3625 if (HIWORD(wParam) == CBN_SELCHANGE) {
3626 int index = SendDlgItemMessage(hwnd, IDC_BUGD_IGNORE1,
3627 CB_GETCURSEL, 0, 0);
3628 cfg.sshbug_ignore1 = (index == 0 ? AUTO :
3629 index == 1 ? FORCE_OFF : FORCE_ON);
3632 case IDC_BUGD_PLAINPW1:
3633 if (HIWORD(wParam) == CBN_SELCHANGE) {
3634 int index = SendDlgItemMessage(hwnd, IDC_BUGD_PLAINPW1,
3635 CB_GETCURSEL, 0, 0);
3636 cfg.sshbug_plainpw1 = (index == 0 ? AUTO :
3637 index == 1 ? FORCE_OFF : FORCE_ON);
3641 if (HIWORD(wParam) == CBN_SELCHANGE) {
3642 int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSA1,
3643 CB_GETCURSEL, 0, 0);
3644 cfg.sshbug_rsa1 = (index == 0 ? AUTO :
3645 index == 1 ? FORCE_OFF : FORCE_ON);
3648 case IDC_BUGD_HMAC2:
3649 if (HIWORD(wParam) == CBN_SELCHANGE) {
3650 int index = SendDlgItemMessage(hwnd, IDC_BUGD_HMAC2,
3651 CB_GETCURSEL, 0, 0);
3652 cfg.sshbug_hmac2 = (index == 0 ? AUTO :
3653 index == 1 ? FORCE_OFF : FORCE_ON);
3656 case IDC_BUGD_DERIVEKEY2:
3657 if (HIWORD(wParam) == CBN_SELCHANGE) {
3658 int index = SendDlgItemMessage(hwnd, IDC_BUGD_DERIVEKEY2,
3659 CB_GETCURSEL, 0, 0);
3660 cfg.sshbug_derivekey2 = (index == 0 ? AUTO :
3661 index == 1 ? FORCE_OFF:FORCE_ON);
3664 case IDC_BUGD_RSAPAD2:
3665 if (HIWORD(wParam) == CBN_SELCHANGE) {
3666 int index = SendDlgItemMessage(hwnd, IDC_BUGD_RSAPAD2,
3667 CB_GETCURSEL, 0, 0);
3668 cfg.sshbug_rsapad2 = (index == 0 ? AUTO :
3669 index == 1 ? FORCE_OFF : FORCE_ON);
3672 case IDC_BUGD_DHGEX2:
3673 if (HIWORD(wParam) == CBN_SELCHANGE) {
3674 int index = SendDlgItemMessage(hwnd, IDC_BUGD_DHGEX2,
3675 CB_GETCURSEL, 0, 0);
3676 cfg.sshbug_dhgex2 = (index == 0 ? AUTO :
3677 index == 1 ? FORCE_OFF : FORCE_ON);
3684 int id = ((LPHELPINFO)lParam)->iCtrlId;
3685 char *cmd = help_context_cmd(id);
3687 WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
3688 requested_help = TRUE;
3695 if (requested_help) {
3696 WinHelp(hwnd, help_path, HELP_QUIT, 0);
3697 requested_help = FALSE;
3702 /* Grrr Explorer will maximize Dialogs! */
3704 if (wParam == SIZE_MAXIMIZED)
3710 * Handle application-defined messages eg. DragListBox
3712 /* First find out what the number is (once). */
3713 if (draglistmsg == WM_NULL)
3714 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
3716 if (msg == draglistmsg) {
3717 /* Only process once dialog is fully formed. */
3718 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
3719 case IDC_CIPHERLIST:
3720 return handle_prefslist(&cipherlist,
3721 cfg.ssh_cipherlist, CIPHER_MAX,
3722 1, hwnd, wParam, lParam);
3731 static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
3732 WPARAM wParam, LPARAM lParam)
3734 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
3736 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
3737 EnableWindow(hwnd, 0);
3738 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3739 EnableWindow(hwnd, 1);
3740 SetActiveWindow(hwnd);
3742 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
3745 static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
3746 WPARAM wParam, LPARAM lParam)
3748 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
3751 void defuse_showwindow(void)
3754 * Work around the fact that the app's first call to ShowWindow
3755 * will ignore the default in favour of the shell-provided
3760 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
3762 ShowWindow(hwnd, SW_HIDE);
3763 SetActiveWindow(hwnd);
3764 DestroyWindow(hwnd);
3772 get_sesslist(&sesslist, TRUE);
3773 savedsession[0] = '\0';
3775 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
3776 get_sesslist(&sesslist, FALSE);
3781 int do_reconfig(HWND hwnd)
3786 backup_cfg = cfg; /* structure copy */
3788 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
3790 cfg = backup_cfg; /* structure copy */
3795 void logevent(void *frontend, char *string)
3800 log_eventlog(logctx, string);
3802 if (nevents >= negsize) {
3804 events = srealloc(events, negsize * sizeof(*events));
3808 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
3811 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
3812 strcpy(events[nevents], timebuf);
3813 strcat(events[nevents], string);
3816 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
3817 0, (LPARAM) events[nevents]);
3818 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
3819 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
3824 void showeventlog(HWND hwnd)
3827 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
3829 ShowWindow(logbox, SW_SHOWNORMAL);
3831 SetActiveWindow(logbox);
3834 void showabout(HWND hwnd)
3836 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3839 void verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,
3840 char *keystr, char *fingerprint)
3844 static const char absentmsg[] =
3845 "The server's host key is not cached in the registry. You\n"
3846 "have no guarantee that the server is the computer you\n"
3848 "The server's key fingerprint is:\n"
3850 "If you trust this host, hit Yes to add the key to\n"
3851 "PuTTY's cache and carry on connecting.\n"
3852 "If you want to carry on connecting just once, without\n"
3853 "adding the key to the cache, hit No.\n"
3854 "If you do not trust this host, hit Cancel to abandon the\n"
3857 static const char wrongmsg[] =
3858 "WARNING - POTENTIAL SECURITY BREACH!\n"
3860 "The server's host key does not match the one PuTTY has\n"
3861 "cached in the registry. This means that either the\n"
3862 "server administrator has changed the host key, or you\n"
3863 "have actually connected to another computer pretending\n"
3864 "to be the server.\n"
3865 "The new key fingerprint is:\n"
3867 "If you were expecting this change and trust the new key,\n"
3868 "hit Yes to update PuTTY's cache and continue connecting.\n"
3869 "If you want to carry on connecting but without updating\n"
3870 "the cache, hit No.\n"
3871 "If you want to abandon the connection completely, hit\n"
3872 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3874 static const char mbtitle[] = "PuTTY Security Alert";
3877 /* sensible fingerprint max size */
3878 (sizeof(absentmsg) > sizeof(wrongmsg) ?
3879 sizeof(absentmsg) : sizeof(wrongmsg))];
3882 * Verify the key against the registry.
3884 ret = verify_host_key(host, port, keytype, keystr);
3886 if (ret == 0) /* success - key matched OK */
3888 if (ret == 2) { /* key was different */
3890 sprintf(message, wrongmsg, fingerprint);
3891 mbret = MessageBox(NULL, message, mbtitle,
3892 MB_ICONWARNING | MB_YESNOCANCEL);
3894 store_host_key(host, port, keytype, keystr);
3895 if (mbret == IDCANCEL)
3898 if (ret == 1) { /* key was absent */
3900 sprintf(message, absentmsg, fingerprint);
3901 mbret = MessageBox(NULL, message, mbtitle,
3902 MB_ICONWARNING | MB_YESNOCANCEL);
3904 store_host_key(host, port, keytype, keystr);
3905 if (mbret == IDCANCEL)
3911 * Ask whether the selected cipher is acceptable (since it was
3912 * below the configured 'warn' threshold).
3913 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3915 void askcipher(void *frontend, char *ciphername, int cs)
3917 static const char mbtitle[] = "PuTTY Security Alert";
3918 static const char msg[] =
3919 "The first %.35scipher supported by the server\n"
3920 "is %.64s, which is below the configured\n"
3921 "warning threshold.\n"
3922 "Do you want to continue with this connection?\n";
3923 /* guessed cipher name + type max length */
3924 char message[100 + sizeof(msg)];
3927 sprintf(message, msg,
3929 (cs == 1) ? "client-to-server " :
3930 "server-to-client ",
3932 mbret = MessageBox(NULL, message, mbtitle,
3933 MB_ICONWARNING | MB_YESNO);
3941 * Ask whether to wipe a session log file before writing to it.
3942 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3944 int askappend(void *frontend, char *filename)
3946 static const char mbtitle[] = "PuTTY Log to File";
3947 static const char msgtemplate[] =
3948 "The session log file \"%.*s\" already exists.\n"
3949 "You can overwrite it with a new session log,\n"
3950 "append your session log to the end of it,\n"
3951 "or disable session logging for this session.\n"
3952 "Hit Yes to wipe the file, No to append to it,\n"
3953 "or Cancel to disable logging.";
3954 char message[sizeof(msgtemplate) + FILENAME_MAX];
3957 sprintf(message, msgtemplate, FILENAME_MAX, filename);
3959 mbret = MessageBox(NULL, message, mbtitle,
3960 MB_ICONQUESTION | MB_YESNOCANCEL);
3963 else if (mbret == IDNO)
3970 * Warn about the obsolescent key file format.
3972 * Uniquely among these functions, this one does _not_ expect a
3973 * frontend handle. This means that if PuTTY is ported to a
3974 * platform which requires frontend handles, this function will be
3975 * an anomaly. Fortunately, the problem it addresses will not have
3976 * been present on that platform, so it can plausibly be
3977 * implemented as an empty function.
3979 void old_keyfile_warning(void)
3981 static const char mbtitle[] = "PuTTY Key File Warning";
3982 static const char message[] =
3983 "You are loading an SSH 2 private key which has an\n"
3984 "old version of the file format. This means your key\n"
3985 "file is not fully tamperproof. Future versions of\n"
3986 "PuTTY may stop supporting this private key format,\n"
3987 "so we recommend you convert your key to the new\n"
3990 "You can perform this conversion by loading the key\n"
3991 "into PuTTYgen and then saving it again.";
3993 MessageBox(NULL, message, mbtitle, MB_OK);