15 static char **events = NULL;
16 static int nevents = 0, negsize = 0;
19 static int sesslist_has_focus;
20 static int requested_help;
22 static struct prefslist cipherlist;
24 void force_normal(HWND hwnd)
26 static int recurse = 0;
34 wp.length = sizeof(wp);
35 if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) {
36 wp.showCmd = SW_SHOWNORMAL;
37 SetWindowPlacement(hwnd, &wp);
42 static void MyGetDlgItemInt(HWND hwnd, int id, int *result)
46 n = GetDlgItemInt(hwnd, id, &ok, FALSE);
51 static void MyGetDlgItemFlt(HWND hwnd, int id, int *result, int scale)
55 ok = GetDlgItemText(hwnd, id, text, sizeof(text) - 1);
57 *result = (int) (scale * atof(text));
60 static void MySetDlgItemFlt(HWND hwnd, int id, double value)
63 sprintf(text, "%g", value);
64 SetDlgItemText(hwnd, id, text);
67 static int CALLBACK LogProc(HWND hwnd, UINT msg,
68 WPARAM wParam, LPARAM lParam)
75 static int tabs[4] = { 78, 108 };
76 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
79 for (i = 0; i < nevents; i++)
80 SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
81 0, (LPARAM) events[i]);
84 switch (LOWORD(wParam)) {
88 SetActiveWindow(GetParent(hwnd));
92 if (HIWORD(wParam) == BN_CLICKED ||
93 HIWORD(wParam) == BN_DOUBLECLICKED) {
96 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
97 LB_GETSELCOUNT, 0, 0);
98 if (selcount == 0) { /* don't even try to copy zero items */
103 selitems = smalloc(selcount * sizeof(int));
105 int count = SendDlgItemMessage(hwnd, IDN_LIST,
112 static unsigned char sel_nl[] = SEL_NL;
114 if (count == 0) { /* can't copy zero stuff */
120 for (i = 0; i < count; i++)
122 strlen(events[selitems[i]]) + sizeof(sel_nl);
124 clipdata = smalloc(size);
127 for (i = 0; i < count; i++) {
128 char *q = events[selitems[i]];
129 int qlen = strlen(q);
132 memcpy(p, sel_nl, sizeof(sel_nl));
135 write_aclip(clipdata, size, TRUE);
140 for (i = 0; i < nevents; i++)
141 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
150 SetActiveWindow(GetParent(hwnd));
157 static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
158 WPARAM wParam, LPARAM lParam)
164 switch (LOWORD(wParam)) {
177 static int CALLBACK AboutProc(HWND hwnd, UINT msg,
178 WPARAM wParam, LPARAM lParam)
182 SetDlgItemText(hwnd, IDA_VERSION, ver);
185 switch (LOWORD(wParam)) {
188 EndDialog(hwnd, TRUE);
191 EnableWindow(hwnd, 0);
192 DialogBox(hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
194 EnableWindow(hwnd, 1);
195 SetActiveWindow(hwnd);
199 /* Load web browser */
200 ShellExecute(hwnd, "open",
201 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
202 0, 0, SW_SHOWDEFAULT);
207 EndDialog(hwnd, TRUE);
214 * Null dialog procedure.
216 static int CALLBACK NullDlgProc(HWND hwnd, UINT msg,
217 WPARAM wParam, LPARAM lParam)
222 static char savedsession[2048];
225 IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
364 IDC_SCROLLBARFULLSCREEN,
379 IDC_FULLSCREENONALTENTER,
382 appearancepanelstart,
383 IDC_TITLE_APPEARANCE,
405 connectionpanelstart,
406 IDC_TITLE_CONNECTION,
524 translationpanelstart,
525 IDC_TITLE_TRANSLATION,
526 IDC_BOX_TRANSLATION1,
527 IDC_BOX_TRANSLATION2,
528 IDC_BOX_TRANSLATION3,
566 static const char *const colours[] = {
567 "Default Foreground", "Default Bold Foreground",
568 "Default Background", "Default Bold Background",
569 "Cursor Text", "Cursor Colour",
570 "ANSI Black", "ANSI Black Bold",
571 "ANSI Red", "ANSI Red Bold",
572 "ANSI Green", "ANSI Green Bold",
573 "ANSI Yellow", "ANSI Yellow Bold",
574 "ANSI Blue", "ANSI Blue Bold",
575 "ANSI Magenta", "ANSI Magenta Bold",
576 "ANSI Cyan", "ANSI Cyan Bold",
577 "ANSI White", "ANSI White Bold"
579 static const int permcolour[] = {
580 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
581 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
582 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
585 static void fmtfont(char *buf)
587 sprintf(buf, "Font: %s, ", cfg.font);
589 strcat(buf, "bold, ");
590 if (cfg.fontheight == 0)
591 strcat(buf, "default height");
593 sprintf(buf + strlen(buf), "%d-point",
594 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
597 char *help_context_cmd(int id)
609 return "JI(`',`session.hostname')";
616 return "JI(`',`session.saved')";
621 return "JI(`',`session.coe')";
622 case IDC_LSTATSTATIC:
626 case IDC_LSTATPACKET:
627 return "JI(`',`logging.main')";
632 return "JI(`',`logging.filename')";
637 return "JI(`',`logging.exists')";
642 return "JI(`',`keyboard.backspace')";
646 return "JI(`',`keyboard.homeend')";
654 return "JI(`',`keyboard.funkeys')";
659 return "JI(`',`keyboard.appkeypad')";
664 return "JI(`',`keyboard.appcursor')";
666 return "JI(`',`keyboard.nethack')";
668 return "JI(`',`keyboard.compose')";
669 case IDC_CTRLALTKEYS:
670 return "JI(`',`keyboard.ctrlalt')";
673 return "JI(`',`terminal.autowrap')";
675 return "JI(`',`terminal.decom')";
677 return "JI(`',`terminal.lfhascr')";
679 return "JI(`',`terminal.bce')";
681 return "JI(`',`terminal.blink')";
684 return "JI(`',`terminal.answerback')";
686 case IDC_ECHOBACKEND:
689 return "JI(`',`terminal.localecho')";
691 case IDC_EDITBACKEND:
694 return "JI(`',`terminal.localedit')";
697 case IDC_BELL_DISABLED:
698 case IDC_BELL_DEFAULT:
699 case IDC_BELL_WAVEFILE:
700 case IDC_BELL_VISUAL:
701 case IDC_BELL_WAVESTATIC:
702 case IDC_BELL_WAVEEDIT:
703 case IDC_BELL_WAVEBROWSE:
704 return "JI(`',`bell.style')";
705 case IDC_B_IND_STATIC:
706 case IDC_B_IND_DISABLED:
707 case IDC_B_IND_FLASH:
708 case IDC_B_IND_STEADY:
709 return "JI(`',`bell.taskbar')";
711 case IDC_BELLOVLNSTATIC:
713 case IDC_BELLOVLTSTATIC:
715 case IDC_BELLOVLEXPLAIN:
716 case IDC_BELLOVLSSTATIC:
718 return "JI(`',`bell.overload')";
724 return "JI(`',`window.size')";
725 case IDC_RESIZESTATIC:
729 case IDC_RESIZEEITHER:
730 return "JI(`',`window.resize')";
732 case IDC_SCROLLBARFULLSCREEN:
737 return "JI(`',`window.scrollback')";
740 return "JI(`',`behaviour.closewarn')";
742 return "JI(`',`behaviour.altf4')";
744 return "JI(`',`behaviour.altspace')";
746 return "JI(`',`behaviour.altonly')";
747 case IDC_ALWAYSONTOP:
748 return "JI(`',`behaviour.alwaysontop')";
749 case IDC_FULLSCREENONALTENTER:
750 return "JI(`',`behaviour.altenter')";
752 case IDC_CURSORSTATIC:
757 return "JI(`',`appearance.cursor')";
760 return "JI(`',`appearance.font')";
764 return "JI(`',`appearance.title')";
766 return "JI(`',`appearance.hidemouse')";
770 return "JI(`',`appearance.border')";
774 return "JI(`',`connection.termtype')";
777 return "JI(`',`connection.username')";
780 return "JI(`',`connection.keepalive')";
782 return "JI(`',`connection.nodelay')";
786 return "JI(`',`telnet.termspeed')";
795 return "JI(`',`telnet.environ')";
799 return "JI(`',`telnet.oldenviron')";
803 return "JI(`',`telnet.passive')";
805 return "JI(`',`telnet.specialkeys')";
809 return "JI(`',`rlogin.termspeed')";
810 case IDC_RLLUSERSTATIC:
811 case IDC_RLLUSEREDIT:
812 return "JI(`',`rlogin.localuser')";
815 return "JI(`',`ssh.nopty')";
816 case IDC_CIPHERSTATIC2:
821 return "JI(`',`ssh.ciphers')";
823 return "JI(`',`ssh.buggymac')";
824 case IDC_SSHPROTSTATIC:
827 return "JI(`',`ssh.protocol')";
830 return "JI(`',`ssh.command')";
832 return "JI(`',`ssh.compress')";
837 return "JI(`',`ssh.auth.privkey')";
839 return "JI(`',`ssh.auth.agentfwd')";
841 return "JI(`',`ssh.auth.changeuser')";
843 return "JI(`',`ssh.auth.tis')";
845 return "JI(`',`ssh.auth.ki')";
850 return "JI(`',`selection.buttons')";
851 case IDC_MOUSEOVERRIDE:
852 return "JI(`',`selection.shiftdrag')";
853 case IDC_SELTYPESTATIC:
855 case IDC_SELTYPERECT:
856 return "JI(`',`selection.rect')";
862 return "JI(`',`selection.charclasses')";
864 return "JI(`',`selection.linedraw')";
866 return "JI(`',`selection.rtf')";
869 return "JI(`',`colours.bold')";
871 return "JI(`',`colours.logpal')";
872 case IDC_COLOURSTATIC:
881 return "JI(`',`colours.config')";
883 case IDC_CODEPAGESTATIC:
885 return "JI(`',`translation.codepage')";
886 case IDC_CAPSLOCKCYR:
887 return "JI(`',`translation.cyrillic')";
894 return "JI(`',`translation.linedraw')";
896 case IDC_X11_FORWARD:
897 case IDC_X11_DISPSTATIC:
898 case IDC_X11_DISPLAY:
899 return "JI(`',`ssh.tunnels.x11')";
901 case IDC_PFWDSTATIC2:
905 case IDC_SPORTSTATIC:
907 case IDC_DPORTSTATIC:
911 return "JI(`',`ssh.tunnels.portfwd')";
914 return "JI(`',`ssh.tunnels.portfwd.localhost')";
921 /* 2nd arg: NZ => don't redraw session list (use when loading
923 static void init_dlg_ctrls(HWND hwnd, int keepsess)
926 char fontstatic[256];
928 SetDlgItemText(hwnd, IDC_HOST, cfg.host);
929 SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
932 n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
933 for (i = n; i-- > 0;)
934 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_DELETESTRING, i, 0);
935 for (i = 0; i < nsessions; i++)
936 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_ADDSTRING,
937 0, (LPARAM) (sessions[i]));
939 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
940 CheckRadioButton(hwnd, IDC_PROTRAW, IDC_PROTSSH,
941 cfg.protocol == PROT_SSH ? IDC_PROTSSH :
942 cfg.protocol == PROT_TELNET ? IDC_PROTTELNET :
944 PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW);
945 SetDlgItemInt(hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
946 CheckDlgButton(hwnd, IDC_NODELAY, cfg.tcp_nodelay);
948 CheckRadioButton(hwnd, IDC_DEL008, IDC_DEL127,
949 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
950 CheckRadioButton(hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
951 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
952 CheckRadioButton(hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
953 cfg.funky_type == 0 ? IDC_FUNCTILDE :
954 cfg.funky_type == 1 ? IDC_FUNCLINUX :
955 cfg.funky_type == 2 ? IDC_FUNCXTERM :
956 cfg.funky_type == 3 ? IDC_FUNCVT400 :
957 cfg.funky_type == 4 ? IDC_FUNCVT100P :
958 cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE);
959 CheckDlgButton(hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
960 CheckDlgButton(hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
961 CheckRadioButton(hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
962 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
963 CheckRadioButton(hwnd, IDC_KPNORMAL, IDC_KPNH,
964 cfg.nethack_keypad ? IDC_KPNH :
965 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
966 CheckDlgButton(hwnd, IDC_ALTF4, cfg.alt_f4);
967 CheckDlgButton(hwnd, IDC_ALTSPACE, cfg.alt_space);
968 CheckDlgButton(hwnd, IDC_ALTONLY, cfg.alt_only);
969 CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
970 CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
971 CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
972 CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
973 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
974 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
975 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
976 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND :
977 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
978 SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
979 CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
980 CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
981 CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
982 CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
984 CheckDlgButton(hwnd, IDC_WRAPMODE, cfg.wrap_mode);
985 CheckDlgButton(hwnd, IDC_DECOM, cfg.dec_om);
986 CheckDlgButton(hwnd, IDC_LFHASCR, cfg.lfhascr);
987 SetDlgItemInt(hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
988 SetDlgItemInt(hwnd, IDC_COLSEDIT, cfg.width, FALSE);
989 SetDlgItemInt(hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
991 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
992 CheckRadioButton(hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
993 cfg.beep == BELL_DISABLED ? IDC_BELL_DISABLED :
994 cfg.beep == BELL_DEFAULT ? IDC_BELL_DEFAULT :
995 cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
997 BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
998 CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
1000 B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
1001 B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
1002 B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
1003 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
1004 CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
1005 SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
1006 MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
1007 MySetDlgItemFlt(hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
1009 CheckDlgButton(hwnd, IDC_BCE, cfg.bce);
1010 CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
1012 SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
1013 CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
1014 CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
1015 CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
1016 SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
1017 CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
1018 cfg.cursor_type == 0 ? IDC_CURBLOCK :
1019 cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
1020 CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
1021 CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
1022 CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
1023 CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZEEITHER,
1024 cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
1025 cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
1026 cfg.resize_action == RESIZE_EITHER ? IDC_RESIZEEITHER :
1028 CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
1029 cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
1030 cfg.close_on_exit ==
1031 COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
1032 CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
1034 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1035 SetDlgItemText(hwnd, IDC_TSEDIT, cfg.termspeed);
1036 SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
1037 SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
1038 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1039 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
1040 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATPACKET,
1041 cfg.logtype == LGTYP_NONE ? IDC_LSTATOFF :
1042 cfg.logtype == LGTYP_ASCII ? IDC_LSTATASCII :
1043 cfg.logtype == LGTYP_DEBUG ? IDC_LSTATRAW :
1045 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
1046 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
1047 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
1050 char *p = cfg.environmt;
1051 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
1053 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
1059 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0,
1064 CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC,
1065 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
1066 CheckRadioButton(hwnd, IDC_TPASSIVE, IDC_TACTIVE,
1067 cfg.passive_telnet ? IDC_TPASSIVE : IDC_TACTIVE);
1069 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1070 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1071 CheckDlgButton(hwnd, IDC_NOPTY, cfg.nopty);
1072 CheckDlgButton(hwnd, IDC_COMPRESS, cfg.compression);
1073 CheckDlgButton(hwnd, IDC_BUGGYMAC, cfg.buggymac);
1074 CheckDlgButton(hwnd, IDC_SSH2DES, cfg.ssh2_des_cbc);
1075 CheckDlgButton(hwnd, IDC_AGENTFWD, cfg.agentfwd);
1076 CheckDlgButton(hwnd, IDC_CHANGEUSER, cfg.change_username);
1077 CheckRadioButton(hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
1078 cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
1079 CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
1080 CheckDlgButton(hwnd, IDC_AUTHKI, cfg.try_ki_auth);
1081 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
1082 SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
1086 static const struct { char *s; int c; } ciphers[] = {
1087 { "3DES", CIPHER_3DES },
1088 { "Blowfish", CIPHER_BLOWFISH },
1089 { "DES", CIPHER_DES },
1090 { "AES (SSH 2 only)", CIPHER_AES },
1091 { "-- warn below here --", CIPHER_WARN }
1094 /* Set up the "selected ciphers" box. */
1095 /* (cipherlist assumed to contain all ciphers) */
1096 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_RESETCONTENT, 0, 0);
1097 for (i = 0; i < CIPHER_MAX; i++) {
1098 int c = cfg.ssh_cipherlist[i];
1101 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
1102 if (ciphers[j].c == c) {
1103 cstr = ciphers[j].s;
1107 pos = SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_ADDSTRING,
1109 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_SETITEMDATA,
1115 CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
1116 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
1117 CheckRadioButton(hwnd, IDC_SELTYPELEX, IDC_SELTYPERECT,
1118 cfg.rect_select == 0 ? IDC_SELTYPELEX : IDC_SELTYPERECT);
1119 CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
1120 CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
1121 CheckDlgButton(hwnd, IDC_RTFPASTE, cfg.rtf_paste);
1123 static int tabs[4] = { 25, 61, 96, 128 };
1124 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
1127 for (i = 0; i < 128; i++) {
1129 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
1130 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg.wordness[i]);
1131 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
1135 CheckDlgButton(hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
1136 CheckDlgButton(hwnd, IDC_PALETTE, cfg.try_palette);
1139 n = SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
1140 for (i = n; i-- > 0;)
1141 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
1142 LB_DELETESTRING, i, 0);
1143 for (i = 0; i < 22; i++)
1144 if (cfg.bold_colour || permcolour[i])
1145 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
1146 (LPARAM) colours[i]);
1148 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
1149 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
1150 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
1151 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
1156 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
1157 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
1158 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
1159 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
1160 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
1163 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
1166 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
1167 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
1168 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
1169 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
1170 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
1173 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
1174 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
1176 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
1177 CheckDlgButton(hwnd, IDC_RPORT_ALL, cfg.rport_acceptall);
1178 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
1181 struct treeview_faff {
1183 HTREEITEM lastat[4];
1186 static HTREEITEM treeview_insert(struct treeview_faff *faff,
1187 int level, char *text)
1192 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
1193 ins.hInsertAfter = faff->lastat[level];
1194 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1195 #define INSITEM DUMMYUNIONNAME.item
1197 #define INSITEM item
1199 ins.INSITEM.mask = TVIF_TEXT;
1200 ins.INSITEM.pszText = text;
1201 newitem = TreeView_InsertItem(faff->treeview, &ins);
1203 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
1205 faff->lastat[level] = newitem;
1206 for (i = level + 1; i < 4; i++)
1207 faff->lastat[i] = NULL;
1212 * Create the panelfuls of controls in the configuration box.
1214 static void create_controls(HWND hwnd, int dlgtype, int panel)
1216 if (panel == sessionpanelstart) {
1217 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
1219 ctlposinit(&cp, hwnd, 80, 3, 13);
1220 bartitle(&cp, "Basic options for your PuTTY session",
1223 beginbox(&cp, "Specify your connection by host name or IP address",
1226 "Host &Name (or IP address)",
1227 IDC_HOSTSTATIC, IDC_HOST, 75,
1228 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
1229 if (backends[3].backend == NULL) {
1230 /* this is PuTTYtel, so only three protocols available */
1231 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
1232 "&Raw", IDC_PROTRAW,
1233 "&Telnet", IDC_PROTTELNET,
1234 "Rlog&in", IDC_PROTRLOGIN, NULL);
1236 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
1237 "&Raw", IDC_PROTRAW,
1238 "&Telnet", IDC_PROTTELNET,
1239 "Rlog&in", IDC_PROTRLOGIN,
1248 beginbox(&cp, "Load, save or delete a stored session",
1250 sesssaver(&cp, "Sav&ed Sessions",
1251 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
1252 "&Load", IDC_SESSLOAD,
1253 "&Save", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
1256 beginbox(&cp, NULL, IDC_BOX_SESSION3);
1257 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
1258 "Always", IDC_COEALWAYS,
1259 "Never", IDC_COENEVER,
1260 "Only on clean exit", IDC_COENORMAL, NULL);
1264 if (panel == loggingpanelstart) {
1265 /* The Logging panel. Accelerators used: [acgo] tplsfwe */
1267 ctlposinit(&cp, hwnd, 80, 3, 13);
1268 bartitle(&cp, "Options controlling session logging",
1270 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
1272 "Session logging:", IDC_LSTATSTATIC,
1273 "Logging &turned off completely", IDC_LSTATOFF,
1274 "Log &printable output only", IDC_LSTATASCII,
1275 "&Log all session output", IDC_LSTATRAW,
1276 "Log &SSH packet data", IDC_LSTATPACKET,
1278 editbutton(&cp, "Log &file name:",
1279 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
1281 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
1282 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
1284 "What to do if the log file already &exists:",
1285 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
1286 "Always append to the end of it", IDC_LSTATXAPN,
1287 "Ask the user every time", IDC_LSTATXASK, NULL);
1291 if (panel == terminalpanelstart) {
1292 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
1294 ctlposinit(&cp, hwnd, 80, 3, 13);
1295 bartitle(&cp, "Options controlling the terminal emulation",
1296 IDC_TITLE_TERMINAL);
1297 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
1298 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
1299 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
1300 checkbox(&cp, "Implicit CR in every &LF", IDC_LFHASCR);
1301 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
1302 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
1304 "An&swerback to ^E:", IDC_ANSWERBACK,
1305 IDC_ANSWEREDIT, 100, NULL);
1308 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
1309 radioline(&cp, "Local ec&ho:", IDC_ECHOSTATIC, 3,
1310 "Auto", IDC_ECHOBACKEND,
1311 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
1312 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
1313 "Auto", IDC_EDITBACKEND,
1314 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
1318 if (panel == bellpanelstart) {
1319 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
1321 ctlposinit(&cp, hwnd, 80, 3, 13);
1322 bartitle(&cp, "Options controlling the terminal bell",
1324 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
1326 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
1327 "None (bell disabled)", IDC_BELL_DISABLED,
1328 "Play Windows Default Sound", IDC_BELL_DEFAULT,
1329 "Play a custom sound file", IDC_BELL_WAVEFILE,
1330 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
1331 editbutton(&cp, "Custom sound file to play as a bell:",
1332 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
1333 "Bro&wse...", IDC_BELL_WAVEBROWSE);
1334 radioline(&cp, "Taskbar/caption &indication on bell:",
1335 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
1336 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
1339 beginbox(&cp, "Control the bell overload behaviour",
1341 checkbox(&cp, "Bell is temporarily &disabled when over-used",
1343 staticedit(&cp, "Over-use means this &many bells...",
1344 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
1345 staticedit(&cp, "... in &this many seconds",
1346 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
1348 "The bell is re-enabled after a few seconds of silence.",
1349 1, IDC_BELLOVLEXPLAIN);
1350 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1355 if (panel == keyboardpanelstart) {
1356 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
1358 ctlposinit(&cp, hwnd, 80, 3, 13);
1359 bartitle(&cp, "Options controlling the effects of keys",
1360 IDC_TITLE_KEYBOARD);
1361 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1362 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1363 "Control-H", IDC_DEL008,
1364 "Control-? (127)", IDC_DEL127, NULL);
1365 radioline(&cp, "The &Home and End keys", IDC_HOMESTATIC, 2,
1366 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1367 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1368 "ESC[n~", IDC_FUNCTILDE,
1369 "Linux", IDC_FUNCLINUX,
1370 "Xterm R6", IDC_FUNCXTERM,
1371 "VT400", IDC_FUNCVT400,
1372 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1374 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1376 "Application c&ursor keys totally disabled",
1378 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1379 "Normal", IDC_CURNORMAL,
1380 "Application", IDC_CURAPPLIC, NULL);
1382 "Application ke&ypad keys totally disabled",
1384 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1385 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1386 "NetHack", IDC_KPNH, NULL);
1388 beginbox(&cp, "Enable extra keyboard features:",
1390 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1391 checkbox(&cp, "Control-Alt is &different from AltGr",
1396 if (panel == windowpanelstart) {
1397 /* The Window panel. Accelerators used: [acgo] rmz sdikp */
1399 ctlposinit(&cp, hwnd, 80, 3, 13);
1400 bartitle(&cp, "Options controlling PuTTY's window",
1402 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1404 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1405 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
1406 radiobig(&cp, "When window is resi&zed:", IDC_RESIZESTATIC,
1407 "Change the number of rows and columns", IDC_RESIZETERM,
1408 "Change the size of the font", IDC_RESIZEFONT,
1409 "Change font size only when maximised", IDC_RESIZEEITHER,
1410 "Forbid resizing completely", IDC_RESIZENONE, NULL);
1412 beginbox(&cp, "Control the scrollback in the window",
1414 staticedit(&cp, "Lines of &scrollback",
1415 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1416 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
1417 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
1418 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1419 checkbox(&cp, "Reset scrollback on dis&play activity",
1424 if (panel == appearancepanelstart) {
1425 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1427 ctlposinit(&cp, hwnd, 80, 3, 13);
1428 bartitle(&cp, "Configure the appearance of PuTTY's window",
1429 IDC_TITLE_APPEARANCE);
1430 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1431 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1432 "B&lock", IDC_CURBLOCK,
1433 "&Underline", IDC_CURUNDER,
1434 "&Vertical line", IDC_CURVERT, NULL);
1435 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1437 beginbox(&cp, "Set the font used in the terminal window",
1438 IDC_BOX_APPEARANCE2);
1439 staticbtn(&cp, "", IDC_FONTSTATIC, "C&hange...", IDC_CHOOSEFONT);
1441 beginbox(&cp, "Adjust the use of the window title",
1442 IDC_BOX_APPEARANCE3);
1444 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1445 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
1447 beginbox(&cp, "Adjust the use of the mouse pointer",
1448 IDC_BOX_APPEARANCE4);
1449 checkbox(&cp, "Hide mouse &pointer when typing in window",
1452 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1453 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1455 staticedit(&cp, "Gap between text and window edge",
1456 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
1460 if (panel == behaviourpanelstart) {
1461 /* The Behaviour panel. Accelerators used: [acgo] w4yltf */
1463 ctlposinit(&cp, hwnd, 80, 3, 13);
1464 bartitle(&cp, "Configure the behaviour of PuTTY's window",
1466 beginbox(&cp, NULL, IDC_BOX_BEHAVIOUR1);
1467 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1468 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1469 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1470 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
1471 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1472 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1476 if (panel == translationpanelstart) {
1477 /* The Translation panel. Accelerators used: [acgo] rxbepus */
1479 ctlposinit(&cp, hwnd, 80, 3, 13);
1480 bartitle(&cp, "Options controlling character set translation",
1481 IDC_TITLE_TRANSLATION);
1482 beginbox(&cp, "Character set translation on received data",
1483 IDC_BOX_TRANSLATION1);
1484 combobox(&cp, "&Received data assumed to be in which character set:",
1485 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1487 beginbox(&cp, "Enable character set translation on input data",
1488 IDC_BOX_TRANSLATION2);
1489 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
1492 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
1493 IDC_BOX_TRANSLATION3);
1495 "Handling of line drawing characters:", IDC_VTSTATIC,
1496 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1497 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1498 "Use font in O&EM mode only", IDC_VTOEMONLY,
1499 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1500 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
1504 if (panel == selectionpanelstart) {
1505 /* The Selection panel. Accelerators used: [acgo] df wxp hst nr */
1507 ctlposinit(&cp, hwnd, 80, 3, 13);
1508 bartitle(&cp, "Options controlling copy and paste",
1509 IDC_TITLE_SELECTION);
1510 beginbox(&cp, "Translation of pasted characters",
1511 IDC_BOX_SELECTION1);
1513 "&Don't translate line drawing chars into +, - and |",
1516 "Paste to clipboard in RT&F as well as plain text",
1519 beginbox(&cp, "Control which mouse button does which thing",
1520 IDC_BOX_SELECTION2);
1521 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1522 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1523 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1526 "Shift overrides a&pplication's use of mouse",
1529 "Default selection mode (Alt+drag does the other one):",
1530 IDC_SELTYPESTATIC, 2,
1531 "&Normal", IDC_SELTYPELEX,
1532 "&Rectangular block", IDC_SELTYPERECT, NULL);
1534 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1535 IDC_BOX_SELECTION3);
1536 charclass(&cp, "C&haracter classes:", IDC_CCSTATIC, IDC_CCLIST,
1537 "&Set", IDC_CCSET, IDC_CCEDIT,
1538 "&to class", IDC_CCSTATIC2);
1542 if (panel == colourspanelstart) {
1543 /* The Colours panel. Accelerators used: [acgo] blum */
1545 ctlposinit(&cp, hwnd, 80, 3, 13);
1546 bartitle(&cp, "Options controlling use of colours",
1548 beginbox(&cp, "General options for colour usage",
1550 checkbox(&cp, "&Bolded text is a different colour",
1552 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1554 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1556 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1557 IDC_COLOURSTATIC, IDC_COLOURLIST,
1558 "&Modify...", IDC_CHANGE,
1559 "Red:", IDC_RSTATIC, IDC_RVALUE,
1560 "Green:", IDC_GSTATIC, IDC_GVALUE,
1561 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1565 if (panel == connectionpanelstart) {
1566 /* The Connection panel. Accelerators used: [acgo] tukn */
1568 ctlposinit(&cp, hwnd, 80, 3, 13);
1569 bartitle(&cp, "Options controlling the connection",
1570 IDC_TITLE_CONNECTION);
1572 beginbox(&cp, "Data to send to the server",
1573 IDC_BOX_CONNECTION1);
1574 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1576 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1580 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1581 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1585 beginbox(&cp, "Sending of null packets to keep session active",
1586 IDC_BOX_CONNECTION2);
1587 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1588 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1591 beginbox(&cp, "Low-level TCP connection options",
1592 IDC_BOX_CONNECTION3);
1593 checkbox(&cp, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1599 if (panel == telnetpanelstart) {
1600 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
1602 ctlposinit(&cp, hwnd, 80, 3, 13);
1604 bartitle(&cp, "Options controlling Telnet connections",
1606 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1607 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1609 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1610 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1611 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1612 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1614 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1615 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1616 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1617 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1618 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1619 "Passive", IDC_TPASSIVE, "Active",
1621 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1627 if (panel == rloginpanelstart) {
1628 /* The Rlogin panel. Accelerators used: [acgo] sl */
1630 ctlposinit(&cp, hwnd, 80, 3, 13);
1632 bartitle(&cp, "Options controlling Rlogin connections",
1634 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1635 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1637 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1638 IDC_RLLUSEREDIT, 50);
1643 if (panel == sshpanelstart) {
1644 /* The SSH panel. Accelerators used: [acgo] r pe12i sd */
1646 ctlposinit(&cp, hwnd, 80, 3, 13);
1648 bartitle(&cp, "Options controlling SSH connections",
1650 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1652 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1655 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
1656 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1657 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1658 radioline(&cp, "Preferred SSH protocol version:",
1659 IDC_SSHPROTSTATIC, 2,
1660 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL);
1661 checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1664 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1665 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1666 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1668 checkbox(&cp, "Enable non-standard use of single-&DES in SSH 2",
1674 if (panel == sshauthpanelstart) {
1675 /* The SSH authentication panel. Accelerators used: [acgo] m fkiw */
1677 ctlposinit(&cp, hwnd, 80, 3, 13);
1679 bartitle(&cp, "Options controlling SSH authentication",
1681 beginbox(&cp, "Authentication methods",
1683 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
1685 checkbox(&cp, "Attempt \"keyboard-&interactive\" authentication"
1686 " (SSH2)", IDC_AUTHKI);
1688 beginbox(&cp, "Authentication parameters",
1690 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
1691 checkbox(&cp, "Allow attempted changes of &username in SSH2",
1693 editbutton(&cp, "Private &key file for authentication:",
1694 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
1700 if (panel == tunnelspanelstart) {
1701 /* The Tunnels panel. Accelerators used: [acgo] deilmrsthx */
1703 ctlposinit(&cp, hwnd, 80, 3, 13);
1705 bartitle(&cp, "Options controlling SSH tunnelling",
1707 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
1708 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
1709 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
1710 IDC_X11_DISPLAY, 50, NULL);
1712 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
1713 checkbox(&cp, "Local ports accept connections from o&ther hosts",
1715 checkbox(&cp, "Remote ports do t&he same (SSH v2 only)",
1717 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
1718 "&Remove", IDC_PFWDREMOVE);
1719 fwdsetter(&cp, IDC_PFWDLIST,
1720 "Add new forwarded port:", IDC_PFWDSTATIC2,
1721 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
1722 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
1723 "A&dd", IDC_PFWDADD);
1724 bareradioline(&cp, 2,
1725 "&Local", IDC_PFWDLOCAL,
1726 "Re&mote", IDC_PFWDREMOTE, NULL);
1734 * Helper function to load the session selected in SESSLIST
1735 * if any, as this is done in more than one place in
1736 * GenericMainDlgProc(). 0 => failure.
1738 static int load_selected_session(HWND hwnd)
1740 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1741 LB_GETCURSEL, 0, 0);
1747 isdef = !strcmp(sessions[n], "Default Settings");
1748 load_settings(sessions[n], !isdef, &cfg);
1749 init_dlg_ctrls(hwnd, TRUE);
1751 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
1753 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
1754 /* Restore the selection, which will have been clobbered by
1755 * SESSEDIT handling. */
1756 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
1761 * This function is the configuration box.
1763 static int GenericMainDlgProc(HWND hwnd, UINT msg,
1764 WPARAM wParam, LPARAM lParam, int dlgtype)
1767 struct treeview_faff tvfaff;
1770 char filename[sizeof(cfg.keyfile)];
1773 char fontstatic[256];
1775 struct servent *service;
1777 static UINT draglistmsg = WM_NULL;
1782 SetWindowLong(hwnd, GWL_USERDATA, 0);
1784 SetWindowLong(hwnd, GWL_EXSTYLE,
1785 GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
1787 HWND item = GetDlgItem(hwnd, IDC_HELPBTN);
1789 DestroyWindow(item);
1791 requested_help = FALSE;
1792 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
1793 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
1795 * Centre the window.
1797 { /* centre the window */
1800 hw = GetDesktopWindow();
1801 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
1803 (rs.right + rs.left + rd.left - rd.right) / 2,
1804 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
1805 rd.right - rd.left, rd.bottom - rd.top, TRUE);
1809 * Create the tree view.
1817 r.right = r.left + 75;
1819 r.bottom = r.top + 10;
1820 MapDialogRect(hwnd, &r);
1821 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
1822 WS_CHILD | WS_VISIBLE,
1824 r.right - r.left, r.bottom - r.top,
1825 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
1827 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1828 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1831 r.right = r.left + 75;
1833 r.bottom = r.top + 219;
1834 MapDialogRect(hwnd, &r);
1835 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
1836 WS_CHILD | WS_VISIBLE |
1837 WS_TABSTOP | TVS_HASLINES |
1838 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
1840 TVS_SHOWSELALWAYS, r.left, r.top,
1841 r.right - r.left, r.bottom - r.top,
1842 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
1844 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1845 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1846 tvfaff.treeview = treeview;
1847 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
1851 * Set up the tree view contents.
1853 hsession = treeview_insert(&tvfaff, 0, "Session");
1854 treeview_insert(&tvfaff, 1, "Logging");
1855 treeview_insert(&tvfaff, 0, "Terminal");
1856 treeview_insert(&tvfaff, 1, "Keyboard");
1857 treeview_insert(&tvfaff, 1, "Bell");
1858 treeview_insert(&tvfaff, 0, "Window");
1859 treeview_insert(&tvfaff, 1, "Appearance");
1860 treeview_insert(&tvfaff, 1, "Behaviour");
1861 treeview_insert(&tvfaff, 1, "Translation");
1862 treeview_insert(&tvfaff, 1, "Selection");
1863 treeview_insert(&tvfaff, 1, "Colours");
1864 treeview_insert(&tvfaff, 0, "Connection");
1866 treeview_insert(&tvfaff, 1, "Telnet");
1867 treeview_insert(&tvfaff, 1, "Rlogin");
1868 if (backends[3].backend != NULL) {
1869 treeview_insert(&tvfaff, 1, "SSH");
1870 /* XXX long name is ugly */
1871 /* XXX make it closed by default? */
1872 treeview_insert(&tvfaff, 2, "Auth");
1873 treeview_insert(&tvfaff, 2, "Tunnels");
1878 * Put the treeview selection on to the Session panel. This
1879 * should also cause creation of the relevant controls.
1881 TreeView_SelectItem(treeview, hsession);
1884 * Set focus into the first available control.
1888 ctl = GetDlgItem(hwnd, IDC_HOST);
1890 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
1894 SetWindowLong(hwnd, GWL_USERDATA, 1);
1895 sesslist_has_focus = 0;
1899 * Button release should trigger WM_OK if there was a
1900 * previous double click on the session list.
1904 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
1907 if (LOWORD(wParam) == IDCX_TREEVIEW &&
1908 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
1910 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
1915 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
1918 item.pszText = buffer;
1919 item.cchTextMax = sizeof(buffer);
1920 item.mask = TVIF_TEXT;
1921 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
1922 for (j = controlstartvalue; j < controlendvalue; j++) {
1923 HWND item = GetDlgItem(hwnd, j);
1925 DestroyWindow(item);
1927 if (!strcmp(buffer, "Session"))
1928 create_controls(hwnd, dlgtype, sessionpanelstart);
1929 if (!strcmp(buffer, "Logging"))
1930 create_controls(hwnd, dlgtype, loggingpanelstart);
1931 if (!strcmp(buffer, "Keyboard"))
1932 create_controls(hwnd, dlgtype, keyboardpanelstart);
1933 if (!strcmp(buffer, "Terminal"))
1934 create_controls(hwnd, dlgtype, terminalpanelstart);
1935 if (!strcmp(buffer, "Bell"))
1936 create_controls(hwnd, dlgtype, bellpanelstart);
1937 if (!strcmp(buffer, "Window"))
1938 create_controls(hwnd, dlgtype, windowpanelstart);
1939 if (!strcmp(buffer, "Appearance"))
1940 create_controls(hwnd, dlgtype, appearancepanelstart);
1941 if (!strcmp(buffer, "Behaviour"))
1942 create_controls(hwnd, dlgtype, behaviourpanelstart);
1943 if (!strcmp(buffer, "Tunnels"))
1944 create_controls(hwnd, dlgtype, tunnelspanelstart);
1945 if (!strcmp(buffer, "Connection"))
1946 create_controls(hwnd, dlgtype, connectionpanelstart);
1947 if (!strcmp(buffer, "Telnet"))
1948 create_controls(hwnd, dlgtype, telnetpanelstart);
1949 if (!strcmp(buffer, "Rlogin"))
1950 create_controls(hwnd, dlgtype, rloginpanelstart);
1951 if (!strcmp(buffer, "SSH"))
1952 create_controls(hwnd, dlgtype, sshpanelstart);
1953 if (!strcmp(buffer, "Auth"))
1954 create_controls(hwnd, dlgtype, sshauthpanelstart);
1955 if (!strcmp(buffer, "Selection"))
1956 create_controls(hwnd, dlgtype, selectionpanelstart);
1957 if (!strcmp(buffer, "Colours"))
1958 create_controls(hwnd, dlgtype, colourspanelstart);
1959 if (!strcmp(buffer, "Translation"))
1960 create_controls(hwnd, dlgtype, translationpanelstart);
1962 init_dlg_ctrls(hwnd, FALSE);
1964 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
1965 InvalidateRect (hwnd, NULL, TRUE);
1967 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
1973 * Only process WM_COMMAND once the dialog is fully formed.
1975 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
1976 switch (LOWORD(wParam)) {
1978 /* Behaviour of the "Open" button is different if the
1979 * session list has focus, *unless* the user just
1980 * double-clicked... */
1981 if (sesslist_has_focus && !readytogo) {
1982 if (!load_selected_session(hwnd)) {
1987 /* If at this point we have a valid session, go! */
1989 if (requested_help) {
1990 WinHelp(hwnd, help_path, HELP_QUIT, 0);
1991 requested_help = FALSE;
1998 if (HIWORD(wParam) == BN_CLICKED ||
1999 HIWORD(wParam) == BN_DOUBLECLICKED) {
2001 WinHelp(hwnd, help_path,
2002 help_has_contents ? HELP_FINDER : HELP_CONTENTS,
2004 requested_help = TRUE;
2009 if (requested_help) {
2010 WinHelp(hwnd, help_path, HELP_QUIT, 0);
2011 requested_help = FALSE;
2015 case IDC_PROTTELNET:
2016 case IDC_PROTRLOGIN:
2019 if (HIWORD(wParam) == BN_CLICKED ||
2020 HIWORD(wParam) == BN_DOUBLECLICKED) {
2021 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
2022 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
2023 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
2025 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
2027 if ((cfg.protocol == PROT_SSH && cfg.port != 22)
2028 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
2029 || (cfg.protocol == PROT_RLOGIN
2030 && cfg.port != 513)) {
2031 cfg.port = i ? 22 : j ? 23 : 513;
2032 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
2037 if (HIWORD(wParam) == EN_CHANGE)
2038 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
2039 sizeof(cfg.host) - 1);
2042 if (HIWORD(wParam) == EN_CHANGE) {
2043 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
2044 if (isdigit(portname[0]))
2045 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
2047 service = getservbyname(portname, NULL);
2049 cfg.port = ntohs(service->s_port);
2056 if (HIWORD(wParam) == EN_CHANGE) {
2057 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2059 GetDlgItemText(hwnd, IDC_SESSEDIT,
2060 savedsession, sizeof(savedsession) - 1);
2061 savedsession[sizeof(savedsession) - 1] = '\0';
2065 if (HIWORD(wParam) == BN_CLICKED ||
2066 HIWORD(wParam) == BN_DOUBLECLICKED) {
2071 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
2074 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2075 LB_GETCURSEL, 0, 0);
2080 strcpy(str, sessions[n]);
2082 save_settings(str, !!strcmp(str, "Default Settings"),
2084 get_sesslist(FALSE);
2086 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2088 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2090 for (i = 0; i < nsessions; i++)
2091 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2093 (LPARAM) (sessions[i]));
2094 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2096 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2098 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2104 if (LOWORD(wParam) == IDC_SESSLIST) {
2105 if (HIWORD(wParam) == LBN_SETFOCUS)
2106 sesslist_has_focus = 1;
2107 else if (HIWORD(wParam) == LBN_KILLFOCUS)
2108 sesslist_has_focus = 0;
2110 if (LOWORD(wParam) == IDC_SESSLOAD &&
2111 HIWORD(wParam) != BN_CLICKED &&
2112 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2113 if (LOWORD(wParam) == IDC_SESSLIST &&
2114 HIWORD(wParam) != LBN_DBLCLK) break;
2115 /* Load the session selected in SESSLIST. */
2116 if (load_selected_session(hwnd) &&
2117 LOWORD(wParam) == IDC_SESSLIST) {
2119 * A double-click on a saved session should
2120 * actually start the session, not just load it.
2121 * Unless it's Default Settings or some other
2122 * host-less set of saved settings.
2131 if (HIWORD(wParam) == BN_CLICKED ||
2132 HIWORD(wParam) == BN_DOUBLECLICKED) {
2133 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2134 LB_GETCURSEL, 0, 0);
2135 if (n == LB_ERR || n == 0) {
2139 del_settings(sessions[n]);
2140 get_sesslist(FALSE);
2142 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2144 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2146 for (i = 0; i < nsessions; i++)
2147 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2149 (LPARAM) (sessions[i]));
2150 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2152 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2154 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2158 if (HIWORD(wParam) == EN_CHANGE)
2159 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
2160 &cfg.ping_interval);
2163 if (HIWORD(wParam) == BN_CLICKED ||
2164 HIWORD(wParam) == BN_DOUBLECLICKED)
2166 IsDlgButtonChecked(hwnd, IDC_NODELAY);
2170 if (HIWORD(wParam) == BN_CLICKED ||
2171 HIWORD(wParam) == BN_DOUBLECLICKED)
2172 cfg.bksp_is_delete =
2173 IsDlgButtonChecked(hwnd, IDC_DEL127);
2177 if (HIWORD(wParam) == BN_CLICKED ||
2178 HIWORD(wParam) == BN_DOUBLECLICKED)
2180 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
2186 case IDC_FUNCVT100P:
2188 if (HIWORD(wParam) == BN_CLICKED ||
2189 HIWORD(wParam) == BN_DOUBLECLICKED)
2190 switch (LOWORD(wParam)) {
2203 case IDC_FUNCVT100P:
2213 if (HIWORD(wParam) == BN_CLICKED ||
2214 HIWORD(wParam) == BN_DOUBLECLICKED) {
2216 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
2217 cfg.nethack_keypad = FALSE;
2221 if (HIWORD(wParam) == BN_CLICKED ||
2222 HIWORD(wParam) == BN_DOUBLECLICKED) {
2223 cfg.app_keypad = FALSE;
2224 cfg.nethack_keypad = TRUE;
2229 if (HIWORD(wParam) == BN_CLICKED ||
2230 HIWORD(wParam) == BN_DOUBLECLICKED)
2232 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
2235 if (HIWORD(wParam) == BN_CLICKED ||
2236 HIWORD(wParam) == BN_DOUBLECLICKED)
2238 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
2241 if (HIWORD(wParam) == BN_CLICKED ||
2242 HIWORD(wParam) == BN_DOUBLECLICKED)
2244 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
2247 if (HIWORD(wParam) == BN_CLICKED ||
2248 HIWORD(wParam) == BN_DOUBLECLICKED)
2249 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
2252 if (HIWORD(wParam) == BN_CLICKED ||
2253 HIWORD(wParam) == BN_DOUBLECLICKED)
2255 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
2258 if (HIWORD(wParam) == BN_CLICKED ||
2259 HIWORD(wParam) == BN_DOUBLECLICKED)
2261 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
2263 case IDC_ECHOBACKEND:
2266 if (HIWORD(wParam) == BN_CLICKED ||
2267 HIWORD(wParam) == BN_DOUBLECLICKED) {
2268 if (LOWORD(wParam) == IDC_ECHOBACKEND)
2269 cfg.localecho = LD_BACKEND;
2270 if (LOWORD(wParam) == IDC_ECHOYES)
2271 cfg.localecho = LD_YES;
2272 if (LOWORD(wParam) == IDC_ECHONO)
2273 cfg.localecho = LD_NO;
2276 case IDC_EDITBACKEND:
2279 if (HIWORD(wParam) == BN_CLICKED ||
2280 HIWORD(wParam) == BN_DOUBLECLICKED) {
2281 if (LOWORD(wParam) == IDC_EDITBACKEND)
2282 cfg.localedit = LD_BACKEND;
2283 if (LOWORD(wParam) == IDC_EDITYES)
2284 cfg.localedit = LD_YES;
2285 if (LOWORD(wParam) == IDC_EDITNO)
2286 cfg.localedit = LD_NO;
2289 case IDC_ANSWEREDIT:
2290 if (HIWORD(wParam) == EN_CHANGE)
2291 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
2292 sizeof(cfg.answerback) - 1);
2294 case IDC_ALWAYSONTOP:
2295 if (HIWORD(wParam) == BN_CLICKED ||
2296 HIWORD(wParam) == BN_DOUBLECLICKED)
2298 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
2300 case IDC_FULLSCREENONALTENTER:
2301 if (HIWORD(wParam) == BN_CLICKED ||
2302 HIWORD(wParam) == BN_DOUBLECLICKED)
2303 cfg.fullscreenonaltenter =
2304 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
2307 if (HIWORD(wParam) == BN_CLICKED ||
2308 HIWORD(wParam) == BN_DOUBLECLICKED)
2310 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
2312 case IDC_SCROLLDISP:
2313 if (HIWORD(wParam) == BN_CLICKED ||
2314 HIWORD(wParam) == BN_DOUBLECLICKED)
2315 cfg.scroll_on_disp =
2316 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
2318 case IDC_COMPOSEKEY:
2319 if (HIWORD(wParam) == BN_CLICKED ||
2320 HIWORD(wParam) == BN_DOUBLECLICKED)
2322 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
2324 case IDC_CTRLALTKEYS:
2325 if (HIWORD(wParam) == BN_CLICKED ||
2326 HIWORD(wParam) == BN_DOUBLECLICKED)
2328 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
2331 if (HIWORD(wParam) == BN_CLICKED ||
2332 HIWORD(wParam) == BN_DOUBLECLICKED)
2333 cfg.telnet_keyboard =
2334 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
2337 if (HIWORD(wParam) == BN_CLICKED ||
2338 HIWORD(wParam) == BN_DOUBLECLICKED)
2340 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
2343 if (HIWORD(wParam) == BN_CLICKED ||
2344 HIWORD(wParam) == BN_DOUBLECLICKED)
2345 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
2348 if (HIWORD(wParam) == BN_CLICKED ||
2349 HIWORD(wParam) == BN_DOUBLECLICKED)
2351 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
2354 if (HIWORD(wParam) == EN_CHANGE)
2355 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
2358 if (HIWORD(wParam) == EN_CHANGE)
2359 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
2362 if (HIWORD(wParam) == EN_CHANGE)
2363 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
2365 case IDC_CHOOSEFONT:
2368 lf.lfHeight = -MulDiv(cfg.fontheight,
2369 GetDeviceCaps(hdc, LOGPIXELSY),
2373 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
2374 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
2375 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
2376 lf.lfCharSet = cfg.fontcharset;
2377 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
2378 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
2379 lf.lfQuality = DEFAULT_QUALITY;
2380 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
2381 strncpy(lf.lfFaceName, cfg.font,
2382 sizeof(lf.lfFaceName) - 1);
2383 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
2385 cf.lStructSize = sizeof(cf);
2386 cf.hwndOwner = hwnd;
2388 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
2389 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
2391 if (ChooseFont(&cf)) {
2392 strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
2393 cfg.font[sizeof(cfg.font) - 1] = '\0';
2394 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
2395 cfg.fontcharset = lf.lfCharSet;
2396 cfg.fontheight = cf.iPointSize / 10;
2397 fmtfont(fontstatic);
2398 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
2401 case IDC_BELL_DISABLED:
2402 case IDC_BELL_DEFAULT:
2403 case IDC_BELL_WAVEFILE:
2404 case IDC_BELL_VISUAL:
2405 if (HIWORD(wParam) == BN_CLICKED ||
2406 HIWORD(wParam) == BN_DOUBLECLICKED) {
2407 if (LOWORD(wParam) == IDC_BELL_DISABLED)
2408 cfg.beep = BELL_DISABLED;
2409 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
2410 cfg.beep = BELL_DEFAULT;
2411 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
2412 cfg.beep = BELL_WAVEFILE;
2413 if (LOWORD(wParam) == IDC_BELL_VISUAL)
2414 cfg.beep = BELL_VISUAL;
2417 case IDC_B_IND_DISABLED:
2418 case IDC_B_IND_FLASH:
2419 case IDC_B_IND_STEADY:
2420 if (HIWORD(wParam) == BN_CLICKED ||
2421 HIWORD(wParam) == BN_DOUBLECLICKED) {
2422 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2423 cfg.beep_ind = B_IND_DISABLED;
2424 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2425 cfg.beep_ind = B_IND_FLASH;
2426 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2427 cfg.beep_ind = B_IND_STEADY;
2430 case IDC_BELL_WAVEBROWSE:
2431 memset(&of, 0, sizeof(of));
2432 #ifdef OPENFILENAME_SIZE_VERSION_400
2433 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2435 of.lStructSize = sizeof(of);
2437 of.hwndOwner = hwnd;
2438 of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2439 of.lpstrCustomFilter = NULL;
2440 of.nFilterIndex = 1;
2441 of.lpstrFile = filename;
2442 strcpy(filename, cfg.bell_wavefile);
2443 of.nMaxFile = sizeof(filename);
2444 of.lpstrFileTitle = NULL;
2445 of.lpstrInitialDir = NULL;
2446 of.lpstrTitle = "Select Bell Sound File";
2448 if (GetOpenFileName(&of)) {
2449 strcpy(cfg.bell_wavefile, filename);
2450 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2454 case IDC_BELL_WAVEEDIT:
2455 if (HIWORD(wParam) == EN_CHANGE)
2456 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2458 sizeof(cfg.bell_wavefile) - 1);
2461 if (HIWORD(wParam) == BN_CLICKED ||
2462 HIWORD(wParam) == BN_DOUBLECLICKED)
2464 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2467 if (HIWORD(wParam) == EN_CHANGE)
2468 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2471 if (HIWORD(wParam) == EN_CHANGE)
2472 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2476 if (HIWORD(wParam) == EN_CHANGE)
2477 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2481 if (HIWORD(wParam) == BN_CLICKED ||
2482 HIWORD(wParam) == BN_DOUBLECLICKED)
2484 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2487 if (HIWORD(wParam) == BN_CLICKED ||
2488 HIWORD(wParam) == BN_DOUBLECLICKED)
2489 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2492 if (HIWORD(wParam) == BN_CLICKED ||
2493 HIWORD(wParam) == BN_DOUBLECLICKED)
2494 cfg.win_name_always =
2495 IsDlgButtonChecked(hwnd, IDC_WINNAME);
2498 if (HIWORD(wParam) == BN_CLICKED ||
2499 HIWORD(wParam) == BN_DOUBLECLICKED)
2501 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2503 case IDC_SUNKENEDGE:
2504 if (HIWORD(wParam) == BN_CLICKED ||
2505 HIWORD(wParam) == BN_DOUBLECLICKED)
2507 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2510 if (HIWORD(wParam) == EN_CHANGE)
2511 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2512 &cfg.window_border);
2513 if (cfg.window_border > 32)
2514 cfg.window_border = 32;
2517 if (HIWORD(wParam) == BN_CLICKED ||
2518 HIWORD(wParam) == BN_DOUBLECLICKED)
2519 cfg.cursor_type = 0;
2522 if (HIWORD(wParam) == BN_CLICKED ||
2523 HIWORD(wParam) == BN_DOUBLECLICKED)
2524 cfg.cursor_type = 1;
2527 if (HIWORD(wParam) == BN_CLICKED ||
2528 HIWORD(wParam) == BN_DOUBLECLICKED)
2529 cfg.cursor_type = 2;
2532 if (HIWORD(wParam) == BN_CLICKED ||
2533 HIWORD(wParam) == BN_DOUBLECLICKED)
2535 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2538 if (HIWORD(wParam) == BN_CLICKED ||
2539 HIWORD(wParam) == BN_DOUBLECLICKED)
2541 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2543 case IDC_SCROLLBARFULLSCREEN:
2544 if (HIWORD(wParam) == BN_CLICKED ||
2545 HIWORD(wParam) == BN_DOUBLECLICKED)
2546 cfg.scrollbar_in_fullscreen =
2547 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2549 case IDC_RESIZETERM:
2550 case IDC_RESIZEFONT:
2551 case IDC_RESIZENONE:
2552 case IDC_RESIZEEITHER:
2553 if (HIWORD(wParam) == BN_CLICKED ||
2554 HIWORD(wParam) == BN_DOUBLECLICKED) {
2556 IsDlgButtonChecked(hwnd,
2557 IDC_RESIZETERM) ? RESIZE_TERM :
2558 IsDlgButtonChecked(hwnd,
2559 IDC_RESIZEFONT) ? RESIZE_FONT :
2560 IsDlgButtonChecked(hwnd,
2561 IDC_RESIZEEITHER) ? RESIZE_EITHER :
2566 if (HIWORD(wParam) == EN_CHANGE)
2567 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2568 sizeof(cfg.wintitle) - 1);
2573 if (HIWORD(wParam) == BN_CLICKED ||
2574 HIWORD(wParam) == BN_DOUBLECLICKED) {
2576 IsDlgButtonChecked(hwnd,
2577 IDC_COEALWAYS) ? COE_ALWAYS :
2578 IsDlgButtonChecked(hwnd,
2579 IDC_COENEVER) ? COE_NEVER :
2584 if (HIWORD(wParam) == BN_CLICKED ||
2585 HIWORD(wParam) == BN_DOUBLECLICKED)
2587 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
2590 if (HIWORD(wParam) == EN_CHANGE)
2591 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
2592 sizeof(cfg.termtype) - 1);
2595 if (HIWORD(wParam) == EN_CHANGE)
2596 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
2597 sizeof(cfg.logfilename) - 1);
2600 memset(&of, 0, sizeof(of));
2601 #ifdef OPENFILENAME_SIZE_VERSION_400
2602 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2604 of.lStructSize = sizeof(of);
2606 of.hwndOwner = hwnd;
2607 of.lpstrFilter = "All Files\0*\0\0\0";
2608 of.lpstrCustomFilter = NULL;
2609 of.nFilterIndex = 1;
2610 of.lpstrFile = filename;
2611 strcpy(filename, cfg.logfilename);
2612 of.nMaxFile = sizeof(filename);
2613 of.lpstrFileTitle = NULL;
2614 of.lpstrInitialDir = NULL;
2615 of.lpstrTitle = "Select session log file";
2617 if (GetSaveFileName(&of)) {
2618 strcpy(cfg.logfilename, filename);
2619 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
2623 case IDC_LSTATASCII:
2625 case IDC_LSTATPACKET:
2626 if (HIWORD(wParam) == BN_CLICKED ||
2627 HIWORD(wParam) == BN_DOUBLECLICKED) {
2628 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
2629 cfg.logtype = LGTYP_NONE;
2630 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
2631 cfg.logtype = LGTYP_ASCII;
2632 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
2633 cfg.logtype = LGTYP_DEBUG;
2634 if (IsDlgButtonChecked(hwnd, IDC_LSTATPACKET))
2635 cfg.logtype = LGTYP_PACKETS;
2641 if (HIWORD(wParam) == BN_CLICKED ||
2642 HIWORD(wParam) == BN_DOUBLECLICKED) {
2643 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
2644 cfg.logxfovr = LGXF_ASK;
2645 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
2646 cfg.logxfovr = LGXF_APN;
2647 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
2648 cfg.logxfovr = LGXF_OVR;
2653 if (HIWORD(wParam) == EN_CHANGE)
2654 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
2655 sizeof(cfg.termspeed) - 1);
2658 if (HIWORD(wParam) == EN_CHANGE)
2659 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
2660 sizeof(cfg.username) - 1);
2662 case IDC_RLLUSEREDIT:
2663 if (HIWORD(wParam) == EN_CHANGE)
2664 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
2666 sizeof(cfg.localusername) - 1);
2670 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
2674 cfg.passive_telnet =
2675 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
2678 if (HIWORD(wParam) == BN_CLICKED ||
2679 HIWORD(wParam) == BN_DOUBLECLICKED) {
2680 char str[sizeof(cfg.environmt)];
2682 GetDlgItemText(hwnd, IDC_VAREDIT, str,
2688 p = str + strlen(str);
2690 GetDlgItemText(hwnd, IDC_VALEDIT, p,
2691 sizeof(str) - 1 - (p - str));
2702 if ((p - cfg.environmt) + strlen(str) + 2 <
2703 sizeof(cfg.environmt)) {
2705 p[strlen(str) + 1] = '\0';
2706 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
2708 SetDlgItemText(hwnd, IDC_VAREDIT, "");
2709 SetDlgItemText(hwnd, IDC_VALEDIT, "");
2711 MessageBox(hwnd, "Environment too big",
2712 "PuTTY Error", MB_OK | MB_ICONERROR);
2717 if (HIWORD(wParam) != BN_CLICKED &&
2718 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2720 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
2727 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
2754 if (HIWORD(wParam) == BN_CLICKED ||
2755 HIWORD(wParam) == BN_DOUBLECLICKED)
2756 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
2759 if (HIWORD(wParam) == BN_CLICKED ||
2760 HIWORD(wParam) == BN_DOUBLECLICKED)
2762 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
2765 if (HIWORD(wParam) == BN_CLICKED ||
2766 HIWORD(wParam) == BN_DOUBLECLICKED)
2768 IsDlgButtonChecked(hwnd, IDC_BUGGYMAC);
2771 if (HIWORD(wParam) == BN_CLICKED ||
2772 HIWORD(wParam) == BN_DOUBLECLICKED)
2774 IsDlgButtonChecked(hwnd, IDC_SSH2DES);
2777 if (HIWORD(wParam) == BN_CLICKED ||
2778 HIWORD(wParam) == BN_DOUBLECLICKED)
2780 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
2782 case IDC_CHANGEUSER:
2783 if (HIWORD(wParam) == BN_CLICKED ||
2784 HIWORD(wParam) == BN_DOUBLECLICKED)
2785 cfg.change_username =
2786 IsDlgButtonChecked(hwnd, IDC_CHANGEUSER);
2788 case IDC_CIPHERLIST:
2791 handle_prefslist(&cipherlist,
2792 cfg.ssh_cipherlist, CIPHER_MAX,
2793 0, hwnd, wParam, lParam);
2797 if (HIWORD(wParam) == BN_CLICKED ||
2798 HIWORD(wParam) == BN_DOUBLECLICKED) {
2799 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
2801 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
2806 if (HIWORD(wParam) == BN_CLICKED ||
2807 HIWORD(wParam) == BN_DOUBLECLICKED)
2809 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
2812 if (HIWORD(wParam) == BN_CLICKED ||
2813 HIWORD(wParam) == BN_DOUBLECLICKED)
2815 IsDlgButtonChecked(hwnd, IDC_AUTHKI);
2818 if (HIWORD(wParam) == EN_CHANGE)
2819 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
2820 sizeof(cfg.keyfile) - 1);
2823 if (HIWORD(wParam) == EN_CHANGE)
2824 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
2825 sizeof(cfg.remote_cmd) - 1);
2828 memset(&of, 0, sizeof(of));
2829 #ifdef OPENFILENAME_SIZE_VERSION_400
2830 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2832 of.lStructSize = sizeof(of);
2834 of.hwndOwner = hwnd;
2835 of.lpstrFilter = "All Files\0*\0\0\0";
2836 of.lpstrCustomFilter = NULL;
2837 of.nFilterIndex = 1;
2838 of.lpstrFile = filename;
2839 strcpy(filename, cfg.keyfile);
2840 of.nMaxFile = sizeof(filename);
2841 of.lpstrFileTitle = NULL;
2842 of.lpstrInitialDir = NULL;
2843 of.lpstrTitle = "Select Private Key File";
2845 if (GetOpenFileName(&of)) {
2846 strcpy(cfg.keyfile, filename);
2847 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
2851 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
2854 cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
2858 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
2860 case IDC_SELTYPELEX:
2861 case IDC_SELTYPERECT:
2862 cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
2864 case IDC_MOUSEOVERRIDE:
2865 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
2871 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
2876 for (i = 0; i < 128; i++)
2877 if (SendDlgItemMessage
2878 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
2880 cfg.wordness[i] = n;
2881 SendDlgItemMessage(hwnd, IDC_CCLIST,
2882 LB_DELETESTRING, i, 0);
2883 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
2884 (i >= 0x21 && i != 0x7F) ? i : ' ',
2886 SendDlgItemMessage(hwnd, IDC_CCLIST,
2893 case IDC_BOLDCOLOUR:
2894 if (HIWORD(wParam) == BN_CLICKED ||
2895 HIWORD(wParam) == BN_DOUBLECLICKED) {
2898 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
2899 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
2902 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2904 if (n != 12 + 10 * cfg.bold_colour) {
2905 for (i = n; i-- > 0;)
2906 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2907 LB_DELETESTRING, i, 0);
2908 for (i = 0; i < 22; i++)
2909 if (cfg.bold_colour || permcolour[i])
2910 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2912 (LPARAM) colours[i]);
2914 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
2916 InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
2921 if (HIWORD(wParam) == BN_CLICKED ||
2922 HIWORD(wParam) == BN_DOUBLECLICKED)
2924 IsDlgButtonChecked(hwnd, IDC_PALETTE);
2926 case IDC_COLOURLIST:
2927 if (HIWORD(wParam) == LBN_DBLCLK ||
2928 HIWORD(wParam) == LBN_SELCHANGE) {
2930 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2933 if (!cfg.bold_colour)
2934 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
2935 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
2937 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
2939 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
2944 if (HIWORD(wParam) == BN_CLICKED ||
2945 HIWORD(wParam) == BN_DOUBLECLICKED) {
2946 static CHOOSECOLOR cc;
2947 static DWORD custom[16] = { 0 }; /* zero initialisers */
2949 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2952 if (!cfg.bold_colour)
2953 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
2954 cc.lStructSize = sizeof(cc);
2955 cc.hwndOwner = hwnd;
2956 cc.hInstance = (HWND) hinst;
2957 cc.lpCustColors = custom;
2959 RGB(cfg.colours[i][0], cfg.colours[i][1],
2961 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
2962 if (ChooseColor(&cc)) {
2964 (unsigned char) (cc.rgbResult & 0xFF);
2966 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
2968 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
2969 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
2971 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
2973 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
2979 if (HIWORD(wParam) == CBN_SELCHANGE) {
2980 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
2981 CB_GETCURSEL, 0, 0);
2982 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
2983 index, (LPARAM)cfg.line_codepage);
2984 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
2985 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
2986 sizeof(cfg.line_codepage) - 1);
2987 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
2988 strcpy(cfg.line_codepage,
2989 cp_name(decode_codepage(cfg.line_codepage)));
2990 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
2993 case IDC_CAPSLOCKCYR:
2994 if (HIWORD(wParam) == BN_CLICKED ||
2995 HIWORD(wParam) == BN_DOUBLECLICKED) {
2996 cfg.xlat_capslockcyr =
2997 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
3000 case IDC_VTXWINDOWS:
3006 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
3007 : IsDlgButtonChecked(hwnd,
3008 IDC_VTOEMANSI) ? VT_OEMANSI :
3009 IsDlgButtonChecked(hwnd,
3010 IDC_VTOEMONLY) ? VT_OEMONLY :
3011 IsDlgButtonChecked(hwnd,
3012 IDC_VTUNICODE) ? VT_UNICODE :
3015 case IDC_X11_FORWARD:
3016 if (HIWORD(wParam) == BN_CLICKED ||
3017 HIWORD(wParam) == BN_DOUBLECLICKED)
3019 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
3022 if (HIWORD(wParam) == BN_CLICKED ||
3023 HIWORD(wParam) == BN_DOUBLECLICKED)
3024 cfg.lport_acceptall =
3025 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
3028 if (HIWORD(wParam) == BN_CLICKED ||
3029 HIWORD(wParam) == BN_DOUBLECLICKED)
3030 cfg.rport_acceptall =
3031 IsDlgButtonChecked(hwnd, IDC_RPORT_ALL);
3033 case IDC_X11_DISPLAY:
3034 if (HIWORD(wParam) == EN_CHANGE)
3035 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
3036 sizeof(cfg.x11_display) - 1);
3039 if (HIWORD(wParam) == BN_CLICKED ||
3040 HIWORD(wParam) == BN_DOUBLECLICKED) {
3041 char str[sizeof(cfg.portfwd)];
3043 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
3047 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
3051 "You need to specify a source port number",
3052 "PuTTY Error", MB_OK | MB_ICONERROR);
3055 p = str + strlen(str);
3057 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
3058 sizeof(str) - 1 - (p - str));
3059 if (!*p || !strchr(p, ':')) {
3061 "You need to specify a destination address\n"
3062 "in the form \"host.name:port\"",
3063 "PuTTY Error", MB_OK | MB_ICONERROR);
3072 if ((p - cfg.portfwd) + strlen(str) + 2 <
3073 sizeof(cfg.portfwd)) {
3075 p[strlen(str) + 1] = '\0';
3076 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
3078 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
3079 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
3081 MessageBox(hwnd, "Too many forwardings",
3082 "PuTTY Error", MB_OK | MB_ICONERROR);
3086 case IDC_PFWDREMOVE:
3087 if (HIWORD(wParam) != BN_CLICKED &&
3088 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3089 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
3090 LB_GETCURSEL, 0, 0);
3096 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
3126 int id = ((LPHELPINFO)lParam)->iCtrlId;
3127 char *cmd = help_context_cmd(id);
3129 WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
3130 requested_help = TRUE;
3137 if (requested_help) {
3138 WinHelp(hwnd, help_path, HELP_QUIT, 0);
3139 requested_help = FALSE;
3144 /* Grrr Explorer will maximize Dialogs! */
3146 if (wParam == SIZE_MAXIMIZED)
3152 * Handle application-defined messages eg. DragListBox
3154 /* First find out what the number is (once). */
3155 if (draglistmsg == WM_NULL)
3156 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
3158 if (msg == draglistmsg) {
3159 /* Only process once dialog is fully formed. */
3160 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
3161 case IDC_CIPHERLIST:
3162 return handle_prefslist(&cipherlist,
3163 cfg.ssh_cipherlist, CIPHER_MAX,
3164 1, hwnd, wParam, lParam);
3173 static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
3174 WPARAM wParam, LPARAM lParam)
3176 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
3178 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
3179 EnableWindow(hwnd, 0);
3180 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3181 EnableWindow(hwnd, 1);
3182 SetActiveWindow(hwnd);
3184 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
3187 static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
3188 WPARAM wParam, LPARAM lParam)
3190 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
3193 void defuse_showwindow(void)
3196 * Work around the fact that the app's first call to ShowWindow
3197 * will ignore the default in favour of the shell-provided
3202 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
3204 ShowWindow(hwnd, SW_HIDE);
3205 SetActiveWindow(hwnd);
3206 DestroyWindow(hwnd);
3215 savedsession[0] = '\0';
3217 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
3218 get_sesslist(FALSE);
3223 int do_reconfig(HWND hwnd)
3228 backup_cfg = cfg; /* structure copy */
3230 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
3232 cfg = backup_cfg; /* structure copy */
3237 void logevent(char *string)
3242 if (nevents >= negsize) {
3244 events = srealloc(events, negsize * sizeof(*events));
3248 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
3251 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
3252 strcpy(events[nevents], timebuf);
3253 strcat(events[nevents], string);
3256 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
3257 0, (LPARAM) events[nevents]);
3258 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
3259 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
3264 void showeventlog(HWND hwnd)
3267 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
3269 ShowWindow(logbox, SW_SHOWNORMAL);
3271 SetActiveWindow(logbox);
3274 void showabout(HWND hwnd)
3276 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
3279 void verify_ssh_host_key(char *host, int port, char *keytype,
3280 char *keystr, char *fingerprint)
3284 static const char absentmsg[] =
3285 "The server's host key is not cached in the registry. You\n"
3286 "have no guarantee that the server is the computer you\n"
3288 "The server's key fingerprint is:\n"
3290 "If you trust this host, hit Yes to add the key to\n"
3291 "PuTTY's cache and carry on connecting.\n"
3292 "If you want to carry on connecting just once, without\n"
3293 "adding the key to the cache, hit No.\n"
3294 "If you do not trust this host, hit Cancel to abandon the\n"
3297 static const char wrongmsg[] =
3298 "WARNING - POTENTIAL SECURITY BREACH!\n"
3300 "The server's host key does not match the one PuTTY has\n"
3301 "cached in the registry. This means that either the\n"
3302 "server administrator has changed the host key, or you\n"
3303 "have actually connected to another computer pretending\n"
3304 "to be the server.\n"
3305 "The new key fingerprint is:\n"
3307 "If you were expecting this change and trust the new key,\n"
3308 "hit Yes to update PuTTY's cache and continue connecting.\n"
3309 "If you want to carry on connecting but without updating\n"
3310 "the cache, hit No.\n"
3311 "If you want to abandon the connection completely, hit\n"
3312 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3314 static const char mbtitle[] = "PuTTY Security Alert";
3317 /* sensible fingerprint max size */
3318 (sizeof(absentmsg) > sizeof(wrongmsg) ?
3319 sizeof(absentmsg) : sizeof(wrongmsg))];
3322 * Verify the key against the registry.
3324 ret = verify_host_key(host, port, keytype, keystr);
3326 if (ret == 0) /* success - key matched OK */
3328 if (ret == 2) { /* key was different */
3330 sprintf(message, wrongmsg, fingerprint);
3331 mbret = MessageBox(NULL, message, mbtitle,
3332 MB_ICONWARNING | MB_YESNOCANCEL);
3334 store_host_key(host, port, keytype, keystr);
3335 if (mbret == IDCANCEL)
3338 if (ret == 1) { /* key was absent */
3340 sprintf(message, absentmsg, fingerprint);
3341 mbret = MessageBox(NULL, message, mbtitle,
3342 MB_ICONWARNING | MB_YESNOCANCEL);
3344 store_host_key(host, port, keytype, keystr);
3345 if (mbret == IDCANCEL)
3351 * Ask whether the selected cipher is acceptable (since it was
3352 * below the configured 'warn' threshold).
3353 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3355 void askcipher(char *ciphername, int cs)
3357 static const char mbtitle[] = "PuTTY Security Alert";
3358 static const char msg[] =
3359 "The first %.35scipher supported by the server\n"
3360 "is %.64s, which is below the configured\n"
3361 "warning threshold.\n"
3362 "Do you want to continue with this connection?\n";
3363 /* guessed cipher name + type max length */
3364 char message[100 + sizeof(msg)];
3367 sprintf(message, msg,
3369 (cs == 1) ? "client-to-server " :
3370 "server-to-client ",
3372 mbret = MessageBox(NULL, message, mbtitle,
3373 MB_ICONWARNING | MB_YESNO);
3381 * Ask whether to wipe a session log file before writing to it.
3382 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3384 int askappend(char *filename)
3386 static const char mbtitle[] = "PuTTY Log to File";
3387 static const char msgtemplate[] =
3388 "The session log file \"%.*s\" already exists.\n"
3389 "You can overwrite it with a new session log,\n"
3390 "append your session log to the end of it,\n"
3391 "or disable session logging for this session.\n"
3392 "Hit Yes to wipe the file, No to append to it,\n"
3393 "or Cancel to disable logging.";
3394 char message[sizeof(msgtemplate) + FILENAME_MAX];
3396 if (cfg.logxfovr != LGXF_ASK) {
3397 return ((cfg.logxfovr == LGXF_OVR) ? 2 : 1);
3399 sprintf(message, msgtemplate, FILENAME_MAX, filename);
3401 mbret = MessageBox(NULL, message, mbtitle,
3402 MB_ICONQUESTION | MB_YESNOCANCEL);
3405 else if (mbret == IDNO)
3412 * Warn about the obsolescent key file format.
3414 void old_keyfile_warning(void)
3416 static const char mbtitle[] = "PuTTY Key File Warning";
3417 static const char message[] =
3418 "You are loading an SSH 2 private key which has an\n"
3419 "old version of the file format. This means your key\n"
3420 "file is not fully tamperproof. Future versions of\n"
3421 "PuTTY may stop supporting this private key format,\n"
3422 "so we recommend you convert your key to the new\n"
3425 "You can perform this conversion by loading the key\n"
3426 "into PuTTYgen and then saving it again.";
3428 MessageBox(NULL, message, mbtitle, MB_OK);