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
,
575 translationpanelstart
,
576 IDC_TITLE_TRANSLATION
,
577 IDC_BOX_TRANSLATION1
,
578 IDC_BOX_TRANSLATION2
,
579 IDC_BOX_TRANSLATION3
,
617 static const char *const colours
[] = {
618 "Default Foreground", "Default Bold Foreground",
619 "Default Background", "Default Bold Background",
620 "Cursor Text", "Cursor Colour",
621 "ANSI Black", "ANSI Black Bold",
622 "ANSI Red", "ANSI Red Bold",
623 "ANSI Green", "ANSI Green Bold",
624 "ANSI Yellow", "ANSI Yellow Bold",
625 "ANSI Blue", "ANSI Blue Bold",
626 "ANSI Magenta", "ANSI Magenta Bold",
627 "ANSI Cyan", "ANSI Cyan Bold",
628 "ANSI White", "ANSI White Bold"
630 static const int permcolour
[] = {
631 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
632 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
633 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
636 static void fmtfont(char *buf
)
638 sprintf(buf
, "Font: %s, ", cfg
.font
);
640 strcat(buf
, "bold, ");
641 if (cfg
.fontheight
== 0)
642 strcat(buf
, "default height");
644 sprintf(buf
+ strlen(buf
), "%d-point",
645 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
648 char *help_context_cmd(int id
)
660 return "JI(`',`session.hostname')";
667 return "JI(`',`session.saved')";
672 return "JI(`',`session.coe')";
673 case IDC_LSTATSTATIC
:
677 case IDC_LSTATPACKET
:
678 return "JI(`',`logging.main')";
683 return "JI(`',`logging.filename')";
688 return "JI(`',`logging.exists')";
693 return "JI(`',`keyboard.backspace')";
697 return "JI(`',`keyboard.homeend')";
705 return "JI(`',`keyboard.funkeys')";
709 return "JI(`',`keyboard.appkeypad')";
713 return "JI(`',`keyboard.appcursor')";
715 return "JI(`',`keyboard.nethack')";
717 return "JI(`',`keyboard.compose')";
718 case IDC_CTRLALTKEYS
:
719 return "JI(`',`keyboard.ctrlalt')";
723 return "JI(`',`features.application')";
725 return "JI(`',`features.mouse')";
727 return "JI(`',`features.resize')";
728 case IDC_NOALTSCREEN
:
729 return "JI(`',`features.altscreen')";
731 return "JI(`',`features.retitle')";
732 case IDC_NODBACKSPACE
:
733 return "JI(`',`features.dbackspace')";
735 return "JI(`',`features.charset')";
738 return "JI(`',`terminal.autowrap')";
740 return "JI(`',`terminal.decom')";
742 return "JI(`',`terminal.lfhascr')";
744 return "JI(`',`terminal.bce')";
746 return "JI(`',`terminal.blink')";
749 return "JI(`',`terminal.answerback')";
751 case IDC_ECHOBACKEND
:
754 return "JI(`',`terminal.localecho')";
756 case IDC_EDITBACKEND
:
759 return "JI(`',`terminal.localedit')";
760 case IDC_PRINTERSTATIC
:
762 return "JI(`',`terminal.printing')";
765 case IDC_BELL_DISABLED
:
766 case IDC_BELL_DEFAULT
:
767 case IDC_BELL_WAVEFILE
:
768 case IDC_BELL_VISUAL
:
769 case IDC_BELL_WAVESTATIC
:
770 case IDC_BELL_WAVEEDIT
:
771 case IDC_BELL_WAVEBROWSE
:
772 return "JI(`',`bell.style')";
773 case IDC_B_IND_STATIC
:
774 case IDC_B_IND_DISABLED
:
775 case IDC_B_IND_FLASH
:
776 case IDC_B_IND_STEADY
:
777 return "JI(`',`bell.taskbar')";
779 case IDC_BELLOVLNSTATIC
:
781 case IDC_BELLOVLTSTATIC
:
783 case IDC_BELLOVLEXPLAIN
:
784 case IDC_BELLOVLSSTATIC
:
786 return "JI(`',`bell.overload')";
792 return "JI(`',`window.size')";
793 case IDC_RESIZESTATIC
:
797 case IDC_RESIZEEITHER
:
798 return "JI(`',`window.resize')";
800 case IDC_SCROLLBARFULLSCREEN
:
805 return "JI(`',`window.scrollback')";
808 return "JI(`',`behaviour.closewarn')";
810 return "JI(`',`behaviour.altf4')";
812 return "JI(`',`behaviour.altspace')";
814 return "JI(`',`behaviour.altonly')";
815 case IDC_ALWAYSONTOP
:
816 return "JI(`',`behaviour.alwaysontop')";
817 case IDC_FULLSCREENONALTENTER
:
818 return "JI(`',`behaviour.altenter')";
820 case IDC_CURSORSTATIC
:
825 return "JI(`',`appearance.cursor')";
828 return "JI(`',`appearance.font')";
832 return "JI(`',`appearance.title')";
834 return "JI(`',`appearance.hidemouse')";
838 return "JI(`',`appearance.border')";
842 return "JI(`',`connection.termtype')";
845 return "JI(`',`connection.username')";
848 return "JI(`',`connection.keepalive')";
850 return "JI(`',`connection.nodelay')";
854 return "JI(`',`telnet.termspeed')";
863 return "JI(`',`telnet.environ')";
867 return "JI(`',`telnet.oldenviron')";
871 return "JI(`',`telnet.passive')";
873 return "JI(`',`telnet.specialkeys')";
875 return "JI(`',`telnet.newline')";
879 return "JI(`',`rlogin.termspeed')";
880 case IDC_RLLUSERSTATIC
:
881 case IDC_RLLUSEREDIT
:
882 return "JI(`',`rlogin.localuser')";
885 return "JI(`',`ssh.nopty')";
886 case IDC_CIPHERSTATIC2
:
891 return "JI(`',`ssh.ciphers')";
893 return "JI(`',`ssh.buggymac')";
894 case IDC_SSHPROTSTATIC
:
895 case IDC_SSHPROT1ONLY
:
898 case IDC_SSHPROT2ONLY
:
899 return "JI(`',`ssh.protocol')";
902 return "JI(`',`ssh.command')";
904 return "JI(`',`ssh.compress')";
909 return "JI(`',`ssh.auth.privkey')";
911 return "JI(`',`ssh.auth.agentfwd')";
913 return "JI(`',`ssh.auth.changeuser')";
915 return "JI(`',`ssh.auth.tis')";
917 return "JI(`',`ssh.auth.ki')";
922 return "JI(`',`selection.buttons')";
923 case IDC_MOUSEOVERRIDE
:
924 return "JI(`',`selection.shiftdrag')";
925 case IDC_SELTYPESTATIC
:
927 case IDC_SELTYPERECT
:
928 return "JI(`',`selection.rect')";
934 return "JI(`',`selection.charclasses')";
936 return "JI(`',`selection.linedraw')";
938 return "JI(`',`selection.rtf')";
941 return "JI(`',`colours.bold')";
943 return "JI(`',`colours.logpal')";
944 case IDC_COLOURSTATIC
:
953 return "JI(`',`colours.config')";
955 case IDC_CODEPAGESTATIC
:
957 return "JI(`',`translation.codepage')";
958 case IDC_CAPSLOCKCYR
:
959 return "JI(`',`translation.cyrillic')";
966 return "JI(`',`translation.linedraw')";
968 case IDC_X11_FORWARD
:
969 case IDC_X11_DISPSTATIC
:
970 case IDC_X11_DISPLAY
:
971 return "JI(`',`ssh.tunnels.x11')";
973 case IDC_PFWDSTATIC2
:
977 case IDC_SPORTSTATIC
:
979 case IDC_DPORTSTATIC
:
983 return "JI(`',`ssh.tunnels.portfwd')";
986 return "JI(`',`ssh.tunnels.portfwd.localhost')";
993 /* 2nd arg: NZ => don't redraw session list (use when loading
995 static void init_dlg_ctrls(HWND hwnd
, int keepsess
)
998 char fontstatic
[256];
1000 SetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
);
1001 SetDlgItemText(hwnd
, IDC_SESSEDIT
, savedsession
);
1004 n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
1005 for (i
= n
; i
-- > 0;)
1006 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_DELETESTRING
, i
, 0);
1007 for (i
= 0; i
< nsessions
; i
++)
1008 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1009 0, (LPARAM
) (sessions
[i
]));
1011 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1012 CheckRadioButton(hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
1013 cfg
.protocol
== PROT_SSH ? IDC_PROTSSH
:
1014 cfg
.protocol
== PROT_TELNET ? IDC_PROTTELNET
:
1016 PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
1017 SetDlgItemInt(hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
1018 CheckDlgButton(hwnd
, IDC_NODELAY
, cfg
.tcp_nodelay
);
1020 CheckRadioButton(hwnd
, IDC_DEL008
, IDC_DEL127
,
1021 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
1022 CheckRadioButton(hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
1023 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
1024 CheckRadioButton(hwnd
, IDC_FUNCTILDE
, IDC_FUNCSCO
,
1025 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
1026 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
1027 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
1028 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
1029 cfg
.funky_type
== 4 ? IDC_FUNCVT100P
:
1030 cfg
.funky_type
== 5 ? IDC_FUNCSCO
: IDC_FUNCTILDE
);
1031 CheckDlgButton(hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
1032 CheckDlgButton(hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
1033 CheckDlgButton(hwnd
, IDC_NOMOUSEREP
, cfg
.no_mouse_rep
);
1034 CheckDlgButton(hwnd
, IDC_NORESIZE
, cfg
.no_remote_resize
);
1035 CheckDlgButton(hwnd
, IDC_NOALTSCREEN
, cfg
.no_alt_screen
);
1036 CheckDlgButton(hwnd
, IDC_NOWINTITLE
, cfg
.no_remote_wintitle
);
1037 CheckDlgButton(hwnd
, IDC_NODBACKSPACE
, cfg
.no_dbackspace
);
1038 CheckDlgButton(hwnd
, IDC_NOCHARSET
, cfg
.no_remote_charset
);
1039 CheckRadioButton(hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
1040 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
1041 CheckRadioButton(hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
1042 cfg
.nethack_keypad ? IDC_KPNH
:
1043 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
1044 CheckDlgButton(hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
1045 CheckDlgButton(hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
1046 CheckDlgButton(hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
1047 CheckDlgButton(hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
1048 CheckDlgButton(hwnd
, IDC_CTRLALTKEYS
, cfg
.ctrlaltkeys
);
1049 CheckDlgButton(hwnd
, IDC_TELNETKEY
, cfg
.telnet_keyboard
);
1050 CheckDlgButton(hwnd
, IDC_TELNETRET
, cfg
.telnet_newline
);
1051 CheckRadioButton(hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
1052 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
1053 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
1054 CheckRadioButton(hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
1055 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
1056 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
1057 SetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
);
1058 CheckDlgButton(hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
1059 CheckDlgButton(hwnd
, IDC_FULLSCREENONALTENTER
, cfg
.fullscreenonaltenter
);
1060 CheckDlgButton(hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
1061 CheckDlgButton(hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
1063 CheckDlgButton(hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
1064 CheckDlgButton(hwnd
, IDC_DECOM
, cfg
.dec_om
);
1065 CheckDlgButton(hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
1066 SetDlgItemInt(hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
1067 SetDlgItemInt(hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
1068 SetDlgItemInt(hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
1069 fmtfont(fontstatic
);
1070 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
1071 CheckRadioButton(hwnd
, IDC_BELL_DISABLED
, IDC_BELL_VISUAL
,
1072 cfg
.beep
== BELL_DISABLED ? IDC_BELL_DISABLED
:
1073 cfg
.beep
== BELL_DEFAULT ? IDC_BELL_DEFAULT
:
1074 cfg
.beep
== BELL_WAVEFILE ? IDC_BELL_WAVEFILE
:
1076 BELL_VISUAL ? IDC_BELL_VISUAL
: IDC_BELL_DEFAULT
);
1077 CheckRadioButton(hwnd
, IDC_B_IND_DISABLED
, IDC_B_IND_STEADY
,
1079 B_IND_DISABLED ? IDC_B_IND_DISABLED
: cfg
.beep_ind
==
1080 B_IND_FLASH ? IDC_B_IND_FLASH
: cfg
.beep_ind
==
1081 B_IND_STEADY ? IDC_B_IND_STEADY
: IDC_B_IND_DISABLED
);
1082 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
1083 CheckDlgButton(hwnd
, IDC_BELLOVL
, cfg
.bellovl
);
1084 SetDlgItemInt(hwnd
, IDC_BELLOVLN
, cfg
.bellovl_n
, FALSE
);
1085 MySetDlgItemFlt(hwnd
, IDC_BELLOVLT
, cfg
.bellovl_t
/ 1000.0);
1086 MySetDlgItemFlt(hwnd
, IDC_BELLOVLS
, cfg
.bellovl_s
/ 1000.0);
1088 CheckDlgButton(hwnd
, IDC_BCE
, cfg
.bce
);
1089 CheckDlgButton(hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
1091 SetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
1092 CheckDlgButton(hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
1093 CheckDlgButton(hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
1094 CheckDlgButton(hwnd
, IDC_SUNKENEDGE
, cfg
.sunken_edge
);
1095 SetDlgItemInt(hwnd
, IDC_WINBEDIT
, cfg
.window_border
, FALSE
);
1096 CheckRadioButton(hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
1097 cfg
.cursor_type
== 0 ? IDC_CURBLOCK
:
1098 cfg
.cursor_type
== 1 ? IDC_CURUNDER
: IDC_CURVERT
);
1099 CheckDlgButton(hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
1100 CheckDlgButton(hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
1101 CheckDlgButton(hwnd
, IDC_SCROLLBARFULLSCREEN
, cfg
.scrollbar_in_fullscreen
);
1102 CheckRadioButton(hwnd
, IDC_RESIZETERM
, IDC_RESIZEEITHER
,
1103 cfg
.resize_action
== RESIZE_TERM ? IDC_RESIZETERM
:
1104 cfg
.resize_action
== RESIZE_FONT ? IDC_RESIZEFONT
:
1105 cfg
.resize_action
== RESIZE_EITHER ? IDC_RESIZEEITHER
:
1107 CheckRadioButton(hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
1108 cfg
.close_on_exit
== COE_NORMAL ? IDC_COENORMAL
:
1109 cfg
.close_on_exit
==
1110 COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
1111 CheckDlgButton(hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
1113 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
1114 SetDlgItemText(hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
1115 SetDlgItemText(hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
1116 SetDlgItemText(hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
1117 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
1118 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
1119 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATPACKET
,
1120 cfg
.logtype
== LGTYP_NONE ? IDC_LSTATOFF
:
1121 cfg
.logtype
== LGTYP_ASCII ? IDC_LSTATASCII
:
1122 cfg
.logtype
== LGTYP_DEBUG ? IDC_LSTATRAW
:
1124 CheckRadioButton(hwnd
, IDC_LSTATXOVR
, IDC_LSTATXASK
,
1125 cfg
.logxfovr
== LGXF_OVR ? IDC_LSTATXOVR
:
1126 cfg
.logxfovr
== LGXF_ASK ? IDC_LSTATXASK
:
1129 char *p
= cfg
.environmt
;
1130 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_RESETCONTENT
, 0, 0);
1132 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
1138 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
, 0,
1143 CheckRadioButton(hwnd
, IDC_EMBSD
, IDC_EMRFC
,
1144 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
1145 CheckRadioButton(hwnd
, IDC_TPASSIVE
, IDC_TACTIVE
,
1146 cfg
.passive_telnet ? IDC_TPASSIVE
: IDC_TACTIVE
);
1148 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
1149 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
1150 CheckDlgButton(hwnd
, IDC_NOPTY
, cfg
.nopty
);
1151 CheckDlgButton(hwnd
, IDC_COMPRESS
, cfg
.compression
);
1152 CheckDlgButton(hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
1153 CheckDlgButton(hwnd
, IDC_SSH2DES
, cfg
.ssh2_des_cbc
);
1154 CheckDlgButton(hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
1155 CheckDlgButton(hwnd
, IDC_CHANGEUSER
, cfg
.change_username
);
1156 CheckRadioButton(hwnd
, IDC_SSHPROT1ONLY
, IDC_SSHPROT2ONLY
,
1157 cfg
.sshprot
== 1 ? IDC_SSHPROT1
:
1158 cfg
.sshprot
== 2 ? IDC_SSHPROT2
:
1159 cfg
.sshprot
== 3 ? IDC_SSHPROT2ONLY
: IDC_SSHPROT1ONLY
);
1160 CheckDlgButton(hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
1161 CheckDlgButton(hwnd
, IDC_AUTHKI
, cfg
.try_ki_auth
);
1162 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1163 SetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
1167 static const struct { char *s
; int c
; } ciphers
[] = {
1168 { "3DES", CIPHER_3DES
},
1169 { "Blowfish", CIPHER_BLOWFISH
},
1170 { "DES", CIPHER_DES
},
1171 { "AES (SSH 2 only)", CIPHER_AES
},
1172 { "-- warn below here --", CIPHER_WARN
}
1175 /* Set up the "selected ciphers" box. */
1176 /* (cipherlist assumed to contain all ciphers) */
1177 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_RESETCONTENT
, 0, 0);
1178 for (i
= 0; i
< CIPHER_MAX
; i
++) {
1179 int c
= cfg
.ssh_cipherlist
[i
];
1182 for (j
= 0; j
< (sizeof ciphers
) / (sizeof ciphers
[0]); j
++) {
1183 if (ciphers
[j
].c
== c
) {
1184 cstr
= ciphers
[j
].s
;
1188 pos
= SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_ADDSTRING
,
1190 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_SETITEMDATA
,
1196 CheckRadioButton(hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
1197 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
1198 CheckRadioButton(hwnd
, IDC_SELTYPELEX
, IDC_SELTYPERECT
,
1199 cfg
.rect_select
== 0 ? IDC_SELTYPELEX
: IDC_SELTYPERECT
);
1200 CheckDlgButton(hwnd
, IDC_MOUSEOVERRIDE
, cfg
.mouse_override
);
1201 CheckDlgButton(hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
1202 CheckDlgButton(hwnd
, IDC_RTFPASTE
, cfg
.rtf_paste
);
1204 static int tabs
[4] = { 25, 61, 96, 128 };
1205 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
1208 for (i
= 0; i
< 128; i
++) {
1210 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
1211 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ', cfg
.wordness
[i
]);
1212 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
1216 CheckDlgButton(hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
1217 CheckDlgButton(hwnd
, IDC_PALETTE
, cfg
.try_palette
);
1220 n
= SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
1221 for (i
= n
; i
-- > 0;)
1222 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
1223 LB_DELETESTRING
, i
, 0);
1224 for (i
= 0; i
< 22; i
++)
1225 if (cfg
.bold_colour
|| permcolour
[i
])
1226 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
1227 (LPARAM
) colours
[i
]);
1229 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
1230 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
1231 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
1232 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
1237 strcpy(cfg
.line_codepage
, cp_name(decode_codepage(cfg
.line_codepage
)));
1238 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_RESETCONTENT
, 0, 0);
1239 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
1240 for (i
= 0; (cp
= cp_enumerate(i
)) != NULL
; i
++) {
1241 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_ADDSTRING
,
1244 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
1250 pe
= printer_start_enum(&nprinters
);
1251 SendDlgItemMessage(hwnd
, IDC_PRINTER
, CB_RESETCONTENT
, 0, 0);
1252 SendDlgItemMessage(hwnd
, IDC_PRINTER
, CB_ADDSTRING
,
1253 0, (LPARAM
) PRINTER_DISABLED_STRING
);
1254 for (i
= 0; i
< nprinters
; i
++) {
1255 char *printer_name
= printer_get_name(pe
, i
);
1256 SendDlgItemMessage(hwnd
, IDC_PRINTER
, CB_ADDSTRING
,
1257 0, (LPARAM
) printer_name
);
1259 printer_finish_enum(pe
);
1260 SetDlgItemText(hwnd
, IDC_PRINTER
,
1261 *cfg
.printer ? cfg
.printer
: PRINTER_DISABLED_STRING
);
1264 CheckRadioButton(hwnd
, IDC_VTXWINDOWS
, IDC_VTUNICODE
,
1265 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
1266 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
1267 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
1268 cfg
.vtmode
== VT_UNICODE ? IDC_VTUNICODE
:
1271 CheckDlgButton(hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
1272 SetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
1274 CheckDlgButton(hwnd
, IDC_LPORT_ALL
, cfg
.lport_acceptall
);
1275 CheckDlgButton(hwnd
, IDC_RPORT_ALL
, cfg
.rport_acceptall
);
1276 CheckRadioButton(hwnd
, IDC_PFWDLOCAL
, IDC_PFWDREMOTE
, IDC_PFWDLOCAL
);
1279 CheckRadioButton(hwnd
, IDC_PROXYTYPENONE
, IDC_PROXYTYPETELNET
,
1280 cfg
.proxy_type
== PROXY_HTTP ? IDC_PROXYTYPEHTTP
:
1281 cfg
.proxy_type
== PROXY_SOCKS ? IDC_PROXYTYPESOCKS
:
1282 cfg
.proxy_type
== PROXY_TELNET ? IDC_PROXYTYPETELNET
: IDC_PROXYTYPENONE
);
1283 SetDlgItemText(hwnd
, IDC_PROXYHOSTEDIT
, cfg
.proxy_host
);
1284 SetDlgItemInt(hwnd
, IDC_PROXYPORTEDIT
, cfg
.proxy_port
, FALSE
);
1285 SetDlgItemText(hwnd
, IDC_PROXYEXCLUDEEDIT
, cfg
.proxy_exclude_list
);
1286 SetDlgItemText(hwnd
, IDC_PROXYTELNETCMDEDIT
, cfg
.proxy_telnet_command
);
1287 SetDlgItemText(hwnd
, IDC_PROXYUSEREDIT
, cfg
.proxy_username
);
1288 SetDlgItemText(hwnd
, IDC_PROXYPASSEDIT
, cfg
.proxy_password
);
1289 CheckRadioButton(hwnd
, IDC_PROXYSOCKSVER5
, IDC_PROXYSOCKSVER4
,
1290 cfg
.proxy_socks_version
== 4 ? IDC_PROXYSOCKSVER4
: IDC_PROXYSOCKSVER5
);
1293 struct treeview_faff
{
1295 HTREEITEM lastat
[4];
1298 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
1299 int level
, char *text
)
1304 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
- 1] : TVI_ROOT
);
1305 ins
.hInsertAfter
= faff
->lastat
[level
];
1306 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1307 #define INSITEM DUMMYUNIONNAME.item
1309 #define INSITEM item
1311 ins
.INSITEM
.mask
= TVIF_TEXT
;
1312 ins
.INSITEM
.pszText
= text
;
1313 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
1315 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
- 1],
1317 faff
->lastat
[level
] = newitem
;
1318 for (i
= level
+ 1; i
< 4; i
++)
1319 faff
->lastat
[i
] = NULL
;
1324 * Create the panelfuls of controls in the configuration box.
1326 static void create_controls(HWND hwnd
, int dlgtype
, int panel
)
1328 if (panel
== sessionpanelstart
) {
1329 /* The Session panel. Accelerators used: [acgoh] nprtis elvd w */
1331 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1332 bartitle(&cp
, "Basic options for your PuTTY session",
1335 beginbox(&cp
, "Specify your connection by host name or IP address",
1338 "Host &Name (or IP address)",
1339 IDC_HOSTSTATIC
, IDC_HOST
, 75,
1340 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
1341 if (backends
[3].backend
== NULL
) {
1342 /* this is PuTTYtel, so only three protocols available */
1343 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 3,
1344 "&Raw", IDC_PROTRAW
,
1345 "&Telnet", IDC_PROTTELNET
,
1346 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
1348 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
1349 "&Raw", IDC_PROTRAW
,
1350 "&Telnet", IDC_PROTTELNET
,
1351 "Rlog&in", IDC_PROTRLOGIN
,
1360 beginbox(&cp
, "Load, save or delete a stored session",
1362 sesssaver(&cp
, "Sav&ed Sessions",
1363 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
1364 "&Load", IDC_SESSLOAD
,
1365 "Sa&ve", IDC_SESSSAVE
, "&Delete", IDC_SESSDEL
, NULL
);
1368 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
1369 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
1370 "Always", IDC_COEALWAYS
,
1371 "Never", IDC_COENEVER
,
1372 "Only on clean exit", IDC_COENORMAL
, NULL
);
1376 if (panel
== loggingpanelstart
) {
1377 /* The Logging panel. Accelerators used: [acgoh] tplsfwe */
1379 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1380 bartitle(&cp
, "Options controlling session logging",
1382 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
1384 "Session logging:", IDC_LSTATSTATIC
,
1385 "Logging &turned off completely", IDC_LSTATOFF
,
1386 "Log &printable output only", IDC_LSTATASCII
,
1387 "&Log all session output", IDC_LSTATRAW
,
1388 "Log &SSH packet data", IDC_LSTATPACKET
,
1390 editbutton(&cp
, "Log &file name:",
1391 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
1393 statictext(&cp
, "(Log file name can contain &&Y, &&M, &&D for date,"
1394 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN
);
1396 "What to do if the log file already &exists:",
1397 IDC_LSTATXIST
, "Always overwrite it", IDC_LSTATXOVR
,
1398 "Always append to the end of it", IDC_LSTATXAPN
,
1399 "Ask the user every time", IDC_LSTATXASK
, NULL
);
1403 if (panel
== terminalpanelstart
) {
1404 /* The Terminal panel. Accelerators used: [acgoh] wdren lts p */
1406 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1407 bartitle(&cp
, "Options controlling the terminal emulation",
1408 IDC_TITLE_TERMINAL
);
1409 beginbox(&cp
, "Set various terminal options", IDC_BOX_TERMINAL1
);
1410 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
1411 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
1412 checkbox(&cp
, "Implicit C&R in every LF", IDC_LFHASCR
);
1413 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
1414 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
1416 "An&swerback to ^E:", IDC_ANSWERBACK
,
1417 IDC_ANSWEREDIT
, 100, NULL
);
1420 beginbox(&cp
, "Line discipline options", IDC_BOX_TERMINAL2
);
1421 radioline(&cp
, "&Local echo:", IDC_ECHOSTATIC
, 3,
1422 "Auto", IDC_ECHOBACKEND
,
1423 "Force on", IDC_ECHOYES
, "Force off", IDC_ECHONO
, NULL
);
1424 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
1425 "Auto", IDC_EDITBACKEND
,
1426 "Force on", IDC_EDITYES
, "Force off", IDC_EDITNO
, NULL
);
1429 beginbox(&cp
, "Remote-controlled printing", IDC_BOX_TERMINAL3
);
1430 combobox(&cp
, "&Printer to send ANSI printer output to:",
1431 IDC_PRINTERSTATIC
, IDC_PRINTER
);
1435 if (panel
== featurespanelstart
) {
1436 /* The Features panel. Accelerators used: [acgoh] ukswtbrx */
1438 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1439 bartitle(&cp
, "Enabling and disabling advanced terminal features ",
1440 IDC_TITLE_FEATURES
);
1441 beginbox(&cp
, NULL
, IDC_BOX_FEATURES1
);
1442 checkbox(&cp
, "Disable application c&ursor keys mode", IDC_NOAPPLICC
);
1443 checkbox(&cp
, "Disable application &keypad mode", IDC_NOAPPLICK
);
1444 checkbox(&cp
, "Disable &xterm-style mouse reporting", IDC_NOMOUSEREP
);
1445 checkbox(&cp
, "Disable remote-controlled terminal re&sizing",
1447 checkbox(&cp
, "Disable s&witching to alternate terminal screen",
1449 checkbox(&cp
, "Disable remote-controlled window &title changing",
1451 checkbox(&cp
, "Disable destructive &backspace on server sending ^?",
1453 checkbox(&cp
, "Disable remote-controlled cha&racter set configuration",
1458 if (panel
== bellpanelstart
) {
1459 /* The Bell panel. Accelerators used: [acgoh] bdsm wit */
1461 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1462 bartitle(&cp
, "Options controlling the terminal bell",
1464 beginbox(&cp
, "Set the style of bell", IDC_BOX_BELL1
);
1466 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
1467 "None (bell disabled)", IDC_BELL_DISABLED
,
1468 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
1469 "Play a custom sound file", IDC_BELL_WAVEFILE
,
1470 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
1471 editbutton(&cp
, "Custom sound file to play as a bell:",
1472 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
1473 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
1474 radioline(&cp
, "Taskbar/caption &indication on bell:",
1475 IDC_B_IND_STATIC
, 3, "Disabled", IDC_B_IND_DISABLED
,
1476 "Flashing", IDC_B_IND_FLASH
, "Steady", IDC_B_IND_STEADY
,
1479 beginbox(&cp
, "Control the bell overload behaviour",
1481 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
1483 staticedit(&cp
, "Over-use means this &many bells...",
1484 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
1485 staticedit(&cp
, "... in &this many seconds",
1486 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
1488 "The bell is re-enabled after a few seconds of silence.",
1489 1, IDC_BELLOVLEXPLAIN
);
1490 staticedit(&cp
, "Seconds of &silence required", IDC_BELLOVLSSTATIC
,
1495 if (panel
== keyboardpanelstart
) {
1496 /* The Keyboard panel. Accelerators used: [acgoh] bef rntd */
1498 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1499 bartitle(&cp
, "Options controlling the effects of keys",
1500 IDC_TITLE_KEYBOARD
);
1501 beginbox(&cp
, "Change the sequences sent by:", IDC_BOX_KEYBOARD1
);
1502 radioline(&cp
, "The &Backspace key", IDC_DELSTATIC
, 2,
1503 "Control-H", IDC_DEL008
,
1504 "Control-? (127)", IDC_DEL127
, NULL
);
1505 radioline(&cp
, "The Home and &End keys", IDC_HOMESTATIC
, 2,
1506 "Standard", IDC_HOMETILDE
, "rxvt", IDC_HOMERXVT
, NULL
);
1507 radioline(&cp
, "The &Function keys and keypad", IDC_FUNCSTATIC
, 3,
1508 "ESC[n~", IDC_FUNCTILDE
,
1509 "Linux", IDC_FUNCLINUX
,
1510 "Xterm R6", IDC_FUNCXTERM
,
1511 "VT400", IDC_FUNCVT400
,
1512 "VT100+", IDC_FUNCVT100P
, "SCO", IDC_FUNCSCO
, NULL
);
1514 beginbox(&cp
, "Application keypad settings:", IDC_BOX_KEYBOARD2
);
1515 radioline(&cp
, "Initial state of cu&rsor keys:", IDC_CURSTATIC
, 2,
1516 "Normal", IDC_CURNORMAL
,
1517 "Application", IDC_CURAPPLIC
, NULL
);
1518 radioline(&cp
, "Initial state of &numeric keypad:", IDC_KPSTATIC
,
1519 3, "Normal", IDC_KPNORMAL
, "Application", IDC_KPAPPLIC
,
1520 "NetHack", IDC_KPNH
, NULL
);
1522 beginbox(&cp
, "Enable extra keyboard features:",
1524 checkbox(&cp
, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY
);
1525 checkbox(&cp
, "Control-Alt is &different from AltGr",
1530 if (panel
== windowpanelstart
) {
1531 /* The Window panel. Accelerators used: [acgoh] rmz sdikp */
1533 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1534 bartitle(&cp
, "Options controlling PuTTY's window",
1536 beginbox(&cp
, "Set the size of the window", IDC_BOX_WINDOW1
);
1538 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
1539 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50, NULL
);
1540 radiobig(&cp
, "When window is resi&zed:", IDC_RESIZESTATIC
,
1541 "Change the number of rows and columns", IDC_RESIZETERM
,
1542 "Change the size of the font", IDC_RESIZEFONT
,
1543 "Change font size only when maximised", IDC_RESIZEEITHER
,
1544 "Forbid resizing completely", IDC_RESIZENONE
, NULL
);
1546 beginbox(&cp
, "Control the scrollback in the window",
1548 staticedit(&cp
, "Lines of &scrollback",
1549 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
1550 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
1551 checkbox(&cp
, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN
);
1552 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
1553 checkbox(&cp
, "Reset scrollback on dis&play activity",
1558 if (panel
== appearancepanelstart
) {
1559 /* The Appearance panel. Accelerators used: [acgoh] luvb n ti p s */
1561 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1562 bartitle(&cp
, "Configure the appearance of PuTTY's window",
1563 IDC_TITLE_APPEARANCE
);
1564 beginbox(&cp
, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1
);
1565 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
1566 "B&lock", IDC_CURBLOCK
,
1567 "&Underline", IDC_CURUNDER
,
1568 "&Vertical line", IDC_CURVERT
, NULL
);
1569 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
1571 beginbox(&cp
, "Set the font used in the terminal window",
1572 IDC_BOX_APPEARANCE2
);
1573 staticbtn(&cp
, "", IDC_FONTSTATIC
, "Cha&nge...", IDC_CHOOSEFONT
);
1575 beginbox(&cp
, "Adjust the use of the window title",
1576 IDC_BOX_APPEARANCE3
);
1578 "Window &title:", IDC_WINTITLE
, IDC_WINEDIT
, 100, NULL
);
1579 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
1581 beginbox(&cp
, "Adjust the use of the mouse pointer",
1582 IDC_BOX_APPEARANCE4
);
1583 checkbox(&cp
, "Hide mouse &pointer when typing in window",
1586 beginbox(&cp
, "Adjust the window border", IDC_BOX_APPEARANCE5
);
1587 checkbox(&cp
, "&Sunken-edge border (slightly thicker)",
1589 staticedit(&cp
, "Gap between text and window edge",
1590 IDC_WINBSTATIC
, IDC_WINBEDIT
, 20);
1594 if (panel
== behaviourpanelstart
) {
1595 /* The Behaviour panel. Accelerators used: [acgoh] w4yltf */
1597 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1598 bartitle(&cp
, "Configure the behaviour of PuTTY's window",
1600 beginbox(&cp
, NULL
, IDC_BOX_BEHAVIOUR1
);
1601 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
1602 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
1603 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
1604 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
1605 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
1606 checkbox(&cp
, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER
);
1610 if (panel
== translationpanelstart
) {
1611 /* The Translation panel. Accelerators used: [acgoh] rxbepus */
1613 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1614 bartitle(&cp
, "Options controlling character set translation",
1615 IDC_TITLE_TRANSLATION
);
1616 beginbox(&cp
, "Character set translation on received data",
1617 IDC_BOX_TRANSLATION1
);
1618 combobox(&cp
, "&Received data assumed to be in which character set:",
1619 IDC_CODEPAGESTATIC
, IDC_CODEPAGE
);
1621 beginbox(&cp
, "Enable character set translation on input data",
1622 IDC_BOX_TRANSLATION2
);
1623 checkbox(&cp
, "Cap&s Lock acts as Cyrillic switch",
1626 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
1627 IDC_BOX_TRANSLATION3
);
1629 "Handling of line drawing characters:", IDC_VTSTATIC
,
1630 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
1631 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
1632 "Use font in O&EM mode only", IDC_VTOEMONLY
,
1633 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1634 IDC_VTPOORMAN
, "&Unicode mode", IDC_VTUNICODE
, NULL
);
1638 if (panel
== selectionpanelstart
) {
1639 /* The Selection panel. Accelerators used: [acgoh] df wxp est nr */
1641 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1642 bartitle(&cp
, "Options controlling copy and paste",
1643 IDC_TITLE_SELECTION
);
1644 beginbox(&cp
, "Translation of pasted characters",
1645 IDC_BOX_SELECTION1
);
1647 "&Don't translate line drawing chars into +, - and |",
1650 "Paste to clipboard in RT&F as well as plain text",
1653 beginbox(&cp
, "Control which mouse button does which thing",
1654 IDC_BOX_SELECTION2
);
1655 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1656 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1657 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1660 "Shift overrides a&pplication's use of mouse",
1663 "Default selection mode (Alt+drag does the other one):",
1664 IDC_SELTYPESTATIC
, 2,
1665 "&Normal", IDC_SELTYPELEX
,
1666 "&Rectangular block", IDC_SELTYPERECT
, NULL
);
1668 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1669 IDC_BOX_SELECTION3
);
1670 charclass(&cp
, "Charact&er classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1671 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1672 "&to class", IDC_CCSTATIC2
);
1676 if (panel
== colourspanelstart
) {
1677 /* The Colours panel. Accelerators used: [acgoh] blum */
1679 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1680 bartitle(&cp
, "Options controlling use of colours",
1682 beginbox(&cp
, "General options for colour usage",
1684 checkbox(&cp
, "&Bolded text is a different colour",
1686 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1688 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1690 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1691 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1692 "&Modify...", IDC_CHANGE
,
1693 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1694 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1695 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1699 if (panel
== connectionpanelstart
) {
1700 /* The Connection panel. Accelerators used: [acgoh] tukn */
1702 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1703 bartitle(&cp
, "Options controlling the connection",
1704 IDC_TITLE_CONNECTION
);
1706 beginbox(&cp
, "Data to send to the server",
1707 IDC_BOX_CONNECTION1
);
1708 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
,
1710 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
,
1714 beginbox(&cp
, "Adjust telnet session.", IDC_BOX_CONNECTION1
);
1715 checkbox(&cp
, "Keyboard sends telnet Backspace and Interrupt",
1717 checkbox(&cp
, "Return key sends telnet New Line instead of ^M",
1721 beginbox(&cp
, "Sending of null packets to keep session active",
1722 IDC_BOX_CONNECTION2
);
1723 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1724 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1727 beginbox(&cp
, "Low-level TCP connection options",
1728 IDC_BOX_CONNECTION3
);
1729 checkbox(&cp
, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1735 if (panel
== proxypanelstart
) {
1736 /* The Proxy panel. Accelerators used: [acgoh] ntslypeuwmv */
1738 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1740 bartitle(&cp
, "Options controlling proxy usage",
1742 beginbox(&cp
, "Proxy basics", IDC_BOX_PROXY1
);
1743 radioline(&cp
, "Proxy type:", IDC_PROXYTYPESTATIC
, 4,
1744 "&None", IDC_PROXYTYPENONE
,
1745 "H&TTP", IDC_PROXYTYPEHTTP
,
1746 "&SOCKS", IDC_PROXYTYPESOCKS
,
1747 "Te&lnet", IDC_PROXYTYPETELNET
, NULL
);
1749 "Prox&y Host", IDC_PROXYHOSTSTATIC
, IDC_PROXYHOSTEDIT
, 80,
1750 "&Port", IDC_PROXYPORTSTATIC
, IDC_PROXYPORTEDIT
, 20, NULL
);
1752 "&Exclude Hosts/IPs", IDC_PROXYEXCLUDESTATIC
,
1753 IDC_PROXYEXCLUDEEDIT
, 100, NULL
);
1754 staticedit(&cp
, "&Username", IDC_PROXYUSERSTATIC
,
1755 IDC_PROXYUSEREDIT
, 60);
1756 staticedit(&cp
, "Pass&word", IDC_PROXYPASSSTATIC
,
1757 IDC_PROXYPASSEDIT
, 60);
1759 beginbox(&cp
, "Misc. proxy settings", IDC_BOX_PROXY2
);
1761 "Telnet co&mmand", IDC_PROXYTELNETCMDSTATIC
,
1762 IDC_PROXYTELNETCMDEDIT
, 100, NULL
);
1763 radioline(&cp
, "SOCKS &Version", IDC_PROXYSOCKSVERSTATIC
,
1764 2, "Version 5", IDC_PROXYSOCKSVER5
, "Version 4",
1765 IDC_PROXYSOCKSVER4
, NULL
);
1770 if (panel
== telnetpanelstart
) {
1771 /* The Telnet panel. Accelerators used: [acgoh] svldr bftk */
1773 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1775 bartitle(&cp
, "Options controlling Telnet connections",
1777 beginbox(&cp
, "Data to send to the server", IDC_BOX_TELNET1
);
1778 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
,
1780 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1781 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
, "Va&lue",
1782 IDC_VALSTATIC
, IDC_VALEDIT
, IDC_ENVLIST
, "A&dd",
1783 IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1785 beginbox(&cp
, "Telnet protocol adjustments", IDC_BOX_TELNET2
);
1786 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:",
1787 IDC_EMSTATIC
, 2, "&BSD (commonplace)", IDC_EMBSD
,
1788 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1789 radioline(&cp
, "&Telnet negotiation mode:", IDC_ACTSTATIC
, 2,
1790 "Passive", IDC_TPASSIVE
, "Active",
1792 checkbox(&cp
, "&Keyboard sends telnet Backspace and Interrupt",
1794 checkbox(&cp
, "Return key sends telnet New Line instead of ^M",
1800 if (panel
== rloginpanelstart
) {
1801 /* The Rlogin panel. Accelerators used: [acgoh] sl */
1803 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1805 bartitle(&cp
, "Options controlling Rlogin connections",
1807 beginbox(&cp
, "Data to send to the server", IDC_BOX_RLOGIN1
);
1808 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
,
1810 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
,
1811 IDC_RLLUSEREDIT
, 50);
1816 if (panel
== sshpanelstart
) {
1817 /* The SSH panel. Accelerators used: [acgoh] r pe12ni sd */
1819 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1821 bartitle(&cp
, "Options controlling SSH connections",
1823 beginbox(&cp
, "Data to send to the server", IDC_BOX_SSH1
);
1825 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1828 beginbox(&cp
, "Protocol options", IDC_BOX_SSH2
);
1829 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1830 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1831 radioline(&cp
, "Preferred SSH protocol version:",
1832 IDC_SSHPROTSTATIC
, 4,
1833 "1 on&ly", IDC_SSHPROT1ONLY
,
1834 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
,
1835 "2 o&nly", IDC_SSHPROT2ONLY
, NULL
);
1836 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1839 beginbox(&cp
, "Encryption options", IDC_BOX_SSH3
);
1840 prefslist(&cipherlist
, &cp
, "Encryption cipher &selection policy:",
1841 IDC_CIPHERSTATIC2
, IDC_CIPHERLIST
, IDC_CIPHERUP
,
1843 checkbox(&cp
, "Enable non-standard use of single-&DES in SSH 2",
1849 if (panel
== sshauthpanelstart
) {
1850 /* The SSH authentication panel. Accelerators used: [acgoh] m fkiuw */
1852 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1854 bartitle(&cp
, "Options controlling SSH authentication",
1856 beginbox(&cp
, "Authentication methods",
1858 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
1860 checkbox(&cp
, "Attempt \"keyboard-&interactive\" authentication"
1861 " (SSH2)", IDC_AUTHKI
);
1863 beginbox(&cp
, "Authentication parameters",
1865 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1866 checkbox(&cp
, "Allow attempted changes of &username in SSH2",
1868 editbutton(&cp
, "Private &key file for authentication:",
1869 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...",
1875 if (panel
== tunnelspanelstart
) {
1876 /* The Tunnels panel. Accelerators used: [acgoh] deilmrstxp */
1878 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1880 bartitle(&cp
, "Options controlling SSH tunnelling",
1882 beginbox(&cp
, "X11 forwarding", IDC_BOX_TUNNELS1
);
1883 checkbox(&cp
, "&Enable X11 forwarding", IDC_X11_FORWARD
);
1884 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1885 IDC_X11_DISPLAY
, 50, NULL
);
1887 beginbox(&cp
, "Port forwarding", IDC_BOX_TUNNELS2
);
1888 checkbox(&cp
, "Local ports accept connections from o&ther hosts",
1890 checkbox(&cp
, "Remote &ports do the same (SSH v2 only)",
1892 staticbtn(&cp
, "Forwarded ports:", IDC_PFWDSTATIC
,
1893 "&Remove", IDC_PFWDREMOVE
);
1894 fwdsetter(&cp
, IDC_PFWDLIST
,
1895 "Add new forwarded port:", IDC_PFWDSTATIC2
,
1896 "&Source port", IDC_SPORTSTATIC
, IDC_SPORTEDIT
,
1897 "Dest&ination", IDC_DPORTSTATIC
, IDC_DPORTEDIT
,
1898 "A&dd", IDC_PFWDADD
);
1899 bareradioline(&cp
, 2,
1900 "&Local", IDC_PFWDLOCAL
,
1901 "Re&mote", IDC_PFWDREMOTE
, NULL
);
1909 * Helper function to load the session selected in SESSLIST
1910 * if any, as this is done in more than one place in
1911 * GenericMainDlgProc(). 0 => failure.
1913 static int load_selected_session(HWND hwnd
)
1915 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1916 LB_GETCURSEL
, 0, 0);
1922 isdef
= !strcmp(sessions
[n
], "Default Settings");
1923 load_settings(sessions
[n
], !isdef
, &cfg
);
1924 init_dlg_ctrls(hwnd
, TRUE
);
1926 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1928 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1929 /* Restore the selection, which will have been clobbered by
1930 * SESSEDIT handling. */
1931 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
, n
, 0);
1936 * This function is the configuration box.
1938 static int GenericMainDlgProc(HWND hwnd
, UINT msg
,
1939 WPARAM wParam
, LPARAM lParam
, int dlgtype
)
1942 struct treeview_faff tvfaff
;
1945 char filename
[sizeof(cfg
.keyfile
)];
1948 char fontstatic
[256];
1950 struct servent
*service
;
1952 static UINT draglistmsg
= WM_NULL
;
1957 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1959 SetWindowLong(hwnd
, GWL_EXSTYLE
,
1960 GetWindowLong(hwnd
, GWL_EXSTYLE
) | WS_EX_CONTEXTHELP
);
1962 HWND item
= GetDlgItem(hwnd
, IDC_HELPBTN
);
1964 DestroyWindow(item
);
1966 requested_help
= FALSE
;
1967 SendMessage(hwnd
, WM_SETICON
, (WPARAM
) ICON_BIG
,
1968 (LPARAM
) LoadIcon(hinst
, MAKEINTRESOURCE(IDI_CFGICON
)));
1970 * Centre the window.
1972 { /* centre the window */
1975 hw
= GetDesktopWindow();
1976 if (GetWindowRect(hw
, &rs
) && GetWindowRect(hwnd
, &rd
))
1978 (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
) / 2,
1979 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
) / 2,
1980 rd
.right
- rd
.left
, rd
.bottom
- rd
.top
, TRUE
);
1984 * Create the tree view.
1992 r
.right
= r
.left
+ 75;
1994 r
.bottom
= r
.top
+ 10;
1995 MapDialogRect(hwnd
, &r
);
1996 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1997 WS_CHILD
| WS_VISIBLE
,
1999 r
.right
- r
.left
, r
.bottom
- r
.top
,
2000 hwnd
, (HMENU
) IDCX_TVSTATIC
, hinst
,
2002 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
2003 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
2006 r
.right
= r
.left
+ 75;
2008 r
.bottom
= r
.top
+ 219;
2009 MapDialogRect(hwnd
, &r
);
2010 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
2011 WS_CHILD
| WS_VISIBLE
|
2012 WS_TABSTOP
| TVS_HASLINES
|
2013 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
2015 TVS_SHOWSELALWAYS
, r
.left
, r
.top
,
2016 r
.right
- r
.left
, r
.bottom
- r
.top
,
2017 hwnd
, (HMENU
) IDCX_TREEVIEW
, hinst
,
2019 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
2020 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
2021 tvfaff
.treeview
= treeview
;
2022 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
2026 * Set up the tree view contents.
2028 hsession
= treeview_insert(&tvfaff
, 0, "Session");
2029 treeview_insert(&tvfaff
, 1, "Logging");
2030 treeview_insert(&tvfaff
, 0, "Terminal");
2031 treeview_insert(&tvfaff
, 1, "Keyboard");
2032 treeview_insert(&tvfaff
, 1, "Bell");
2033 treeview_insert(&tvfaff
, 1, "Features");
2034 treeview_insert(&tvfaff
, 0, "Window");
2035 treeview_insert(&tvfaff
, 1, "Appearance");
2036 treeview_insert(&tvfaff
, 1, "Behaviour");
2037 treeview_insert(&tvfaff
, 1, "Translation");
2038 treeview_insert(&tvfaff
, 1, "Selection");
2039 treeview_insert(&tvfaff
, 1, "Colours");
2040 treeview_insert(&tvfaff
, 0, "Connection");
2042 treeview_insert(&tvfaff
, 1, "Proxy");
2043 treeview_insert(&tvfaff
, 1, "Telnet");
2044 treeview_insert(&tvfaff
, 1, "Rlogin");
2045 if (backends
[3].backend
!= NULL
) {
2046 treeview_insert(&tvfaff
, 1, "SSH");
2047 /* XXX long name is ugly */
2048 /* XXX make it closed by default? */
2049 treeview_insert(&tvfaff
, 2, "Auth");
2050 treeview_insert(&tvfaff
, 2, "Tunnels");
2055 * Put the treeview selection on to the Session panel. This
2056 * should also cause creation of the relevant controls.
2058 TreeView_SelectItem(treeview
, hsession
);
2061 * Set focus into the first available control.
2065 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
2067 ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
2071 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
2072 sesslist_has_focus
= 0;
2076 * Button release should trigger WM_OK if there was a
2077 * previous double click on the session list.
2081 SendMessage(hwnd
, WM_COMMAND
, IDOK
, 0);
2084 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
2085 ((LPNMHDR
) lParam
)->code
== TVN_SELCHANGED
) {
2087 TreeView_GetSelection(((LPNMHDR
) lParam
)->hwndFrom
);
2092 SendMessage (hwnd
, WM_SETREDRAW
, FALSE
, 0);
2095 item
.pszText
= buffer
;
2096 item
.cchTextMax
= sizeof(buffer
);
2097 item
.mask
= TVIF_TEXT
;
2098 TreeView_GetItem(((LPNMHDR
) lParam
)->hwndFrom
, &item
);
2099 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
2100 HWND item
= GetDlgItem(hwnd
, j
);
2102 DestroyWindow(item
);
2104 if (!strcmp(buffer
, "Session"))
2105 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
2106 if (!strcmp(buffer
, "Logging"))
2107 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
2108 if (!strcmp(buffer
, "Keyboard"))
2109 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
2110 if (!strcmp(buffer
, "Terminal"))
2111 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
2112 if (!strcmp(buffer
, "Bell"))
2113 create_controls(hwnd
, dlgtype
, bellpanelstart
);
2114 if (!strcmp(buffer
, "Features"))
2115 create_controls(hwnd
, dlgtype
, featurespanelstart
);
2116 if (!strcmp(buffer
, "Window"))
2117 create_controls(hwnd
, dlgtype
, windowpanelstart
);
2118 if (!strcmp(buffer
, "Appearance"))
2119 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
2120 if (!strcmp(buffer
, "Behaviour"))
2121 create_controls(hwnd
, dlgtype
, behaviourpanelstart
);
2122 if (!strcmp(buffer
, "Tunnels"))
2123 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
2124 if (!strcmp(buffer
, "Connection"))
2125 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
2126 if (!strcmp(buffer
, "Proxy"))
2127 create_controls(hwnd
, dlgtype
, proxypanelstart
);
2128 if (!strcmp(buffer
, "Telnet"))
2129 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
2130 if (!strcmp(buffer
, "Rlogin"))
2131 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
2132 if (!strcmp(buffer
, "SSH"))
2133 create_controls(hwnd
, dlgtype
, sshpanelstart
);
2134 if (!strcmp(buffer
, "Auth"))
2135 create_controls(hwnd
, dlgtype
, sshauthpanelstart
);
2136 if (!strcmp(buffer
, "Selection"))
2137 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
2138 if (!strcmp(buffer
, "Colours"))
2139 create_controls(hwnd
, dlgtype
, colourspanelstart
);
2140 if (!strcmp(buffer
, "Translation"))
2141 create_controls(hwnd
, dlgtype
, translationpanelstart
);
2143 init_dlg_ctrls(hwnd
, FALSE
);
2145 SendMessage (hwnd
, WM_SETREDRAW
, TRUE
, 0);
2146 InvalidateRect (hwnd
, NULL
, TRUE
);
2148 SetFocus(((LPNMHDR
) lParam
)->hwndFrom
); /* ensure focus stays */
2154 * Only process WM_COMMAND once the dialog is fully formed.
2156 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1)
2157 switch (LOWORD(wParam
)) {
2159 /* Behaviour of the "Open" button is different if the
2160 * session list has focus, *unless* the user just
2161 * double-clicked... */
2162 if (sesslist_has_focus
&& !readytogo
) {
2163 if (!load_selected_session(hwnd
)) {
2168 /* If at this point we have a valid session, go! */
2170 if (requested_help
) {
2171 WinHelp(hwnd
, help_path
, HELP_QUIT
, 0);
2172 requested_help
= FALSE
;
2179 if (HIWORD(wParam
) == BN_CLICKED
||
2180 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2182 WinHelp(hwnd
, help_path
,
2183 help_has_contents ? HELP_FINDER
: HELP_CONTENTS
,
2185 requested_help
= TRUE
;
2190 if (requested_help
) {
2191 WinHelp(hwnd
, help_path
, HELP_QUIT
, 0);
2192 requested_help
= FALSE
;
2196 case IDC_PROTTELNET
:
2197 case IDC_PROTRLOGIN
:
2200 if (HIWORD(wParam
) == BN_CLICKED
||
2201 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2202 int i
= IsDlgButtonChecked(hwnd
, IDC_PROTSSH
);
2203 int j
= IsDlgButtonChecked(hwnd
, IDC_PROTTELNET
);
2204 int k
= IsDlgButtonChecked(hwnd
, IDC_PROTRLOGIN
);
2206 i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
:
2209 * When switching using the arrow keys, we
2210 * appear to get two of these messages, both
2211 * mentioning the target button in
2212 * LOWORD(wParam), but one of them called while
2213 * the previous button is still checked. This
2214 * causes an unnecessary reset of the port
2215 * number field, which we fix by ensuring here
2216 * that the button selected is indeed the one
2219 if (IsDlgButtonChecked(hwnd
, LOWORD(wParam
)) &&
2220 ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22)
2221 || (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23)
2222 || (cfg
.protocol
== PROT_RLOGIN
2223 && cfg
.port
!= 513))) {
2224 cfg
.port
= i ?
22 : j ?
23 : 513;
2225 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
2230 if (HIWORD(wParam
) == EN_CHANGE
)
2231 GetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
,
2232 sizeof(cfg
.host
) - 1);
2235 if (HIWORD(wParam
) == EN_CHANGE
) {
2236 GetDlgItemText(hwnd
, IDC_PORT
, portname
, 31);
2237 if (isdigit(portname
[0]))
2238 MyGetDlgItemInt(hwnd
, IDC_PORT
, &cfg
.port
);
2240 service
= getservbyname(portname
, NULL
);
2242 cfg
.port
= ntohs(service
->s_port
);
2249 if (HIWORD(wParam
) == EN_CHANGE
) {
2250 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
2252 GetDlgItemText(hwnd
, IDC_SESSEDIT
,
2253 savedsession
, sizeof(savedsession
) - 1);
2254 savedsession
[sizeof(savedsession
) - 1] = '\0';
2258 if (HIWORD(wParam
) == BN_CLICKED
||
2259 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2264 GetDlgItemText(hwnd
, IDC_SESSEDIT
, str
,
2267 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2268 LB_GETCURSEL
, 0, 0);
2273 strcpy(str
, sessions
[n
]);
2275 save_settings(str
, !!strcmp(str
, "Default Settings"),
2277 get_sesslist(FALSE
);
2279 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2281 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
2283 for (i
= 0; i
< nsessions
; i
++)
2284 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2286 (LPARAM
) (sessions
[i
]));
2287 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
2289 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2291 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
2297 if (LOWORD(wParam
) == IDC_SESSLIST
) {
2298 if (HIWORD(wParam
) == LBN_SETFOCUS
)
2299 sesslist_has_focus
= 1;
2300 else if (HIWORD(wParam
) == LBN_KILLFOCUS
)
2301 sesslist_has_focus
= 0;
2303 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
2304 HIWORD(wParam
) != BN_CLICKED
&&
2305 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2306 if (LOWORD(wParam
) == IDC_SESSLIST
&&
2307 HIWORD(wParam
) != LBN_DBLCLK
) break;
2308 /* Load the session selected in SESSLIST. */
2309 if (load_selected_session(hwnd
) &&
2310 LOWORD(wParam
) == IDC_SESSLIST
) {
2312 * A double-click on a saved session should
2313 * actually start the session, not just load it.
2314 * Unless it's Default Settings or some other
2315 * host-less set of saved settings.
2324 if (HIWORD(wParam
) == BN_CLICKED
||
2325 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2326 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2327 LB_GETCURSEL
, 0, 0);
2328 if (n
== LB_ERR
|| n
== 0) {
2332 del_settings(sessions
[n
]);
2333 get_sesslist(FALSE
);
2335 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2337 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
2339 for (i
= 0; i
< nsessions
; i
++)
2340 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2342 (LPARAM
) (sessions
[i
]));
2343 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
2345 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2347 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
2351 if (HIWORD(wParam
) == EN_CHANGE
)
2352 MyGetDlgItemInt(hwnd
, IDC_PINGEDIT
,
2353 &cfg
.ping_interval
);
2356 if (HIWORD(wParam
) == BN_CLICKED
||
2357 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2359 IsDlgButtonChecked(hwnd
, IDC_NODELAY
);
2363 if (HIWORD(wParam
) == BN_CLICKED
||
2364 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2365 cfg
.bksp_is_delete
=
2366 IsDlgButtonChecked(hwnd
, IDC_DEL127
);
2370 if (HIWORD(wParam
) == BN_CLICKED
||
2371 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2373 IsDlgButtonChecked(hwnd
, IDC_HOMERXVT
);
2379 case IDC_FUNCVT100P
:
2381 if (HIWORD(wParam
) == BN_CLICKED
||
2382 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2383 switch (LOWORD(wParam
)) {
2396 case IDC_FUNCVT100P
:
2406 if (HIWORD(wParam
) == BN_CLICKED
||
2407 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2409 IsDlgButtonChecked(hwnd
, IDC_KPAPPLIC
);
2410 cfg
.nethack_keypad
= FALSE
;
2414 if (HIWORD(wParam
) == BN_CLICKED
||
2415 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2416 cfg
.app_keypad
= FALSE
;
2417 cfg
.nethack_keypad
= TRUE
;
2422 if (HIWORD(wParam
) == BN_CLICKED
||
2423 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2425 IsDlgButtonChecked(hwnd
, IDC_CURAPPLIC
);
2428 if (HIWORD(wParam
) == BN_CLICKED
||
2429 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2431 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICC
);
2434 if (HIWORD(wParam
) == BN_CLICKED
||
2435 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2437 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICK
);
2439 case IDC_NOMOUSEREP
:
2440 if (HIWORD(wParam
) == BN_CLICKED
||
2441 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2443 IsDlgButtonChecked(hwnd
, IDC_NOMOUSEREP
);
2446 if (HIWORD(wParam
) == BN_CLICKED
||
2447 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2448 cfg
.no_remote_resize
=
2449 IsDlgButtonChecked(hwnd
, IDC_NORESIZE
);
2451 case IDC_NOALTSCREEN
:
2452 if (HIWORD(wParam
) == BN_CLICKED
||
2453 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2455 IsDlgButtonChecked(hwnd
, IDC_NOALTSCREEN
);
2457 case IDC_NOWINTITLE
:
2458 if (HIWORD(wParam
) == BN_CLICKED
||
2459 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2460 cfg
.no_remote_wintitle
=
2461 IsDlgButtonChecked(hwnd
, IDC_NOWINTITLE
);
2463 case IDC_NODBACKSPACE
:
2464 if (HIWORD(wParam
) == BN_CLICKED
||
2465 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2467 IsDlgButtonChecked(hwnd
, IDC_NODBACKSPACE
);
2470 if (HIWORD(wParam
) == BN_CLICKED
||
2471 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2472 cfg
.no_remote_charset
=
2473 IsDlgButtonChecked(hwnd
, IDC_NOCHARSET
);
2476 if (HIWORD(wParam
) == BN_CLICKED
||
2477 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2478 cfg
.alt_f4
= IsDlgButtonChecked(hwnd
, IDC_ALTF4
);
2481 if (HIWORD(wParam
) == BN_CLICKED
||
2482 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2484 IsDlgButtonChecked(hwnd
, IDC_ALTSPACE
);
2487 if (HIWORD(wParam
) == BN_CLICKED
||
2488 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2490 IsDlgButtonChecked(hwnd
, IDC_ALTONLY
);
2492 case IDC_ECHOBACKEND
:
2495 if (HIWORD(wParam
) == BN_CLICKED
||
2496 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2497 if (LOWORD(wParam
) == IDC_ECHOBACKEND
)
2498 cfg
.localecho
= LD_BACKEND
;
2499 if (LOWORD(wParam
) == IDC_ECHOYES
)
2500 cfg
.localecho
= LD_YES
;
2501 if (LOWORD(wParam
) == IDC_ECHONO
)
2502 cfg
.localecho
= LD_NO
;
2505 case IDC_EDITBACKEND
:
2508 if (HIWORD(wParam
) == BN_CLICKED
||
2509 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2510 if (LOWORD(wParam
) == IDC_EDITBACKEND
)
2511 cfg
.localedit
= LD_BACKEND
;
2512 if (LOWORD(wParam
) == IDC_EDITYES
)
2513 cfg
.localedit
= LD_YES
;
2514 if (LOWORD(wParam
) == IDC_EDITNO
)
2515 cfg
.localedit
= LD_NO
;
2518 case IDC_ANSWEREDIT
:
2519 if (HIWORD(wParam
) == EN_CHANGE
)
2520 GetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
2521 sizeof(cfg
.answerback
) - 1);
2523 case IDC_ALWAYSONTOP
:
2524 if (HIWORD(wParam
) == BN_CLICKED
||
2525 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2527 IsDlgButtonChecked(hwnd
, IDC_ALWAYSONTOP
);
2529 case IDC_FULLSCREENONALTENTER
:
2530 if (HIWORD(wParam
) == BN_CLICKED
||
2531 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2532 cfg
.fullscreenonaltenter
=
2533 IsDlgButtonChecked(hwnd
, IDC_FULLSCREENONALTENTER
);
2536 if (HIWORD(wParam
) == BN_CLICKED
||
2537 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2539 IsDlgButtonChecked(hwnd
, IDC_SCROLLKEY
);
2541 case IDC_SCROLLDISP
:
2542 if (HIWORD(wParam
) == BN_CLICKED
||
2543 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2544 cfg
.scroll_on_disp
=
2545 IsDlgButtonChecked(hwnd
, IDC_SCROLLDISP
);
2547 case IDC_COMPOSEKEY
:
2548 if (HIWORD(wParam
) == BN_CLICKED
||
2549 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2551 IsDlgButtonChecked(hwnd
, IDC_COMPOSEKEY
);
2553 case IDC_CTRLALTKEYS
:
2554 if (HIWORD(wParam
) == BN_CLICKED
||
2555 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2557 IsDlgButtonChecked(hwnd
, IDC_CTRLALTKEYS
);
2560 if (HIWORD(wParam
) == BN_CLICKED
||
2561 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2562 cfg
.telnet_keyboard
=
2563 IsDlgButtonChecked(hwnd
, IDC_TELNETKEY
);
2566 if (HIWORD(wParam
) == BN_CLICKED
||
2567 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2568 cfg
.telnet_newline
=
2569 IsDlgButtonChecked(hwnd
, IDC_TELNETRET
);
2572 if (HIWORD(wParam
) == BN_CLICKED
||
2573 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2575 IsDlgButtonChecked(hwnd
, IDC_WRAPMODE
);
2578 if (HIWORD(wParam
) == BN_CLICKED
||
2579 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2580 cfg
.dec_om
= IsDlgButtonChecked(hwnd
, IDC_DECOM
);
2583 if (HIWORD(wParam
) == BN_CLICKED
||
2584 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2586 IsDlgButtonChecked(hwnd
, IDC_LFHASCR
);
2589 if (HIWORD(wParam
) == EN_CHANGE
)
2590 MyGetDlgItemInt(hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
2593 if (HIWORD(wParam
) == EN_CHANGE
)
2594 MyGetDlgItemInt(hwnd
, IDC_COLSEDIT
, &cfg
.width
);
2597 if (HIWORD(wParam
) == EN_CHANGE
)
2598 MyGetDlgItemInt(hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
2600 case IDC_CHOOSEFONT
:
2603 lf
.lfHeight
= -MulDiv(cfg
.fontheight
,
2604 GetDeviceCaps(hdc
, LOGPIXELSY
),
2608 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
2609 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
2610 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
2611 lf
.lfCharSet
= cfg
.fontcharset
;
2612 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
2613 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
2614 lf
.lfQuality
= DEFAULT_QUALITY
;
2615 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
2616 strncpy(lf
.lfFaceName
, cfg
.font
,
2617 sizeof(lf
.lfFaceName
) - 1);
2618 lf
.lfFaceName
[sizeof(lf
.lfFaceName
) - 1] = '\0';
2620 cf
.lStructSize
= sizeof(cf
);
2621 cf
.hwndOwner
= hwnd
;
2623 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
2624 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
2626 if (ChooseFont(&cf
)) {
2627 strncpy(cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
) - 1);
2628 cfg
.font
[sizeof(cfg
.font
) - 1] = '\0';
2629 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
2630 cfg
.fontcharset
= lf
.lfCharSet
;
2631 cfg
.fontheight
= cf
.iPointSize
/ 10;
2632 fmtfont(fontstatic
);
2633 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
2636 case IDC_BELL_DISABLED
:
2637 case IDC_BELL_DEFAULT
:
2638 case IDC_BELL_WAVEFILE
:
2639 case IDC_BELL_VISUAL
:
2640 if (HIWORD(wParam
) == BN_CLICKED
||
2641 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2642 if (LOWORD(wParam
) == IDC_BELL_DISABLED
)
2643 cfg
.beep
= BELL_DISABLED
;
2644 if (LOWORD(wParam
) == IDC_BELL_DEFAULT
)
2645 cfg
.beep
= BELL_DEFAULT
;
2646 if (LOWORD(wParam
) == IDC_BELL_WAVEFILE
)
2647 cfg
.beep
= BELL_WAVEFILE
;
2648 if (LOWORD(wParam
) == IDC_BELL_VISUAL
)
2649 cfg
.beep
= BELL_VISUAL
;
2652 case IDC_B_IND_DISABLED
:
2653 case IDC_B_IND_FLASH
:
2654 case IDC_B_IND_STEADY
:
2655 if (HIWORD(wParam
) == BN_CLICKED
||
2656 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2657 if (LOWORD(wParam
) == IDC_B_IND_DISABLED
)
2658 cfg
.beep_ind
= B_IND_DISABLED
;
2659 if (LOWORD(wParam
) == IDC_B_IND_FLASH
)
2660 cfg
.beep_ind
= B_IND_FLASH
;
2661 if (LOWORD(wParam
) == IDC_B_IND_STEADY
)
2662 cfg
.beep_ind
= B_IND_STEADY
;
2665 case IDC_BELL_WAVEBROWSE
:
2666 memset(&of
, 0, sizeof(of
));
2667 #ifdef OPENFILENAME_SIZE_VERSION_400
2668 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2670 of
.lStructSize
= sizeof(of
);
2672 of
.hwndOwner
= hwnd
;
2673 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2674 of
.lpstrCustomFilter
= NULL
;
2675 of
.nFilterIndex
= 1;
2676 of
.lpstrFile
= filename
;
2677 strcpy(filename
, cfg
.bell_wavefile
);
2678 of
.nMaxFile
= sizeof(filename
);
2679 of
.lpstrFileTitle
= NULL
;
2680 of
.lpstrInitialDir
= NULL
;
2681 of
.lpstrTitle
= "Select Bell Sound File";
2683 if (GetOpenFileName(&of
)) {
2684 strcpy(cfg
.bell_wavefile
, filename
);
2685 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2689 case IDC_BELL_WAVEEDIT
:
2690 if (HIWORD(wParam
) == EN_CHANGE
)
2691 GetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2693 sizeof(cfg
.bell_wavefile
) - 1);
2696 if (HIWORD(wParam
) == BN_CLICKED
||
2697 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2699 IsDlgButtonChecked(hwnd
, IDC_BELLOVL
);
2702 if (HIWORD(wParam
) == EN_CHANGE
)
2703 MyGetDlgItemInt(hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
2706 if (HIWORD(wParam
) == EN_CHANGE
)
2707 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
,
2711 if (HIWORD(wParam
) == EN_CHANGE
)
2712 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
,
2716 if (HIWORD(wParam
) == BN_CLICKED
||
2717 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2719 IsDlgButtonChecked(hwnd
, IDC_BLINKTEXT
);
2722 if (HIWORD(wParam
) == BN_CLICKED
||
2723 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2724 cfg
.bce
= IsDlgButtonChecked(hwnd
, IDC_BCE
);
2727 if (HIWORD(wParam
) == BN_CLICKED
||
2728 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2729 cfg
.win_name_always
=
2730 IsDlgButtonChecked(hwnd
, IDC_WINNAME
);
2733 if (HIWORD(wParam
) == BN_CLICKED
||
2734 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2736 IsDlgButtonChecked(hwnd
, IDC_HIDEMOUSE
);
2738 case IDC_SUNKENEDGE
:
2739 if (HIWORD(wParam
) == BN_CLICKED
||
2740 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2742 IsDlgButtonChecked(hwnd
, IDC_SUNKENEDGE
);
2745 if (HIWORD(wParam
) == EN_CHANGE
)
2746 MyGetDlgItemInt(hwnd
, IDC_WINBEDIT
,
2747 &cfg
.window_border
);
2748 if (cfg
.window_border
> 32)
2749 cfg
.window_border
= 32;
2752 if (HIWORD(wParam
) == BN_CLICKED
||
2753 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2754 cfg
.cursor_type
= 0;
2757 if (HIWORD(wParam
) == BN_CLICKED
||
2758 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2759 cfg
.cursor_type
= 1;
2762 if (HIWORD(wParam
) == BN_CLICKED
||
2763 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2764 cfg
.cursor_type
= 2;
2767 if (HIWORD(wParam
) == BN_CLICKED
||
2768 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2770 IsDlgButtonChecked(hwnd
, IDC_BLINKCUR
);
2773 if (HIWORD(wParam
) == BN_CLICKED
||
2774 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2776 IsDlgButtonChecked(hwnd
, IDC_SCROLLBAR
);
2778 case IDC_SCROLLBARFULLSCREEN
:
2779 if (HIWORD(wParam
) == BN_CLICKED
||
2780 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2781 cfg
.scrollbar_in_fullscreen
=
2782 IsDlgButtonChecked(hwnd
, IDC_SCROLLBARFULLSCREEN
);
2784 case IDC_RESIZETERM
:
2785 case IDC_RESIZEFONT
:
2786 case IDC_RESIZENONE
:
2787 case IDC_RESIZEEITHER
:
2788 if (HIWORD(wParam
) == BN_CLICKED
||
2789 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2791 IsDlgButtonChecked(hwnd
,
2792 IDC_RESIZETERM
) ? RESIZE_TERM
:
2793 IsDlgButtonChecked(hwnd
,
2794 IDC_RESIZEFONT
) ? RESIZE_FONT
:
2795 IsDlgButtonChecked(hwnd
,
2796 IDC_RESIZEEITHER
) ? RESIZE_EITHER
:
2801 if (HIWORD(wParam
) == EN_CHANGE
)
2802 GetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
2803 sizeof(cfg
.wintitle
) - 1);
2808 if (HIWORD(wParam
) == BN_CLICKED
||
2809 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2811 IsDlgButtonChecked(hwnd
,
2812 IDC_COEALWAYS
) ? COE_ALWAYS
:
2813 IsDlgButtonChecked(hwnd
,
2814 IDC_COENEVER
) ? COE_NEVER
:
2819 if (HIWORD(wParam
) == BN_CLICKED
||
2820 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2822 IsDlgButtonChecked(hwnd
, IDC_CLOSEWARN
);
2825 if (HIWORD(wParam
) == EN_CHANGE
)
2826 GetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
,
2827 sizeof(cfg
.termtype
) - 1);
2831 case IDC_PROXYHOSTEDIT
:
2832 if (HIWORD(wParam
) == EN_CHANGE
)
2833 GetDlgItemText(hwnd
, IDC_PROXYHOSTEDIT
, cfg
.proxy_host
,
2834 sizeof(cfg
.proxy_host
) - 1);
2836 case IDC_PROXYPORTEDIT
:
2837 if (HIWORD(wParam
) == EN_CHANGE
) {
2838 GetDlgItemText(hwnd
, IDC_PROXYPORTEDIT
, portname
, 31);
2839 if (isdigit(portname
[0]))
2840 MyGetDlgItemInt(hwnd
, IDC_PROXYPORTEDIT
, &cfg
.proxy_port
);
2842 service
= getservbyname(portname
, NULL
);
2844 cfg
.proxy_port
= ntohs(service
->s_port
);
2850 case IDC_PROXYEXCLUDEEDIT
:
2851 if (HIWORD(wParam
) == EN_CHANGE
)
2852 GetDlgItemText(hwnd
, IDC_PROXYEXCLUDEEDIT
,
2853 cfg
.proxy_exclude_list
,
2854 sizeof(cfg
.proxy_exclude_list
) - 1);
2856 case IDC_PROXYUSEREDIT
:
2857 if (HIWORD(wParam
) == EN_CHANGE
)
2858 GetDlgItemText(hwnd
, IDC_PROXYUSEREDIT
,
2860 sizeof(cfg
.proxy_username
) - 1);
2862 case IDC_PROXYPASSEDIT
:
2863 if (HIWORD(wParam
) == EN_CHANGE
)
2864 GetDlgItemText(hwnd
, IDC_PROXYPASSEDIT
,
2866 sizeof(cfg
.proxy_password
) - 1);
2868 case IDC_PROXYTELNETCMDEDIT
:
2869 if (HIWORD(wParam
) == EN_CHANGE
)
2870 GetDlgItemText(hwnd
, IDC_PROXYTELNETCMDEDIT
,
2871 cfg
.proxy_telnet_command
,
2872 sizeof(cfg
.proxy_telnet_command
) - 1);
2874 case IDC_PROXYSOCKSVER5
:
2875 case IDC_PROXYSOCKSVER4
:
2876 if (HIWORD(wParam
) == BN_CLICKED
||
2877 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2878 cfg
.proxy_socks_version
=
2879 IsDlgButtonChecked(hwnd
, IDC_PROXYSOCKSVER4
) ?
4 : 5;
2882 case IDC_PROXYTYPENONE
:
2883 case IDC_PROXYTYPEHTTP
:
2884 case IDC_PROXYTYPESOCKS
:
2885 case IDC_PROXYTYPETELNET
:
2886 if (HIWORD(wParam
) == BN_CLICKED
||
2887 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2889 IsDlgButtonChecked(hwnd
, IDC_PROXYTYPEHTTP
) ? PROXY_HTTP
:
2890 IsDlgButtonChecked(hwnd
, IDC_PROXYTYPESOCKS
) ? PROXY_SOCKS
:
2891 IsDlgButtonChecked(hwnd
, IDC_PROXYTYPETELNET
) ? PROXY_TELNET
:
2897 if (HIWORD(wParam
) == EN_CHANGE
)
2898 GetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
2899 sizeof(cfg
.logfilename
) - 1);
2902 memset(&of
, 0, sizeof(of
));
2903 #ifdef OPENFILENAME_SIZE_VERSION_400
2904 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2906 of
.lStructSize
= sizeof(of
);
2908 of
.hwndOwner
= hwnd
;
2909 of
.lpstrFilter
= "All Files\0*\0\0\0";
2910 of
.lpstrCustomFilter
= NULL
;
2911 of
.nFilterIndex
= 1;
2912 of
.lpstrFile
= filename
;
2913 strcpy(filename
, cfg
.logfilename
);
2914 of
.nMaxFile
= sizeof(filename
);
2915 of
.lpstrFileTitle
= NULL
;
2916 of
.lpstrInitialDir
= NULL
;
2917 of
.lpstrTitle
= "Select session log file";
2919 if (GetSaveFileName(&of
)) {
2920 strcpy(cfg
.logfilename
, filename
);
2921 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
2925 case IDC_LSTATASCII
:
2927 case IDC_LSTATPACKET
:
2928 if (HIWORD(wParam
) == BN_CLICKED
||
2929 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2930 if (IsDlgButtonChecked(hwnd
, IDC_LSTATOFF
))
2931 cfg
.logtype
= LGTYP_NONE
;
2932 if (IsDlgButtonChecked(hwnd
, IDC_LSTATASCII
))
2933 cfg
.logtype
= LGTYP_ASCII
;
2934 if (IsDlgButtonChecked(hwnd
, IDC_LSTATRAW
))
2935 cfg
.logtype
= LGTYP_DEBUG
;
2936 if (IsDlgButtonChecked(hwnd
, IDC_LSTATPACKET
))
2937 cfg
.logtype
= LGTYP_PACKETS
;
2943 if (HIWORD(wParam
) == BN_CLICKED
||
2944 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2945 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXASK
))
2946 cfg
.logxfovr
= LGXF_ASK
;
2947 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXAPN
))
2948 cfg
.logxfovr
= LGXF_APN
;
2949 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXOVR
))
2950 cfg
.logxfovr
= LGXF_OVR
;
2955 if (HIWORD(wParam
) == EN_CHANGE
)
2956 GetDlgItemText(hwnd
, LOWORD(wParam
), cfg
.termspeed
,
2957 sizeof(cfg
.termspeed
) - 1);
2960 if (HIWORD(wParam
) == EN_CHANGE
)
2961 GetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
,
2962 sizeof(cfg
.username
) - 1);
2964 case IDC_RLLUSEREDIT
:
2965 if (HIWORD(wParam
) == EN_CHANGE
)
2966 GetDlgItemText(hwnd
, IDC_RLLUSEREDIT
,
2968 sizeof(cfg
.localusername
) - 1);
2972 cfg
.rfc_environ
= IsDlgButtonChecked(hwnd
, IDC_EMRFC
);
2976 cfg
.passive_telnet
=
2977 IsDlgButtonChecked(hwnd
, IDC_TPASSIVE
);
2980 if (HIWORD(wParam
) == BN_CLICKED
||
2981 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2982 char str
[sizeof(cfg
.environmt
)];
2984 GetDlgItemText(hwnd
, IDC_VAREDIT
, str
,
2990 p
= str
+ strlen(str
);
2992 GetDlgItemText(hwnd
, IDC_VALEDIT
, p
,
2993 sizeof(str
) - 1 - (p
- str
));
3004 if ((p
- cfg
.environmt
) + strlen(str
) + 2 <
3005 sizeof(cfg
.environmt
)) {
3007 p
[strlen(str
) + 1] = '\0';
3008 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
3010 SetDlgItemText(hwnd
, IDC_VAREDIT
, "");
3011 SetDlgItemText(hwnd
, IDC_VALEDIT
, "");
3013 MessageBox(hwnd
, "Environment too big",
3014 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3019 if (HIWORD(wParam
) != BN_CLICKED
&&
3020 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
3022 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0,
3029 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
3056 if (HIWORD(wParam
) == BN_CLICKED
||
3057 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3058 cfg
.nopty
= IsDlgButtonChecked(hwnd
, IDC_NOPTY
);
3061 if (HIWORD(wParam
) == BN_CLICKED
||
3062 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3064 IsDlgButtonChecked(hwnd
, IDC_COMPRESS
);
3067 if (HIWORD(wParam
) == BN_CLICKED
||
3068 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3070 IsDlgButtonChecked(hwnd
, IDC_BUGGYMAC
);
3073 if (HIWORD(wParam
) == BN_CLICKED
||
3074 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3076 IsDlgButtonChecked(hwnd
, IDC_SSH2DES
);
3079 if (HIWORD(wParam
) == BN_CLICKED
||
3080 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3082 IsDlgButtonChecked(hwnd
, IDC_AGENTFWD
);
3084 case IDC_CHANGEUSER
:
3085 if (HIWORD(wParam
) == BN_CLICKED
||
3086 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3087 cfg
.change_username
=
3088 IsDlgButtonChecked(hwnd
, IDC_CHANGEUSER
);
3090 case IDC_CIPHERLIST
:
3093 handle_prefslist(&cipherlist
,
3094 cfg
.ssh_cipherlist
, CIPHER_MAX
,
3095 0, hwnd
, wParam
, lParam
);
3097 case IDC_SSHPROT1ONLY
:
3100 case IDC_SSHPROT2ONLY
:
3101 if (HIWORD(wParam
) == BN_CLICKED
||
3102 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3103 if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT1ONLY
))
3105 if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT1
))
3107 else if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT2
))
3109 else if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT2ONLY
))
3114 if (HIWORD(wParam
) == BN_CLICKED
||
3115 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3117 IsDlgButtonChecked(hwnd
, IDC_AUTHTIS
);
3120 if (HIWORD(wParam
) == BN_CLICKED
||
3121 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3123 IsDlgButtonChecked(hwnd
, IDC_AUTHKI
);
3126 if (HIWORD(wParam
) == EN_CHANGE
)
3127 GetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
3128 sizeof(cfg
.keyfile
) - 1);
3131 if (HIWORD(wParam
) == EN_CHANGE
)
3132 GetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
3133 sizeof(cfg
.remote_cmd
) - 1);
3136 memset(&of
, 0, sizeof(of
));
3137 #ifdef OPENFILENAME_SIZE_VERSION_400
3138 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
3140 of
.lStructSize
= sizeof(of
);
3142 of
.hwndOwner
= hwnd
;
3143 of
.lpstrFilter
= "PuTTY Private Key Files\0*.PPK\0"
3144 "AllFiles\0*\0\0\0";
3145 of
.lpstrCustomFilter
= NULL
;
3146 of
.nFilterIndex
= 1;
3147 of
.lpstrFile
= filename
;
3148 strcpy(filename
, cfg
.keyfile
);
3149 of
.nMaxFile
= sizeof(filename
);
3150 of
.lpstrFileTitle
= NULL
;
3151 of
.lpstrInitialDir
= NULL
;
3152 of
.lpstrTitle
= "Select Private Key File";
3154 if (GetOpenFileName(&of
)) {
3155 strcpy(cfg
.keyfile
, filename
);
3156 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
3160 cfg
.rawcnp
= IsDlgButtonChecked(hwnd
, IDC_RAWCNP
);
3163 cfg
.rtf_paste
= IsDlgButtonChecked(hwnd
, IDC_RTFPASTE
);
3167 cfg
.mouse_is_xterm
= IsDlgButtonChecked(hwnd
, IDC_MBXTERM
);
3169 case IDC_SELTYPELEX
:
3170 case IDC_SELTYPERECT
:
3171 cfg
.rect_select
= IsDlgButtonChecked(hwnd
, IDC_SELTYPERECT
);
3173 case IDC_MOUSEOVERRIDE
:
3174 cfg
.mouse_override
= IsDlgButtonChecked(hwnd
, IDC_MOUSEOVERRIDE
);
3180 int n
= GetDlgItemInt(hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
3185 for (i
= 0; i
< 128; i
++)
3186 if (SendDlgItemMessage
3187 (hwnd
, IDC_CCLIST
, LB_GETSEL
, i
, 0)) {
3189 cfg
.wordness
[i
] = n
;
3190 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
3191 LB_DELETESTRING
, i
, 0);
3192 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
3193 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ',
3195 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
3202 case IDC_BOLDCOLOUR
:
3203 if (HIWORD(wParam
) == BN_CLICKED
||
3204 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3207 IsDlgButtonChecked(hwnd
, IDC_BOLDCOLOUR
);
3208 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
3211 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3213 if (n
!= 12 + 10 * cfg
.bold_colour
) {
3214 for (i
= n
; i
-- > 0;)
3215 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3216 LB_DELETESTRING
, i
, 0);
3217 for (i
= 0; i
< 22; i
++)
3218 if (cfg
.bold_colour
|| permcolour
[i
])
3219 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3221 (LPARAM
) colours
[i
]);
3223 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
3225 InvalidateRect(GetDlgItem(hwnd
, IDC_COLOURLIST
), NULL
,
3230 if (HIWORD(wParam
) == BN_CLICKED
||
3231 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3233 IsDlgButtonChecked(hwnd
, IDC_PALETTE
);
3235 case IDC_COLOURLIST
:
3236 if (HIWORD(wParam
) == LBN_DBLCLK
||
3237 HIWORD(wParam
) == LBN_SELCHANGE
) {
3239 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3242 if (!cfg
.bold_colour
)
3243 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
3244 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
3246 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
3248 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
3253 if (HIWORD(wParam
) == BN_CLICKED
||
3254 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3255 static CHOOSECOLOR cc
;
3256 static DWORD custom
[16] = { 0 }; /* zero initialisers */
3258 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3261 if (!cfg
.bold_colour
)
3262 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
3263 cc
.lStructSize
= sizeof(cc
);
3264 cc
.hwndOwner
= hwnd
;
3265 cc
.hInstance
= (HWND
) hinst
;
3266 cc
.lpCustColors
= custom
;
3268 RGB(cfg
.colours
[i
][0], cfg
.colours
[i
][1],
3270 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
3271 if (ChooseColor(&cc
)) {
3273 (unsigned char) (cc
.rgbResult
& 0xFF);
3275 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
3277 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
3278 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
3280 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
3282 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
3288 if (HIWORD(wParam
) == CBN_SELCHANGE
) {
3289 int index
= SendDlgItemMessage(hwnd
, IDC_CODEPAGE
,
3290 CB_GETCURSEL
, 0, 0);
3291 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_GETLBTEXT
,
3292 index
, (LPARAM
)cfg
.line_codepage
);
3293 } else if (HIWORD(wParam
) == CBN_EDITCHANGE
) {
3294 GetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
,
3295 sizeof(cfg
.line_codepage
) - 1);
3296 } else if (HIWORD(wParam
) == CBN_KILLFOCUS
) {
3297 strcpy(cfg
.line_codepage
,
3298 cp_name(decode_codepage(cfg
.line_codepage
)));
3299 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
3303 if (HIWORD(wParam
) == CBN_SELCHANGE
) {
3304 int index
= SendDlgItemMessage(hwnd
, IDC_PRINTER
,
3305 CB_GETCURSEL
, 0, 0);
3306 SendDlgItemMessage(hwnd
, IDC_PRINTER
, CB_GETLBTEXT
,
3307 index
, (LPARAM
)cfg
.printer
);
3308 } else if (HIWORD(wParam
) == CBN_EDITCHANGE
) {
3309 GetDlgItemText(hwnd
, IDC_PRINTER
, cfg
.printer
,
3310 sizeof(cfg
.printer
) - 1);
3312 if (!strcmp(cfg
.printer
, PRINTER_DISABLED_STRING
))
3313 *cfg
.printer
= '\0';
3315 case IDC_CAPSLOCKCYR
:
3316 if (HIWORD(wParam
) == BN_CLICKED
||
3317 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3318 cfg
.xlat_capslockcyr
=
3319 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
3322 case IDC_VTXWINDOWS
:
3328 (IsDlgButtonChecked(hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
3329 : IsDlgButtonChecked(hwnd
,
3330 IDC_VTOEMANSI
) ? VT_OEMANSI
:
3331 IsDlgButtonChecked(hwnd
,
3332 IDC_VTOEMONLY
) ? VT_OEMONLY
:
3333 IsDlgButtonChecked(hwnd
,
3334 IDC_VTUNICODE
) ? VT_UNICODE
:
3337 case IDC_X11_FORWARD
:
3338 if (HIWORD(wParam
) == BN_CLICKED
||
3339 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3341 IsDlgButtonChecked(hwnd
, IDC_X11_FORWARD
);
3344 if (HIWORD(wParam
) == BN_CLICKED
||
3345 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3346 cfg
.lport_acceptall
=
3347 IsDlgButtonChecked(hwnd
, IDC_LPORT_ALL
);
3350 if (HIWORD(wParam
) == BN_CLICKED
||
3351 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3352 cfg
.rport_acceptall
=
3353 IsDlgButtonChecked(hwnd
, IDC_RPORT_ALL
);
3355 case IDC_X11_DISPLAY
:
3356 if (HIWORD(wParam
) == EN_CHANGE
)
3357 GetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
3358 sizeof(cfg
.x11_display
) - 1);
3361 if (HIWORD(wParam
) == BN_CLICKED
||
3362 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3363 char str
[sizeof(cfg
.portfwd
)];
3365 if (IsDlgButtonChecked(hwnd
, IDC_PFWDLOCAL
))
3369 GetDlgItemText(hwnd
, IDC_SPORTEDIT
, str
+1,
3373 "You need to specify a source port number",
3374 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3377 p
= str
+ strlen(str
);
3379 GetDlgItemText(hwnd
, IDC_DPORTEDIT
, p
,
3380 sizeof(str
) - 1 - (p
- str
));
3381 if (!*p
|| !strchr(p
, ':')) {
3383 "You need to specify a destination address\n"
3384 "in the form \"host.name:port\"",
3385 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3394 if ((p
- cfg
.portfwd
) + strlen(str
) + 2 <
3395 sizeof(cfg
.portfwd
)) {
3397 p
[strlen(str
) + 1] = '\0';
3398 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
,
3400 SetDlgItemText(hwnd
, IDC_SPORTEDIT
, "");
3401 SetDlgItemText(hwnd
, IDC_DPORTEDIT
, "");
3403 MessageBox(hwnd
, "Too many forwardings",
3404 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3408 case IDC_PFWDREMOVE
:
3409 if (HIWORD(wParam
) != BN_CLICKED
&&
3410 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
3411 i
= SendDlgItemMessage(hwnd
, IDC_PFWDLIST
,
3412 LB_GETCURSEL
, 0, 0);
3418 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_DELETESTRING
,
3448 int id
= ((LPHELPINFO
)lParam
)->iCtrlId
;
3449 char *cmd
= help_context_cmd(id
);
3451 WinHelp(hwnd
, help_path
, HELP_COMMAND
, (DWORD
)cmd
);
3452 requested_help
= TRUE
;
3459 if (requested_help
) {
3460 WinHelp(hwnd
, help_path
, HELP_QUIT
, 0);
3461 requested_help
= FALSE
;
3466 /* Grrr Explorer will maximize Dialogs! */
3468 if (wParam
== SIZE_MAXIMIZED
)
3474 * Handle application-defined messages eg. DragListBox
3476 /* First find out what the number is (once). */
3477 if (draglistmsg
== WM_NULL
)
3478 draglistmsg
= RegisterWindowMessage (DRAGLISTMSGSTRING
);
3480 if (msg
== draglistmsg
) {
3481 /* Only process once dialog is fully formed. */
3482 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
3483 case IDC_CIPHERLIST
:
3484 return handle_prefslist(&cipherlist
,
3485 cfg
.ssh_cipherlist
, CIPHER_MAX
,
3486 1, hwnd
, wParam
, lParam
);
3495 static int CALLBACK
MainDlgProc(HWND hwnd
, UINT msg
,
3496 WPARAM wParam
, LPARAM lParam
)
3498 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
3500 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
3501 EnableWindow(hwnd
, 0);
3502 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
3503 EnableWindow(hwnd
, 1);
3504 SetActiveWindow(hwnd
);
3506 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 0);
3509 static int CALLBACK
ReconfDlgProc(HWND hwnd
, UINT msg
,
3510 WPARAM wParam
, LPARAM lParam
)
3512 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 1);
3515 void defuse_showwindow(void)
3518 * Work around the fact that the app's first call to ShowWindow
3519 * will ignore the default in favour of the shell-provided
3524 hwnd
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
3526 ShowWindow(hwnd
, SW_HIDE
);
3527 SetActiveWindow(hwnd
);
3528 DestroyWindow(hwnd
);
3537 savedsession
[0] = '\0';
3539 DialogBox(hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
3540 get_sesslist(FALSE
);
3545 int do_reconfig(HWND hwnd
)
3550 backup_cfg
= cfg
; /* structure copy */
3552 DialogBox(hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
3554 cfg
= backup_cfg
; /* structure copy */
3559 void logevent(char *string
)
3564 if (nevents
>= negsize
) {
3566 events
= srealloc(events
, negsize
* sizeof(*events
));
3570 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t",
3573 events
[nevents
] = smalloc(strlen(timebuf
) + strlen(string
) + 1);
3574 strcpy(events
[nevents
], timebuf
);
3575 strcat(events
[nevents
], string
);
3578 SendDlgItemMessage(logbox
, IDN_LIST
, LB_ADDSTRING
,
3579 0, (LPARAM
) events
[nevents
]);
3580 count
= SendDlgItemMessage(logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
3581 SendDlgItemMessage(logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
- 1, 0);
3586 void showeventlog(HWND hwnd
)
3589 logbox
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
3591 ShowWindow(logbox
, SW_SHOWNORMAL
);
3593 SetActiveWindow(logbox
);
3596 void showabout(HWND hwnd
)
3598 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
3601 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
3602 char *keystr
, char *fingerprint
)
3606 static const char absentmsg
[] =
3607 "The server's host key is not cached in the registry. You\n"
3608 "have no guarantee that the server is the computer you\n"
3610 "The server's key fingerprint is:\n"
3612 "If you trust this host, hit Yes to add the key to\n"
3613 "PuTTY's cache and carry on connecting.\n"
3614 "If you want to carry on connecting just once, without\n"
3615 "adding the key to the cache, hit No.\n"
3616 "If you do not trust this host, hit Cancel to abandon the\n"
3619 static const char wrongmsg
[] =
3620 "WARNING - POTENTIAL SECURITY BREACH!\n"
3622 "The server's host key does not match the one PuTTY has\n"
3623 "cached in the registry. This means that either the\n"
3624 "server administrator has changed the host key, or you\n"
3625 "have actually connected to another computer pretending\n"
3626 "to be the server.\n"
3627 "The new key fingerprint is:\n"
3629 "If you were expecting this change and trust the new key,\n"
3630 "hit Yes to update PuTTY's cache and continue connecting.\n"
3631 "If you want to carry on connecting but without updating\n"
3632 "the cache, hit No.\n"
3633 "If you want to abandon the connection completely, hit\n"
3634 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3636 static const char mbtitle
[] = "PuTTY Security Alert";
3639 /* sensible fingerprint max size */
3640 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
3641 sizeof(absentmsg
) : sizeof(wrongmsg
))];
3644 * Verify the key against the registry.
3646 ret
= verify_host_key(host
, port
, keytype
, keystr
);
3648 if (ret
== 0) /* success - key matched OK */
3650 if (ret
== 2) { /* key was different */
3652 sprintf(message
, wrongmsg
, fingerprint
);
3653 mbret
= MessageBox(NULL
, message
, mbtitle
,
3654 MB_ICONWARNING
| MB_YESNOCANCEL
);
3656 store_host_key(host
, port
, keytype
, keystr
);
3657 if (mbret
== IDCANCEL
)
3660 if (ret
== 1) { /* key was absent */
3662 sprintf(message
, absentmsg
, fingerprint
);
3663 mbret
= MessageBox(NULL
, message
, mbtitle
,
3664 MB_ICONWARNING
| MB_YESNOCANCEL
);
3666 store_host_key(host
, port
, keytype
, keystr
);
3667 if (mbret
== IDCANCEL
)
3673 * Ask whether the selected cipher is acceptable (since it was
3674 * below the configured 'warn' threshold).
3675 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3677 void askcipher(char *ciphername
, int cs
)
3679 static const char mbtitle
[] = "PuTTY Security Alert";
3680 static const char msg
[] =
3681 "The first %.35scipher supported by the server\n"
3682 "is %.64s, which is below the configured\n"
3683 "warning threshold.\n"
3684 "Do you want to continue with this connection?\n";
3685 /* guessed cipher name + type max length */
3686 char message
[100 + sizeof(msg
)];
3689 sprintf(message
, msg
,
3691 (cs
== 1) ?
"client-to-server " :
3692 "server-to-client ",
3694 mbret
= MessageBox(NULL
, message
, mbtitle
,
3695 MB_ICONWARNING
| MB_YESNO
);
3703 * Ask whether to wipe a session log file before writing to it.
3704 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3706 int askappend(char *filename
)
3708 static const char mbtitle
[] = "PuTTY Log to File";
3709 static const char msgtemplate
[] =
3710 "The session log file \"%.*s\" already exists.\n"
3711 "You can overwrite it with a new session log,\n"
3712 "append your session log to the end of it,\n"
3713 "or disable session logging for this session.\n"
3714 "Hit Yes to wipe the file, No to append to it,\n"
3715 "or Cancel to disable logging.";
3716 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
3718 if (cfg
.logxfovr
!= LGXF_ASK
) {
3719 return ((cfg
.logxfovr
== LGXF_OVR
) ?
2 : 1);
3721 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
3723 mbret
= MessageBox(NULL
, message
, mbtitle
,
3724 MB_ICONQUESTION
| MB_YESNOCANCEL
);
3727 else if (mbret
== IDNO
)
3734 * Warn about the obsolescent key file format.
3736 void old_keyfile_warning(void)
3738 static const char mbtitle
[] = "PuTTY Key File Warning";
3739 static const char message
[] =
3740 "You are loading an SSH 2 private key which has an\n"
3741 "old version of the file format. This means your key\n"
3742 "file is not fully tamperproof. Future versions of\n"
3743 "PuTTY may stop supporting this private key format,\n"
3744 "so we recommend you convert your key to the new\n"
3747 "You can perform this conversion by loading the key\n"
3748 "into PuTTYgen and then saving it again.";
3750 MessageBox(NULL
, message
, mbtitle
, MB_OK
);