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 void force_normal(HWND hwnd
)
32 static int recurse
= 0;
40 wp
.length
= sizeof(wp
);
41 if (GetWindowPlacement(hwnd
, &wp
) && wp
.showCmd
== SW_SHOWMAXIMIZED
) {
42 wp
.showCmd
= SW_SHOWNORMAL
;
43 SetWindowPlacement(hwnd
, &wp
);
48 static void MyGetDlgItemInt(HWND hwnd
, int id
, int *result
)
52 n
= GetDlgItemInt(hwnd
, id
, &ok
, FALSE
);
57 static void MyGetDlgItemFlt(HWND hwnd
, int id
, int *result
, int scale
)
61 ok
= GetDlgItemText(hwnd
, id
, text
, sizeof(text
) - 1);
63 *result
= (int) (scale
* atof(text
));
66 static void MySetDlgItemFlt(HWND hwnd
, int id
, double value
)
69 sprintf(text
, "%g", value
);
70 SetDlgItemText(hwnd
, id
, text
);
73 static int CALLBACK
LogProc(HWND hwnd
, UINT msg
,
74 WPARAM wParam
, LPARAM lParam
)
81 static int tabs
[4] = { 78, 108 };
82 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETTABSTOPS
, 2,
85 for (i
= 0; i
< nevents
; i
++)
86 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_ADDSTRING
,
87 0, (LPARAM
) events
[i
]);
90 switch (LOWORD(wParam
)) {
94 SetActiveWindow(GetParent(hwnd
));
98 if (HIWORD(wParam
) == BN_CLICKED
||
99 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
102 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
103 LB_GETSELCOUNT
, 0, 0);
104 if (selcount
== 0) { /* don't even try to copy zero items */
109 selitems
= smalloc(selcount
* sizeof(int));
111 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
118 static unsigned char sel_nl
[] = SEL_NL
;
120 if (count
== 0) { /* can't copy zero stuff */
126 for (i
= 0; i
< count
; i
++)
128 strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
130 clipdata
= smalloc(size
);
133 for (i
= 0; i
< count
; i
++) {
134 char *q
= events
[selitems
[i
]];
135 int qlen
= strlen(q
);
138 memcpy(p
, sel_nl
, sizeof(sel_nl
));
141 write_aclip(clipdata
, size
, TRUE
);
146 for (i
= 0; i
< nevents
; i
++)
147 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
156 SetActiveWindow(GetParent(hwnd
));
163 static int CALLBACK
LicenceProc(HWND hwnd
, UINT msg
,
164 WPARAM wParam
, LPARAM lParam
)
170 switch (LOWORD(wParam
)) {
183 static int CALLBACK
AboutProc(HWND hwnd
, UINT msg
,
184 WPARAM wParam
, LPARAM lParam
)
188 SetDlgItemText(hwnd
, IDA_VERSION
, ver
);
191 switch (LOWORD(wParam
)) {
194 EndDialog(hwnd
, TRUE
);
197 EnableWindow(hwnd
, 0);
198 DialogBox(hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
200 EnableWindow(hwnd
, 1);
201 SetActiveWindow(hwnd
);
205 /* Load web browser */
206 ShellExecute(hwnd
, "open",
207 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
208 0, 0, SW_SHOWDEFAULT
);
213 EndDialog(hwnd
, TRUE
);
220 * Null dialog procedure.
222 static int CALLBACK
NullDlgProc(HWND hwnd
, UINT msg
,
223 WPARAM wParam
, LPARAM lParam
)
228 static char savedsession
[2048];
231 IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
380 IDC_SCROLLBARFULLSCREEN
,
395 IDC_FULLSCREENONALTENTER
,
398 appearancepanelstart
,
399 IDC_TITLE_APPEARANCE
,
421 connectionpanelstart
,
422 IDC_TITLE_CONNECTION
,
541 translationpanelstart
,
542 IDC_TITLE_TRANSLATION
,
543 IDC_BOX_TRANSLATION1
,
544 IDC_BOX_TRANSLATION2
,
545 IDC_BOX_TRANSLATION3
,
583 static const char *const colours
[] = {
584 "Default Foreground", "Default Bold Foreground",
585 "Default Background", "Default Bold Background",
586 "Cursor Text", "Cursor Colour",
587 "ANSI Black", "ANSI Black Bold",
588 "ANSI Red", "ANSI Red Bold",
589 "ANSI Green", "ANSI Green Bold",
590 "ANSI Yellow", "ANSI Yellow Bold",
591 "ANSI Blue", "ANSI Blue Bold",
592 "ANSI Magenta", "ANSI Magenta Bold",
593 "ANSI Cyan", "ANSI Cyan Bold",
594 "ANSI White", "ANSI White Bold"
596 static const int permcolour
[] = {
597 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
598 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
599 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
602 static void fmtfont(char *buf
)
604 sprintf(buf
, "Font: %s, ", cfg
.font
);
606 strcat(buf
, "bold, ");
607 if (cfg
.fontheight
== 0)
608 strcat(buf
, "default height");
610 sprintf(buf
+ strlen(buf
), "%d-point",
611 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
614 char *help_context_cmd(int id
)
626 return "JI(`',`session.hostname')";
633 return "JI(`',`session.saved')";
638 return "JI(`',`session.coe')";
639 case IDC_LSTATSTATIC
:
643 case IDC_LSTATPACKET
:
644 return "JI(`',`logging.main')";
649 return "JI(`',`logging.filename')";
654 return "JI(`',`logging.exists')";
659 return "JI(`',`keyboard.backspace')";
663 return "JI(`',`keyboard.homeend')";
671 return "JI(`',`keyboard.funkeys')";
675 return "JI(`',`keyboard.appkeypad')";
679 return "JI(`',`keyboard.appcursor')";
681 return "JI(`',`keyboard.nethack')";
683 return "JI(`',`keyboard.compose')";
684 case IDC_CTRLALTKEYS
:
685 return "JI(`',`keyboard.ctrlalt')";
689 return "JI(`',`features.application')";
691 return "JI(`',`features.resize')";
692 case IDC_NOALTSCREEN
:
693 return "JI(`',`features.altscreen')";
695 return "JI(`',`features.retitle')";
696 case IDC_NODBACKSPACE
:
697 return "JI(`',`features.dbackspace')";
699 return "JI(`',`features.charset')";
702 return "JI(`',`terminal.autowrap')";
704 return "JI(`',`terminal.decom')";
706 return "JI(`',`terminal.lfhascr')";
708 return "JI(`',`terminal.bce')";
710 return "JI(`',`terminal.blink')";
713 return "JI(`',`terminal.answerback')";
715 case IDC_ECHOBACKEND
:
718 return "JI(`',`terminal.localecho')";
720 case IDC_EDITBACKEND
:
723 return "JI(`',`terminal.localedit')";
726 case IDC_BELL_DISABLED
:
727 case IDC_BELL_DEFAULT
:
728 case IDC_BELL_WAVEFILE
:
729 case IDC_BELL_VISUAL
:
730 case IDC_BELL_WAVESTATIC
:
731 case IDC_BELL_WAVEEDIT
:
732 case IDC_BELL_WAVEBROWSE
:
733 return "JI(`',`bell.style')";
734 case IDC_B_IND_STATIC
:
735 case IDC_B_IND_DISABLED
:
736 case IDC_B_IND_FLASH
:
737 case IDC_B_IND_STEADY
:
738 return "JI(`',`bell.taskbar')";
740 case IDC_BELLOVLNSTATIC
:
742 case IDC_BELLOVLTSTATIC
:
744 case IDC_BELLOVLEXPLAIN
:
745 case IDC_BELLOVLSSTATIC
:
747 return "JI(`',`bell.overload')";
753 return "JI(`',`window.size')";
754 case IDC_RESIZESTATIC
:
758 case IDC_RESIZEEITHER
:
759 return "JI(`',`window.resize')";
761 case IDC_SCROLLBARFULLSCREEN
:
766 return "JI(`',`window.scrollback')";
769 return "JI(`',`behaviour.closewarn')";
771 return "JI(`',`behaviour.altf4')";
773 return "JI(`',`behaviour.altspace')";
775 return "JI(`',`behaviour.altonly')";
776 case IDC_ALWAYSONTOP
:
777 return "JI(`',`behaviour.alwaysontop')";
778 case IDC_FULLSCREENONALTENTER
:
779 return "JI(`',`behaviour.altenter')";
781 case IDC_CURSORSTATIC
:
786 return "JI(`',`appearance.cursor')";
789 return "JI(`',`appearance.font')";
793 return "JI(`',`appearance.title')";
795 return "JI(`',`appearance.hidemouse')";
799 return "JI(`',`appearance.border')";
803 return "JI(`',`connection.termtype')";
806 return "JI(`',`connection.username')";
809 return "JI(`',`connection.keepalive')";
811 return "JI(`',`connection.nodelay')";
815 return "JI(`',`telnet.termspeed')";
824 return "JI(`',`telnet.environ')";
828 return "JI(`',`telnet.oldenviron')";
832 return "JI(`',`telnet.passive')";
834 return "JI(`',`telnet.specialkeys')";
836 return "JI(`',`telnet.newline')";
840 return "JI(`',`rlogin.termspeed')";
841 case IDC_RLLUSERSTATIC
:
842 case IDC_RLLUSEREDIT
:
843 return "JI(`',`rlogin.localuser')";
846 return "JI(`',`ssh.nopty')";
847 case IDC_CIPHERSTATIC2
:
852 return "JI(`',`ssh.ciphers')";
854 return "JI(`',`ssh.buggymac')";
855 case IDC_SSHPROTSTATIC
:
858 return "JI(`',`ssh.protocol')";
861 return "JI(`',`ssh.command')";
863 return "JI(`',`ssh.compress')";
868 return "JI(`',`ssh.auth.privkey')";
870 return "JI(`',`ssh.auth.agentfwd')";
872 return "JI(`',`ssh.auth.changeuser')";
874 return "JI(`',`ssh.auth.tis')";
876 return "JI(`',`ssh.auth.ki')";
881 return "JI(`',`selection.buttons')";
882 case IDC_MOUSEOVERRIDE
:
883 return "JI(`',`selection.shiftdrag')";
884 case IDC_SELTYPESTATIC
:
886 case IDC_SELTYPERECT
:
887 return "JI(`',`selection.rect')";
893 return "JI(`',`selection.charclasses')";
895 return "JI(`',`selection.linedraw')";
897 return "JI(`',`selection.rtf')";
900 return "JI(`',`colours.bold')";
902 return "JI(`',`colours.logpal')";
903 case IDC_COLOURSTATIC
:
912 return "JI(`',`colours.config')";
914 case IDC_CODEPAGESTATIC
:
916 return "JI(`',`translation.codepage')";
917 case IDC_CAPSLOCKCYR
:
918 return "JI(`',`translation.cyrillic')";
925 return "JI(`',`translation.linedraw')";
927 case IDC_X11_FORWARD
:
928 case IDC_X11_DISPSTATIC
:
929 case IDC_X11_DISPLAY
:
930 return "JI(`',`ssh.tunnels.x11')";
932 case IDC_PFWDSTATIC2
:
936 case IDC_SPORTSTATIC
:
938 case IDC_DPORTSTATIC
:
942 return "JI(`',`ssh.tunnels.portfwd')";
945 return "JI(`',`ssh.tunnels.portfwd.localhost')";
952 /* 2nd arg: NZ => don't redraw session list (use when loading
954 static void init_dlg_ctrls(HWND hwnd
, int keepsess
)
957 char fontstatic
[256];
959 SetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
);
960 SetDlgItemText(hwnd
, IDC_SESSEDIT
, savedsession
);
963 n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
964 for (i
= n
; i
-- > 0;)
965 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_DELETESTRING
, i
, 0);
966 for (i
= 0; i
< nsessions
; i
++)
967 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
968 0, (LPARAM
) (sessions
[i
]));
970 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
971 CheckRadioButton(hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
972 cfg
.protocol
== PROT_SSH ? IDC_PROTSSH
:
973 cfg
.protocol
== PROT_TELNET ? IDC_PROTTELNET
:
975 PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
976 SetDlgItemInt(hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
977 CheckDlgButton(hwnd
, IDC_NODELAY
, cfg
.tcp_nodelay
);
979 CheckRadioButton(hwnd
, IDC_DEL008
, IDC_DEL127
,
980 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
981 CheckRadioButton(hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
982 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
983 CheckRadioButton(hwnd
, IDC_FUNCTILDE
, IDC_FUNCSCO
,
984 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
985 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
986 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
987 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
988 cfg
.funky_type
== 4 ? IDC_FUNCVT100P
:
989 cfg
.funky_type
== 5 ? IDC_FUNCSCO
: IDC_FUNCTILDE
);
990 CheckDlgButton(hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
991 CheckDlgButton(hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
992 CheckDlgButton(hwnd
, IDC_NORESIZE
, cfg
.no_remote_resize
);
993 CheckDlgButton(hwnd
, IDC_NOALTSCREEN
, cfg
.no_alt_screen
);
994 CheckDlgButton(hwnd
, IDC_NOWINTITLE
, cfg
.no_remote_wintitle
);
995 CheckDlgButton(hwnd
, IDC_NODBACKSPACE
, cfg
.no_dbackspace
);
996 CheckDlgButton(hwnd
, IDC_NOCHARSET
, cfg
.no_remote_charset
);
997 CheckRadioButton(hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
998 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
999 CheckRadioButton(hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
1000 cfg
.nethack_keypad ? IDC_KPNH
:
1001 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
1002 CheckDlgButton(hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
1003 CheckDlgButton(hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
1004 CheckDlgButton(hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
1005 CheckDlgButton(hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
1006 CheckDlgButton(hwnd
, IDC_CTRLALTKEYS
, cfg
.ctrlaltkeys
);
1007 CheckDlgButton(hwnd
, IDC_TELNETKEY
, cfg
.telnet_keyboard
);
1008 CheckDlgButton(hwnd
, IDC_TELNETRET
, cfg
.telnet_newline
);
1009 CheckRadioButton(hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
1010 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
1011 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
1012 CheckRadioButton(hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
1013 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
1014 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
1015 SetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
);
1016 CheckDlgButton(hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
1017 CheckDlgButton(hwnd
, IDC_FULLSCREENONALTENTER
, cfg
.fullscreenonaltenter
);
1018 CheckDlgButton(hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
1019 CheckDlgButton(hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
1021 CheckDlgButton(hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
1022 CheckDlgButton(hwnd
, IDC_DECOM
, cfg
.dec_om
);
1023 CheckDlgButton(hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
1024 SetDlgItemInt(hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
1025 SetDlgItemInt(hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
1026 SetDlgItemInt(hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
1027 fmtfont(fontstatic
);
1028 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
1029 CheckRadioButton(hwnd
, IDC_BELL_DISABLED
, IDC_BELL_VISUAL
,
1030 cfg
.beep
== BELL_DISABLED ? IDC_BELL_DISABLED
:
1031 cfg
.beep
== BELL_DEFAULT ? IDC_BELL_DEFAULT
:
1032 cfg
.beep
== BELL_WAVEFILE ? IDC_BELL_WAVEFILE
:
1034 BELL_VISUAL ? IDC_BELL_VISUAL
: IDC_BELL_DEFAULT
);
1035 CheckRadioButton(hwnd
, IDC_B_IND_DISABLED
, IDC_B_IND_STEADY
,
1037 B_IND_DISABLED ? IDC_B_IND_DISABLED
: cfg
.beep_ind
==
1038 B_IND_FLASH ? IDC_B_IND_FLASH
: cfg
.beep_ind
==
1039 B_IND_STEADY ? IDC_B_IND_STEADY
: IDC_B_IND_DISABLED
);
1040 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
1041 CheckDlgButton(hwnd
, IDC_BELLOVL
, cfg
.bellovl
);
1042 SetDlgItemInt(hwnd
, IDC_BELLOVLN
, cfg
.bellovl_n
, FALSE
);
1043 MySetDlgItemFlt(hwnd
, IDC_BELLOVLT
, cfg
.bellovl_t
/ 1000.0);
1044 MySetDlgItemFlt(hwnd
, IDC_BELLOVLS
, cfg
.bellovl_s
/ 1000.0);
1046 CheckDlgButton(hwnd
, IDC_BCE
, cfg
.bce
);
1047 CheckDlgButton(hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
1049 SetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
1050 CheckDlgButton(hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
1051 CheckDlgButton(hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
1052 CheckDlgButton(hwnd
, IDC_SUNKENEDGE
, cfg
.sunken_edge
);
1053 SetDlgItemInt(hwnd
, IDC_WINBEDIT
, cfg
.window_border
, FALSE
);
1054 CheckRadioButton(hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
1055 cfg
.cursor_type
== 0 ? IDC_CURBLOCK
:
1056 cfg
.cursor_type
== 1 ? IDC_CURUNDER
: IDC_CURVERT
);
1057 CheckDlgButton(hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
1058 CheckDlgButton(hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
1059 CheckDlgButton(hwnd
, IDC_SCROLLBARFULLSCREEN
, cfg
.scrollbar_in_fullscreen
);
1060 CheckRadioButton(hwnd
, IDC_RESIZETERM
, IDC_RESIZEEITHER
,
1061 cfg
.resize_action
== RESIZE_TERM ? IDC_RESIZETERM
:
1062 cfg
.resize_action
== RESIZE_FONT ? IDC_RESIZEFONT
:
1063 cfg
.resize_action
== RESIZE_EITHER ? IDC_RESIZEEITHER
:
1065 CheckRadioButton(hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
1066 cfg
.close_on_exit
== COE_NORMAL ? IDC_COENORMAL
:
1067 cfg
.close_on_exit
==
1068 COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
1069 CheckDlgButton(hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
1071 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
1072 SetDlgItemText(hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
1073 SetDlgItemText(hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
1074 SetDlgItemText(hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
1075 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
1076 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
1077 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATPACKET
,
1078 cfg
.logtype
== LGTYP_NONE ? IDC_LSTATOFF
:
1079 cfg
.logtype
== LGTYP_ASCII ? IDC_LSTATASCII
:
1080 cfg
.logtype
== LGTYP_DEBUG ? IDC_LSTATRAW
:
1082 CheckRadioButton(hwnd
, IDC_LSTATXOVR
, IDC_LSTATXASK
,
1083 cfg
.logxfovr
== LGXF_OVR ? IDC_LSTATXOVR
:
1084 cfg
.logxfovr
== LGXF_ASK ? IDC_LSTATXASK
:
1087 char *p
= cfg
.environmt
;
1088 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_RESETCONTENT
, 0, 0);
1090 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
1096 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
, 0,
1101 CheckRadioButton(hwnd
, IDC_EMBSD
, IDC_EMRFC
,
1102 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
1103 CheckRadioButton(hwnd
, IDC_TPASSIVE
, IDC_TACTIVE
,
1104 cfg
.passive_telnet ? IDC_TPASSIVE
: IDC_TACTIVE
);
1106 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
1107 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
1108 CheckDlgButton(hwnd
, IDC_NOPTY
, cfg
.nopty
);
1109 CheckDlgButton(hwnd
, IDC_COMPRESS
, cfg
.compression
);
1110 CheckDlgButton(hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
1111 CheckDlgButton(hwnd
, IDC_SSH2DES
, cfg
.ssh2_des_cbc
);
1112 CheckDlgButton(hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
1113 CheckDlgButton(hwnd
, IDC_CHANGEUSER
, cfg
.change_username
);
1114 CheckRadioButton(hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
1115 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
1116 CheckDlgButton(hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
1117 CheckDlgButton(hwnd
, IDC_AUTHKI
, cfg
.try_ki_auth
);
1118 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1119 SetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
1123 static const struct { char *s
; int c
; } ciphers
[] = {
1124 { "3DES", CIPHER_3DES
},
1125 { "Blowfish", CIPHER_BLOWFISH
},
1126 { "DES", CIPHER_DES
},
1127 { "AES (SSH 2 only)", CIPHER_AES
},
1128 { "-- warn below here --", CIPHER_WARN
}
1131 /* Set up the "selected ciphers" box. */
1132 /* (cipherlist assumed to contain all ciphers) */
1133 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_RESETCONTENT
, 0, 0);
1134 for (i
= 0; i
< CIPHER_MAX
; i
++) {
1135 int c
= cfg
.ssh_cipherlist
[i
];
1138 for (j
= 0; j
< (sizeof ciphers
) / (sizeof ciphers
[0]); j
++) {
1139 if (ciphers
[j
].c
== c
) {
1140 cstr
= ciphers
[j
].s
;
1144 pos
= SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_ADDSTRING
,
1146 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_SETITEMDATA
,
1152 CheckRadioButton(hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
1153 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
1154 CheckRadioButton(hwnd
, IDC_SELTYPELEX
, IDC_SELTYPERECT
,
1155 cfg
.rect_select
== 0 ? IDC_SELTYPELEX
: IDC_SELTYPERECT
);
1156 CheckDlgButton(hwnd
, IDC_MOUSEOVERRIDE
, cfg
.mouse_override
);
1157 CheckDlgButton(hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
1158 CheckDlgButton(hwnd
, IDC_RTFPASTE
, cfg
.rtf_paste
);
1160 static int tabs
[4] = { 25, 61, 96, 128 };
1161 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
1164 for (i
= 0; i
< 128; i
++) {
1166 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
1167 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ', cfg
.wordness
[i
]);
1168 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
1172 CheckDlgButton(hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
1173 CheckDlgButton(hwnd
, IDC_PALETTE
, cfg
.try_palette
);
1176 n
= SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
1177 for (i
= n
; i
-- > 0;)
1178 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
1179 LB_DELETESTRING
, i
, 0);
1180 for (i
= 0; i
< 22; i
++)
1181 if (cfg
.bold_colour
|| permcolour
[i
])
1182 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
1183 (LPARAM
) colours
[i
]);
1185 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
1186 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
1187 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
1188 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
1193 strcpy(cfg
.line_codepage
, cp_name(decode_codepage(cfg
.line_codepage
)));
1194 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_RESETCONTENT
, 0, 0);
1195 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
1196 for (i
= 0; (cp
= cp_enumerate(i
)) != NULL
; i
++) {
1197 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_ADDSTRING
,
1200 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
1203 CheckRadioButton(hwnd
, IDC_VTXWINDOWS
, IDC_VTUNICODE
,
1204 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
1205 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
1206 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
1207 cfg
.vtmode
== VT_UNICODE ? IDC_VTUNICODE
:
1210 CheckDlgButton(hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
1211 SetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
1213 CheckDlgButton(hwnd
, IDC_LPORT_ALL
, cfg
.lport_acceptall
);
1214 CheckDlgButton(hwnd
, IDC_RPORT_ALL
, cfg
.rport_acceptall
);
1215 CheckRadioButton(hwnd
, IDC_PFWDLOCAL
, IDC_PFWDREMOTE
, IDC_PFWDLOCAL
);
1218 struct treeview_faff
{
1220 HTREEITEM lastat
[4];
1223 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
1224 int level
, char *text
)
1229 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
- 1] : TVI_ROOT
);
1230 ins
.hInsertAfter
= faff
->lastat
[level
];
1231 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1232 #define INSITEM DUMMYUNIONNAME.item
1234 #define INSITEM item
1236 ins
.INSITEM
.mask
= TVIF_TEXT
;
1237 ins
.INSITEM
.pszText
= text
;
1238 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
1240 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
- 1],
1242 faff
->lastat
[level
] = newitem
;
1243 for (i
= level
+ 1; i
< 4; i
++)
1244 faff
->lastat
[i
] = NULL
;
1249 * Create the panelfuls of controls in the configuration box.
1251 static void create_controls(HWND hwnd
, int dlgtype
, int panel
)
1253 if (panel
== sessionpanelstart
) {
1254 /* The Session panel. Accelerators used: [acgoh] nprtis elvd w */
1256 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1257 bartitle(&cp
, "Basic options for your PuTTY session",
1260 beginbox(&cp
, "Specify your connection by host name or IP address",
1263 "Host &Name (or IP address)",
1264 IDC_HOSTSTATIC
, IDC_HOST
, 75,
1265 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
1266 if (backends
[3].backend
== NULL
) {
1267 /* this is PuTTYtel, so only three protocols available */
1268 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 3,
1269 "&Raw", IDC_PROTRAW
,
1270 "&Telnet", IDC_PROTTELNET
,
1271 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
1273 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
1274 "&Raw", IDC_PROTRAW
,
1275 "&Telnet", IDC_PROTTELNET
,
1276 "Rlog&in", IDC_PROTRLOGIN
,
1285 beginbox(&cp
, "Load, save or delete a stored session",
1287 sesssaver(&cp
, "Sav&ed Sessions",
1288 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
1289 "&Load", IDC_SESSLOAD
,
1290 "Sa&ve", IDC_SESSSAVE
, "&Delete", IDC_SESSDEL
, NULL
);
1293 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
1294 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
1295 "Always", IDC_COEALWAYS
,
1296 "Never", IDC_COENEVER
,
1297 "Only on clean exit", IDC_COENORMAL
, NULL
);
1301 if (panel
== loggingpanelstart
) {
1302 /* The Logging panel. Accelerators used: [acgoh] tplsfwe */
1304 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1305 bartitle(&cp
, "Options controlling session logging",
1307 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
1309 "Session logging:", IDC_LSTATSTATIC
,
1310 "Logging &turned off completely", IDC_LSTATOFF
,
1311 "Log &printable output only", IDC_LSTATASCII
,
1312 "&Log all session output", IDC_LSTATRAW
,
1313 "Log &SSH packet data", IDC_LSTATPACKET
,
1315 editbutton(&cp
, "Log &file name:",
1316 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
1318 statictext(&cp
, "(Log file name can contain &&Y, &&M, &&D for date,"
1319 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN
);
1321 "What to do if the log file already &exists:",
1322 IDC_LSTATXIST
, "Always overwrite it", IDC_LSTATXOVR
,
1323 "Always append to the end of it", IDC_LSTATXAPN
,
1324 "Ask the user every time", IDC_LSTATXASK
, NULL
);
1328 if (panel
== terminalpanelstart
) {
1329 /* The Terminal panel. Accelerators used: [acgoh] wdren lts */
1331 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1332 bartitle(&cp
, "Options controlling the terminal emulation",
1333 IDC_TITLE_TERMINAL
);
1334 beginbox(&cp
, "Set various terminal options", IDC_BOX_TERMINAL1
);
1335 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
1336 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
1337 checkbox(&cp
, "Implicit C&R in every LF", IDC_LFHASCR
);
1338 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
1339 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
1341 "An&swerback to ^E:", IDC_ANSWERBACK
,
1342 IDC_ANSWEREDIT
, 100, NULL
);
1345 beginbox(&cp
, "Line discipline options", IDC_BOX_TERMINAL2
);
1346 radioline(&cp
, "&Local echo:", IDC_ECHOSTATIC
, 3,
1347 "Auto", IDC_ECHOBACKEND
,
1348 "Force on", IDC_ECHOYES
, "Force off", IDC_ECHONO
, NULL
);
1349 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
1350 "Auto", IDC_EDITBACKEND
,
1351 "Force on", IDC_EDITYES
, "Force off", IDC_EDITNO
, NULL
);
1355 if (panel
== featurespanelstart
) {
1356 /* The Features panel. Accelerators used: [acgoh] ukswtbr */
1358 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1359 bartitle(&cp
, "Enabling and disabling advanced terminal features ",
1360 IDC_TITLE_FEATURES
);
1361 beginbox(&cp
, NULL
, IDC_BOX_FEATURES1
);
1362 checkbox(&cp
, "Disable application c&ursor keys mode", IDC_NOAPPLICC
);
1363 checkbox(&cp
, "Disable application &keypad mode", IDC_NOAPPLICK
);
1364 checkbox(&cp
, "Disable remote-controlled terminal re&sizing",
1366 checkbox(&cp
, "Disable s&witching to alternate terminal screen",
1368 checkbox(&cp
, "Disable remote-controlled window &title changing",
1370 checkbox(&cp
, "Disable destructive &backspace on server sending ^?",
1372 checkbox(&cp
, "Disable remote-controlled cha&racter set configuration",
1377 if (panel
== bellpanelstart
) {
1378 /* The Bell panel. Accelerators used: [acgoh] bdsm wit */
1380 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1381 bartitle(&cp
, "Options controlling the terminal bell",
1383 beginbox(&cp
, "Set the style of bell", IDC_BOX_BELL1
);
1385 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
1386 "None (bell disabled)", IDC_BELL_DISABLED
,
1387 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
1388 "Play a custom sound file", IDC_BELL_WAVEFILE
,
1389 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
1390 editbutton(&cp
, "Custom sound file to play as a bell:",
1391 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
1392 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
1393 radioline(&cp
, "Taskbar/caption &indication on bell:",
1394 IDC_B_IND_STATIC
, 3, "Disabled", IDC_B_IND_DISABLED
,
1395 "Flashing", IDC_B_IND_FLASH
, "Steady", IDC_B_IND_STEADY
,
1398 beginbox(&cp
, "Control the bell overload behaviour",
1400 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
1402 staticedit(&cp
, "Over-use means this &many bells...",
1403 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
1404 staticedit(&cp
, "... in &this many seconds",
1405 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
1407 "The bell is re-enabled after a few seconds of silence.",
1408 1, IDC_BELLOVLEXPLAIN
);
1409 staticedit(&cp
, "Seconds of &silence required", IDC_BELLOVLSSTATIC
,
1414 if (panel
== keyboardpanelstart
) {
1415 /* The Keyboard panel. Accelerators used: [acgoh] bef rntd */
1417 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1418 bartitle(&cp
, "Options controlling the effects of keys",
1419 IDC_TITLE_KEYBOARD
);
1420 beginbox(&cp
, "Change the sequences sent by:", IDC_BOX_KEYBOARD1
);
1421 radioline(&cp
, "The &Backspace key", IDC_DELSTATIC
, 2,
1422 "Control-H", IDC_DEL008
,
1423 "Control-? (127)", IDC_DEL127
, NULL
);
1424 radioline(&cp
, "The Home and &End keys", IDC_HOMESTATIC
, 2,
1425 "Standard", IDC_HOMETILDE
, "rxvt", IDC_HOMERXVT
, NULL
);
1426 radioline(&cp
, "The &Function keys and keypad", IDC_FUNCSTATIC
, 3,
1427 "ESC[n~", IDC_FUNCTILDE
,
1428 "Linux", IDC_FUNCLINUX
,
1429 "Xterm R6", IDC_FUNCXTERM
,
1430 "VT400", IDC_FUNCVT400
,
1431 "VT100+", IDC_FUNCVT100P
, "SCO", IDC_FUNCSCO
, NULL
);
1433 beginbox(&cp
, "Application keypad settings:", IDC_BOX_KEYBOARD2
);
1434 radioline(&cp
, "Initial state of cu&rsor keys:", IDC_CURSTATIC
, 2,
1435 "Normal", IDC_CURNORMAL
,
1436 "Application", IDC_CURAPPLIC
, NULL
);
1437 radioline(&cp
, "Initial state of &numeric keypad:", IDC_KPSTATIC
,
1438 3, "Normal", IDC_KPNORMAL
, "Application", IDC_KPAPPLIC
,
1439 "NetHack", IDC_KPNH
, NULL
);
1441 beginbox(&cp
, "Enable extra keyboard features:",
1443 checkbox(&cp
, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY
);
1444 checkbox(&cp
, "Control-Alt is &different from AltGr",
1449 if (panel
== windowpanelstart
) {
1450 /* The Window panel. Accelerators used: [acgoh] rmz sdikp */
1452 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1453 bartitle(&cp
, "Options controlling PuTTY's window",
1455 beginbox(&cp
, "Set the size of the window", IDC_BOX_WINDOW1
);
1457 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
1458 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50, NULL
);
1459 radiobig(&cp
, "When window is resi&zed:", IDC_RESIZESTATIC
,
1460 "Change the number of rows and columns", IDC_RESIZETERM
,
1461 "Change the size of the font", IDC_RESIZEFONT
,
1462 "Change font size only when maximised", IDC_RESIZEEITHER
,
1463 "Forbid resizing completely", IDC_RESIZENONE
, NULL
);
1465 beginbox(&cp
, "Control the scrollback in the window",
1467 staticedit(&cp
, "Lines of &scrollback",
1468 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
1469 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
1470 checkbox(&cp
, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN
);
1471 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
1472 checkbox(&cp
, "Reset scrollback on dis&play activity",
1477 if (panel
== appearancepanelstart
) {
1478 /* The Appearance panel. Accelerators used: [acgoh] luvb n ti p s */
1480 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1481 bartitle(&cp
, "Configure the appearance of PuTTY's window",
1482 IDC_TITLE_APPEARANCE
);
1483 beginbox(&cp
, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1
);
1484 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
1485 "B&lock", IDC_CURBLOCK
,
1486 "&Underline", IDC_CURUNDER
,
1487 "&Vertical line", IDC_CURVERT
, NULL
);
1488 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
1490 beginbox(&cp
, "Set the font used in the terminal window",
1491 IDC_BOX_APPEARANCE2
);
1492 staticbtn(&cp
, "", IDC_FONTSTATIC
, "Cha&nge...", IDC_CHOOSEFONT
);
1494 beginbox(&cp
, "Adjust the use of the window title",
1495 IDC_BOX_APPEARANCE3
);
1497 "Window &title:", IDC_WINTITLE
, IDC_WINEDIT
, 100, NULL
);
1498 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
1500 beginbox(&cp
, "Adjust the use of the mouse pointer",
1501 IDC_BOX_APPEARANCE4
);
1502 checkbox(&cp
, "Hide mouse &pointer when typing in window",
1505 beginbox(&cp
, "Adjust the window border", IDC_BOX_APPEARANCE5
);
1506 checkbox(&cp
, "&Sunken-edge border (slightly thicker)",
1508 staticedit(&cp
, "Gap between text and window edge",
1509 IDC_WINBSTATIC
, IDC_WINBEDIT
, 20);
1513 if (panel
== behaviourpanelstart
) {
1514 /* The Behaviour panel. Accelerators used: [acgoh] w4yltf */
1516 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1517 bartitle(&cp
, "Configure the behaviour of PuTTY's window",
1519 beginbox(&cp
, NULL
, IDC_BOX_BEHAVIOUR1
);
1520 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
1521 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
1522 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
1523 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
1524 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
1525 checkbox(&cp
, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER
);
1529 if (panel
== translationpanelstart
) {
1530 /* The Translation panel. Accelerators used: [acgoh] rxbepus */
1532 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1533 bartitle(&cp
, "Options controlling character set translation",
1534 IDC_TITLE_TRANSLATION
);
1535 beginbox(&cp
, "Character set translation on received data",
1536 IDC_BOX_TRANSLATION1
);
1537 combobox(&cp
, "&Received data assumed to be in which character set:",
1538 IDC_CODEPAGESTATIC
, IDC_CODEPAGE
);
1540 beginbox(&cp
, "Enable character set translation on input data",
1541 IDC_BOX_TRANSLATION2
);
1542 checkbox(&cp
, "Cap&s Lock acts as Cyrillic switch",
1545 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
1546 IDC_BOX_TRANSLATION3
);
1548 "Handling of line drawing characters:", IDC_VTSTATIC
,
1549 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
1550 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
1551 "Use font in O&EM mode only", IDC_VTOEMONLY
,
1552 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1553 IDC_VTPOORMAN
, "&Unicode mode", IDC_VTUNICODE
, NULL
);
1557 if (panel
== selectionpanelstart
) {
1558 /* The Selection panel. Accelerators used: [acgoh] df wxp est nr */
1560 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1561 bartitle(&cp
, "Options controlling copy and paste",
1562 IDC_TITLE_SELECTION
);
1563 beginbox(&cp
, "Translation of pasted characters",
1564 IDC_BOX_SELECTION1
);
1566 "&Don't translate line drawing chars into +, - and |",
1569 "Paste to clipboard in RT&F as well as plain text",
1572 beginbox(&cp
, "Control which mouse button does which thing",
1573 IDC_BOX_SELECTION2
);
1574 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1575 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1576 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1579 "Shift overrides a&pplication's use of mouse",
1582 "Default selection mode (Alt+drag does the other one):",
1583 IDC_SELTYPESTATIC
, 2,
1584 "&Normal", IDC_SELTYPELEX
,
1585 "&Rectangular block", IDC_SELTYPERECT
, NULL
);
1587 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1588 IDC_BOX_SELECTION3
);
1589 charclass(&cp
, "Charact&er classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1590 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1591 "&to class", IDC_CCSTATIC2
);
1595 if (panel
== colourspanelstart
) {
1596 /* The Colours panel. Accelerators used: [acgoh] blum */
1598 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1599 bartitle(&cp
, "Options controlling use of colours",
1601 beginbox(&cp
, "General options for colour usage",
1603 checkbox(&cp
, "&Bolded text is a different colour",
1605 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1607 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1609 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1610 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1611 "&Modify...", IDC_CHANGE
,
1612 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1613 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1614 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1618 if (panel
== connectionpanelstart
) {
1619 /* The Connection panel. Accelerators used: [acgoh] tukn */
1621 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1622 bartitle(&cp
, "Options controlling the connection",
1623 IDC_TITLE_CONNECTION
);
1625 beginbox(&cp
, "Data to send to the server",
1626 IDC_BOX_CONNECTION1
);
1627 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
,
1629 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
,
1633 beginbox(&cp
, "Adjust telnet session.", IDC_BOX_CONNECTION1
);
1634 checkbox(&cp
, "Keyboard sends telnet Backspace and Interrupt",
1636 checkbox(&cp
, "Return key sends telnet New Line instead of ^M",
1640 beginbox(&cp
, "Sending of null packets to keep session active",
1641 IDC_BOX_CONNECTION2
);
1642 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1643 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1646 beginbox(&cp
, "Low-level TCP connection options",
1647 IDC_BOX_CONNECTION3
);
1648 checkbox(&cp
, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1654 if (panel
== telnetpanelstart
) {
1655 /* The Telnet panel. Accelerators used: [acgoh] svldr bftk */
1657 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1659 bartitle(&cp
, "Options controlling Telnet connections",
1661 beginbox(&cp
, "Data to send to the server", IDC_BOX_TELNET1
);
1662 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
,
1664 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1665 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
, "Va&lue",
1666 IDC_VALSTATIC
, IDC_VALEDIT
, IDC_ENVLIST
, "A&dd",
1667 IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1669 beginbox(&cp
, "Telnet protocol adjustments", IDC_BOX_TELNET2
);
1670 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:",
1671 IDC_EMSTATIC
, 2, "&BSD (commonplace)", IDC_EMBSD
,
1672 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1673 radioline(&cp
, "&Telnet negotiation mode:", IDC_ACTSTATIC
, 2,
1674 "Passive", IDC_TPASSIVE
, "Active",
1676 checkbox(&cp
, "&Keyboard sends telnet Backspace and Interrupt",
1678 checkbox(&cp
, "Return key sends telnet New Line instead of ^M",
1684 if (panel
== rloginpanelstart
) {
1685 /* The Rlogin panel. Accelerators used: [acgoh] sl */
1687 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1689 bartitle(&cp
, "Options controlling Rlogin connections",
1691 beginbox(&cp
, "Data to send to the server", IDC_BOX_RLOGIN1
);
1692 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
,
1694 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
,
1695 IDC_RLLUSEREDIT
, 50);
1700 if (panel
== sshpanelstart
) {
1701 /* The SSH panel. Accelerators used: [acgoh] r pe12i sd */
1703 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1705 bartitle(&cp
, "Options controlling SSH connections",
1707 beginbox(&cp
, "Data to send to the server", IDC_BOX_SSH1
);
1709 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1712 beginbox(&cp
, "Protocol options", IDC_BOX_SSH2
);
1713 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1714 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1715 radioline(&cp
, "Preferred SSH protocol version:",
1716 IDC_SSHPROTSTATIC
, 2,
1717 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1718 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1721 beginbox(&cp
, "Encryption options", IDC_BOX_SSH3
);
1722 prefslist(&cipherlist
, &cp
, "Encryption cipher &selection policy:",
1723 IDC_CIPHERSTATIC2
, IDC_CIPHERLIST
, IDC_CIPHERUP
,
1725 checkbox(&cp
, "Enable non-standard use of single-&DES in SSH 2",
1731 if (panel
== sshauthpanelstart
) {
1732 /* The SSH authentication panel. Accelerators used: [acgoh] m fkiuw */
1734 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1736 bartitle(&cp
, "Options controlling SSH authentication",
1738 beginbox(&cp
, "Authentication methods",
1740 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
1742 checkbox(&cp
, "Attempt \"keyboard-&interactive\" authentication"
1743 " (SSH2)", IDC_AUTHKI
);
1745 beginbox(&cp
, "Authentication parameters",
1747 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1748 checkbox(&cp
, "Allow attempted changes of &username in SSH2",
1750 editbutton(&cp
, "Private &key file for authentication:",
1751 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...",
1757 if (panel
== tunnelspanelstart
) {
1758 /* The Tunnels panel. Accelerators used: [acgoh] deilmrstxp */
1760 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1762 bartitle(&cp
, "Options controlling SSH tunnelling",
1764 beginbox(&cp
, "X11 forwarding", IDC_BOX_TUNNELS1
);
1765 checkbox(&cp
, "&Enable X11 forwarding", IDC_X11_FORWARD
);
1766 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1767 IDC_X11_DISPLAY
, 50, NULL
);
1769 beginbox(&cp
, "Port forwarding", IDC_BOX_TUNNELS2
);
1770 checkbox(&cp
, "Local ports accept connections from o&ther hosts",
1772 checkbox(&cp
, "Remote &ports do the same (SSH v2 only)",
1774 staticbtn(&cp
, "Forwarded ports:", IDC_PFWDSTATIC
,
1775 "&Remove", IDC_PFWDREMOVE
);
1776 fwdsetter(&cp
, IDC_PFWDLIST
,
1777 "Add new forwarded port:", IDC_PFWDSTATIC2
,
1778 "&Source port", IDC_SPORTSTATIC
, IDC_SPORTEDIT
,
1779 "Dest&ination", IDC_DPORTSTATIC
, IDC_DPORTEDIT
,
1780 "A&dd", IDC_PFWDADD
);
1781 bareradioline(&cp
, 2,
1782 "&Local", IDC_PFWDLOCAL
,
1783 "Re&mote", IDC_PFWDREMOTE
, NULL
);
1791 * Helper function to load the session selected in SESSLIST
1792 * if any, as this is done in more than one place in
1793 * GenericMainDlgProc(). 0 => failure.
1795 static int load_selected_session(HWND hwnd
)
1797 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1798 LB_GETCURSEL
, 0, 0);
1804 isdef
= !strcmp(sessions
[n
], "Default Settings");
1805 load_settings(sessions
[n
], !isdef
, &cfg
);
1806 init_dlg_ctrls(hwnd
, TRUE
);
1808 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1810 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1811 /* Restore the selection, which will have been clobbered by
1812 * SESSEDIT handling. */
1813 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
, n
, 0);
1818 * This function is the configuration box.
1820 static int GenericMainDlgProc(HWND hwnd
, UINT msg
,
1821 WPARAM wParam
, LPARAM lParam
, int dlgtype
)
1824 struct treeview_faff tvfaff
;
1827 char filename
[sizeof(cfg
.keyfile
)];
1830 char fontstatic
[256];
1832 struct servent
*service
;
1834 static UINT draglistmsg
= WM_NULL
;
1839 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1841 SetWindowLong(hwnd
, GWL_EXSTYLE
,
1842 GetWindowLong(hwnd
, GWL_EXSTYLE
) | WS_EX_CONTEXTHELP
);
1844 HWND item
= GetDlgItem(hwnd
, IDC_HELPBTN
);
1846 DestroyWindow(item
);
1848 requested_help
= FALSE
;
1849 SendMessage(hwnd
, WM_SETICON
, (WPARAM
) ICON_BIG
,
1850 (LPARAM
) LoadIcon(hinst
, MAKEINTRESOURCE(IDI_CFGICON
)));
1852 * Centre the window.
1854 { /* centre the window */
1857 hw
= GetDesktopWindow();
1858 if (GetWindowRect(hw
, &rs
) && GetWindowRect(hwnd
, &rd
))
1860 (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
) / 2,
1861 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
) / 2,
1862 rd
.right
- rd
.left
, rd
.bottom
- rd
.top
, TRUE
);
1866 * Create the tree view.
1874 r
.right
= r
.left
+ 75;
1876 r
.bottom
= r
.top
+ 10;
1877 MapDialogRect(hwnd
, &r
);
1878 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1879 WS_CHILD
| WS_VISIBLE
,
1881 r
.right
- r
.left
, r
.bottom
- r
.top
,
1882 hwnd
, (HMENU
) IDCX_TVSTATIC
, hinst
,
1884 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1885 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1888 r
.right
= r
.left
+ 75;
1890 r
.bottom
= r
.top
+ 219;
1891 MapDialogRect(hwnd
, &r
);
1892 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1893 WS_CHILD
| WS_VISIBLE
|
1894 WS_TABSTOP
| TVS_HASLINES
|
1895 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
1897 TVS_SHOWSELALWAYS
, r
.left
, r
.top
,
1898 r
.right
- r
.left
, r
.bottom
- r
.top
,
1899 hwnd
, (HMENU
) IDCX_TREEVIEW
, hinst
,
1901 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1902 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1903 tvfaff
.treeview
= treeview
;
1904 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1908 * Set up the tree view contents.
1910 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1911 treeview_insert(&tvfaff
, 1, "Logging");
1912 treeview_insert(&tvfaff
, 0, "Terminal");
1913 treeview_insert(&tvfaff
, 1, "Keyboard");
1914 treeview_insert(&tvfaff
, 1, "Bell");
1915 treeview_insert(&tvfaff
, 1, "Features");
1916 treeview_insert(&tvfaff
, 0, "Window");
1917 treeview_insert(&tvfaff
, 1, "Appearance");
1918 treeview_insert(&tvfaff
, 1, "Behaviour");
1919 treeview_insert(&tvfaff
, 1, "Translation");
1920 treeview_insert(&tvfaff
, 1, "Selection");
1921 treeview_insert(&tvfaff
, 1, "Colours");
1922 treeview_insert(&tvfaff
, 0, "Connection");
1924 treeview_insert(&tvfaff
, 1, "Telnet");
1925 treeview_insert(&tvfaff
, 1, "Rlogin");
1926 if (backends
[3].backend
!= NULL
) {
1927 treeview_insert(&tvfaff
, 1, "SSH");
1928 /* XXX long name is ugly */
1929 /* XXX make it closed by default? */
1930 treeview_insert(&tvfaff
, 2, "Auth");
1931 treeview_insert(&tvfaff
, 2, "Tunnels");
1936 * Put the treeview selection on to the Session panel. This
1937 * should also cause creation of the relevant controls.
1939 TreeView_SelectItem(treeview
, hsession
);
1942 * Set focus into the first available control.
1946 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1948 ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1952 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1953 sesslist_has_focus
= 0;
1957 * Button release should trigger WM_OK if there was a
1958 * previous double click on the session list.
1962 SendMessage(hwnd
, WM_COMMAND
, IDOK
, 0);
1965 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1966 ((LPNMHDR
) lParam
)->code
== TVN_SELCHANGED
) {
1968 TreeView_GetSelection(((LPNMHDR
) lParam
)->hwndFrom
);
1973 SendMessage (hwnd
, WM_SETREDRAW
, FALSE
, 0);
1976 item
.pszText
= buffer
;
1977 item
.cchTextMax
= sizeof(buffer
);
1978 item
.mask
= TVIF_TEXT
;
1979 TreeView_GetItem(((LPNMHDR
) lParam
)->hwndFrom
, &item
);
1980 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1981 HWND item
= GetDlgItem(hwnd
, j
);
1983 DestroyWindow(item
);
1985 if (!strcmp(buffer
, "Session"))
1986 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1987 if (!strcmp(buffer
, "Logging"))
1988 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1989 if (!strcmp(buffer
, "Keyboard"))
1990 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1991 if (!strcmp(buffer
, "Terminal"))
1992 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1993 if (!strcmp(buffer
, "Bell"))
1994 create_controls(hwnd
, dlgtype
, bellpanelstart
);
1995 if (!strcmp(buffer
, "Features"))
1996 create_controls(hwnd
, dlgtype
, featurespanelstart
);
1997 if (!strcmp(buffer
, "Window"))
1998 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1999 if (!strcmp(buffer
, "Appearance"))
2000 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
2001 if (!strcmp(buffer
, "Behaviour"))
2002 create_controls(hwnd
, dlgtype
, behaviourpanelstart
);
2003 if (!strcmp(buffer
, "Tunnels"))
2004 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
2005 if (!strcmp(buffer
, "Connection"))
2006 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
2007 if (!strcmp(buffer
, "Telnet"))
2008 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
2009 if (!strcmp(buffer
, "Rlogin"))
2010 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
2011 if (!strcmp(buffer
, "SSH"))
2012 create_controls(hwnd
, dlgtype
, sshpanelstart
);
2013 if (!strcmp(buffer
, "Auth"))
2014 create_controls(hwnd
, dlgtype
, sshauthpanelstart
);
2015 if (!strcmp(buffer
, "Selection"))
2016 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
2017 if (!strcmp(buffer
, "Colours"))
2018 create_controls(hwnd
, dlgtype
, colourspanelstart
);
2019 if (!strcmp(buffer
, "Translation"))
2020 create_controls(hwnd
, dlgtype
, translationpanelstart
);
2022 init_dlg_ctrls(hwnd
, FALSE
);
2024 SendMessage (hwnd
, WM_SETREDRAW
, TRUE
, 0);
2025 InvalidateRect (hwnd
, NULL
, TRUE
);
2027 SetFocus(((LPNMHDR
) lParam
)->hwndFrom
); /* ensure focus stays */
2033 * Only process WM_COMMAND once the dialog is fully formed.
2035 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1)
2036 switch (LOWORD(wParam
)) {
2038 /* Behaviour of the "Open" button is different if the
2039 * session list has focus, *unless* the user just
2040 * double-clicked... */
2041 if (sesslist_has_focus
&& !readytogo
) {
2042 if (!load_selected_session(hwnd
)) {
2047 /* If at this point we have a valid session, go! */
2049 if (requested_help
) {
2050 WinHelp(hwnd
, help_path
, HELP_QUIT
, 0);
2051 requested_help
= FALSE
;
2058 if (HIWORD(wParam
) == BN_CLICKED
||
2059 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2061 WinHelp(hwnd
, help_path
,
2062 help_has_contents ? HELP_FINDER
: HELP_CONTENTS
,
2064 requested_help
= TRUE
;
2069 if (requested_help
) {
2070 WinHelp(hwnd
, help_path
, HELP_QUIT
, 0);
2071 requested_help
= FALSE
;
2075 case IDC_PROTTELNET
:
2076 case IDC_PROTRLOGIN
:
2079 if (HIWORD(wParam
) == BN_CLICKED
||
2080 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2081 int i
= IsDlgButtonChecked(hwnd
, IDC_PROTSSH
);
2082 int j
= IsDlgButtonChecked(hwnd
, IDC_PROTTELNET
);
2083 int k
= IsDlgButtonChecked(hwnd
, IDC_PROTRLOGIN
);
2085 i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
:
2088 * When switching using the arrow keys, we
2089 * appear to get two of these messages, both
2090 * mentioning the target button in
2091 * LOWORD(wParam), but one of them called while
2092 * the previous button is still checked. This
2093 * causes an unnecessary reset of the port
2094 * number field, which we fix by ensuring here
2095 * that the button selected is indeed the one
2098 if (IsDlgButtonChecked(hwnd
, LOWORD(wParam
)) &&
2099 ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22)
2100 || (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23)
2101 || (cfg
.protocol
== PROT_RLOGIN
2102 && cfg
.port
!= 513))) {
2103 cfg
.port
= i ?
22 : j ?
23 : 513;
2104 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
2109 if (HIWORD(wParam
) == EN_CHANGE
)
2110 GetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
,
2111 sizeof(cfg
.host
) - 1);
2114 if (HIWORD(wParam
) == EN_CHANGE
) {
2115 GetDlgItemText(hwnd
, IDC_PORT
, portname
, 31);
2116 if (isdigit(portname
[0]))
2117 MyGetDlgItemInt(hwnd
, IDC_PORT
, &cfg
.port
);
2119 service
= getservbyname(portname
, NULL
);
2121 cfg
.port
= ntohs(service
->s_port
);
2128 if (HIWORD(wParam
) == EN_CHANGE
) {
2129 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
2131 GetDlgItemText(hwnd
, IDC_SESSEDIT
,
2132 savedsession
, sizeof(savedsession
) - 1);
2133 savedsession
[sizeof(savedsession
) - 1] = '\0';
2137 if (HIWORD(wParam
) == BN_CLICKED
||
2138 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2143 GetDlgItemText(hwnd
, IDC_SESSEDIT
, str
,
2146 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2147 LB_GETCURSEL
, 0, 0);
2152 strcpy(str
, sessions
[n
]);
2154 save_settings(str
, !!strcmp(str
, "Default Settings"),
2156 get_sesslist(FALSE
);
2158 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2160 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
2162 for (i
= 0; i
< nsessions
; i
++)
2163 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2165 (LPARAM
) (sessions
[i
]));
2166 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
2168 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2170 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
2176 if (LOWORD(wParam
) == IDC_SESSLIST
) {
2177 if (HIWORD(wParam
) == LBN_SETFOCUS
)
2178 sesslist_has_focus
= 1;
2179 else if (HIWORD(wParam
) == LBN_KILLFOCUS
)
2180 sesslist_has_focus
= 0;
2182 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
2183 HIWORD(wParam
) != BN_CLICKED
&&
2184 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2185 if (LOWORD(wParam
) == IDC_SESSLIST
&&
2186 HIWORD(wParam
) != LBN_DBLCLK
) break;
2187 /* Load the session selected in SESSLIST. */
2188 if (load_selected_session(hwnd
) &&
2189 LOWORD(wParam
) == IDC_SESSLIST
) {
2191 * A double-click on a saved session should
2192 * actually start the session, not just load it.
2193 * Unless it's Default Settings or some other
2194 * host-less set of saved settings.
2203 if (HIWORD(wParam
) == BN_CLICKED
||
2204 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2205 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2206 LB_GETCURSEL
, 0, 0);
2207 if (n
== LB_ERR
|| n
== 0) {
2211 del_settings(sessions
[n
]);
2212 get_sesslist(FALSE
);
2214 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2216 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
2218 for (i
= 0; i
< nsessions
; i
++)
2219 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2221 (LPARAM
) (sessions
[i
]));
2222 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
2224 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2226 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
2230 if (HIWORD(wParam
) == EN_CHANGE
)
2231 MyGetDlgItemInt(hwnd
, IDC_PINGEDIT
,
2232 &cfg
.ping_interval
);
2235 if (HIWORD(wParam
) == BN_CLICKED
||
2236 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2238 IsDlgButtonChecked(hwnd
, IDC_NODELAY
);
2242 if (HIWORD(wParam
) == BN_CLICKED
||
2243 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2244 cfg
.bksp_is_delete
=
2245 IsDlgButtonChecked(hwnd
, IDC_DEL127
);
2249 if (HIWORD(wParam
) == BN_CLICKED
||
2250 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2252 IsDlgButtonChecked(hwnd
, IDC_HOMERXVT
);
2258 case IDC_FUNCVT100P
:
2260 if (HIWORD(wParam
) == BN_CLICKED
||
2261 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2262 switch (LOWORD(wParam
)) {
2275 case IDC_FUNCVT100P
:
2285 if (HIWORD(wParam
) == BN_CLICKED
||
2286 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2288 IsDlgButtonChecked(hwnd
, IDC_KPAPPLIC
);
2289 cfg
.nethack_keypad
= FALSE
;
2293 if (HIWORD(wParam
) == BN_CLICKED
||
2294 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2295 cfg
.app_keypad
= FALSE
;
2296 cfg
.nethack_keypad
= TRUE
;
2301 if (HIWORD(wParam
) == BN_CLICKED
||
2302 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2304 IsDlgButtonChecked(hwnd
, IDC_CURAPPLIC
);
2307 if (HIWORD(wParam
) == BN_CLICKED
||
2308 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2310 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICC
);
2313 if (HIWORD(wParam
) == BN_CLICKED
||
2314 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2316 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICK
);
2319 if (HIWORD(wParam
) == BN_CLICKED
||
2320 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2321 cfg
.no_remote_resize
=
2322 IsDlgButtonChecked(hwnd
, IDC_NORESIZE
);
2324 case IDC_NOALTSCREEN
:
2325 if (HIWORD(wParam
) == BN_CLICKED
||
2326 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2328 IsDlgButtonChecked(hwnd
, IDC_NOALTSCREEN
);
2330 case IDC_NOWINTITLE
:
2331 if (HIWORD(wParam
) == BN_CLICKED
||
2332 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2333 cfg
.no_remote_wintitle
=
2334 IsDlgButtonChecked(hwnd
, IDC_NOWINTITLE
);
2336 case IDC_NODBACKSPACE
:
2337 if (HIWORD(wParam
) == BN_CLICKED
||
2338 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2340 IsDlgButtonChecked(hwnd
, IDC_NODBACKSPACE
);
2343 if (HIWORD(wParam
) == BN_CLICKED
||
2344 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2345 cfg
.no_remote_charset
=
2346 IsDlgButtonChecked(hwnd
, IDC_NOCHARSET
);
2349 if (HIWORD(wParam
) == BN_CLICKED
||
2350 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2351 cfg
.alt_f4
= IsDlgButtonChecked(hwnd
, IDC_ALTF4
);
2354 if (HIWORD(wParam
) == BN_CLICKED
||
2355 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2357 IsDlgButtonChecked(hwnd
, IDC_ALTSPACE
);
2360 if (HIWORD(wParam
) == BN_CLICKED
||
2361 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2363 IsDlgButtonChecked(hwnd
, IDC_ALTONLY
);
2365 case IDC_ECHOBACKEND
:
2368 if (HIWORD(wParam
) == BN_CLICKED
||
2369 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2370 if (LOWORD(wParam
) == IDC_ECHOBACKEND
)
2371 cfg
.localecho
= LD_BACKEND
;
2372 if (LOWORD(wParam
) == IDC_ECHOYES
)
2373 cfg
.localecho
= LD_YES
;
2374 if (LOWORD(wParam
) == IDC_ECHONO
)
2375 cfg
.localecho
= LD_NO
;
2378 case IDC_EDITBACKEND
:
2381 if (HIWORD(wParam
) == BN_CLICKED
||
2382 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2383 if (LOWORD(wParam
) == IDC_EDITBACKEND
)
2384 cfg
.localedit
= LD_BACKEND
;
2385 if (LOWORD(wParam
) == IDC_EDITYES
)
2386 cfg
.localedit
= LD_YES
;
2387 if (LOWORD(wParam
) == IDC_EDITNO
)
2388 cfg
.localedit
= LD_NO
;
2391 case IDC_ANSWEREDIT
:
2392 if (HIWORD(wParam
) == EN_CHANGE
)
2393 GetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
2394 sizeof(cfg
.answerback
) - 1);
2396 case IDC_ALWAYSONTOP
:
2397 if (HIWORD(wParam
) == BN_CLICKED
||
2398 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2400 IsDlgButtonChecked(hwnd
, IDC_ALWAYSONTOP
);
2402 case IDC_FULLSCREENONALTENTER
:
2403 if (HIWORD(wParam
) == BN_CLICKED
||
2404 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2405 cfg
.fullscreenonaltenter
=
2406 IsDlgButtonChecked(hwnd
, IDC_FULLSCREENONALTENTER
);
2409 if (HIWORD(wParam
) == BN_CLICKED
||
2410 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2412 IsDlgButtonChecked(hwnd
, IDC_SCROLLKEY
);
2414 case IDC_SCROLLDISP
:
2415 if (HIWORD(wParam
) == BN_CLICKED
||
2416 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2417 cfg
.scroll_on_disp
=
2418 IsDlgButtonChecked(hwnd
, IDC_SCROLLDISP
);
2420 case IDC_COMPOSEKEY
:
2421 if (HIWORD(wParam
) == BN_CLICKED
||
2422 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2424 IsDlgButtonChecked(hwnd
, IDC_COMPOSEKEY
);
2426 case IDC_CTRLALTKEYS
:
2427 if (HIWORD(wParam
) == BN_CLICKED
||
2428 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2430 IsDlgButtonChecked(hwnd
, IDC_CTRLALTKEYS
);
2433 if (HIWORD(wParam
) == BN_CLICKED
||
2434 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2435 cfg
.telnet_keyboard
=
2436 IsDlgButtonChecked(hwnd
, IDC_TELNETKEY
);
2439 if (HIWORD(wParam
) == BN_CLICKED
||
2440 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2441 cfg
.telnet_newline
=
2442 IsDlgButtonChecked(hwnd
, IDC_TELNETRET
);
2445 if (HIWORD(wParam
) == BN_CLICKED
||
2446 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2448 IsDlgButtonChecked(hwnd
, IDC_WRAPMODE
);
2451 if (HIWORD(wParam
) == BN_CLICKED
||
2452 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2453 cfg
.dec_om
= IsDlgButtonChecked(hwnd
, IDC_DECOM
);
2456 if (HIWORD(wParam
) == BN_CLICKED
||
2457 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2459 IsDlgButtonChecked(hwnd
, IDC_LFHASCR
);
2462 if (HIWORD(wParam
) == EN_CHANGE
)
2463 MyGetDlgItemInt(hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
2466 if (HIWORD(wParam
) == EN_CHANGE
)
2467 MyGetDlgItemInt(hwnd
, IDC_COLSEDIT
, &cfg
.width
);
2470 if (HIWORD(wParam
) == EN_CHANGE
)
2471 MyGetDlgItemInt(hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
2473 case IDC_CHOOSEFONT
:
2476 lf
.lfHeight
= -MulDiv(cfg
.fontheight
,
2477 GetDeviceCaps(hdc
, LOGPIXELSY
),
2481 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
2482 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
2483 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
2484 lf
.lfCharSet
= cfg
.fontcharset
;
2485 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
2486 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
2487 lf
.lfQuality
= DEFAULT_QUALITY
;
2488 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
2489 strncpy(lf
.lfFaceName
, cfg
.font
,
2490 sizeof(lf
.lfFaceName
) - 1);
2491 lf
.lfFaceName
[sizeof(lf
.lfFaceName
) - 1] = '\0';
2493 cf
.lStructSize
= sizeof(cf
);
2494 cf
.hwndOwner
= hwnd
;
2496 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
2497 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
2499 if (ChooseFont(&cf
)) {
2500 strncpy(cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
) - 1);
2501 cfg
.font
[sizeof(cfg
.font
) - 1] = '\0';
2502 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
2503 cfg
.fontcharset
= lf
.lfCharSet
;
2504 cfg
.fontheight
= cf
.iPointSize
/ 10;
2505 fmtfont(fontstatic
);
2506 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
2509 case IDC_BELL_DISABLED
:
2510 case IDC_BELL_DEFAULT
:
2511 case IDC_BELL_WAVEFILE
:
2512 case IDC_BELL_VISUAL
:
2513 if (HIWORD(wParam
) == BN_CLICKED
||
2514 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2515 if (LOWORD(wParam
) == IDC_BELL_DISABLED
)
2516 cfg
.beep
= BELL_DISABLED
;
2517 if (LOWORD(wParam
) == IDC_BELL_DEFAULT
)
2518 cfg
.beep
= BELL_DEFAULT
;
2519 if (LOWORD(wParam
) == IDC_BELL_WAVEFILE
)
2520 cfg
.beep
= BELL_WAVEFILE
;
2521 if (LOWORD(wParam
) == IDC_BELL_VISUAL
)
2522 cfg
.beep
= BELL_VISUAL
;
2525 case IDC_B_IND_DISABLED
:
2526 case IDC_B_IND_FLASH
:
2527 case IDC_B_IND_STEADY
:
2528 if (HIWORD(wParam
) == BN_CLICKED
||
2529 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2530 if (LOWORD(wParam
) == IDC_B_IND_DISABLED
)
2531 cfg
.beep_ind
= B_IND_DISABLED
;
2532 if (LOWORD(wParam
) == IDC_B_IND_FLASH
)
2533 cfg
.beep_ind
= B_IND_FLASH
;
2534 if (LOWORD(wParam
) == IDC_B_IND_STEADY
)
2535 cfg
.beep_ind
= B_IND_STEADY
;
2538 case IDC_BELL_WAVEBROWSE
:
2539 memset(&of
, 0, sizeof(of
));
2540 #ifdef OPENFILENAME_SIZE_VERSION_400
2541 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2543 of
.lStructSize
= sizeof(of
);
2545 of
.hwndOwner
= hwnd
;
2546 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2547 of
.lpstrCustomFilter
= NULL
;
2548 of
.nFilterIndex
= 1;
2549 of
.lpstrFile
= filename
;
2550 strcpy(filename
, cfg
.bell_wavefile
);
2551 of
.nMaxFile
= sizeof(filename
);
2552 of
.lpstrFileTitle
= NULL
;
2553 of
.lpstrInitialDir
= NULL
;
2554 of
.lpstrTitle
= "Select Bell Sound File";
2556 if (GetOpenFileName(&of
)) {
2557 strcpy(cfg
.bell_wavefile
, filename
);
2558 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2562 case IDC_BELL_WAVEEDIT
:
2563 if (HIWORD(wParam
) == EN_CHANGE
)
2564 GetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2566 sizeof(cfg
.bell_wavefile
) - 1);
2569 if (HIWORD(wParam
) == BN_CLICKED
||
2570 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2572 IsDlgButtonChecked(hwnd
, IDC_BELLOVL
);
2575 if (HIWORD(wParam
) == EN_CHANGE
)
2576 MyGetDlgItemInt(hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
2579 if (HIWORD(wParam
) == EN_CHANGE
)
2580 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
,
2584 if (HIWORD(wParam
) == EN_CHANGE
)
2585 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
,
2589 if (HIWORD(wParam
) == BN_CLICKED
||
2590 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2592 IsDlgButtonChecked(hwnd
, IDC_BLINKTEXT
);
2595 if (HIWORD(wParam
) == BN_CLICKED
||
2596 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2597 cfg
.bce
= IsDlgButtonChecked(hwnd
, IDC_BCE
);
2600 if (HIWORD(wParam
) == BN_CLICKED
||
2601 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2602 cfg
.win_name_always
=
2603 IsDlgButtonChecked(hwnd
, IDC_WINNAME
);
2606 if (HIWORD(wParam
) == BN_CLICKED
||
2607 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2609 IsDlgButtonChecked(hwnd
, IDC_HIDEMOUSE
);
2611 case IDC_SUNKENEDGE
:
2612 if (HIWORD(wParam
) == BN_CLICKED
||
2613 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2615 IsDlgButtonChecked(hwnd
, IDC_SUNKENEDGE
);
2618 if (HIWORD(wParam
) == EN_CHANGE
)
2619 MyGetDlgItemInt(hwnd
, IDC_WINBEDIT
,
2620 &cfg
.window_border
);
2621 if (cfg
.window_border
> 32)
2622 cfg
.window_border
= 32;
2625 if (HIWORD(wParam
) == BN_CLICKED
||
2626 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2627 cfg
.cursor_type
= 0;
2630 if (HIWORD(wParam
) == BN_CLICKED
||
2631 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2632 cfg
.cursor_type
= 1;
2635 if (HIWORD(wParam
) == BN_CLICKED
||
2636 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2637 cfg
.cursor_type
= 2;
2640 if (HIWORD(wParam
) == BN_CLICKED
||
2641 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2643 IsDlgButtonChecked(hwnd
, IDC_BLINKCUR
);
2646 if (HIWORD(wParam
) == BN_CLICKED
||
2647 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2649 IsDlgButtonChecked(hwnd
, IDC_SCROLLBAR
);
2651 case IDC_SCROLLBARFULLSCREEN
:
2652 if (HIWORD(wParam
) == BN_CLICKED
||
2653 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2654 cfg
.scrollbar_in_fullscreen
=
2655 IsDlgButtonChecked(hwnd
, IDC_SCROLLBARFULLSCREEN
);
2657 case IDC_RESIZETERM
:
2658 case IDC_RESIZEFONT
:
2659 case IDC_RESIZENONE
:
2660 case IDC_RESIZEEITHER
:
2661 if (HIWORD(wParam
) == BN_CLICKED
||
2662 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2664 IsDlgButtonChecked(hwnd
,
2665 IDC_RESIZETERM
) ? RESIZE_TERM
:
2666 IsDlgButtonChecked(hwnd
,
2667 IDC_RESIZEFONT
) ? RESIZE_FONT
:
2668 IsDlgButtonChecked(hwnd
,
2669 IDC_RESIZEEITHER
) ? RESIZE_EITHER
:
2674 if (HIWORD(wParam
) == EN_CHANGE
)
2675 GetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
2676 sizeof(cfg
.wintitle
) - 1);
2681 if (HIWORD(wParam
) == BN_CLICKED
||
2682 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2684 IsDlgButtonChecked(hwnd
,
2685 IDC_COEALWAYS
) ? COE_ALWAYS
:
2686 IsDlgButtonChecked(hwnd
,
2687 IDC_COENEVER
) ? COE_NEVER
:
2692 if (HIWORD(wParam
) == BN_CLICKED
||
2693 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2695 IsDlgButtonChecked(hwnd
, IDC_CLOSEWARN
);
2698 if (HIWORD(wParam
) == EN_CHANGE
)
2699 GetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
,
2700 sizeof(cfg
.termtype
) - 1);
2703 if (HIWORD(wParam
) == EN_CHANGE
)
2704 GetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
2705 sizeof(cfg
.logfilename
) - 1);
2708 memset(&of
, 0, sizeof(of
));
2709 #ifdef OPENFILENAME_SIZE_VERSION_400
2710 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2712 of
.lStructSize
= sizeof(of
);
2714 of
.hwndOwner
= hwnd
;
2715 of
.lpstrFilter
= "All Files\0*\0\0\0";
2716 of
.lpstrCustomFilter
= NULL
;
2717 of
.nFilterIndex
= 1;
2718 of
.lpstrFile
= filename
;
2719 strcpy(filename
, cfg
.logfilename
);
2720 of
.nMaxFile
= sizeof(filename
);
2721 of
.lpstrFileTitle
= NULL
;
2722 of
.lpstrInitialDir
= NULL
;
2723 of
.lpstrTitle
= "Select session log file";
2725 if (GetSaveFileName(&of
)) {
2726 strcpy(cfg
.logfilename
, filename
);
2727 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
2731 case IDC_LSTATASCII
:
2733 case IDC_LSTATPACKET
:
2734 if (HIWORD(wParam
) == BN_CLICKED
||
2735 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2736 if (IsDlgButtonChecked(hwnd
, IDC_LSTATOFF
))
2737 cfg
.logtype
= LGTYP_NONE
;
2738 if (IsDlgButtonChecked(hwnd
, IDC_LSTATASCII
))
2739 cfg
.logtype
= LGTYP_ASCII
;
2740 if (IsDlgButtonChecked(hwnd
, IDC_LSTATRAW
))
2741 cfg
.logtype
= LGTYP_DEBUG
;
2742 if (IsDlgButtonChecked(hwnd
, IDC_LSTATPACKET
))
2743 cfg
.logtype
= LGTYP_PACKETS
;
2749 if (HIWORD(wParam
) == BN_CLICKED
||
2750 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2751 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXASK
))
2752 cfg
.logxfovr
= LGXF_ASK
;
2753 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXAPN
))
2754 cfg
.logxfovr
= LGXF_APN
;
2755 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXOVR
))
2756 cfg
.logxfovr
= LGXF_OVR
;
2761 if (HIWORD(wParam
) == EN_CHANGE
)
2762 GetDlgItemText(hwnd
, LOWORD(wParam
), cfg
.termspeed
,
2763 sizeof(cfg
.termspeed
) - 1);
2766 if (HIWORD(wParam
) == EN_CHANGE
)
2767 GetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
,
2768 sizeof(cfg
.username
) - 1);
2770 case IDC_RLLUSEREDIT
:
2771 if (HIWORD(wParam
) == EN_CHANGE
)
2772 GetDlgItemText(hwnd
, IDC_RLLUSEREDIT
,
2774 sizeof(cfg
.localusername
) - 1);
2778 cfg
.rfc_environ
= IsDlgButtonChecked(hwnd
, IDC_EMRFC
);
2782 cfg
.passive_telnet
=
2783 IsDlgButtonChecked(hwnd
, IDC_TPASSIVE
);
2786 if (HIWORD(wParam
) == BN_CLICKED
||
2787 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2788 char str
[sizeof(cfg
.environmt
)];
2790 GetDlgItemText(hwnd
, IDC_VAREDIT
, str
,
2796 p
= str
+ strlen(str
);
2798 GetDlgItemText(hwnd
, IDC_VALEDIT
, p
,
2799 sizeof(str
) - 1 - (p
- str
));
2810 if ((p
- cfg
.environmt
) + strlen(str
) + 2 <
2811 sizeof(cfg
.environmt
)) {
2813 p
[strlen(str
) + 1] = '\0';
2814 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
2816 SetDlgItemText(hwnd
, IDC_VAREDIT
, "");
2817 SetDlgItemText(hwnd
, IDC_VALEDIT
, "");
2819 MessageBox(hwnd
, "Environment too big",
2820 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2825 if (HIWORD(wParam
) != BN_CLICKED
&&
2826 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2828 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0,
2835 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
2862 if (HIWORD(wParam
) == BN_CLICKED
||
2863 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2864 cfg
.nopty
= IsDlgButtonChecked(hwnd
, IDC_NOPTY
);
2867 if (HIWORD(wParam
) == BN_CLICKED
||
2868 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2870 IsDlgButtonChecked(hwnd
, IDC_COMPRESS
);
2873 if (HIWORD(wParam
) == BN_CLICKED
||
2874 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2876 IsDlgButtonChecked(hwnd
, IDC_BUGGYMAC
);
2879 if (HIWORD(wParam
) == BN_CLICKED
||
2880 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2882 IsDlgButtonChecked(hwnd
, IDC_SSH2DES
);
2885 if (HIWORD(wParam
) == BN_CLICKED
||
2886 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2888 IsDlgButtonChecked(hwnd
, IDC_AGENTFWD
);
2890 case IDC_CHANGEUSER
:
2891 if (HIWORD(wParam
) == BN_CLICKED
||
2892 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2893 cfg
.change_username
=
2894 IsDlgButtonChecked(hwnd
, IDC_CHANGEUSER
);
2896 case IDC_CIPHERLIST
:
2899 handle_prefslist(&cipherlist
,
2900 cfg
.ssh_cipherlist
, CIPHER_MAX
,
2901 0, hwnd
, wParam
, lParam
);
2905 if (HIWORD(wParam
) == BN_CLICKED
||
2906 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2907 if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT1
))
2909 else if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT2
))
2914 if (HIWORD(wParam
) == BN_CLICKED
||
2915 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2917 IsDlgButtonChecked(hwnd
, IDC_AUTHTIS
);
2920 if (HIWORD(wParam
) == BN_CLICKED
||
2921 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2923 IsDlgButtonChecked(hwnd
, IDC_AUTHKI
);
2926 if (HIWORD(wParam
) == EN_CHANGE
)
2927 GetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
2928 sizeof(cfg
.keyfile
) - 1);
2931 if (HIWORD(wParam
) == EN_CHANGE
)
2932 GetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
2933 sizeof(cfg
.remote_cmd
) - 1);
2936 memset(&of
, 0, sizeof(of
));
2937 #ifdef OPENFILENAME_SIZE_VERSION_400
2938 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2940 of
.lStructSize
= sizeof(of
);
2942 of
.hwndOwner
= hwnd
;
2943 of
.lpstrFilter
= "All Files\0*\0\0\0";
2944 of
.lpstrCustomFilter
= NULL
;
2945 of
.nFilterIndex
= 1;
2946 of
.lpstrFile
= filename
;
2947 strcpy(filename
, cfg
.keyfile
);
2948 of
.nMaxFile
= sizeof(filename
);
2949 of
.lpstrFileTitle
= NULL
;
2950 of
.lpstrInitialDir
= NULL
;
2951 of
.lpstrTitle
= "Select Private Key File";
2953 if (GetOpenFileName(&of
)) {
2954 strcpy(cfg
.keyfile
, filename
);
2955 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
2959 cfg
.rawcnp
= IsDlgButtonChecked(hwnd
, IDC_RAWCNP
);
2962 cfg
.rtf_paste
= IsDlgButtonChecked(hwnd
, IDC_RTFPASTE
);
2966 cfg
.mouse_is_xterm
= IsDlgButtonChecked(hwnd
, IDC_MBXTERM
);
2968 case IDC_SELTYPELEX
:
2969 case IDC_SELTYPERECT
:
2970 cfg
.rect_select
= IsDlgButtonChecked(hwnd
, IDC_SELTYPERECT
);
2972 case IDC_MOUSEOVERRIDE
:
2973 cfg
.mouse_override
= IsDlgButtonChecked(hwnd
, IDC_MOUSEOVERRIDE
);
2979 int n
= GetDlgItemInt(hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
2984 for (i
= 0; i
< 128; i
++)
2985 if (SendDlgItemMessage
2986 (hwnd
, IDC_CCLIST
, LB_GETSEL
, i
, 0)) {
2988 cfg
.wordness
[i
] = n
;
2989 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2990 LB_DELETESTRING
, i
, 0);
2991 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
2992 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ',
2994 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
3001 case IDC_BOLDCOLOUR
:
3002 if (HIWORD(wParam
) == BN_CLICKED
||
3003 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3006 IsDlgButtonChecked(hwnd
, IDC_BOLDCOLOUR
);
3007 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
3010 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3012 if (n
!= 12 + 10 * cfg
.bold_colour
) {
3013 for (i
= n
; i
-- > 0;)
3014 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3015 LB_DELETESTRING
, i
, 0);
3016 for (i
= 0; i
< 22; i
++)
3017 if (cfg
.bold_colour
|| permcolour
[i
])
3018 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3020 (LPARAM
) colours
[i
]);
3022 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
3024 InvalidateRect(GetDlgItem(hwnd
, IDC_COLOURLIST
), NULL
,
3029 if (HIWORD(wParam
) == BN_CLICKED
||
3030 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3032 IsDlgButtonChecked(hwnd
, IDC_PALETTE
);
3034 case IDC_COLOURLIST
:
3035 if (HIWORD(wParam
) == LBN_DBLCLK
||
3036 HIWORD(wParam
) == LBN_SELCHANGE
) {
3038 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3041 if (!cfg
.bold_colour
)
3042 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
3043 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
3045 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
3047 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
3052 if (HIWORD(wParam
) == BN_CLICKED
||
3053 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3054 static CHOOSECOLOR cc
;
3055 static DWORD custom
[16] = { 0 }; /* zero initialisers */
3057 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
3060 if (!cfg
.bold_colour
)
3061 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
3062 cc
.lStructSize
= sizeof(cc
);
3063 cc
.hwndOwner
= hwnd
;
3064 cc
.hInstance
= (HWND
) hinst
;
3065 cc
.lpCustColors
= custom
;
3067 RGB(cfg
.colours
[i
][0], cfg
.colours
[i
][1],
3069 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
3070 if (ChooseColor(&cc
)) {
3072 (unsigned char) (cc
.rgbResult
& 0xFF);
3074 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
3076 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
3077 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
3079 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
3081 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
3087 if (HIWORD(wParam
) == CBN_SELCHANGE
) {
3088 int index
= SendDlgItemMessage(hwnd
, IDC_CODEPAGE
,
3089 CB_GETCURSEL
, 0, 0);
3090 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_GETLBTEXT
,
3091 index
, (LPARAM
)cfg
.line_codepage
);
3092 } else if (HIWORD(wParam
) == CBN_EDITCHANGE
) {
3093 GetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
,
3094 sizeof(cfg
.line_codepage
) - 1);
3095 } else if (HIWORD(wParam
) == CBN_KILLFOCUS
) {
3096 strcpy(cfg
.line_codepage
,
3097 cp_name(decode_codepage(cfg
.line_codepage
)));
3098 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
3101 case IDC_CAPSLOCKCYR
:
3102 if (HIWORD(wParam
) == BN_CLICKED
||
3103 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3104 cfg
.xlat_capslockcyr
=
3105 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
3108 case IDC_VTXWINDOWS
:
3114 (IsDlgButtonChecked(hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
3115 : IsDlgButtonChecked(hwnd
,
3116 IDC_VTOEMANSI
) ? VT_OEMANSI
:
3117 IsDlgButtonChecked(hwnd
,
3118 IDC_VTOEMONLY
) ? VT_OEMONLY
:
3119 IsDlgButtonChecked(hwnd
,
3120 IDC_VTUNICODE
) ? VT_UNICODE
:
3123 case IDC_X11_FORWARD
:
3124 if (HIWORD(wParam
) == BN_CLICKED
||
3125 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3127 IsDlgButtonChecked(hwnd
, IDC_X11_FORWARD
);
3130 if (HIWORD(wParam
) == BN_CLICKED
||
3131 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3132 cfg
.lport_acceptall
=
3133 IsDlgButtonChecked(hwnd
, IDC_LPORT_ALL
);
3136 if (HIWORD(wParam
) == BN_CLICKED
||
3137 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3138 cfg
.rport_acceptall
=
3139 IsDlgButtonChecked(hwnd
, IDC_RPORT_ALL
);
3141 case IDC_X11_DISPLAY
:
3142 if (HIWORD(wParam
) == EN_CHANGE
)
3143 GetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
3144 sizeof(cfg
.x11_display
) - 1);
3147 if (HIWORD(wParam
) == BN_CLICKED
||
3148 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3149 char str
[sizeof(cfg
.portfwd
)];
3151 if (IsDlgButtonChecked(hwnd
, IDC_PFWDLOCAL
))
3155 GetDlgItemText(hwnd
, IDC_SPORTEDIT
, str
+1,
3159 "You need to specify a source port number",
3160 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3163 p
= str
+ strlen(str
);
3165 GetDlgItemText(hwnd
, IDC_DPORTEDIT
, p
,
3166 sizeof(str
) - 1 - (p
- str
));
3167 if (!*p
|| !strchr(p
, ':')) {
3169 "You need to specify a destination address\n"
3170 "in the form \"host.name:port\"",
3171 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3180 if ((p
- cfg
.portfwd
) + strlen(str
) + 2 <
3181 sizeof(cfg
.portfwd
)) {
3183 p
[strlen(str
) + 1] = '\0';
3184 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
,
3186 SetDlgItemText(hwnd
, IDC_SPORTEDIT
, "");
3187 SetDlgItemText(hwnd
, IDC_DPORTEDIT
, "");
3189 MessageBox(hwnd
, "Too many forwardings",
3190 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3194 case IDC_PFWDREMOVE
:
3195 if (HIWORD(wParam
) != BN_CLICKED
&&
3196 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
3197 i
= SendDlgItemMessage(hwnd
, IDC_PFWDLIST
,
3198 LB_GETCURSEL
, 0, 0);
3204 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_DELETESTRING
,
3234 int id
= ((LPHELPINFO
)lParam
)->iCtrlId
;
3235 char *cmd
= help_context_cmd(id
);
3237 WinHelp(hwnd
, help_path
, HELP_COMMAND
, (DWORD
)cmd
);
3238 requested_help
= TRUE
;
3245 if (requested_help
) {
3246 WinHelp(hwnd
, help_path
, HELP_QUIT
, 0);
3247 requested_help
= FALSE
;
3252 /* Grrr Explorer will maximize Dialogs! */
3254 if (wParam
== SIZE_MAXIMIZED
)
3260 * Handle application-defined messages eg. DragListBox
3262 /* First find out what the number is (once). */
3263 if (draglistmsg
== WM_NULL
)
3264 draglistmsg
= RegisterWindowMessage (DRAGLISTMSGSTRING
);
3266 if (msg
== draglistmsg
) {
3267 /* Only process once dialog is fully formed. */
3268 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
3269 case IDC_CIPHERLIST
:
3270 return handle_prefslist(&cipherlist
,
3271 cfg
.ssh_cipherlist
, CIPHER_MAX
,
3272 1, hwnd
, wParam
, lParam
);
3281 static int CALLBACK
MainDlgProc(HWND hwnd
, UINT msg
,
3282 WPARAM wParam
, LPARAM lParam
)
3284 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
3286 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
3287 EnableWindow(hwnd
, 0);
3288 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
3289 EnableWindow(hwnd
, 1);
3290 SetActiveWindow(hwnd
);
3292 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 0);
3295 static int CALLBACK
ReconfDlgProc(HWND hwnd
, UINT msg
,
3296 WPARAM wParam
, LPARAM lParam
)
3298 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 1);
3301 void defuse_showwindow(void)
3304 * Work around the fact that the app's first call to ShowWindow
3305 * will ignore the default in favour of the shell-provided
3310 hwnd
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
3312 ShowWindow(hwnd
, SW_HIDE
);
3313 SetActiveWindow(hwnd
);
3314 DestroyWindow(hwnd
);
3323 savedsession
[0] = '\0';
3325 DialogBox(hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
3326 get_sesslist(FALSE
);
3331 int do_reconfig(HWND hwnd
)
3336 backup_cfg
= cfg
; /* structure copy */
3338 DialogBox(hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
3340 cfg
= backup_cfg
; /* structure copy */
3345 void logevent(char *string
)
3350 if (nevents
>= negsize
) {
3352 events
= srealloc(events
, negsize
* sizeof(*events
));
3356 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t",
3359 events
[nevents
] = smalloc(strlen(timebuf
) + strlen(string
) + 1);
3360 strcpy(events
[nevents
], timebuf
);
3361 strcat(events
[nevents
], string
);
3364 SendDlgItemMessage(logbox
, IDN_LIST
, LB_ADDSTRING
,
3365 0, (LPARAM
) events
[nevents
]);
3366 count
= SendDlgItemMessage(logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
3367 SendDlgItemMessage(logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
- 1, 0);
3372 void showeventlog(HWND hwnd
)
3375 logbox
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
3377 ShowWindow(logbox
, SW_SHOWNORMAL
);
3379 SetActiveWindow(logbox
);
3382 void showabout(HWND hwnd
)
3384 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
3387 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
3388 char *keystr
, char *fingerprint
)
3392 static const char absentmsg
[] =
3393 "The server's host key is not cached in the registry. You\n"
3394 "have no guarantee that the server is the computer you\n"
3396 "The server's key fingerprint is:\n"
3398 "If you trust this host, hit Yes to add the key to\n"
3399 "PuTTY's cache and carry on connecting.\n"
3400 "If you want to carry on connecting just once, without\n"
3401 "adding the key to the cache, hit No.\n"
3402 "If you do not trust this host, hit Cancel to abandon the\n"
3405 static const char wrongmsg
[] =
3406 "WARNING - POTENTIAL SECURITY BREACH!\n"
3408 "The server's host key does not match the one PuTTY has\n"
3409 "cached in the registry. This means that either the\n"
3410 "server administrator has changed the host key, or you\n"
3411 "have actually connected to another computer pretending\n"
3412 "to be the server.\n"
3413 "The new key fingerprint is:\n"
3415 "If you were expecting this change and trust the new key,\n"
3416 "hit Yes to update PuTTY's cache and continue connecting.\n"
3417 "If you want to carry on connecting but without updating\n"
3418 "the cache, hit No.\n"
3419 "If you want to abandon the connection completely, hit\n"
3420 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3422 static const char mbtitle
[] = "PuTTY Security Alert";
3425 /* sensible fingerprint max size */
3426 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
3427 sizeof(absentmsg
) : sizeof(wrongmsg
))];
3430 * Verify the key against the registry.
3432 ret
= verify_host_key(host
, port
, keytype
, keystr
);
3434 if (ret
== 0) /* success - key matched OK */
3436 if (ret
== 2) { /* key was different */
3438 sprintf(message
, wrongmsg
, fingerprint
);
3439 mbret
= MessageBox(NULL
, message
, mbtitle
,
3440 MB_ICONWARNING
| MB_YESNOCANCEL
);
3442 store_host_key(host
, port
, keytype
, keystr
);
3443 if (mbret
== IDCANCEL
)
3446 if (ret
== 1) { /* key was absent */
3448 sprintf(message
, absentmsg
, fingerprint
);
3449 mbret
= MessageBox(NULL
, message
, mbtitle
,
3450 MB_ICONWARNING
| MB_YESNOCANCEL
);
3452 store_host_key(host
, port
, keytype
, keystr
);
3453 if (mbret
== IDCANCEL
)
3459 * Ask whether the selected cipher is acceptable (since it was
3460 * below the configured 'warn' threshold).
3461 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3463 void askcipher(char *ciphername
, int cs
)
3465 static const char mbtitle
[] = "PuTTY Security Alert";
3466 static const char msg
[] =
3467 "The first %.35scipher supported by the server\n"
3468 "is %.64s, which is below the configured\n"
3469 "warning threshold.\n"
3470 "Do you want to continue with this connection?\n";
3471 /* guessed cipher name + type max length */
3472 char message
[100 + sizeof(msg
)];
3475 sprintf(message
, msg
,
3477 (cs
== 1) ?
"client-to-server " :
3478 "server-to-client ",
3480 mbret
= MessageBox(NULL
, message
, mbtitle
,
3481 MB_ICONWARNING
| MB_YESNO
);
3489 * Ask whether to wipe a session log file before writing to it.
3490 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3492 int askappend(char *filename
)
3494 static const char mbtitle
[] = "PuTTY Log to File";
3495 static const char msgtemplate
[] =
3496 "The session log file \"%.*s\" already exists.\n"
3497 "You can overwrite it with a new session log,\n"
3498 "append your session log to the end of it,\n"
3499 "or disable session logging for this session.\n"
3500 "Hit Yes to wipe the file, No to append to it,\n"
3501 "or Cancel to disable logging.";
3502 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
3504 if (cfg
.logxfovr
!= LGXF_ASK
) {
3505 return ((cfg
.logxfovr
== LGXF_OVR
) ?
2 : 1);
3507 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
3509 mbret
= MessageBox(NULL
, message
, mbtitle
,
3510 MB_ICONQUESTION
| MB_YESNOCANCEL
);
3513 else if (mbret
== IDNO
)
3520 * Warn about the obsolescent key file format.
3522 void old_keyfile_warning(void)
3524 static const char mbtitle
[] = "PuTTY Key File Warning";
3525 static const char message
[] =
3526 "You are loading an SSH 2 private key which has an\n"
3527 "old version of the file format. This means your key\n"
3528 "file is not fully tamperproof. Future versions of\n"
3529 "PuTTY may stop supporting this private key format,\n"
3530 "so we recommend you convert your key to the new\n"
3533 "You can perform this conversion by loading the key\n"
3534 "into PuTTYgen and then saving it again.";
3536 MessageBox(NULL
, message
, mbtitle
, MB_OK
);