16 #define TVINSERTSTRUCT TV_INSERTSTRUCT
17 #define TVITEM TV_ITEM
21 static char **events
= NULL
;
22 static int nevents
= 0, negsize
= 0;
25 static int sesslist_has_focus
;
26 static int requested_help
;
28 static struct prefslist cipherlist
;
30 #define PRINTER_DISABLED_STRING "None (printing disabled)"
32 void force_normal(HWND hwnd
)
34 static int recurse
= 0;
42 wp
.length
= sizeof(wp
);
43 if (GetWindowPlacement(hwnd
, &wp
) && wp
.showCmd
== SW_SHOWMAXIMIZED
) {
44 wp
.showCmd
= SW_SHOWNORMAL
;
45 SetWindowPlacement(hwnd
, &wp
);
50 static void MyGetDlgItemInt(HWND hwnd
, int id
, int *result
)
54 n
= GetDlgItemInt(hwnd
, id
, &ok
, FALSE
);
59 static void MyGetDlgItemFlt(HWND hwnd
, int id
, int *result
, int scale
)
63 ok
= GetDlgItemText(hwnd
, id
, text
, sizeof(text
) - 1);
65 *result
= (int) (scale
* atof(text
));
68 static void MySetDlgItemFlt(HWND hwnd
, int id
, double value
)
71 sprintf(text
, "%g", value
);
72 SetDlgItemText(hwnd
, id
, text
);
75 static int CALLBACK
LogProc(HWND hwnd
, UINT msg
,
76 WPARAM wParam
, LPARAM lParam
)
83 static int tabs
[4] = { 78, 108 };
84 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETTABSTOPS
, 2,
87 for (i
= 0; i
< nevents
; i
++)
88 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_ADDSTRING
,
89 0, (LPARAM
) events
[i
]);
92 switch (LOWORD(wParam
)) {
96 SetActiveWindow(GetParent(hwnd
));
100 if (HIWORD(wParam
) == BN_CLICKED
||
101 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
104 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
105 LB_GETSELCOUNT
, 0, 0);
106 if (selcount
== 0) { /* don't even try to copy zero items */
111 selitems
= smalloc(selcount
* sizeof(int));
113 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
120 static unsigned char sel_nl
[] = SEL_NL
;
122 if (count
== 0) { /* can't copy zero stuff */
128 for (i
= 0; i
< count
; i
++)
130 strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
132 clipdata
= smalloc(size
);
135 for (i
= 0; i
< count
; i
++) {
136 char *q
= events
[selitems
[i
]];
137 int qlen
= strlen(q
);
140 memcpy(p
, sel_nl
, sizeof(sel_nl
));
143 write_aclip(clipdata
, size
, TRUE
);
148 for (i
= 0; i
< nevents
; i
++)
149 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
158 SetActiveWindow(GetParent(hwnd
));
165 static int CALLBACK
LicenceProc(HWND hwnd
, UINT msg
,
166 WPARAM wParam
, LPARAM lParam
)
172 switch (LOWORD(wParam
)) {
185 static int CALLBACK
AboutProc(HWND hwnd
, UINT msg
,
186 WPARAM wParam
, LPARAM lParam
)
190 SetDlgItemText(hwnd
, IDA_VERSION
, ver
);
193 switch (LOWORD(wParam
)) {
196 EndDialog(hwnd
, TRUE
);
199 EnableWindow(hwnd
, 0);
200 DialogBox(hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
202 EnableWindow(hwnd
, 1);
203 SetActiveWindow(hwnd
);
207 /* Load web browser */
208 ShellExecute(hwnd
, "open",
209 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
210 0, 0, SW_SHOWDEFAULT
);
215 EndDialog(hwnd
, TRUE
);
222 * Null dialog procedure.
224 static int CALLBACK
NullDlgProc(HWND hwnd
, UINT msg
,
225 WPARAM wParam
, LPARAM lParam
)
230 static char savedsession
[2048];
233 IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
386 IDC_SCROLLBARFULLSCREEN
,
401 IDC_FULLSCREENONALTENTER
,
404 appearancepanelstart
,
405 IDC_TITLE_APPEARANCE
,
427 connectionpanelstart
,
428 IDC_TITLE_CONNECTION
,
453 IDC_PROXYEXCLUDESTATIC
,
454 IDC_PROXYEXCLUDEEDIT
,
460 IDC_PROXYTELNETCMDSTATIC
,
461 IDC_PROXYTELNETCMDEDIT
,
462 IDC_PROXYSOCKSVERSTATIC
,
573 translationpanelstart
,
574 IDC_TITLE_TRANSLATION
,
575 IDC_BOX_TRANSLATION1
,
576 IDC_BOX_TRANSLATION2
,
577 IDC_BOX_TRANSLATION3
,
615 static const char *const colours
[] = {
616 "Default Foreground", "Default Bold Foreground",
617 "Default Background", "Default Bold Background",
618 "Cursor Text", "Cursor Colour",
619 "ANSI Black", "ANSI Black Bold",
620 "ANSI Red", "ANSI Red Bold",
621 "ANSI Green", "ANSI Green Bold",
622 "ANSI Yellow", "ANSI Yellow Bold",
623 "ANSI Blue", "ANSI Blue Bold",
624 "ANSI Magenta", "ANSI Magenta Bold",
625 "ANSI Cyan", "ANSI Cyan Bold",
626 "ANSI White", "ANSI White Bold"
628 static const int permcolour
[] = {
629 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
630 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
631 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
634 static void fmtfont(char *buf
)
636 sprintf(buf
, "Font: %s, ", cfg
.font
);
638 strcat(buf
, "bold, ");
639 if (cfg
.fontheight
== 0)
640 strcat(buf
, "default height");
642 sprintf(buf
+ strlen(buf
), "%d-point",
643 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
646 char *help_context_cmd(int id
)
658 return "JI(`',`session.hostname')";
665 return "JI(`',`session.saved')";
670 return "JI(`',`session.coe')";
671 case IDC_LSTATSTATIC
:
675 case IDC_LSTATPACKET
:
676 return "JI(`',`logging.main')";
681 return "JI(`',`logging.filename')";
686 return "JI(`',`logging.exists')";
691 return "JI(`',`keyboard.backspace')";
695 return "JI(`',`keyboard.homeend')";
703 return "JI(`',`keyboard.funkeys')";
707 return "JI(`',`keyboard.appkeypad')";
711 return "JI(`',`keyboard.appcursor')";
713 return "JI(`',`keyboard.nethack')";
715 return "JI(`',`keyboard.compose')";
716 case IDC_CTRLALTKEYS
:
717 return "JI(`',`keyboard.ctrlalt')";
721 return "JI(`',`features.application')";
723 return "JI(`',`features.mouse')";
725 return "JI(`',`features.resize')";
726 case IDC_NOALTSCREEN
:
727 return "JI(`',`features.altscreen')";
729 return "JI(`',`features.retitle')";
730 case IDC_NODBACKSPACE
:
731 return "JI(`',`features.dbackspace')";
733 return "JI(`',`features.charset')";
736 return "JI(`',`terminal.autowrap')";
738 return "JI(`',`terminal.decom')";
740 return "JI(`',`terminal.lfhascr')";
742 return "JI(`',`terminal.bce')";
744 return "JI(`',`terminal.blink')";
747 return "JI(`',`terminal.answerback')";
749 case IDC_ECHOBACKEND
:
752 return "JI(`',`terminal.localecho')";
754 case IDC_EDITBACKEND
:
757 return "JI(`',`terminal.localedit')";
758 case IDC_PRINTERSTATIC
:
760 return "JI(`',`terminal.printing')";
763 case IDC_BELL_DISABLED
:
764 case IDC_BELL_DEFAULT
:
765 case IDC_BELL_WAVEFILE
:
766 case IDC_BELL_VISUAL
:
767 case IDC_BELL_WAVESTATIC
:
768 case IDC_BELL_WAVEEDIT
:
769 case IDC_BELL_WAVEBROWSE
:
770 return "JI(`',`bell.style')";
771 case IDC_B_IND_STATIC
:
772 case IDC_B_IND_DISABLED
:
773 case IDC_B_IND_FLASH
:
774 case IDC_B_IND_STEADY
:
775 return "JI(`',`bell.taskbar')";
777 case IDC_BELLOVLNSTATIC
:
779 case IDC_BELLOVLTSTATIC
:
781 case IDC_BELLOVLEXPLAIN
:
782 case IDC_BELLOVLSSTATIC
:
784 return "JI(`',`bell.overload')";
790 return "JI(`',`window.size')";
791 case IDC_RESIZESTATIC
:
795 case IDC_RESIZEEITHER
:
796 return "JI(`',`window.resize')";
798 case IDC_SCROLLBARFULLSCREEN
:
803 return "JI(`',`window.scrollback')";
806 return "JI(`',`behaviour.closewarn')";
808 return "JI(`',`behaviour.altf4')";
810 return "JI(`',`behaviour.altspace')";
812 return "JI(`',`behaviour.altonly')";
813 case IDC_ALWAYSONTOP
:
814 return "JI(`',`behaviour.alwaysontop')";
815 case IDC_FULLSCREENONALTENTER
:
816 return "JI(`',`behaviour.altenter')";
818 case IDC_CURSORSTATIC
:
823 return "JI(`',`appearance.cursor')";
826 return "JI(`',`appearance.font')";
830 return "JI(`',`appearance.title')";
832 return "JI(`',`appearance.hidemouse')";
836 return "JI(`',`appearance.border')";
840 return "JI(`',`connection.termtype')";
843 return "JI(`',`connection.username')";
846 return "JI(`',`connection.keepalive')";
848 return "JI(`',`connection.nodelay')";
852 return "JI(`',`telnet.termspeed')";
861 return "JI(`',`telnet.environ')";
865 return "JI(`',`telnet.oldenviron')";
869 return "JI(`',`telnet.passive')";
871 return "JI(`',`telnet.specialkeys')";
873 return "JI(`',`telnet.newline')";
877 return "JI(`',`rlogin.termspeed')";
878 case IDC_RLLUSERSTATIC
:
879 case IDC_RLLUSEREDIT
:
880 return "JI(`',`rlogin.localuser')";
883 return "JI(`',`ssh.nopty')";
884 case IDC_CIPHERSTATIC2
:
889 return "JI(`',`ssh.ciphers')";
891 return "JI(`',`ssh.buggymac')";
892 case IDC_SSHPROTSTATIC
:
895 return "JI(`',`ssh.protocol')";
898 return "JI(`',`ssh.command')";
900 return "JI(`',`ssh.compress')";
905 return "JI(`',`ssh.auth.privkey')";
907 return "JI(`',`ssh.auth.agentfwd')";
909 return "JI(`',`ssh.auth.changeuser')";
911 return "JI(`',`ssh.auth.tis')";
913 return "JI(`',`ssh.auth.ki')";
918 return "JI(`',`selection.buttons')";
919 case IDC_MOUSEOVERRIDE
:
920 return "JI(`',`selection.shiftdrag')";
921 case IDC_SELTYPESTATIC
:
923 case IDC_SELTYPERECT
:
924 return "JI(`',`selection.rect')";
930 return "JI(`',`selection.charclasses')";
932 return "JI(`',`selection.linedraw')";
934 return "JI(`',`selection.rtf')";
937 return "JI(`',`colours.bold')";
939 return "JI(`',`colours.logpal')";
940 case IDC_COLOURSTATIC
:
949 return "JI(`',`colours.config')";
951 case IDC_CODEPAGESTATIC
:
953 return "JI(`',`translation.codepage')";
954 case IDC_CAPSLOCKCYR
:
955 return "JI(`',`translation.cyrillic')";
962 return "JI(`',`translation.linedraw')";
964 case IDC_X11_FORWARD
:
965 case IDC_X11_DISPSTATIC
:
966 case IDC_X11_DISPLAY
:
967 return "JI(`',`ssh.tunnels.x11')";
969 case IDC_PFWDSTATIC2
:
973 case IDC_SPORTSTATIC
:
975 case IDC_DPORTSTATIC
:
979 return "JI(`',`ssh.tunnels.portfwd')";
982 return "JI(`',`ssh.tunnels.portfwd.localhost')";
989 /* 2nd arg: NZ => don't redraw session list (use when loading
991 static void init_dlg_ctrls(HWND hwnd
, int keepsess
)
994 char fontstatic
[256];
996 SetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
);
997 SetDlgItemText(hwnd
, IDC_SESSEDIT
, savedsession
);
1000 n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
1001 for (i
= n
; i
-- > 0;)
1002 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_DELETESTRING
, i
, 0);
1003 for (i
= 0; i
< nsessions
; i
++)
1004 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1005 0, (LPARAM
) (sessions
[i
]));
1007 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1008 CheckRadioButton(hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
1009 cfg
.protocol
== PROT_SSH ? IDC_PROTSSH
:
1010 cfg
.protocol
== PROT_TELNET ? IDC_PROTTELNET
:
1012 PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
1013 SetDlgItemInt(hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
1014 CheckDlgButton(hwnd
, IDC_NODELAY
, cfg
.tcp_nodelay
);
1016 CheckRadioButton(hwnd
, IDC_DEL008
, IDC_DEL127
,
1017 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
1018 CheckRadioButton(hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
1019 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
1020 CheckRadioButton(hwnd
, IDC_FUNCTILDE
, IDC_FUNCSCO
,
1021 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
1022 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
1023 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
1024 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
1025 cfg
.funky_type
== 4 ? IDC_FUNCVT100P
:
1026 cfg
.funky_type
== 5 ? IDC_FUNCSCO
: IDC_FUNCTILDE
);
1027 CheckDlgButton(hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
1028 CheckDlgButton(hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
1029 CheckDlgButton(hwnd
, IDC_NOMOUSEREP
, cfg
.no_mouse_rep
);
1030 CheckDlgButton(hwnd
, IDC_NORESIZE
, cfg
.no_remote_resize
);
1031 CheckDlgButton(hwnd
, IDC_NOALTSCREEN
, cfg
.no_alt_screen
);
1032 CheckDlgButton(hwnd
, IDC_NOWINTITLE
, cfg
.no_remote_wintitle
);
1033 CheckDlgButton(hwnd
, IDC_NODBACKSPACE
, cfg
.no_dbackspace
);
1034 CheckDlgButton(hwnd
, IDC_NOCHARSET
, cfg
.no_remote_charset
);
1035 CheckRadioButton(hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
1036 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
1037 CheckRadioButton(hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
1038 cfg
.nethack_keypad ? IDC_KPNH
:
1039 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
1040 CheckDlgButton(hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
1041 CheckDlgButton(hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
1042 CheckDlgButton(hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
1043 CheckDlgButton(hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
1044 CheckDlgButton(hwnd
, IDC_CTRLALTKEYS
, cfg
.ctrlaltkeys
);
1045 CheckDlgButton(hwnd
, IDC_TELNETKEY
, cfg
.telnet_keyboard
);
1046 CheckDlgButton(hwnd
, IDC_TELNETRET
, cfg
.telnet_newline
);
1047 CheckRadioButton(hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
1048 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
1049 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
1050 CheckRadioButton(hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
1051 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
1052 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
1053 SetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
);
1054 CheckDlgButton(hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
1055 CheckDlgButton(hwnd
, IDC_FULLSCREENONALTENTER
, cfg
.fullscreenonaltenter
);
1056 CheckDlgButton(hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
1057 CheckDlgButton(hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
1059 CheckDlgButton(hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
1060 CheckDlgButton(hwnd
, IDC_DECOM
, cfg
.dec_om
);
1061 CheckDlgButton(hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
1062 SetDlgItemInt(hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
1063 SetDlgItemInt(hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
1064 SetDlgItemInt(hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
1065 fmtfont(fontstatic
);
1066 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
1067 CheckRadioButton(hwnd
, IDC_BELL_DISABLED
, IDC_BELL_VISUAL
,
1068 cfg
.beep
== BELL_DISABLED ? IDC_BELL_DISABLED
:
1069 cfg
.beep
== BELL_DEFAULT ? IDC_BELL_DEFAULT
:
1070 cfg
.beep
== BELL_WAVEFILE ? IDC_BELL_WAVEFILE
:
1072 BELL_VISUAL ? IDC_BELL_VISUAL
: IDC_BELL_DEFAULT
);
1073 CheckRadioButton(hwnd
, IDC_B_IND_DISABLED
, IDC_B_IND_STEADY
,
1075 B_IND_DISABLED ? IDC_B_IND_DISABLED
: cfg
.beep_ind
==
1076 B_IND_FLASH ? IDC_B_IND_FLASH
: cfg
.beep_ind
==
1077 B_IND_STEADY ? IDC_B_IND_STEADY
: IDC_B_IND_DISABLED
);
1078 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
1079 CheckDlgButton(hwnd
, IDC_BELLOVL
, cfg
.bellovl
);
1080 SetDlgItemInt(hwnd
, IDC_BELLOVLN
, cfg
.bellovl_n
, FALSE
);
1081 MySetDlgItemFlt(hwnd
, IDC_BELLOVLT
, cfg
.bellovl_t
/ 1000.0);
1082 MySetDlgItemFlt(hwnd
, IDC_BELLOVLS
, cfg
.bellovl_s
/ 1000.0);
1084 CheckDlgButton(hwnd
, IDC_BCE
, cfg
.bce
);
1085 CheckDlgButton(hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
1087 SetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
1088 CheckDlgButton(hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
1089 CheckDlgButton(hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
1090 CheckDlgButton(hwnd
, IDC_SUNKENEDGE
, cfg
.sunken_edge
);
1091 SetDlgItemInt(hwnd
, IDC_WINBEDIT
, cfg
.window_border
, FALSE
);
1092 CheckRadioButton(hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
1093 cfg
.cursor_type
== 0 ? IDC_CURBLOCK
:
1094 cfg
.cursor_type
== 1 ? IDC_CURUNDER
: IDC_CURVERT
);
1095 CheckDlgButton(hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
1096 CheckDlgButton(hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
1097 CheckDlgButton(hwnd
, IDC_SCROLLBARFULLSCREEN
, cfg
.scrollbar_in_fullscreen
);
1098 CheckRadioButton(hwnd
, IDC_RESIZETERM
, IDC_RESIZEEITHER
,
1099 cfg
.resize_action
== RESIZE_TERM ? IDC_RESIZETERM
:
1100 cfg
.resize_action
== RESIZE_FONT ? IDC_RESIZEFONT
:
1101 cfg
.resize_action
== RESIZE_EITHER ? IDC_RESIZEEITHER
:
1103 CheckRadioButton(hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
1104 cfg
.close_on_exit
== COE_NORMAL ? IDC_COENORMAL
:
1105 cfg
.close_on_exit
==
1106 COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
1107 CheckDlgButton(hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
1109 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
1110 SetDlgItemText(hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
1111 SetDlgItemText(hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
1112 SetDlgItemText(hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
1113 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
1114 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
1115 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATPACKET
,
1116 cfg
.logtype
== LGTYP_NONE ? IDC_LSTATOFF
:
1117 cfg
.logtype
== LGTYP_ASCII ? IDC_LSTATASCII
:
1118 cfg
.logtype
== LGTYP_DEBUG ? IDC_LSTATRAW
:
1120 CheckRadioButton(hwnd
, IDC_LSTATXOVR
, IDC_LSTATXASK
,
1121 cfg
.logxfovr
== LGXF_OVR ? IDC_LSTATXOVR
:
1122 cfg
.logxfovr
== LGXF_ASK ? IDC_LSTATXASK
:
1125 char *p
= cfg
.environmt
;
1126 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_RESETCONTENT
, 0, 0);
1128 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
1134 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
, 0,
1139 CheckRadioButton(hwnd
, IDC_EMBSD
, IDC_EMRFC
,
1140 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
1141 CheckRadioButton(hwnd
, IDC_TPASSIVE
, IDC_TACTIVE
,
1142 cfg
.passive_telnet ? IDC_TPASSIVE
: IDC_TACTIVE
);
1144 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
1145 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
1146 CheckDlgButton(hwnd
, IDC_NOPTY
, cfg
.nopty
);
1147 CheckDlgButton(hwnd
, IDC_COMPRESS
, cfg
.compression
);
1148 CheckDlgButton(hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
1149 CheckDlgButton(hwnd
, IDC_SSH2DES
, cfg
.ssh2_des_cbc
);
1150 CheckDlgButton(hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
1151 CheckDlgButton(hwnd
, IDC_CHANGEUSER
, cfg
.change_username
);
1152 CheckRadioButton(hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
1153 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
1154 CheckDlgButton(hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
1155 CheckDlgButton(hwnd
, IDC_AUTHKI
, cfg
.try_ki_auth
);
1156 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1157 SetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
1161 static const struct { char *s
; int c
; } ciphers
[] = {
1162 { "3DES", CIPHER_3DES
},
1163 { "Blowfish", CIPHER_BLOWFISH
},
1164 { "DES", CIPHER_DES
},
1165 { "AES (SSH 2 only)", CIPHER_AES
},
1166 { "-- warn below here --", CIPHER_WARN
}
1169 /* Set up the "selected ciphers" box. */
1170 /* (cipherlist assumed to contain all ciphers) */
1171 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_RESETCONTENT
, 0, 0);
1172 for (i
= 0; i
< CIPHER_MAX
; i
++) {
1173 int c
= cfg
.ssh_cipherlist
[i
];
1176 for (j
= 0; j
< (sizeof ciphers
) / (sizeof ciphers
[0]); j
++) {
1177 if (ciphers
[j
].c
== c
) {
1178 cstr
= ciphers
[j
].s
;
1182 pos
= SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_ADDSTRING
,
1184 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_SETITEMDATA
,
1190 CheckRadioButton(hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
1191 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
1192 CheckRadioButton(hwnd
, IDC_SELTYPELEX
, IDC_SELTYPERECT
,
1193 cfg
.rect_select
== 0 ? IDC_SELTYPELEX
: IDC_SELTYPERECT
);
1194 CheckDlgButton(hwnd
, IDC_MOUSEOVERRIDE
, cfg
.mouse_override
);
1195 CheckDlgButton(hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
1196 CheckDlgButton(hwnd
, IDC_RTFPASTE
, cfg
.rtf_paste
);
1198 static int tabs
[4] = { 25, 61, 96, 128 };
1199 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
1202 for (i
= 0; i
< 128; i
++) {
1204 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
1205 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ', cfg
.wordness
[i
]);
1206 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
1210 CheckDlgButton(hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
1211 CheckDlgButton(hwnd
, IDC_PALETTE
, cfg
.try_palette
);
1214 n
= SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
1215 for (i
= n
; i
-- > 0;)
1216 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
1217 LB_DELETESTRING
, i
, 0);
1218 for (i
= 0; i
< 22; i
++)
1219 if (cfg
.bold_colour
|| permcolour
[i
])
1220 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
1221 (LPARAM
) colours
[i
]);
1223 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
1224 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
1225 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
1226 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
1231 strcpy(cfg
.line_codepage
, cp_name(decode_codepage(cfg
.line_codepage
)));
1232 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_RESETCONTENT
, 0, 0);
1233 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
1234 for (i
= 0; (cp
= cp_enumerate(i
)) != NULL
; i
++) {
1235 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_ADDSTRING
,
1238 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
1244 pe
= printer_start_enum(&nprinters
);
1245 strcpy(cfg
.line_codepage
, cp_name(decode_codepage(cfg
.line_codepage
)));
1246 SendDlgItemMessage(hwnd
, IDC_PRINTER
, CB_RESETCONTENT
, 0, 0);
1247 SendDlgItemMessage(hwnd
, IDC_PRINTER
, CB_ADDSTRING
,
1248 0, (LPARAM
) PRINTER_DISABLED_STRING
);
1249 for (i
= 0; i
< nprinters
; i
++) {
1250 char *printer_name
= printer_get_name(pe
, i
);
1251 SendDlgItemMessage(hwnd
, IDC_PRINTER
, CB_ADDSTRING
,
1252 0, (LPARAM
) printer_name
);
1254 printer_finish_enum(pe
);
1255 SetDlgItemText(hwnd
, IDC_PRINTER
,
1256 *cfg
.printer ? cfg
.printer
: PRINTER_DISABLED_STRING
);
1259 CheckRadioButton(hwnd
, IDC_VTXWINDOWS
, IDC_VTUNICODE
,
1260 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
1261 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
1262 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
1263 cfg
.vtmode
== VT_UNICODE ? IDC_VTUNICODE
:
1266 CheckDlgButton(hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
1267 SetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
1269 CheckDlgButton(hwnd
, IDC_LPORT_ALL
, cfg
.lport_acceptall
);
1270 CheckDlgButton(hwnd
, IDC_RPORT_ALL
, cfg
.rport_acceptall
);
1271 CheckRadioButton(hwnd
, IDC_PFWDLOCAL
, IDC_PFWDREMOTE
, IDC_PFWDLOCAL
);
1274 CheckRadioButton(hwnd
, IDC_PROXYTYPENONE
, IDC_PROXYTYPETELNET
,
1275 cfg
.proxy_type
== PROXY_HTTP ? IDC_PROXYTYPEHTTP
:
1276 cfg
.proxy_type
== PROXY_SOCKS ? IDC_PROXYTYPESOCKS
:
1277 cfg
.proxy_type
== PROXY_TELNET ? IDC_PROXYTYPETELNET
: IDC_PROXYTYPENONE
);
1278 SetDlgItemText(hwnd
, IDC_PROXYHOSTEDIT
, cfg
.proxy_host
);
1279 SetDlgItemInt(hwnd
, IDC_PROXYPORTEDIT
, cfg
.proxy_port
, FALSE
);
1280 SetDlgItemText(hwnd
, IDC_PROXYEXCLUDEEDIT
, cfg
.proxy_exclude_list
);
1281 SetDlgItemText(hwnd
, IDC_PROXYTELNETCMDEDIT
, cfg
.proxy_telnet_command
);
1282 SetDlgItemText(hwnd
, IDC_PROXYUSEREDIT
, cfg
.proxy_username
);
1283 SetDlgItemText(hwnd
, IDC_PROXYPASSEDIT
, cfg
.proxy_password
);
1284 CheckRadioButton(hwnd
, IDC_PROXYSOCKSVER5
, IDC_PROXYSOCKSVER4
,
1285 cfg
.proxy_socks_version
== 4 ? IDC_PROXYSOCKSVER4
: IDC_PROXYSOCKSVER5
);
1288 struct treeview_faff
{
1290 HTREEITEM lastat
[4];
1293 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
1294 int level
, char *text
)
1299 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
- 1] : TVI_ROOT
);
1300 ins
.hInsertAfter
= faff
->lastat
[level
];
1301 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1302 #define INSITEM DUMMYUNIONNAME.item
1304 #define INSITEM item
1306 ins
.INSITEM
.mask
= TVIF_TEXT
;
1307 ins
.INSITEM
.pszText
= text
;
1308 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
1310 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
- 1],
1312 faff
->lastat
[level
] = newitem
;
1313 for (i
= level
+ 1; i
< 4; i
++)
1314 faff
->lastat
[i
] = NULL
;
1319 * Create the panelfuls of controls in the configuration box.
1321 static void create_controls(HWND hwnd
, int dlgtype
, int panel
)
1323 if (panel
== sessionpanelstart
) {
1324 /* The Session panel. Accelerators used: [acgoh] nprtis elvd w */
1326 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1327 bartitle(&cp
, "Basic options for your PuTTY session",
1330 beginbox(&cp
, "Specify your connection by host name or IP address",
1333 "Host &Name (or IP address)",
1334 IDC_HOSTSTATIC
, IDC_HOST
, 75,
1335 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
1336 if (backends
[3].backend
== NULL
) {
1337 /* this is PuTTYtel, so only three protocols available */
1338 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 3,
1339 "&Raw", IDC_PROTRAW
,
1340 "&Telnet", IDC_PROTTELNET
,
1341 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
1343 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
1344 "&Raw", IDC_PROTRAW
,
1345 "&Telnet", IDC_PROTTELNET
,
1346 "Rlog&in", IDC_PROTRLOGIN
,
1355 beginbox(&cp
, "Load, save or delete a stored session",
1357 sesssaver(&cp
, "Sav&ed Sessions",
1358 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
1359 "&Load", IDC_SESSLOAD
,
1360 "Sa&ve", IDC_SESSSAVE
, "&Delete", IDC_SESSDEL
, NULL
);
1363 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
1364 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
1365 "Always", IDC_COEALWAYS
,
1366 "Never", IDC_COENEVER
,
1367 "Only on clean exit", IDC_COENORMAL
, NULL
);
1371 if (panel
== loggingpanelstart
) {
1372 /* The Logging panel. Accelerators used: [acgoh] tplsfwe */
1374 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1375 bartitle(&cp
, "Options controlling session logging",
1377 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
1379 "Session logging:", IDC_LSTATSTATIC
,
1380 "Logging &turned off completely", IDC_LSTATOFF
,
1381 "Log &printable output only", IDC_LSTATASCII
,
1382 "&Log all session output", IDC_LSTATRAW
,
1383 "Log &SSH packet data", IDC_LSTATPACKET
,
1385 editbutton(&cp
, "Log &file name:",
1386 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
1388 statictext(&cp
, "(Log file name can contain &&Y, &&M, &&D for date,"
1389 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN
);
1391 "What to do if the log file already &exists:",
1392 IDC_LSTATXIST
, "Always overwrite it", IDC_LSTATXOVR
,
1393 "Always append to the end of it", IDC_LSTATXAPN
,
1394 "Ask the user every time", IDC_LSTATXASK
, NULL
);
1398 if (panel
== terminalpanelstart
) {
1399 /* The Terminal panel. Accelerators used: [acgoh] wdren lts p */
1401 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1402 bartitle(&cp
, "Options controlling the terminal emulation",
1403 IDC_TITLE_TERMINAL
);
1404 beginbox(&cp
, "Set various terminal options", IDC_BOX_TERMINAL1
);
1405 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
1406 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
1407 checkbox(&cp
, "Implicit C&R in every LF", IDC_LFHASCR
);
1408 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
1409 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
1411 "An&swerback to ^E:", IDC_ANSWERBACK
,
1412 IDC_ANSWEREDIT
, 100, NULL
);
1415 beginbox(&cp
, "Line discipline options", IDC_BOX_TERMINAL2
);
1416 radioline(&cp
, "&Local echo:", IDC_ECHOSTATIC
, 3,
1417 "Auto", IDC_ECHOBACKEND
,
1418 "Force on", IDC_ECHOYES
, "Force off", IDC_ECHONO
, NULL
);
1419 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
1420 "Auto", IDC_EDITBACKEND
,
1421 "Force on", IDC_EDITYES
, "Force off", IDC_EDITNO
, NULL
);
1424 beginbox(&cp
, "Remote-controlled printing", IDC_BOX_TERMINAL3
);
1425 combobox(&cp
, "&Printer to send ANSI printer output to:",
1426 IDC_PRINTERSTATIC
, IDC_PRINTER
);
1430 if (panel
== featurespanelstart
) {
1431 /* The Features panel. Accelerators used: [acgoh] ukswtbrx */
1433 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1434 bartitle(&cp
, "Enabling and disabling advanced terminal features ",
1435 IDC_TITLE_FEATURES
);
1436 beginbox(&cp
, NULL
, IDC_BOX_FEATURES1
);
1437 checkbox(&cp
, "Disable application c&ursor keys mode", IDC_NOAPPLICC
);
1438 checkbox(&cp
, "Disable application &keypad mode", IDC_NOAPPLICK
);
1439 checkbox(&cp
, "Disable &xterm-style mouse reporting", IDC_NOMOUSEREP
);
1440 checkbox(&cp
, "Disable remote-controlled terminal re&sizing",
1442 checkbox(&cp
, "Disable s&witching to alternate terminal screen",
1444 checkbox(&cp
, "Disable remote-controlled window &title changing",
1446 checkbox(&cp
, "Disable destructive &backspace on server sending ^?",
1448 checkbox(&cp
, "Disable remote-controlled cha&racter set configuration",
1453 if (panel
== bellpanelstart
) {
1454 /* The Bell panel. Accelerators used: [acgoh] bdsm wit */
1456 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1457 bartitle(&cp
, "Options controlling the terminal bell",
1459 beginbox(&cp
, "Set the style of bell", IDC_BOX_BELL1
);
1461 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
1462 "None (bell disabled)", IDC_BELL_DISABLED
,
1463 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
1464 "Play a custom sound file", IDC_BELL_WAVEFILE
,
1465 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
1466 editbutton(&cp
, "Custom sound file to play as a bell:",
1467 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
1468 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
1469 radioline(&cp
, "Taskbar/caption &indication on bell:",
1470 IDC_B_IND_STATIC
, 3, "Disabled", IDC_B_IND_DISABLED
,
1471 "Flashing", IDC_B_IND_FLASH
, "Steady", IDC_B_IND_STEADY
,
1474 beginbox(&cp
, "Control the bell overload behaviour",
1476 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
1478 staticedit(&cp
, "Over-use means this &many bells...",
1479 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
1480 staticedit(&cp
, "... in &this many seconds",
1481 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
1483 "The bell is re-enabled after a few seconds of silence.",
1484 1, IDC_BELLOVLEXPLAIN
);
1485 staticedit(&cp
, "Seconds of &silence required", IDC_BELLOVLSSTATIC
,
1490 if (panel
== keyboardpanelstart
) {
1491 /* The Keyboard panel. Accelerators used: [acgoh] bef rntd */
1493 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1494 bartitle(&cp
, "Options controlling the effects of keys",
1495 IDC_TITLE_KEYBOARD
);
1496 beginbox(&cp
, "Change the sequences sent by:", IDC_BOX_KEYBOARD1
);
1497 radioline(&cp
, "The &Backspace key", IDC_DELSTATIC
, 2,
1498 "Control-H", IDC_DEL008
,
1499 "Control-? (127)", IDC_DEL127
, NULL
);
1500 radioline(&cp
, "The Home and &End keys", IDC_HOMESTATIC
, 2,
1501 "Standard", IDC_HOMETILDE
, "rxvt", IDC_HOMERXVT
, NULL
);
1502 radioline(&cp
, "The &Function keys and keypad", IDC_FUNCSTATIC
, 3,
1503 "ESC[n~", IDC_FUNCTILDE
,
1504 "Linux", IDC_FUNCLINUX
,
1505 "Xterm R6", IDC_FUNCXTERM
,
1506 "VT400", IDC_FUNCVT400
,
1507 "VT100+", IDC_FUNCVT100P
, "SCO", IDC_FUNCSCO
, NULL
);
1509 beginbox(&cp
, "Application keypad settings:", IDC_BOX_KEYBOARD2
);
1510 radioline(&cp
, "Initial state of cu&rsor keys:", IDC_CURSTATIC
, 2,
1511 "Normal", IDC_CURNORMAL
,
1512 "Application", IDC_CURAPPLIC
, NULL
);
1513 radioline(&cp
, "Initial state of &numeric keypad:", IDC_KPSTATIC
,
1514 3, "Normal", IDC_KPNORMAL
, "Application", IDC_KPAPPLIC
,
1515 "NetHack", IDC_KPNH
, NULL
);
1517 beginbox(&cp
, "Enable extra keyboard features:",
1519 checkbox(&cp
, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY
);
1520 checkbox(&cp
, "Control-Alt is &different from AltGr",
1525 if (panel
== windowpanelstart
) {
1526 /* The Window panel. Accelerators used: [acgoh] rmz sdikp */
1528 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1529 bartitle(&cp
, "Options controlling PuTTY's window",
1531 beginbox(&cp
, "Set the size of the window", IDC_BOX_WINDOW1
);
1533 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
1534 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50, NULL
);
1535 radiobig(&cp
, "When window is resi&zed:", IDC_RESIZESTATIC
,
1536 "Change the number of rows and columns", IDC_RESIZETERM
,
1537 "Change the size of the font", IDC_RESIZEFONT
,
1538 "Change font size only when maximised", IDC_RESIZEEITHER
,
1539 "Forbid resizing completely", IDC_RESIZENONE
, NULL
);
1541 beginbox(&cp
, "Control the scrollback in the window",
1543 staticedit(&cp
, "Lines of &scrollback",
1544 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
1545 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
1546 checkbox(&cp
, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN
);
1547 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
1548 checkbox(&cp
, "Reset scrollback on dis&play activity",
1553 if (panel
== appearancepanelstart
) {
1554 /* The Appearance panel. Accelerators used: [acgoh] luvb n ti p s */
1556 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1557 bartitle(&cp
, "Configure the appearance of PuTTY's window",
1558 IDC_TITLE_APPEARANCE
);
1559 beginbox(&cp
, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1
);
1560 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
1561 "B&lock", IDC_CURBLOCK
,
1562 "&Underline", IDC_CURUNDER
,
1563 "&Vertical line", IDC_CURVERT
, NULL
);
1564 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
1566 beginbox(&cp
, "Set the font used in the terminal window",
1567 IDC_BOX_APPEARANCE2
);
1568 staticbtn(&cp
, "", IDC_FONTSTATIC
, "Cha&nge...", IDC_CHOOSEFONT
);
1570 beginbox(&cp
, "Adjust the use of the window title",
1571 IDC_BOX_APPEARANCE3
);
1573 "Window &title:", IDC_WINTITLE
, IDC_WINEDIT
, 100, NULL
);
1574 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
1576 beginbox(&cp
, "Adjust the use of the mouse pointer",
1577 IDC_BOX_APPEARANCE4
);
1578 checkbox(&cp
, "Hide mouse &pointer when typing in window",
1581 beginbox(&cp
, "Adjust the window border", IDC_BOX_APPEARANCE5
);
1582 checkbox(&cp
, "&Sunken-edge border (slightly thicker)",
1584 staticedit(&cp
, "Gap between text and window edge",
1585 IDC_WINBSTATIC
, IDC_WINBEDIT
, 20);
1589 if (panel
== behaviourpanelstart
) {
1590 /* The Behaviour panel. Accelerators used: [acgoh] w4yltf */
1592 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1593 bartitle(&cp
, "Configure the behaviour of PuTTY's window",
1595 beginbox(&cp
, NULL
, IDC_BOX_BEHAVIOUR1
);
1596 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
1597 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
1598 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
1599 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
1600 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
1601 checkbox(&cp
, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER
);
1605 if (panel
== translationpanelstart
) {
1606 /* The Translation panel. Accelerators used: [acgoh] rxbepus */
1608 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1609 bartitle(&cp
, "Options controlling character set translation",
1610 IDC_TITLE_TRANSLATION
);
1611 beginbox(&cp
, "Character set translation on received data",
1612 IDC_BOX_TRANSLATION1
);
1613 combobox(&cp
, "&Received data assumed to be in which character set:",
1614 IDC_CODEPAGESTATIC
, IDC_CODEPAGE
);
1616 beginbox(&cp
, "Enable character set translation on input data",
1617 IDC_BOX_TRANSLATION2
);
1618 checkbox(&cp
, "Cap&s Lock acts as Cyrillic switch",
1621 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
1622 IDC_BOX_TRANSLATION3
);
1624 "Handling of line drawing characters:", IDC_VTSTATIC
,
1625 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
1626 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
1627 "Use font in O&EM mode only", IDC_VTOEMONLY
,
1628 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1629 IDC_VTPOORMAN
, "&Unicode mode", IDC_VTUNICODE
, NULL
);
1633 if (panel
== selectionpanelstart
) {
1634 /* The Selection panel. Accelerators used: [acgoh] df wxp est nr */
1636 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1637 bartitle(&cp
, "Options controlling copy and paste",
1638 IDC_TITLE_SELECTION
);
1639 beginbox(&cp
, "Translation of pasted characters",
1640 IDC_BOX_SELECTION1
);
1642 "&Don't translate line drawing chars into +, - and |",
1645 "Paste to clipboard in RT&F as well as plain text",
1648 beginbox(&cp
, "Control which mouse button does which thing",
1649 IDC_BOX_SELECTION2
);
1650 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1651 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1652 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1655 "Shift overrides a&pplication's use of mouse",
1658 "Default selection mode (Alt+drag does the other one):",
1659 IDC_SELTYPESTATIC
, 2,
1660 "&Normal", IDC_SELTYPELEX
,
1661 "&Rectangular block", IDC_SELTYPERECT
, NULL
);
1663 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1664 IDC_BOX_SELECTION3
);
1665 charclass(&cp
, "Charact&er classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1666 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1667 "&to class", IDC_CCSTATIC2
);
1671 if (panel
== colourspanelstart
) {
1672 /* The Colours panel. Accelerators used: [acgoh] blum */
1674 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1675 bartitle(&cp
, "Options controlling use of colours",
1677 beginbox(&cp
, "General options for colour usage",
1679 checkbox(&cp
, "&Bolded text is a different colour",
1681 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1683 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1685 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1686 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1687 "&Modify...", IDC_CHANGE
,
1688 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1689 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1690 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1694 if (panel
== connectionpanelstart
) {
1695 /* The Connection panel. Accelerators used: [acgoh] tukn */
1697 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1698 bartitle(&cp
, "Options controlling the connection",
1699 IDC_TITLE_CONNECTION
);
1701 beginbox(&cp
, "Data to send to the server",
1702 IDC_BOX_CONNECTION1
);
1703 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
,
1705 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
,
1709 beginbox(&cp
, "Adjust telnet session.", IDC_BOX_CONNECTION1
);
1710 checkbox(&cp
, "Keyboard sends telnet Backspace and Interrupt",
1712 checkbox(&cp
, "Return key sends telnet New Line instead of ^M",
1716 beginbox(&cp
, "Sending of null packets to keep session active",
1717 IDC_BOX_CONNECTION2
);
1718 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1719 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1722 beginbox(&cp
, "Low-level TCP connection options",
1723 IDC_BOX_CONNECTION3
);
1724 checkbox(&cp
, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1730 if (panel
== proxypanelstart
) {
1731 /* The Proxy panel. Accelerators used: [acgoh] ntslypeuwmv */
1733 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1735 bartitle(&cp
, "Options controlling proxy usage",
1737 beginbox(&cp
, "Proxy basics", IDC_BOX_PROXY1
);
1738 radioline(&cp
, "Proxy type:", IDC_PROXYTYPESTATIC
, 4,
1739 "&None", IDC_PROXYTYPENONE
,
1740 "H&TTP", IDC_PROXYTYPEHTTP
,
1741 "&SOCKS", IDC_PROXYTYPESOCKS
,
1742 "Te&lnet", IDC_PROXYTYPETELNET
, NULL
);
1744 "Prox&y Host", IDC_PROXYHOSTSTATIC
, IDC_PROXYHOSTEDIT
, 80,
1745 "&Port", IDC_PROXYPORTSTATIC
, IDC_PROXYPORTEDIT
, 20, NULL
);
1747 "&Exclude Hosts/IPs", IDC_PROXYEXCLUDESTATIC
,
1748 IDC_PROXYEXCLUDEEDIT
, 100, NULL
);
1749 staticedit(&cp
, "&Username", IDC_PROXYUSERSTATIC
,
1750 IDC_PROXYUSEREDIT
, 60);
1751 staticedit(&cp
, "Pass&word", IDC_PROXYPASSSTATIC
,
1752 IDC_PROXYPASSEDIT
, 60);
1754 beginbox(&cp
, "Misc. proxy settings", IDC_BOX_PROXY2
);
1756 "Telnet co&mmand", IDC_PROXYTELNETCMDSTATIC
,
1757 IDC_PROXYTELNETCMDEDIT
, 100, NULL
);
1758 radioline(&cp
, "SOCKS &Version", IDC_PROXYSOCKSVERSTATIC
,
1759 2, "Version 5", IDC_PROXYSOCKSVER5
, "Version 4",
1760 IDC_PROXYSOCKSVER4
, NULL
);
1765 if (panel
== telnetpanelstart
) {
1766 /* The Telnet panel. Accelerators used: [acgoh] svldr bftk */
1768 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1770 bartitle(&cp
, "Options controlling Telnet connections",
1772 beginbox(&cp
, "Data to send to the server", IDC_BOX_TELNET1
);
1773 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
,
1775 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1776 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
, "Va&lue",
1777 IDC_VALSTATIC
, IDC_VALEDIT
, IDC_ENVLIST
, "A&dd",
1778 IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1780 beginbox(&cp
, "Telnet protocol adjustments", IDC_BOX_TELNET2
);
1781 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:",
1782 IDC_EMSTATIC
, 2, "&BSD (commonplace)", IDC_EMBSD
,
1783 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1784 radioline(&cp
, "&Telnet negotiation mode:", IDC_ACTSTATIC
, 2,
1785 "Passive", IDC_TPASSIVE
, "Active",
1787 checkbox(&cp
, "&Keyboard sends telnet Backspace and Interrupt",
1789 checkbox(&cp
, "Return key sends telnet New Line instead of ^M",
1795 if (panel
== rloginpanelstart
) {
1796 /* The Rlogin panel. Accelerators used: [acgoh] sl */
1798 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1800 bartitle(&cp
, "Options controlling Rlogin connections",
1802 beginbox(&cp
, "Data to send to the server", IDC_BOX_RLOGIN1
);
1803 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
,
1805 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
,
1806 IDC_RLLUSEREDIT
, 50);
1811 if (panel
== sshpanelstart
) {
1812 /* The SSH panel. Accelerators used: [acgoh] r pe12i sd */
1814 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1816 bartitle(&cp
, "Options controlling SSH connections",
1818 beginbox(&cp
, "Data to send to the server", IDC_BOX_SSH1
);
1820 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1823 beginbox(&cp
, "Protocol options", IDC_BOX_SSH2
);
1824 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1825 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1826 radioline(&cp
, "Preferred SSH protocol version:",
1827 IDC_SSHPROTSTATIC
, 2,
1828 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1829 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1832 beginbox(&cp
, "Encryption options", IDC_BOX_SSH3
);
1833 prefslist(&cipherlist
, &cp
, "Encryption cipher &selection policy:",
1834 IDC_CIPHERSTATIC2
, IDC_CIPHERLIST
, IDC_CIPHERUP
,
1836 checkbox(&cp
, "Enable non-standard use of single-&DES in SSH 2",
1842 if (panel
== sshauthpanelstart
) {
1843 /* The SSH authentication panel. Accelerators used: [acgoh] m fkiuw */
1845 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1847 bartitle(&cp
, "Options controlling SSH authentication",
1849 beginbox(&cp
, "Authentication methods",
1851 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
1853 checkbox(&cp
, "Attempt \"keyboard-&interactive\" authentication"
1854 " (SSH2)", IDC_AUTHKI
);
1856 beginbox(&cp
, "Authentication parameters",
1858 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1859 checkbox(&cp
, "Allow attempted changes of &username in SSH2",
1861 editbutton(&cp
, "Private &key file for authentication:",
1862 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...",
1868 if (panel
== tunnelspanelstart
) {
1869 /* The Tunnels panel. Accelerators used: [acgoh] deilmrstxp */
1871 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1873 bartitle(&cp
, "Options controlling SSH tunnelling",
1875 beginbox(&cp
, "X11 forwarding", IDC_BOX_TUNNELS1
);
1876 checkbox(&cp
, "&Enable X11 forwarding", IDC_X11_FORWARD
);
1877 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1878 IDC_X11_DISPLAY
, 50, NULL
);
1880 beginbox(&cp
, "Port forwarding", IDC_BOX_TUNNELS2
);
1881 checkbox(&cp
, "Local ports accept connections from o&ther hosts",
1883 checkbox(&cp
, "Remote &ports do the same (SSH v2 only)",
1885 staticbtn(&cp
, "Forwarded ports:", IDC_PFWDSTATIC
,
1886 "&Remove", IDC_PFWDREMOVE
);
1887 fwdsetter(&cp
, IDC_PFWDLIST
,
1888 "Add new forwarded port:", IDC_PFWDSTATIC2
,
1889 "&Source port", IDC_SPORTSTATIC
, IDC_SPORTEDIT
,
1890 "Dest&ination", IDC_DPORTSTATIC
, IDC_DPORTEDIT
,
1891 "A&dd", IDC_PFWDADD
);
1892 bareradioline(&cp
, 2,
1893 "&Local", IDC_PFWDLOCAL
,
1894 "Re&mote", IDC_PFWDREMOTE
, NULL
);
1902 * Helper function to load the session selected in SESSLIST
1903 * if any, as this is done in more than one place in
1904 * GenericMainDlgProc(). 0 => failure.
1906 static int load_selected_session(HWND hwnd
)
1908 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1909 LB_GETCURSEL
, 0, 0);
1915 isdef
= !strcmp(sessions
[n
], "Default Settings");
1916 load_settings(sessions
[n
], !isdef
, &cfg
);
1917 init_dlg_ctrls(hwnd
, TRUE
);
1919 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1921 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1922 /* Restore the selection, which will have been clobbered by
1923 * SESSEDIT handling. */
1924 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
, n
, 0);
1929 * This function is the configuration box.
1931 static int GenericMainDlgProc(HWND hwnd
, UINT msg
,
1932 WPARAM wParam
, LPARAM lParam
, int dlgtype
)
1935 struct treeview_faff tvfaff
;
1938 char filename
[sizeof(cfg
.keyfile
)];
1941 char fontstatic
[256];
1943 struct servent
*service
;
1945 static UINT draglistmsg
= WM_NULL
;
1950 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1952 SetWindowLong(hwnd
, GWL_EXSTYLE
,
1953 GetWindowLong(hwnd
, GWL_EXSTYLE
) | WS_EX_CONTEXTHELP
);
1955 HWND item
= GetDlgItem(hwnd
, IDC_HELPBTN
);
1957 DestroyWindow(item
);
1959 requested_help
= FALSE
;
1960 SendMessage(hwnd
, WM_SETICON
, (WPARAM
) ICON_BIG
,
1961 (LPARAM
) LoadIcon(hinst
, MAKEINTRESOURCE(IDI_CFGICON
)));
1963 * Centre the window.
1965 { /* centre the window */
1968 hw
= GetDesktopWindow();
1969 if (GetWindowRect(hw
, &rs
) && GetWindowRect(hwnd
, &rd
))
1971 (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
) / 2,
1972 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
) / 2,
1973 rd
.right
- rd
.left
, rd
.bottom
- rd
.top
, TRUE
);
1977 * Create the tree view.
1985 r
.right
= r
.left
+ 75;
1987 r
.bottom
= r
.top
+ 10;
1988 MapDialogRect(hwnd
, &r
);
1989 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1990 WS_CHILD
| WS_VISIBLE
,
1992 r
.right
- r
.left
, r
.bottom
- r
.top
,
1993 hwnd
, (HMENU
) IDCX_TVSTATIC
, hinst
,
1995 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1996 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1999 r
.right
= r
.left
+ 75;
2001 r
.bottom
= r
.top
+ 219;
2002 MapDialogRect(hwnd
, &r
);
2003 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
2004 WS_CHILD
| WS_VISIBLE
|
2005 WS_TABSTOP
| TVS_HASLINES
|
2006 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
2008 TVS_SHOWSELALWAYS
, r
.left
, r
.top
,
2009 r
.right
- r
.left
, r
.bottom
- r
.top
,
2010 hwnd
, (HMENU
) IDCX_TREEVIEW
, hinst
,
2012 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
2013 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
2014 tvfaff
.treeview
= treeview
;
2015 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
2019 * Set up the tree view contents.
2021 hsession
= treeview_insert(&tvfaff
, 0, "Session");
2022 treeview_insert(&tvfaff
, 1, "Logging");
2023 treeview_insert(&tvfaff
, 0, "Terminal");
2024 treeview_insert(&tvfaff
, 1, "Keyboard");
2025 treeview_insert(&tvfaff
, 1, "Bell");
2026 treeview_insert(&tvfaff
, 1, "Features");
2027 treeview_insert(&tvfaff
, 0, "Window");
2028 treeview_insert(&tvfaff
, 1, "Appearance");
2029 treeview_insert(&tvfaff
, 1, "Behaviour");
2030 treeview_insert(&tvfaff
, 1, "Translation");
2031 treeview_insert(&tvfaff
, 1, "Selection");
2032 treeview_insert(&tvfaff
, 1, "Colours");
2033 treeview_insert(&tvfaff
, 0, "Connection");
2035 treeview_insert(&tvfaff
, 1, "Proxy");
2036 treeview_insert(&tvfaff
, 1, "Telnet");
2037 treeview_insert(&tvfaff
, 1, "Rlogin");
2038 if (backends
[3].backend
!= NULL
) {
2039 treeview_insert(&tvfaff
, 1, "SSH");
2040 /* XXX long name is ugly */
2041 /* XXX make it closed by default? */
2042 treeview_insert(&tvfaff
, 2, "Auth");
2043 treeview_insert(&tvfaff
, 2, "Tunnels");
2048 * Put the treeview selection on to the Session panel. This
2049 * should also cause creation of the relevant controls.
2051 TreeView_SelectItem(treeview
, hsession
);
2054 * Set focus into the first available control.
2058 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
2060 ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
2064 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
2065 sesslist_has_focus
= 0;
2069 * Button release should trigger WM_OK if there was a
2070 * previous double click on the session list.
2074 SendMessage(hwnd
, WM_COMMAND
, IDOK
, 0);
2077 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
2078 ((LPNMHDR
) lParam
)->code
== TVN_SELCHANGED
) {
2080 TreeView_GetSelection(((LPNMHDR
) lParam
)->hwndFrom
);
2085 SendMessage (hwnd
, WM_SETREDRAW
, FALSE
, 0);
2088 item
.pszText
= buffer
;
2089 item
.cchTextMax
= sizeof(buffer
);
2090 item
.mask
= TVIF_TEXT
;
2091 TreeView_GetItem(((LPNMHDR
) lParam
)->hwndFrom
, &item
);
2092 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
2093 HWND item
= GetDlgItem(hwnd
, j
);
2095 DestroyWindow(item
);
2097 if (!strcmp(buffer
, "Session"))
2098 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
2099 if (!strcmp(buffer
, "Logging"))
2100 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
2101 if (!strcmp(buffer
, "Keyboard"))
2102 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
2103 if (!strcmp(buffer
, "Terminal"))
2104 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
2105 if (!strcmp(buffer
, "Bell"))
2106 create_controls(hwnd
, dlgtype
, bellpanelstart
);
2107 if (!strcmp(buffer
, "Features"))
2108 create_controls(hwnd
, dlgtype
, featurespanelstart
);
2109 if (!strcmp(buffer
, "Window"))
2110 create_controls(hwnd
, dlgtype
, windowpanelstart
);
2111 if (!strcmp(buffer
, "Appearance"))
2112 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
2113 if (!strcmp(buffer
, "Behaviour"))
2114 create_controls(hwnd
, dlgtype
, behaviourpanelstart
);
2115 if (!strcmp(buffer
, "Tunnels"))
2116 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
2117 if (!strcmp(buffer
, "Connection"))
2118 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
2119 if (!strcmp(buffer
, "Proxy"))
2120 create_controls(hwnd
, dlgtype
, proxypanelstart
);
2121 if (!strcmp(buffer
, "Telnet"))
2122 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
2123 if (!strcmp(buffer
, "Rlogin"))
2124 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
2125 if (!strcmp(buffer
, "SSH"))
2126 create_controls(hwnd
, dlgtype
, sshpanelstart
);
2127 if (!strcmp(buffer
, "Auth"))
2128 create_controls(hwnd
, dlgtype
, sshauthpanelstart
);
2129 if (!strcmp(buffer
, "Selection"))
2130 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
2131 if (!strcmp(buffer
, "Colours"))
2132 create_controls(hwnd
, dlgtype
, colourspanelstart
);
2133 if (!strcmp(buffer
, "Translation"))
2134 create_controls(hwnd
, dlgtype
, translationpanelstart
);
2136 init_dlg_ctrls(hwnd
, FALSE
);
2138 SendMessage (hwnd
, WM_SETREDRAW
, TRUE
, 0);
2139 InvalidateRect (hwnd
, NULL
, TRUE
);
2141 SetFocus(((LPNMHDR
) lParam
)->hwndFrom
); /* ensure focus stays */
2147 * Only process WM_COMMAND once the dialog is fully formed.
2149 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1)
2150 switch (LOWORD(wParam
)) {
2152 /* Behaviour of the "Open" button is different if the
2153 * session list has focus, *unless* the user just
2154 * double-clicked... */
2155 if (sesslist_has_focus
&& !readytogo
) {
2156 if (!load_selected_session(hwnd
)) {
2161 /* If at this point we have a valid session, go! */
2163 if (requested_help
) {
2164 WinHelp(hwnd
, help_path
, HELP_QUIT
, 0);
2165 requested_help
= FALSE
;
2172 if (HIWORD(wParam
) == BN_CLICKED
||
2173 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2175 WinHelp(hwnd
, help_path
,
2176 help_has_contents ? HELP_FINDER
: HELP_CONTENTS
,
2178 requested_help
= TRUE
;
2183 if (requested_help
) {
2184 WinHelp(hwnd
, help_path
, HELP_QUIT
, 0);
2185 requested_help
= FALSE
;
2189 case IDC_PROTTELNET
:
2190 case IDC_PROTRLOGIN
:
2193 if (HIWORD(wParam
) == BN_CLICKED
||
2194 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2195 int i
= IsDlgButtonChecked(hwnd
, IDC_PROTSSH
);
2196 int j
= IsDlgButtonChecked(hwnd
, IDC_PROTTELNET
);
2197 int k
= IsDlgButtonChecked(hwnd
, IDC_PROTRLOGIN
);
2199 i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
:
2202 * When switching using the arrow keys, we
2203 * appear to get two of these messages, both
2204 * mentioning the target button in
2205 * LOWORD(wParam), but one of them called while
2206 * the previous button is still checked. This
2207 * causes an unnecessary reset of the port
2208 * number field, which we fix by ensuring here
2209 * that the button selected is indeed the one
2212 if (IsDlgButtonChecked(hwnd
, LOWORD(wParam
)) &&
2213 ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22)
2214 || (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23)
2215 || (cfg
.protocol
== PROT_RLOGIN
2216 && cfg
.port
!= 513))) {
2217 cfg
.port
= i ?
22 : j ?
23 : 513;
2218 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
2223 if (HIWORD(wParam
) == EN_CHANGE
)
2224 GetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
,
2225 sizeof(cfg
.host
) - 1);
2228 if (HIWORD(wParam
) == EN_CHANGE
) {
2229 GetDlgItemText(hwnd
, IDC_PORT
, portname
, 31);
2230 if (isdigit(portname
[0]))
2231 MyGetDlgItemInt(hwnd
, IDC_PORT
, &cfg
.port
);
2233 service
= getservbyname(portname
, NULL
);
2235 cfg
.port
= ntohs(service
->s_port
);
2242 if (HIWORD(wParam
) == EN_CHANGE
) {
2243 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
2245 GetDlgItemText(hwnd
, IDC_SESSEDIT
,
2246 savedsession
, sizeof(savedsession
) - 1);
2247 savedsession
[sizeof(savedsession
) - 1] = '\0';
2251 if (HIWORD(wParam
) == BN_CLICKED
||
2252 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2257 GetDlgItemText(hwnd
, IDC_SESSEDIT
, str
,
2260 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2261 LB_GETCURSEL
, 0, 0);
2266 strcpy(str
, sessions
[n
]);
2268 save_settings(str
, !!strcmp(str
, "Default Settings"),
2270 get_sesslist(FALSE
);
2272 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2274 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
2276 for (i
= 0; i
< nsessions
; i
++)
2277 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2279 (LPARAM
) (sessions
[i
]));
2280 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
2282 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2284 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
2290 if (LOWORD(wParam
) == IDC_SESSLIST
) {
2291 if (HIWORD(wParam
) == LBN_SETFOCUS
)
2292 sesslist_has_focus
= 1;
2293 else if (HIWORD(wParam
) == LBN_KILLFOCUS
)
2294 sesslist_has_focus
= 0;
2296 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
2297 HIWORD(wParam
) != BN_CLICKED
&&
2298 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2299 if (LOWORD(wParam
) == IDC_SESSLIST
&&
2300 HIWORD(wParam
) != LBN_DBLCLK
) break;
2301 /* Load the session selected in SESSLIST. */
2302 if (load_selected_session(hwnd
) &&
2303 LOWORD(wParam
) == IDC_SESSLIST
) {
2305 * A double-click on a saved session should
2306 * actually start the session, not just load it.
2307 * Unless it's Default Settings or some other
2308 * host-less set of saved settings.
2317 if (HIWORD(wParam
) == BN_CLICKED
||
2318 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2319 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2320 LB_GETCURSEL
, 0, 0);
2321 if (n
== LB_ERR
|| n
== 0) {
2325 del_settings(sessions
[n
]);
2326 get_sesslist(FALSE
);
2328 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2330 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
2332 for (i
= 0; i
< nsessions
; i
++)
2333 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2335 (LPARAM
) (sessions
[i
]));
2336 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
2338 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2340 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
2344 if (HIWORD(wParam
) == EN_CHANGE
)
2345 MyGetDlgItemInt(hwnd
, IDC_PINGEDIT
,
2346 &cfg
.ping_interval
);
2349 if (HIWORD(wParam
) == BN_CLICKED
||
2350 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2352 IsDlgButtonChecked(hwnd
, IDC_NODELAY
);
2356 if (HIWORD(wParam
) == BN_CLICKED
||
2357 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2358 cfg
.bksp_is_delete
=
2359 IsDlgButtonChecked(hwnd
, IDC_DEL127
);
2363 if (HIWORD(wParam
) == BN_CLICKED
||
2364 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2366 IsDlgButtonChecked(hwnd
, IDC_HOMERXVT
);
2372 case IDC_FUNCVT100P
:
2374 if (HIWORD(wParam
) == BN_CLICKED
||
2375 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2376 switch (LOWORD(wParam
)) {
2389 case IDC_FUNCVT100P
:
2399 if (HIWORD(wParam
) == BN_CLICKED
||
2400 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2402 IsDlgButtonChecked(hwnd
, IDC_KPAPPLIC
);
2403 cfg
.nethack_keypad
= FALSE
;
2407 if (HIWORD(wParam
) == BN_CLICKED
||
2408 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2409 cfg
.app_keypad
= FALSE
;
2410 cfg
.nethack_keypad
= TRUE
;
2415 if (HIWORD(wParam
) == BN_CLICKED
||
2416 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2418 IsDlgButtonChecked(hwnd
, IDC_CURAPPLIC
);
2421 if (HIWORD(wParam
) == BN_CLICKED
||
2422 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2424 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICC
);
2427 if (HIWORD(wParam
) == BN_CLICKED
||
2428 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2430 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICK
);
2432 case IDC_NOMOUSEREP
:
2433 if (HIWORD(wParam
) == BN_CLICKED
||
2434 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2436 IsDlgButtonChecked(hwnd
, IDC_NOMOUSEREP
);
2439 if (HIWORD(wParam
) == BN_CLICKED
||
2440 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2441 cfg
.no_remote_resize
=
2442 IsDlgButtonChecked(hwnd
, IDC_NORESIZE
);
2444 case IDC_NOALTSCREEN
:
2445 if (HIWORD(wParam
) == BN_CLICKED
||
2446 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2448 IsDlgButtonChecked(hwnd
, IDC_NOALTSCREEN
);
2450 case IDC_NOWINTITLE
:
2451 if (HIWORD(wParam
) == BN_CLICKED
||
2452 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2453 cfg
.no_remote_wintitle
=
2454 IsDlgButtonChecked(hwnd
, IDC_NOWINTITLE
);
2456 case IDC_NODBACKSPACE
:
2457 if (HIWORD(wParam
) == BN_CLICKED
||
2458 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2460 IsDlgButtonChecked(hwnd
, IDC_NODBACKSPACE
);
2463 if (HIWORD(wParam
) == BN_CLICKED
||
2464 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2465 cfg
.no_remote_charset
=
2466 IsDlgButtonChecked(hwnd
, IDC_NOCHARSET
);
2469 if (HIWORD(wParam
) == BN_CLICKED
||
2470 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2471 cfg
.alt_f4
= IsDlgButtonChecked(hwnd
, IDC_ALTF4
);
2474 if (HIWORD(wParam
) == BN_CLICKED
||
2475 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2477 IsDlgButtonChecked(hwnd
, IDC_ALTSPACE
);
2480 if (HIWORD(wParam
) == BN_CLICKED
||
2481 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2483 IsDlgButtonChecked(hwnd
, IDC_ALTONLY
);
2485 case IDC_ECHOBACKEND
:
2488 if (HIWORD(wParam
) == BN_CLICKED
||
2489 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2490 if (LOWORD(wParam
) == IDC_ECHOBACKEND
)
2491 cfg
.localecho
= LD_BACKEND
;
2492 if (LOWORD(wParam
) == IDC_ECHOYES
)
2493 cfg
.localecho
= LD_YES
;
2494 if (LOWORD(wParam
) == IDC_ECHONO
)
2495 cfg
.localecho
= LD_NO
;
2498 case IDC_EDITBACKEND
:
2501 if (HIWORD(wParam
) == BN_CLICKED
||
2502 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2503 if (LOWORD(wParam
) == IDC_EDITBACKEND
)
2504 cfg
.localedit
= LD_BACKEND
;
2505 if (LOWORD(wParam
) == IDC_EDITYES
)
2506 cfg
.localedit
= LD_YES
;
2507 if (LOWORD(wParam
) == IDC_EDITNO
)
2508 cfg
.localedit
= LD_NO
;
2511 case IDC_ANSWEREDIT
:
2512 if (HIWORD(wParam
) == EN_CHANGE
)
2513 GetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
2514 sizeof(cfg
.answerback
) - 1);
2516 case IDC_ALWAYSONTOP
:
2517 if (HIWORD(wParam
) == BN_CLICKED
||
2518 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2520 IsDlgButtonChecked(hwnd
, IDC_ALWAYSONTOP
);
2522 case IDC_FULLSCREENONALTENTER
:
2523 if (HIWORD(wParam
) == BN_CLICKED
||
2524 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2525 cfg
.fullscreenonaltenter
=
2526 IsDlgButtonChecked(hwnd
, IDC_FULLSCREENONALTENTER
);
2529 if (HIWORD(wParam
) == BN_CLICKED
||
2530 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2532 IsDlgButtonChecked(hwnd
, IDC_SCROLLKEY
);
2534 case IDC_SCROLLDISP
:
2535 if (HIWORD(wParam
) == BN_CLICKED
||
2536 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2537 cfg
.scroll_on_disp
=
2538 IsDlgButtonChecked(hwnd
, IDC_SCROLLDISP
);
2540 case IDC_COMPOSEKEY
:
2541 if (HIWORD(wParam
) == BN_CLICKED
||
2542 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2544 IsDlgButtonChecked(hwnd
, IDC_COMPOSEKEY
);
2546 case IDC_CTRLALTKEYS
:
2547 if (HIWORD(wParam
) == BN_CLICKED
||
2548 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2550 IsDlgButtonChecked(hwnd
, IDC_CTRLALTKEYS
);
2553 if (HIWORD(wParam
) == BN_CLICKED
||
2554 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2555 cfg
.telnet_keyboard
=
2556 IsDlgButtonChecked(hwnd
, IDC_TELNETKEY
);
2559 if (HIWORD(wParam
) == BN_CLICKED
||
2560 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2561 cfg
.telnet_newline
=
2562 IsDlgButtonChecked(hwnd
, IDC_TELNETRET
);
2565 if (HIWORD(wParam
) == BN_CLICKED
||
2566 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2568 IsDlgButtonChecked(hwnd
, IDC_WRAPMODE
);
2571 if (HIWORD(wParam
) == BN_CLICKED
||
2572 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2573 cfg
.dec_om
= IsDlgButtonChecked(hwnd
, IDC_DECOM
);
2576 if (HIWORD(wParam
) == BN_CLICKED
||
2577 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2579 IsDlgButtonChecked(hwnd
, IDC_LFHASCR
);
2582 if (HIWORD(wParam
) == EN_CHANGE
)
2583 MyGetDlgItemInt(hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
2586 if (HIWORD(wParam
) == EN_CHANGE
)
2587 MyGetDlgItemInt(hwnd
, IDC_COLSEDIT
, &cfg
.width
);
2590 if (HIWORD(wParam
) == EN_CHANGE
)
2591 MyGetDlgItemInt(hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
2593 case IDC_CHOOSEFONT
:
2596 lf
.lfHeight
= -MulDiv(cfg
.fontheight
,
2597 GetDeviceCaps(hdc
, LOGPIXELSY
),
2601 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
2602 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
2603 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
2604 lf
.lfCharSet
= cfg
.fontcharset
;
2605 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
2606 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
2607 lf
.lfQuality
= DEFAULT_QUALITY
;
2608 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
2609 strncpy(lf
.lfFaceName
, cfg
.font
,
2610 sizeof(lf
.lfFaceName
) - 1);
2611 lf
.lfFaceName
[sizeof(lf
.lfFaceName
) - 1] = '\0';
2613 cf
.lStructSize
= sizeof(cf
);
2614 cf
.hwndOwner
= hwnd
;
2616 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
2617 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
2619 if (ChooseFont(&cf
)) {
2620 strncpy(cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
) - 1);
2621 cfg
.font
[sizeof(cfg
.font
) - 1] = '\0';
2622 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
2623 cfg
.fontcharset
= lf
.lfCharSet
;
2624 cfg
.fontheight
= cf
.iPointSize
/ 10;
2625 fmtfont(fontstatic
);
2626 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
2629 case IDC_BELL_DISABLED
:
2630 case IDC_BELL_DEFAULT
:
2631 case IDC_BELL_WAVEFILE
:
2632 case IDC_BELL_VISUAL
:
2633 if (HIWORD(wParam
) == BN_CLICKED
||
2634 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2635 if (LOWORD(wParam
) == IDC_BELL_DISABLED
)
2636 cfg
.beep
= BELL_DISABLED
;
2637 if (LOWORD(wParam
) == IDC_BELL_DEFAULT
)
2638 cfg
.beep
= BELL_DEFAULT
;
2639 if (LOWORD(wParam
) == IDC_BELL_WAVEFILE
)
2640 cfg
.beep
= BELL_WAVEFILE
;
2641 if (LOWORD(wParam
) == IDC_BELL_VISUAL
)
2642 cfg
.beep
= BELL_VISUAL
;
2645 case IDC_B_IND_DISABLED
:
2646 case IDC_B_IND_FLASH
:
2647 case IDC_B_IND_STEADY
:
2648 if (HIWORD(wParam
) == BN_CLICKED
||
2649 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2650 if (LOWORD(wParam
) == IDC_B_IND_DISABLED
)
2651 cfg
.beep_ind
= B_IND_DISABLED
;
2652 if (LOWORD(wParam
) == IDC_B_IND_FLASH
)
2653 cfg
.beep_ind
= B_IND_FLASH
;
2654 if (LOWORD(wParam
) == IDC_B_IND_STEADY
)
2655 cfg
.beep_ind
= B_IND_STEADY
;
2658 case IDC_BELL_WAVEBROWSE
:
2659 memset(&of
, 0, sizeof(of
));
2660 #ifdef OPENFILENAME_SIZE_VERSION_400
2661 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2663 of
.lStructSize
= sizeof(of
);
2665 of
.hwndOwner
= hwnd
;
2666 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2667 of
.lpstrCustomFilter
= NULL
;
2668 of
.nFilterIndex
= 1;
2669 of
.lpstrFile
= filename
;
2670 strcpy(filename
, cfg
.bell_wavefile
);
2671 of
.nMaxFile
= sizeof(filename
);
2672 of
.lpstrFileTitle
= NULL
;
2673 of
.lpstrInitialDir
= NULL
;
2674 of
.lpstrTitle
= "Select Bell Sound File";
2676 if (GetOpenFileName(&of
)) {
2677 strcpy(cfg
.bell_wavefile
, filename
);
2678 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2682 case IDC_BELL_WAVEEDIT
:
2683 if (HIWORD(wParam
) == EN_CHANGE
)
2684 GetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2686 sizeof(cfg
.bell_wavefile
) - 1);
2689 if (HIWORD(wParam
) == BN_CLICKED
||
2690 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2692 IsDlgButtonChecked(hwnd
, IDC_BELLOVL
);
2695 if (HIWORD(wParam
) == EN_CHANGE
)
2696 MyGetDlgItemInt(hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
2699 if (HIWORD(wParam
) == EN_CHANGE
)
2700 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
,
2704 if (HIWORD(wParam
) == EN_CHANGE
)
2705 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
,
2709 if (HIWORD(wParam
) == BN_CLICKED
||
2710 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2712 IsDlgButtonChecked(hwnd
, IDC_BLINKTEXT
);
2715 if (HIWORD(wParam
) == BN_CLICKED
||
2716 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2717 cfg
.bce
= IsDlgButtonChecked(hwnd
, IDC_BCE
);
2720 if (HIWORD(wParam
) == BN_CLICKED
||
2721 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2722 cfg
.win_name_always
=
2723 IsDlgButtonChecked(hwnd
, IDC_WINNAME
);
2726 if (HIWORD(wParam
) == BN_CLICKED
||
2727 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2729 IsDlgButtonChecked(hwnd
, IDC_HIDEMOUSE
);
2731 case IDC_SUNKENEDGE
:
2732 if (HIWORD(wParam
) == BN_CLICKED
||
2733 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2735 IsDlgButtonChecked(hwnd
, IDC_SUNKENEDGE
);
2738 if (HIWORD(wParam
) == EN_CHANGE
)
2739 MyGetDlgItemInt(hwnd
, IDC_WINBEDIT
,
2740 &cfg
.window_border
);
2741 if (cfg
.window_border
> 32)
2742 cfg
.window_border
= 32;
2745 if (HIWORD(wParam
) == BN_CLICKED
||
2746 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2747 cfg
.cursor_type
= 0;
2750 if (HIWORD(wParam
) == BN_CLICKED
||
2751 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2752 cfg
.cursor_type
= 1;
2755 if (HIWORD(wParam
) == BN_CLICKED
||
2756 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2757 cfg
.cursor_type
= 2;
2760 if (HIWORD(wParam
) == BN_CLICKED
||
2761 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2763 IsDlgButtonChecked(hwnd
, IDC_BLINKCUR
);
2766 if (HIWORD(wParam
) == BN_CLICKED
||
2767 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2769 IsDlgButtonChecked(hwnd
, IDC_SCROLLBAR
);
2771 case IDC_SCROLLBARFULLSCREEN
:
2772 if (HIWORD(wParam
) == BN_CLICKED
||
2773 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2774 cfg
.scrollbar_in_fullscreen
=
2775 IsDlgButtonChecked(hwnd
, IDC_SCROLLBARFULLSCREEN
);
2777 case IDC_RESIZETERM
:
2778 case IDC_RESIZEFONT
:
2779 case IDC_RESIZENONE
:
2780 case IDC_RESIZEEITHER
:
2781 if (HIWORD(wParam
) == BN_CLICKED
||
2782 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2784 IsDlgButtonChecked(hwnd
,
2785 IDC_RESIZETERM
) ? RESIZE_TERM
:
2786 IsDlgButtonChecked(hwnd
,
2787 IDC_RESIZEFONT
) ? RESIZE_FONT
:
2788 IsDlgButtonChecked(hwnd
,
2789 IDC_RESIZEEITHER
) ? RESIZE_EITHER
:
2794 if (HIWORD(wParam
) == EN_CHANGE
)
2795 GetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
2796 sizeof(cfg
.wintitle
) - 1);
2801 if (HIWORD(wParam
) == BN_CLICKED
||
2802 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2804 IsDlgButtonChecked(hwnd
,
2805 IDC_COEALWAYS
) ? COE_ALWAYS
:
2806 IsDlgButtonChecked(hwnd
,
2807 IDC_COENEVER
) ? COE_NEVER
:
2812 if (HIWORD(wParam
) == BN_CLICKED
||
2813 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2815 IsDlgButtonChecked(hwnd
, IDC_CLOSEWARN
);
2818 if (HIWORD(wParam
) == EN_CHANGE
)
2819 GetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
,
2820 sizeof(cfg
.termtype
) - 1);
2824 case IDC_PROXYHOSTEDIT
:
2825 if (HIWORD(wParam
) == EN_CHANGE
)
2826 GetDlgItemText(hwnd
, IDC_PROXYHOSTEDIT
, cfg
.proxy_host
,
2827 sizeof(cfg
.proxy_host
) - 1);
2829 case IDC_PROXYPORTEDIT
:
2830 if (HIWORD(wParam
) == EN_CHANGE
) {
2831 GetDlgItemText(hwnd
, IDC_PROXYPORTEDIT
, portname
, 31);
2832 if (isdigit(portname
[0]))
2833 MyGetDlgItemInt(hwnd
, IDC_PROXYPORTEDIT
, &cfg
.proxy_port
);
2835 service
= getservbyname(portname
, NULL
);
2837 cfg
.proxy_port
= ntohs(service
->s_port
);
2843 case IDC_PROXYEXCLUDEEDIT
:
2844 if (HIWORD(wParam
) == EN_CHANGE
)
2845 GetDlgItemText(hwnd
, IDC_PROXYEXCLUDEEDIT
,
2846 cfg
.proxy_exclude_list
,
2847 sizeof(cfg
.proxy_exclude_list
) - 1);
2849 case IDC_PROXYUSEREDIT
:
2850 if (HIWORD(wParam
) == EN_CHANGE
)
2851 GetDlgItemText(hwnd
, IDC_PROXYUSEREDIT
,
2853 sizeof(cfg
.proxy_username
) - 1);
2855 case IDC_PROXYPASSEDIT
:
2856 if (HIWORD(wParam
) == EN_CHANGE
)
2857 GetDlgItemText(hwnd
, IDC_PROXYPASSEDIT
,
2859 sizeof(cfg
.proxy_password
) - 1);
2861 case IDC_PROXYTELNETCMDEDIT
:
2862 if (HIWORD(wParam
) == EN_CHANGE
)
2863 GetDlgItemText(hwnd
, IDC_PROXYTELNETCMDEDIT
,
2864 cfg
.proxy_telnet_command
,
2865 sizeof(cfg
.proxy_telnet_command
) - 1);
2867 case IDC_PROXYSOCKSVER5
:
2868 case IDC_PROXYSOCKSVER4
:
2869 if (HIWORD(wParam
) == BN_CLICKED
||
2870 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2871 cfg
.proxy_socks_version
=
2872 IsDlgButtonChecked(hwnd
, IDC_PROXYSOCKSVER4
) ?
4 : 5;
2875 case IDC_PROXYTYPENONE
:
2876 case IDC_PROXYTYPEHTTP
:
2877 case IDC_PROXYTYPESOCKS
:
2878 case IDC_PROXYTYPETELNET
:
2879 if (HIWORD(wParam
) == BN_CLICKED
||
2880 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2882 IsDlgButtonChecked(hwnd
, IDC_PROXYTYPEHTTP
) ? PROXY_HTTP
:
2883 IsDlgButtonChecked(hwnd
, IDC_PROXYTYPESOCKS
) ? PROXY_SOCKS
:
2884 IsDlgButtonChecked(hwnd
, IDC_PROXYTYPETELNET
) ? PROXY_TELNET
:
2890 if (HIWORD(wParam
) == EN_CHANGE
)
2891 GetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
2892 sizeof(cfg
.logfilename
) - 1);
2895 memset(&of
, 0, sizeof(of
));
2896 #ifdef OPENFILENAME_SIZE_VERSION_400
2897 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2899 of
.lStructSize
= sizeof(of
);
2901 of
.hwndOwner
= hwnd
;
2902 of
.lpstrFilter
= "All Files\0*\0\0\0";
2903 of
.lpstrCustomFilter
= NULL
;
2904 of
.nFilterIndex
= 1;
2905 of
.lpstrFile
= filename
;
2906 strcpy(filename
, cfg
.logfilename
);
2907 of
.nMaxFile
= sizeof(filename
);
2908 of
.lpstrFileTitle
= NULL
;
2909 of
.lpstrInitialDir
= NULL
;
2910 of
.lpstrTitle
= "Select session log file";
2912 if (GetSaveFileName(&of
)) {
2913 strcpy(cfg
.logfilename
, filename
);
2914 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
2918 case IDC_LSTATASCII
:
2920 case IDC_LSTATPACKET
:
2921 if (HIWORD(wParam
) == BN_CLICKED
||
2922 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2923 if (IsDlgButtonChecked(hwnd
, IDC_LSTATOFF
))
2924 cfg
.logtype
= LGTYP_NONE
;
2925 if (IsDlgButtonChecked(hwnd
, IDC_LSTATASCII
))
2926 cfg
.logtype
= LGTYP_ASCII
;
2927 if (IsDlgButtonChecked(hwnd
, IDC_LSTATRAW
))
2928 cfg
.logtype
= LGTYP_DEBUG
;
2929 if (IsDlgButtonChecked(hwnd
, IDC_LSTATPACKET
))
2930 cfg
.logtype
= LGTYP_PACKETS
;
2936 if (HIWORD(wParam
) == BN_CLICKED
||
2937 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2938 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXASK
))
2939 cfg
.logxfovr
= LGXF_ASK
;
2940 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXAPN
))
2941 cfg
.logxfovr
= LGXF_APN
;
2942 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXOVR
))
2943 cfg
.logxfovr
= LGXF_OVR
;
2948 if (HIWORD(wParam
) == EN_CHANGE
)
2949 GetDlgItemText(hwnd
, LOWORD(wParam
), cfg
.termspeed
,
2950 sizeof(cfg
.termspeed
) - 1);
2953 if (HIWORD(wParam
) == EN_CHANGE
)
2954 GetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
,
2955 sizeof(cfg
.username
) - 1);
2957 case IDC_RLLUSEREDIT
:
2958 if (HIWORD(wParam
) == EN_CHANGE
)
2959 GetDlgItemText(hwnd
, IDC_RLLUSEREDIT
,
2961 sizeof(cfg
.localusername
) - 1);
2965 cfg
.rfc_environ
= IsDlgButtonChecked(hwnd
, IDC_EMRFC
);
2969 cfg
.passive_telnet
=
2970 IsDlgButtonChecked(hwnd
, IDC_TPASSIVE
);
2973 if (HIWORD(wParam
) == BN_CLICKED
||
2974 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2975 char str
[sizeof(cfg
.environmt
)];
2977 GetDlgItemText(hwnd
, IDC_VAREDIT
, str
,
2983 p
= str
+ strlen(str
);
2985 GetDlgItemText(hwnd
, IDC_VALEDIT
, p
,
2986 sizeof(str
) - 1 - (p
- str
));
2997 if ((p
- cfg
.environmt
) + strlen(str
) + 2 <
2998 sizeof(cfg
.environmt
)) {
3000 p
[strlen(str
) + 1] = '\0';
3001 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
3003 SetDlgItemText(hwnd
, IDC_VAREDIT
, "");
3004 SetDlgItemText(hwnd
, IDC_VALEDIT
, "");
3006 MessageBox(hwnd
, "Environment too big",
3007 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3012 if (HIWORD(wParam
) != BN_CLICKED
&&
3013 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
3015 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0,
3022 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
3049 if (HIWORD(wParam
) == BN_CLICKED
||
3050 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3051 cfg
.nopty
= IsDlgButtonChecked(hwnd
, IDC_NOPTY
);
3054 if (HIWORD(wParam
) == BN_CLICKED
||
3055 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3057 IsDlgButtonChecked(hwnd
, IDC_COMPRESS
);
3060 if (HIWORD(wParam
) == BN_CLICKED
||
3061 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3063 IsDlgButtonChecked(hwnd
, IDC_BUGGYMAC
);
3066 if (HIWORD(wParam
) == BN_CLICKED
||
3067 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3069 IsDlgButtonChecked(hwnd
, IDC_SSH2DES
);
3072 if (HIWORD(wParam
) == BN_CLICKED
||
3073 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3075 IsDlgButtonChecked(hwnd
, IDC_AGENTFWD
);
3077 case IDC_CHANGEUSER
:
3078 if (HIWORD(wParam
) == BN_CLICKED
||
3079 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3080 cfg
.change_username
=
3081 IsDlgButtonChecked(hwnd
, IDC_CHANGEUSER
);
3083 case IDC_CIPHERLIST
:
3086 handle_prefslist(&cipherlist
,
3087 cfg
.ssh_cipherlist
, CIPHER_MAX
,
3088 0, hwnd
, wParam
, lParam
);
3092 if (HIWORD(wParam
) == BN_CLICKED
||
3093 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3094 if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT1
))
3096 else if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT2
))
3101 if (HIWORD(wParam
) == BN_CLICKED
||
3102 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3104 IsDlgButtonChecked(hwnd
, IDC_AUTHTIS
);
3107 if (HIWORD(wParam
) == BN_CLICKED
||
3108 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3110 IsDlgButtonChecked(hwnd
, IDC_AUTHKI
);
3113 if (HIWORD(wParam
) == EN_CHANGE
)
3114 GetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
3115 sizeof(cfg
.keyfile
) - 1);
3118 if (HIWORD(wParam
) == EN_CHANGE
)
3119 GetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
3120 sizeof(cfg
.remote_cmd
) - 1);
3123 memset(&of
, 0, sizeof(of
));
3124 #ifdef OPENFILENAME_SIZE_VERSION_400
3125 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
3127 of
.lStructSize
= sizeof(of
);
3129 of
.hwndOwner
= hwnd
;
3130 of
.lpstrFilter
= "All Files\0*\0\0\0";
3131 of
.lpstrCustomFilter
= NULL
;
3132 of
.nFilterIndex
= 1;
3133 of
.lpstrFile
= filename
;
3134 strcpy(filename
, cfg
.keyfile
);
3135 of
.nMaxFile
= sizeof(filename
);
3136 of
.lpstrFileTitle
= NULL
;
3137 of
.lpstrInitialDir
= NULL
;
3138 of
.lpstrTitle
= "Select Private Key File";
3140 if (GetOpenFileName(&of
)) {
3141 strcpy(cfg
.keyfile
, filename
);
3142 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
3146 cfg
.rawcnp
= IsDlgButtonChecked(hwnd
, IDC_RAWCNP
);
3149 cfg
.rtf_paste
= IsDlgButtonChecked(hwnd
, IDC_RTFPASTE
);
3153 cfg
.mouse_is_xterm
= IsDlgButtonChecked(hwnd
, IDC_MBXTERM
);
3155 case IDC_SELTYPELEX
:
3156 case IDC_SELTYPERECT
:
3157 cfg
.rect_select
= IsDlgButtonChecked(hwnd
, IDC_SELTYPERECT
);
3159 case IDC_MOUSEOVERRIDE
:
3160 cfg
.mouse_override
= IsDlgButtonChecked(hwnd
, IDC_MOUSEOVERRIDE
);
3166 int n
= GetDlgItemInt(hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
3171 for (i
= 0; i
< 128; i
++)
3172 if (SendDlgItemMessage
3173 (hwnd
, IDC_CCLIST
, LB_GETSEL
, i
, 0)) {
3175 cfg
.wordness
[i
] = n
;
3176 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
3177 LB_DELETESTRING
, i
, 0);
3178 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
3179 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ',
3181 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
3188 case IDC_BOLDCOLOUR
:
3189 if (HIWORD(wParam
) == BN_CLICKED
||
3190 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3193 IsDlgButtonChecked(hwnd
, IDC_BOLDCOLOUR
);
3194 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
3197 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3199 if (n
!= 12 + 10 * cfg
.bold_colour
) {
3200 for (i
= n
; i
-- > 0;)
3201 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3202 LB_DELETESTRING
, i
, 0);
3203 for (i
= 0; i
< 22; i
++)
3204 if (cfg
.bold_colour
|| permcolour
[i
])
3205 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3207 (LPARAM
) colours
[i
]);
3209 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
3211 InvalidateRect(GetDlgItem(hwnd
, IDC_COLOURLIST
), NULL
,
3216 if (HIWORD(wParam
) == BN_CLICKED
||
3217 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3219 IsDlgButtonChecked(hwnd
, IDC_PALETTE
);
3221 case IDC_COLOURLIST
:
3222 if (HIWORD(wParam
) == LBN_DBLCLK
||
3223 HIWORD(wParam
) == LBN_SELCHANGE
) {
3225 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3228 if (!cfg
.bold_colour
)
3229 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
3230 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
3232 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
3234 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
3239 if (HIWORD(wParam
) == BN_CLICKED
||
3240 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3241 static CHOOSECOLOR cc
;
3242 static DWORD custom
[16] = { 0 }; /* zero initialisers */
3244 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3247 if (!cfg
.bold_colour
)
3248 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
3249 cc
.lStructSize
= sizeof(cc
);
3250 cc
.hwndOwner
= hwnd
;
3251 cc
.hInstance
= (HWND
) hinst
;
3252 cc
.lpCustColors
= custom
;
3254 RGB(cfg
.colours
[i
][0], cfg
.colours
[i
][1],
3256 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
3257 if (ChooseColor(&cc
)) {
3259 (unsigned char) (cc
.rgbResult
& 0xFF);
3261 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
3263 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
3264 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
3266 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
3268 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
3274 if (HIWORD(wParam
) == CBN_SELCHANGE
) {
3275 int index
= SendDlgItemMessage(hwnd
, IDC_CODEPAGE
,
3276 CB_GETCURSEL
, 0, 0);
3277 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_GETLBTEXT
,
3278 index
, (LPARAM
)cfg
.line_codepage
);
3279 } else if (HIWORD(wParam
) == CBN_EDITCHANGE
) {
3280 GetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
,
3281 sizeof(cfg
.line_codepage
) - 1);
3282 } else if (HIWORD(wParam
) == CBN_KILLFOCUS
) {
3283 strcpy(cfg
.line_codepage
,
3284 cp_name(decode_codepage(cfg
.line_codepage
)));
3285 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
3289 if (HIWORD(wParam
) == CBN_SELCHANGE
) {
3290 int index
= SendDlgItemMessage(hwnd
, IDC_PRINTER
,
3291 CB_GETCURSEL
, 0, 0);
3292 SendDlgItemMessage(hwnd
, IDC_PRINTER
, CB_GETLBTEXT
,
3293 index
, (LPARAM
)cfg
.printer
);
3294 } else if (HIWORD(wParam
) == CBN_EDITCHANGE
) {
3295 GetDlgItemText(hwnd
, IDC_PRINTER
, cfg
.printer
,
3296 sizeof(cfg
.printer
) - 1);
3298 if (!strcmp(cfg
.printer
, PRINTER_DISABLED_STRING
))
3299 *cfg
.printer
= '\0';
3301 case IDC_CAPSLOCKCYR
:
3302 if (HIWORD(wParam
) == BN_CLICKED
||
3303 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3304 cfg
.xlat_capslockcyr
=
3305 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
3308 case IDC_VTXWINDOWS
:
3314 (IsDlgButtonChecked(hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
3315 : IsDlgButtonChecked(hwnd
,
3316 IDC_VTOEMANSI
) ? VT_OEMANSI
:
3317 IsDlgButtonChecked(hwnd
,
3318 IDC_VTOEMONLY
) ? VT_OEMONLY
:
3319 IsDlgButtonChecked(hwnd
,
3320 IDC_VTUNICODE
) ? VT_UNICODE
:
3323 case IDC_X11_FORWARD
:
3324 if (HIWORD(wParam
) == BN_CLICKED
||
3325 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3327 IsDlgButtonChecked(hwnd
, IDC_X11_FORWARD
);
3330 if (HIWORD(wParam
) == BN_CLICKED
||
3331 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3332 cfg
.lport_acceptall
=
3333 IsDlgButtonChecked(hwnd
, IDC_LPORT_ALL
);
3336 if (HIWORD(wParam
) == BN_CLICKED
||
3337 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3338 cfg
.rport_acceptall
=
3339 IsDlgButtonChecked(hwnd
, IDC_RPORT_ALL
);
3341 case IDC_X11_DISPLAY
:
3342 if (HIWORD(wParam
) == EN_CHANGE
)
3343 GetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
3344 sizeof(cfg
.x11_display
) - 1);
3347 if (HIWORD(wParam
) == BN_CLICKED
||
3348 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3349 char str
[sizeof(cfg
.portfwd
)];
3351 if (IsDlgButtonChecked(hwnd
, IDC_PFWDLOCAL
))
3355 GetDlgItemText(hwnd
, IDC_SPORTEDIT
, str
+1,
3359 "You need to specify a source port number",
3360 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3363 p
= str
+ strlen(str
);
3365 GetDlgItemText(hwnd
, IDC_DPORTEDIT
, p
,
3366 sizeof(str
) - 1 - (p
- str
));
3367 if (!*p
|| !strchr(p
, ':')) {
3369 "You need to specify a destination address\n"
3370 "in the form \"host.name:port\"",
3371 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3380 if ((p
- cfg
.portfwd
) + strlen(str
) + 2 <
3381 sizeof(cfg
.portfwd
)) {
3383 p
[strlen(str
) + 1] = '\0';
3384 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
,
3386 SetDlgItemText(hwnd
, IDC_SPORTEDIT
, "");
3387 SetDlgItemText(hwnd
, IDC_DPORTEDIT
, "");
3389 MessageBox(hwnd
, "Too many forwardings",
3390 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3394 case IDC_PFWDREMOVE
:
3395 if (HIWORD(wParam
) != BN_CLICKED
&&
3396 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
3397 i
= SendDlgItemMessage(hwnd
, IDC_PFWDLIST
,
3398 LB_GETCURSEL
, 0, 0);
3404 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_DELETESTRING
,
3434 int id
= ((LPHELPINFO
)lParam
)->iCtrlId
;
3435 char *cmd
= help_context_cmd(id
);
3437 WinHelp(hwnd
, help_path
, HELP_COMMAND
, (DWORD
)cmd
);
3438 requested_help
= TRUE
;
3445 if (requested_help
) {
3446 WinHelp(hwnd
, help_path
, HELP_QUIT
, 0);
3447 requested_help
= FALSE
;
3452 /* Grrr Explorer will maximize Dialogs! */
3454 if (wParam
== SIZE_MAXIMIZED
)
3460 * Handle application-defined messages eg. DragListBox
3462 /* First find out what the number is (once). */
3463 if (draglistmsg
== WM_NULL
)
3464 draglistmsg
= RegisterWindowMessage (DRAGLISTMSGSTRING
);
3466 if (msg
== draglistmsg
) {
3467 /* Only process once dialog is fully formed. */
3468 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
3469 case IDC_CIPHERLIST
:
3470 return handle_prefslist(&cipherlist
,
3471 cfg
.ssh_cipherlist
, CIPHER_MAX
,
3472 1, hwnd
, wParam
, lParam
);
3481 static int CALLBACK
MainDlgProc(HWND hwnd
, UINT msg
,
3482 WPARAM wParam
, LPARAM lParam
)
3484 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
3486 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
3487 EnableWindow(hwnd
, 0);
3488 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
3489 EnableWindow(hwnd
, 1);
3490 SetActiveWindow(hwnd
);
3492 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 0);
3495 static int CALLBACK
ReconfDlgProc(HWND hwnd
, UINT msg
,
3496 WPARAM wParam
, LPARAM lParam
)
3498 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 1);
3501 void defuse_showwindow(void)
3504 * Work around the fact that the app's first call to ShowWindow
3505 * will ignore the default in favour of the shell-provided
3510 hwnd
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
3512 ShowWindow(hwnd
, SW_HIDE
);
3513 SetActiveWindow(hwnd
);
3514 DestroyWindow(hwnd
);
3523 savedsession
[0] = '\0';
3525 DialogBox(hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
3526 get_sesslist(FALSE
);
3531 int do_reconfig(HWND hwnd
)
3536 backup_cfg
= cfg
; /* structure copy */
3538 DialogBox(hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
3540 cfg
= backup_cfg
; /* structure copy */
3545 void logevent(char *string
)
3550 if (nevents
>= negsize
) {
3552 events
= srealloc(events
, negsize
* sizeof(*events
));
3556 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t",
3559 events
[nevents
] = smalloc(strlen(timebuf
) + strlen(string
) + 1);
3560 strcpy(events
[nevents
], timebuf
);
3561 strcat(events
[nevents
], string
);
3564 SendDlgItemMessage(logbox
, IDN_LIST
, LB_ADDSTRING
,
3565 0, (LPARAM
) events
[nevents
]);
3566 count
= SendDlgItemMessage(logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
3567 SendDlgItemMessage(logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
- 1, 0);
3572 void showeventlog(HWND hwnd
)
3575 logbox
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
3577 ShowWindow(logbox
, SW_SHOWNORMAL
);
3579 SetActiveWindow(logbox
);
3582 void showabout(HWND hwnd
)
3584 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
3587 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
3588 char *keystr
, char *fingerprint
)
3592 static const char absentmsg
[] =
3593 "The server's host key is not cached in the registry. You\n"
3594 "have no guarantee that the server is the computer you\n"
3596 "The server's key fingerprint is:\n"
3598 "If you trust this host, hit Yes to add the key to\n"
3599 "PuTTY's cache and carry on connecting.\n"
3600 "If you want to carry on connecting just once, without\n"
3601 "adding the key to the cache, hit No.\n"
3602 "If you do not trust this host, hit Cancel to abandon the\n"
3605 static const char wrongmsg
[] =
3606 "WARNING - POTENTIAL SECURITY BREACH!\n"
3608 "The server's host key does not match the one PuTTY has\n"
3609 "cached in the registry. This means that either the\n"
3610 "server administrator has changed the host key, or you\n"
3611 "have actually connected to another computer pretending\n"
3612 "to be the server.\n"
3613 "The new key fingerprint is:\n"
3615 "If you were expecting this change and trust the new key,\n"
3616 "hit Yes to update PuTTY's cache and continue connecting.\n"
3617 "If you want to carry on connecting but without updating\n"
3618 "the cache, hit No.\n"
3619 "If you want to abandon the connection completely, hit\n"
3620 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3622 static const char mbtitle
[] = "PuTTY Security Alert";
3625 /* sensible fingerprint max size */
3626 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
3627 sizeof(absentmsg
) : sizeof(wrongmsg
))];
3630 * Verify the key against the registry.
3632 ret
= verify_host_key(host
, port
, keytype
, keystr
);
3634 if (ret
== 0) /* success - key matched OK */
3636 if (ret
== 2) { /* key was different */
3638 sprintf(message
, wrongmsg
, fingerprint
);
3639 mbret
= MessageBox(NULL
, message
, mbtitle
,
3640 MB_ICONWARNING
| MB_YESNOCANCEL
);
3642 store_host_key(host
, port
, keytype
, keystr
);
3643 if (mbret
== IDCANCEL
)
3646 if (ret
== 1) { /* key was absent */
3648 sprintf(message
, absentmsg
, fingerprint
);
3649 mbret
= MessageBox(NULL
, message
, mbtitle
,
3650 MB_ICONWARNING
| MB_YESNOCANCEL
);
3652 store_host_key(host
, port
, keytype
, keystr
);
3653 if (mbret
== IDCANCEL
)
3659 * Ask whether the selected cipher is acceptable (since it was
3660 * below the configured 'warn' threshold).
3661 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3663 void askcipher(char *ciphername
, int cs
)
3665 static const char mbtitle
[] = "PuTTY Security Alert";
3666 static const char msg
[] =
3667 "The first %.35scipher supported by the server\n"
3668 "is %.64s, which is below the configured\n"
3669 "warning threshold.\n"
3670 "Do you want to continue with this connection?\n";
3671 /* guessed cipher name + type max length */
3672 char message
[100 + sizeof(msg
)];
3675 sprintf(message
, msg
,
3677 (cs
== 1) ?
"client-to-server " :
3678 "server-to-client ",
3680 mbret
= MessageBox(NULL
, message
, mbtitle
,
3681 MB_ICONWARNING
| MB_YESNO
);
3689 * Ask whether to wipe a session log file before writing to it.
3690 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3692 int askappend(char *filename
)
3694 static const char mbtitle
[] = "PuTTY Log to File";
3695 static const char msgtemplate
[] =
3696 "The session log file \"%.*s\" already exists.\n"
3697 "You can overwrite it with a new session log,\n"
3698 "append your session log to the end of it,\n"
3699 "or disable session logging for this session.\n"
3700 "Hit Yes to wipe the file, No to append to it,\n"
3701 "or Cancel to disable logging.";
3702 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
3704 if (cfg
.logxfovr
!= LGXF_ASK
) {
3705 return ((cfg
.logxfovr
== LGXF_OVR
) ?
2 : 1);
3707 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
3709 mbret
= MessageBox(NULL
, message
, mbtitle
,
3710 MB_ICONQUESTION
| MB_YESNOCANCEL
);
3713 else if (mbret
== IDNO
)
3720 * Warn about the obsolescent key file format.
3722 void old_keyfile_warning(void)
3724 static const char mbtitle
[] = "PuTTY Key File Warning";
3725 static const char message
[] =
3726 "You are loading an SSH 2 private key which has an\n"
3727 "old version of the file format. This means your key\n"
3728 "file is not fully tamperproof. Future versions of\n"
3729 "PuTTY may stop supporting this private key format,\n"
3730 "so we recommend you convert your key to the new\n"
3733 "You can perform this conversion by loading the key\n"
3734 "into PuTTYgen and then saving it again.";
3736 MessageBox(NULL
, message
, mbtitle
, MB_OK
);