15 static char **events
= NULL
;
16 static int nevents
= 0, negsize
= 0;
19 static int sesslist_has_focus
;
20 static int requested_help
;
22 static struct prefslist cipherlist
;
24 void force_normal(HWND hwnd
)
26 static int recurse
= 0;
34 wp
.length
= sizeof(wp
);
35 if (GetWindowPlacement(hwnd
, &wp
) && wp
.showCmd
== SW_SHOWMAXIMIZED
) {
36 wp
.showCmd
= SW_SHOWNORMAL
;
37 SetWindowPlacement(hwnd
, &wp
);
42 static void MyGetDlgItemInt(HWND hwnd
, int id
, int *result
)
46 n
= GetDlgItemInt(hwnd
, id
, &ok
, FALSE
);
51 static void MyGetDlgItemFlt(HWND hwnd
, int id
, int *result
, int scale
)
55 ok
= GetDlgItemText(hwnd
, id
, text
, sizeof(text
) - 1);
57 *result
= (int) (scale
* atof(text
));
60 static void MySetDlgItemFlt(HWND hwnd
, int id
, double value
)
63 sprintf(text
, "%g", value
);
64 SetDlgItemText(hwnd
, id
, text
);
67 static int CALLBACK
LogProc(HWND hwnd
, UINT msg
,
68 WPARAM wParam
, LPARAM lParam
)
75 static int tabs
[4] = { 78, 108 };
76 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETTABSTOPS
, 2,
79 for (i
= 0; i
< nevents
; i
++)
80 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_ADDSTRING
,
81 0, (LPARAM
) events
[i
]);
84 switch (LOWORD(wParam
)) {
88 SetActiveWindow(GetParent(hwnd
));
92 if (HIWORD(wParam
) == BN_CLICKED
||
93 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
96 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
97 LB_GETSELCOUNT
, 0, 0);
98 if (selcount
== 0) { /* don't even try to copy zero items */
103 selitems
= smalloc(selcount
* sizeof(int));
105 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
112 static unsigned char sel_nl
[] = SEL_NL
;
114 if (count
== 0) { /* can't copy zero stuff */
120 for (i
= 0; i
< count
; i
++)
122 strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
124 clipdata
= smalloc(size
);
127 for (i
= 0; i
< count
; i
++) {
128 char *q
= events
[selitems
[i
]];
129 int qlen
= strlen(q
);
132 memcpy(p
, sel_nl
, sizeof(sel_nl
));
135 write_aclip(clipdata
, size
, TRUE
);
140 for (i
= 0; i
< nevents
; i
++)
141 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
150 SetActiveWindow(GetParent(hwnd
));
157 static int CALLBACK
LicenceProc(HWND hwnd
, UINT msg
,
158 WPARAM wParam
, LPARAM lParam
)
164 switch (LOWORD(wParam
)) {
177 static int CALLBACK
AboutProc(HWND hwnd
, UINT msg
,
178 WPARAM wParam
, LPARAM lParam
)
182 SetDlgItemText(hwnd
, IDA_VERSION
, ver
);
185 switch (LOWORD(wParam
)) {
188 EndDialog(hwnd
, TRUE
);
191 EnableWindow(hwnd
, 0);
192 DialogBox(hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
194 EnableWindow(hwnd
, 1);
195 SetActiveWindow(hwnd
);
199 /* Load web browser */
200 ShellExecute(hwnd
, "open",
201 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
202 0, 0, SW_SHOWDEFAULT
);
207 EndDialog(hwnd
, TRUE
);
214 * Null dialog procedure.
216 static int CALLBACK
NullDlgProc(HWND hwnd
, UINT msg
,
217 WPARAM wParam
, LPARAM lParam
)
222 static char savedsession
[2048];
225 IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
364 IDC_SCROLLBARFULLSCREEN
,
379 IDC_FULLSCREENONALTENTER
,
382 appearancepanelstart
,
383 IDC_TITLE_APPEARANCE
,
405 connectionpanelstart
,
406 IDC_TITLE_CONNECTION
,
524 translationpanelstart
,
525 IDC_TITLE_TRANSLATION
,
526 IDC_BOX_TRANSLATION1
,
527 IDC_BOX_TRANSLATION2
,
528 IDC_BOX_TRANSLATION3
,
565 static const char *const colours
[] = {
566 "Default Foreground", "Default Bold Foreground",
567 "Default Background", "Default Bold Background",
568 "Cursor Text", "Cursor Colour",
569 "ANSI Black", "ANSI Black Bold",
570 "ANSI Red", "ANSI Red Bold",
571 "ANSI Green", "ANSI Green Bold",
572 "ANSI Yellow", "ANSI Yellow Bold",
573 "ANSI Blue", "ANSI Blue Bold",
574 "ANSI Magenta", "ANSI Magenta Bold",
575 "ANSI Cyan", "ANSI Cyan Bold",
576 "ANSI White", "ANSI White Bold"
578 static const int permcolour
[] = {
579 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
580 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
581 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
584 static void fmtfont(char *buf
)
586 sprintf(buf
, "Font: %s, ", cfg
.font
);
588 strcat(buf
, "bold, ");
589 if (cfg
.fontheight
== 0)
590 strcat(buf
, "default height");
592 sprintf(buf
+ strlen(buf
), "%d-point",
593 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
596 char *help_context_cmd(int id
)
608 return "JI(`',`session.hostname')";
615 return "JI(`',`session.saved')";
620 return "JI(`',`session.coe')";
621 case IDC_LSTATSTATIC
:
625 case IDC_LSTATPACKET
:
626 return "JI(`',`logging.main')";
631 return "JI(`',`logging.filename')";
636 return "JI(`',`logging.exists')";
641 return "JI(`',`keyboard.backspace')";
645 return "JI(`',`keyboard.homeend')";
653 return "JI(`',`keyboard.funkeys')";
658 return "JI(`',`keyboard.appkeypad')";
663 return "JI(`',`keyboard.appcursor')";
665 return "JI(`',`keyboard.nethack')";
667 return "JI(`',`keyboard.compose')";
668 case IDC_CTRLALTKEYS
:
669 return "JI(`',`keyboard.ctrlalt')";
672 return "JI(`',`terminal.autowrap')";
674 return "JI(`',`terminal.decom')";
676 return "JI(`',`terminal.lfhascr')";
678 return "JI(`',`terminal.bce')";
680 return "JI(`',`terminal.blink')";
683 return "JI(`',`terminal.answerback')";
685 case IDC_ECHOBACKEND
:
688 return "JI(`',`terminal.localecho')";
690 case IDC_EDITBACKEND
:
693 return "JI(`',`terminal.localedit')";
696 case IDC_BELL_DISABLED
:
697 case IDC_BELL_DEFAULT
:
698 case IDC_BELL_WAVEFILE
:
699 case IDC_BELL_VISUAL
:
700 case IDC_BELL_WAVESTATIC
:
701 case IDC_BELL_WAVEEDIT
:
702 case IDC_BELL_WAVEBROWSE
:
703 return "JI(`',`bell.style')";
704 case IDC_B_IND_STATIC
:
705 case IDC_B_IND_DISABLED
:
706 case IDC_B_IND_FLASH
:
707 case IDC_B_IND_STEADY
:
708 return "JI(`',`bell.taskbar')";
710 case IDC_BELLOVLNSTATIC
:
712 case IDC_BELLOVLTSTATIC
:
714 case IDC_BELLOVLEXPLAIN
:
715 case IDC_BELLOVLSSTATIC
:
717 return "JI(`',`bell.overload')";
723 return "JI(`',`window.size')";
724 case IDC_RESIZESTATIC
:
728 case IDC_RESIZEEITHER
:
729 return "JI(`',`window.resize')";
731 case IDC_SCROLLBARFULLSCREEN
:
736 return "JI(`',`window.scrollback')";
739 return "JI(`',`behaviour.closewarn')";
741 return "JI(`',`behaviour.altf4')";
743 return "JI(`',`behaviour.altspace')";
745 return "JI(`',`behaviour.altonly')";
746 case IDC_ALWAYSONTOP
:
747 return "JI(`',`behaviour.alwaysontop')";
748 case IDC_FULLSCREENONALTENTER
:
749 return "JI(`',`behaviour.altenter')";
751 case IDC_CURSORSTATIC
:
756 return "JI(`',`appearance.cursor')";
759 return "JI(`',`appearance.font')";
763 return "JI(`',`appearance.title')";
765 return "JI(`',`appearance.hidemouse')";
769 return "JI(`',`appearance.border')";
773 return "JI(`',`connection.termtype')";
776 return "JI(`',`connection.username')";
779 return "JI(`',`connection.keepalive')";
781 return "JI(`',`connection.nodelay')";
785 return "JI(`',`telnet.termspeed')";
794 return "JI(`',`telnet.environ')";
798 return "JI(`',`telnet.oldenviron')";
802 return "JI(`',`telnet.passive')";
804 return "JI(`',`telnet.specialkeys')";
808 return "JI(`',`rlogin.termspeed')";
809 case IDC_RLLUSERSTATIC
:
810 case IDC_RLLUSEREDIT
:
811 return "JI(`',`rlogin.localuser')";
814 return "JI(`',`ssh.nopty')";
815 case IDC_CIPHERSTATIC2
:
820 return "JI(`',`ssh.ciphers')";
822 return "JI(`',`ssh.buggymac')";
823 case IDC_SSHPROTSTATIC
:
826 return "JI(`',`ssh.protocol')";
829 return "JI(`',`ssh.command')";
831 return "JI(`',`ssh.compress')";
836 return "JI(`',`ssh.auth.privkey')";
838 return "JI(`',`ssh.auth.agentfwd')";
840 return "JI(`',`ssh.auth.changeuser')";
842 return "JI(`',`ssh.auth.tis')";
844 return "JI(`',`ssh.auth.ki')";
849 return "JI(`',`selection.buttons')";
850 case IDC_MOUSEOVERRIDE
:
851 return "JI(`',`selection.shiftdrag')";
852 case IDC_SELTYPESTATIC
:
854 case IDC_SELTYPERECT
:
855 return "JI(`',`selection.rect')";
861 return "JI(`',`selection.charclasses')";
863 return "JI(`',`selection.linedraw')";
865 return "JI(`',`selection.rtf')";
868 return "JI(`',`colours.bold')";
870 return "JI(`',`colours.logpal')";
871 case IDC_COLOURSTATIC
:
880 return "JI(`',`colours.config')";
882 case IDC_CODEPAGESTATIC
:
884 return "JI(`',`translation.codepage')";
885 case IDC_CAPSLOCKCYR
:
886 return "JI(`',`translation.cyrillic')";
893 return "JI(`',`translation.linedraw')";
895 case IDC_X11_FORWARD
:
896 case IDC_X11_DISPSTATIC
:
897 case IDC_X11_DISPLAY
:
898 return "JI(`',`ssh.tunnels.x11')";
901 case IDC_PFWDSTATIC2
:
905 case IDC_SPORTSTATIC
:
907 case IDC_DPORTSTATIC
:
911 return "JI(`',`ssh.tunnels.portfwd')";
918 /* 2nd arg: NZ => don't redraw session list (use when loading
920 static void init_dlg_ctrls(HWND hwnd
, int keepsess
)
923 char fontstatic
[256];
925 SetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
);
926 SetDlgItemText(hwnd
, IDC_SESSEDIT
, savedsession
);
929 n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
930 for (i
= n
; i
-- > 0;)
931 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_DELETESTRING
, i
, 0);
932 for (i
= 0; i
< nsessions
; i
++)
933 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
934 0, (LPARAM
) (sessions
[i
]));
936 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
937 CheckRadioButton(hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
938 cfg
.protocol
== PROT_SSH ? IDC_PROTSSH
:
939 cfg
.protocol
== PROT_TELNET ? IDC_PROTTELNET
:
941 PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
942 SetDlgItemInt(hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
943 CheckDlgButton(hwnd
, IDC_NODELAY
, cfg
.tcp_nodelay
);
945 CheckRadioButton(hwnd
, IDC_DEL008
, IDC_DEL127
,
946 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
947 CheckRadioButton(hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
948 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
949 CheckRadioButton(hwnd
, IDC_FUNCTILDE
, IDC_FUNCSCO
,
950 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
951 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
952 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
953 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
954 cfg
.funky_type
== 4 ? IDC_FUNCVT100P
:
955 cfg
.funky_type
== 5 ? IDC_FUNCSCO
: IDC_FUNCTILDE
);
956 CheckDlgButton(hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
957 CheckDlgButton(hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
958 CheckRadioButton(hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
959 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
960 CheckRadioButton(hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
961 cfg
.nethack_keypad ? IDC_KPNH
:
962 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
963 CheckDlgButton(hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
964 CheckDlgButton(hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
965 CheckDlgButton(hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
966 CheckDlgButton(hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
967 CheckDlgButton(hwnd
, IDC_CTRLALTKEYS
, cfg
.ctrlaltkeys
);
968 CheckDlgButton(hwnd
, IDC_TELNETKEY
, cfg
.telnet_keyboard
);
969 CheckRadioButton(hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
970 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
971 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
972 CheckRadioButton(hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
973 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
974 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
975 SetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
);
976 CheckDlgButton(hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
977 CheckDlgButton(hwnd
, IDC_FULLSCREENONALTENTER
, cfg
.fullscreenonaltenter
);
978 CheckDlgButton(hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
979 CheckDlgButton(hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
981 CheckDlgButton(hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
982 CheckDlgButton(hwnd
, IDC_DECOM
, cfg
.dec_om
);
983 CheckDlgButton(hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
984 SetDlgItemInt(hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
985 SetDlgItemInt(hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
986 SetDlgItemInt(hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
988 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
989 CheckRadioButton(hwnd
, IDC_BELL_DISABLED
, IDC_BELL_VISUAL
,
990 cfg
.beep
== BELL_DISABLED ? IDC_BELL_DISABLED
:
991 cfg
.beep
== BELL_DEFAULT ? IDC_BELL_DEFAULT
:
992 cfg
.beep
== BELL_WAVEFILE ? IDC_BELL_WAVEFILE
:
994 BELL_VISUAL ? IDC_BELL_VISUAL
: IDC_BELL_DEFAULT
);
995 CheckRadioButton(hwnd
, IDC_B_IND_DISABLED
, IDC_B_IND_STEADY
,
997 B_IND_DISABLED ? IDC_B_IND_DISABLED
: cfg
.beep_ind
==
998 B_IND_FLASH ? IDC_B_IND_FLASH
: cfg
.beep_ind
==
999 B_IND_STEADY ? IDC_B_IND_STEADY
: IDC_B_IND_DISABLED
);
1000 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
1001 CheckDlgButton(hwnd
, IDC_BELLOVL
, cfg
.bellovl
);
1002 SetDlgItemInt(hwnd
, IDC_BELLOVLN
, cfg
.bellovl_n
, FALSE
);
1003 MySetDlgItemFlt(hwnd
, IDC_BELLOVLT
, cfg
.bellovl_t
/ 1000.0);
1004 MySetDlgItemFlt(hwnd
, IDC_BELLOVLS
, cfg
.bellovl_s
/ 1000.0);
1006 CheckDlgButton(hwnd
, IDC_BCE
, cfg
.bce
);
1007 CheckDlgButton(hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
1009 SetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
1010 CheckDlgButton(hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
1011 CheckDlgButton(hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
1012 CheckDlgButton(hwnd
, IDC_SUNKENEDGE
, cfg
.sunken_edge
);
1013 SetDlgItemInt(hwnd
, IDC_WINBEDIT
, cfg
.window_border
, FALSE
);
1014 CheckRadioButton(hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
1015 cfg
.cursor_type
== 0 ? IDC_CURBLOCK
:
1016 cfg
.cursor_type
== 1 ? IDC_CURUNDER
: IDC_CURVERT
);
1017 CheckDlgButton(hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
1018 CheckDlgButton(hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
1019 CheckDlgButton(hwnd
, IDC_SCROLLBARFULLSCREEN
, cfg
.scrollbar_in_fullscreen
);
1020 CheckRadioButton(hwnd
, IDC_RESIZETERM
, IDC_RESIZEEITHER
,
1021 cfg
.resize_action
== RESIZE_TERM ? IDC_RESIZETERM
:
1022 cfg
.resize_action
== RESIZE_FONT ? IDC_RESIZEFONT
:
1023 cfg
.resize_action
== RESIZE_EITHER ? IDC_RESIZEEITHER
:
1025 CheckRadioButton(hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
1026 cfg
.close_on_exit
== COE_NORMAL ? IDC_COENORMAL
:
1027 cfg
.close_on_exit
==
1028 COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
1029 CheckDlgButton(hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
1031 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
1032 SetDlgItemText(hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
1033 SetDlgItemText(hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
1034 SetDlgItemText(hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
1035 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
1036 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
1037 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATPACKET
,
1038 cfg
.logtype
== LGTYP_NONE ? IDC_LSTATOFF
:
1039 cfg
.logtype
== LGTYP_ASCII ? IDC_LSTATASCII
:
1040 cfg
.logtype
== LGTYP_DEBUG ? IDC_LSTATRAW
:
1042 CheckRadioButton(hwnd
, IDC_LSTATXOVR
, IDC_LSTATXASK
,
1043 cfg
.logxfovr
== LGXF_OVR ? IDC_LSTATXOVR
:
1044 cfg
.logxfovr
== LGXF_ASK ? IDC_LSTATXASK
:
1047 char *p
= cfg
.environmt
;
1048 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_RESETCONTENT
, 0, 0);
1050 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
1056 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
, 0,
1061 CheckRadioButton(hwnd
, IDC_EMBSD
, IDC_EMRFC
,
1062 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
1063 CheckRadioButton(hwnd
, IDC_TPASSIVE
, IDC_TACTIVE
,
1064 cfg
.passive_telnet ? IDC_TPASSIVE
: IDC_TACTIVE
);
1066 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
1067 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
1068 CheckDlgButton(hwnd
, IDC_NOPTY
, cfg
.nopty
);
1069 CheckDlgButton(hwnd
, IDC_COMPRESS
, cfg
.compression
);
1070 CheckDlgButton(hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
1071 CheckDlgButton(hwnd
, IDC_SSH2DES
, cfg
.ssh2_des_cbc
);
1072 CheckDlgButton(hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
1073 CheckDlgButton(hwnd
, IDC_CHANGEUSER
, cfg
.change_username
);
1074 CheckRadioButton(hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
1075 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
1076 CheckDlgButton(hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
1077 CheckDlgButton(hwnd
, IDC_AUTHKI
, cfg
.try_ki_auth
);
1078 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1079 SetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
1083 static const struct { char *s
; int c
; } ciphers
[] = {
1084 { "3DES", CIPHER_3DES
},
1085 { "Blowfish", CIPHER_BLOWFISH
},
1086 { "DES", CIPHER_DES
},
1087 { "AES (SSH 2 only)", CIPHER_AES
},
1088 { "-- warn below here --", CIPHER_WARN
}
1091 /* Set up the "selected ciphers" box. */
1092 /* (cipherlist assumed to contain all ciphers) */
1093 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_RESETCONTENT
, 0, 0);
1094 for (i
= 0; i
< CIPHER_MAX
; i
++) {
1095 int c
= cfg
.ssh_cipherlist
[i
];
1098 for (j
= 0; j
< (sizeof ciphers
) / (sizeof ciphers
[0]); j
++) {
1099 if (ciphers
[j
].c
== c
) {
1100 cstr
= ciphers
[j
].s
;
1104 pos
= SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_ADDSTRING
,
1106 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_SETITEMDATA
,
1112 CheckRadioButton(hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
1113 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
1114 CheckRadioButton(hwnd
, IDC_SELTYPELEX
, IDC_SELTYPERECT
,
1115 cfg
.rect_select
== 0 ? IDC_SELTYPELEX
: IDC_SELTYPERECT
);
1116 CheckDlgButton(hwnd
, IDC_MOUSEOVERRIDE
, cfg
.mouse_override
);
1117 CheckDlgButton(hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
1118 CheckDlgButton(hwnd
, IDC_RTFPASTE
, cfg
.rtf_paste
);
1120 static int tabs
[4] = { 25, 61, 96, 128 };
1121 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
1124 for (i
= 0; i
< 128; i
++) {
1126 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
1127 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ', cfg
.wordness
[i
]);
1128 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
1132 CheckDlgButton(hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
1133 CheckDlgButton(hwnd
, IDC_PALETTE
, cfg
.try_palette
);
1136 n
= SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
1137 for (i
= n
; i
-- > 0;)
1138 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
1139 LB_DELETESTRING
, i
, 0);
1140 for (i
= 0; i
< 22; i
++)
1141 if (cfg
.bold_colour
|| permcolour
[i
])
1142 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
1143 (LPARAM
) colours
[i
]);
1145 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
1146 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
1147 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
1148 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
1153 strcpy(cfg
.line_codepage
, cp_name(decode_codepage(cfg
.line_codepage
)));
1154 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_RESETCONTENT
, 0, 0);
1155 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
1156 for (i
= 0; (cp
= cp_enumerate(i
)) != NULL
; i
++) {
1157 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_ADDSTRING
,
1160 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
1163 CheckRadioButton(hwnd
, IDC_VTXWINDOWS
, IDC_VTUNICODE
,
1164 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
1165 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
1166 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
1167 cfg
.vtmode
== VT_UNICODE ? IDC_VTUNICODE
:
1170 CheckDlgButton(hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
1171 SetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
1173 CheckDlgButton(hwnd
, IDC_LPORT_ALL
, cfg
.lport_acceptall
);
1174 CheckRadioButton(hwnd
, IDC_PFWDLOCAL
, IDC_PFWDREMOTE
, IDC_PFWDLOCAL
);
1177 struct treeview_faff
{
1179 HTREEITEM lastat
[4];
1182 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
1183 int level
, char *text
)
1188 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
- 1] : TVI_ROOT
);
1189 ins
.hInsertAfter
= faff
->lastat
[level
];
1190 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1191 #define INSITEM DUMMYUNIONNAME.item
1193 #define INSITEM item
1195 ins
.INSITEM
.mask
= TVIF_TEXT
;
1196 ins
.INSITEM
.pszText
= text
;
1197 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
1199 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
- 1],
1201 faff
->lastat
[level
] = newitem
;
1202 for (i
= level
+ 1; i
< 4; i
++)
1203 faff
->lastat
[i
] = NULL
;
1208 * Create the panelfuls of controls in the configuration box.
1210 static void create_controls(HWND hwnd
, int dlgtype
, int panel
)
1212 if (panel
== sessionpanelstart
) {
1213 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
1215 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1216 bartitle(&cp
, "Basic options for your PuTTY session",
1219 beginbox(&cp
, "Specify your connection by host name or IP address",
1222 "Host &Name (or IP address)",
1223 IDC_HOSTSTATIC
, IDC_HOST
, 75,
1224 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
1225 if (backends
[3].backend
== NULL
) {
1226 /* this is PuTTYtel, so only three protocols available */
1227 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 3,
1228 "&Raw", IDC_PROTRAW
,
1229 "&Telnet", IDC_PROTTELNET
,
1230 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
1232 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
1233 "&Raw", IDC_PROTRAW
,
1234 "&Telnet", IDC_PROTTELNET
,
1235 "Rlog&in", IDC_PROTRLOGIN
,
1244 beginbox(&cp
, "Load, save or delete a stored session",
1246 sesssaver(&cp
, "Sav&ed Sessions",
1247 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
1248 "&Load", IDC_SESSLOAD
,
1249 "&Save", IDC_SESSSAVE
, "&Delete", IDC_SESSDEL
, NULL
);
1252 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
1253 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
1254 "Always", IDC_COEALWAYS
,
1255 "Never", IDC_COENEVER
,
1256 "Only on clean exit", IDC_COENORMAL
, NULL
);
1260 if (panel
== loggingpanelstart
) {
1261 /* The Logging panel. Accelerators used: [acgo] tplsfwe */
1263 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1264 bartitle(&cp
, "Options controlling session logging",
1266 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
1268 "Session logging:", IDC_LSTATSTATIC
,
1269 "Logging &turned off completely", IDC_LSTATOFF
,
1270 "Log &printable output only", IDC_LSTATASCII
,
1271 "&Log all session output", IDC_LSTATRAW
,
1272 "Log &SSH packet data", IDC_LSTATPACKET
,
1274 editbutton(&cp
, "Log &file name:",
1275 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
1277 statictext(&cp
, "(Log file name can contain &&Y, &&M, &&D for date,"
1278 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN
);
1280 "What to do if the log file already &exists:",
1281 IDC_LSTATXIST
, "Always overwrite it", IDC_LSTATXOVR
,
1282 "Always append to the end of it", IDC_LSTATXAPN
,
1283 "Ask the user every time", IDC_LSTATXASK
, NULL
);
1287 if (panel
== terminalpanelstart
) {
1288 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
1290 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1291 bartitle(&cp
, "Options controlling the terminal emulation",
1292 IDC_TITLE_TERMINAL
);
1293 beginbox(&cp
, "Set various terminal options", IDC_BOX_TERMINAL1
);
1294 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
1295 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
1296 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
1297 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
1298 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
1300 "An&swerback to ^E:", IDC_ANSWERBACK
,
1301 IDC_ANSWEREDIT
, 100, NULL
);
1304 beginbox(&cp
, "Line discipline options", IDC_BOX_TERMINAL2
);
1305 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
1306 "Auto", IDC_ECHOBACKEND
,
1307 "Force on", IDC_ECHOYES
, "Force off", IDC_ECHONO
, NULL
);
1308 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
1309 "Auto", IDC_EDITBACKEND
,
1310 "Force on", IDC_EDITYES
, "Force off", IDC_EDITNO
, NULL
);
1314 if (panel
== bellpanelstart
) {
1315 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
1317 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1318 bartitle(&cp
, "Options controlling the terminal bell",
1320 beginbox(&cp
, "Set the style of bell", IDC_BOX_BELL1
);
1322 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
1323 "None (bell disabled)", IDC_BELL_DISABLED
,
1324 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
1325 "Play a custom sound file", IDC_BELL_WAVEFILE
,
1326 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
1327 editbutton(&cp
, "Custom sound file to play as a bell:",
1328 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
1329 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
1330 radioline(&cp
, "Taskbar/caption &indication on bell:",
1331 IDC_B_IND_STATIC
, 3, "Disabled", IDC_B_IND_DISABLED
,
1332 "Flashing", IDC_B_IND_FLASH
, "Steady", IDC_B_IND_STEADY
,
1335 beginbox(&cp
, "Control the bell overload behaviour",
1337 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
1339 staticedit(&cp
, "Over-use means this &many bells...",
1340 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
1341 staticedit(&cp
, "... in &this many seconds",
1342 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
1344 "The bell is re-enabled after a few seconds of silence.",
1345 1, IDC_BELLOVLEXPLAIN
);
1346 staticedit(&cp
, "Seconds of &silence required", IDC_BELLOVLSSTATIC
,
1351 if (panel
== keyboardpanelstart
) {
1352 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
1354 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1355 bartitle(&cp
, "Options controlling the effects of keys",
1356 IDC_TITLE_KEYBOARD
);
1357 beginbox(&cp
, "Change the sequences sent by:", IDC_BOX_KEYBOARD1
);
1358 radioline(&cp
, "The &Backspace key", IDC_DELSTATIC
, 2,
1359 "Control-H", IDC_DEL008
,
1360 "Control-? (127)", IDC_DEL127
, NULL
);
1361 radioline(&cp
, "The &Home and End keys", IDC_HOMESTATIC
, 2,
1362 "Standard", IDC_HOMETILDE
, "rxvt", IDC_HOMERXVT
, NULL
);
1363 radioline(&cp
, "The &Function keys and keypad", IDC_FUNCSTATIC
, 3,
1364 "ESC[n~", IDC_FUNCTILDE
,
1365 "Linux", IDC_FUNCLINUX
,
1366 "Xterm R6", IDC_FUNCXTERM
,
1367 "VT400", IDC_FUNCVT400
,
1368 "VT100+", IDC_FUNCVT100P
, "SCO", IDC_FUNCSCO
, NULL
);
1370 beginbox(&cp
, "Application keypad settings:", IDC_BOX_KEYBOARD2
);
1372 "Application c&ursor keys totally disabled",
1374 radioline(&cp
, "Initial state of cu&rsor keys:", IDC_CURSTATIC
, 2,
1375 "Normal", IDC_CURNORMAL
,
1376 "Application", IDC_CURAPPLIC
, NULL
);
1378 "Application ke&ypad keys totally disabled",
1380 radioline(&cp
, "Initial state of &numeric keypad:", IDC_KPSTATIC
,
1381 3, "Normal", IDC_KPNORMAL
, "Application", IDC_KPAPPLIC
,
1382 "NetHack", IDC_KPNH
, NULL
);
1384 beginbox(&cp
, "Enable extra keyboard features:",
1386 checkbox(&cp
, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY
);
1387 checkbox(&cp
, "Control-Alt is &different from AltGr",
1392 if (panel
== windowpanelstart
) {
1393 /* The Window panel. Accelerators used: [acgo] rmz sdikp */
1395 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1396 bartitle(&cp
, "Options controlling PuTTY's window",
1398 beginbox(&cp
, "Set the size of the window", IDC_BOX_WINDOW1
);
1400 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
1401 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50, NULL
);
1402 radiobig(&cp
, "When window is resi&zed:", IDC_RESIZESTATIC
,
1403 "Change the number of rows and columns", IDC_RESIZETERM
,
1404 "Change the size of the font", IDC_RESIZEFONT
,
1405 "Change font size only when maximised", IDC_RESIZEEITHER
,
1406 "Forbid resizing completely", IDC_RESIZENONE
, NULL
);
1408 beginbox(&cp
, "Control the scrollback in the window",
1410 staticedit(&cp
, "Lines of &scrollback",
1411 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
1412 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
1413 checkbox(&cp
, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN
);
1414 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
1415 checkbox(&cp
, "Reset scrollback on dis&play activity",
1420 if (panel
== appearancepanelstart
) {
1421 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1423 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1424 bartitle(&cp
, "Configure the appearance of PuTTY's window",
1425 IDC_TITLE_APPEARANCE
);
1426 beginbox(&cp
, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1
);
1427 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
1428 "B&lock", IDC_CURBLOCK
,
1429 "&Underline", IDC_CURUNDER
,
1430 "&Vertical line", IDC_CURVERT
, NULL
);
1431 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
1433 beginbox(&cp
, "Set the font used in the terminal window",
1434 IDC_BOX_APPEARANCE2
);
1435 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
1437 beginbox(&cp
, "Adjust the use of the window title",
1438 IDC_BOX_APPEARANCE3
);
1440 "Window &title:", IDC_WINTITLE
, IDC_WINEDIT
, 100, NULL
);
1441 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
1443 beginbox(&cp
, "Adjust the use of the mouse pointer",
1444 IDC_BOX_APPEARANCE4
);
1445 checkbox(&cp
, "Hide mouse &pointer when typing in window",
1448 beginbox(&cp
, "Adjust the window border", IDC_BOX_APPEARANCE5
);
1449 checkbox(&cp
, "&Sunken-edge border (slightly thicker)",
1451 staticedit(&cp
, "Gap between text and window edge",
1452 IDC_WINBSTATIC
, IDC_WINBEDIT
, 20);
1456 if (panel
== behaviourpanelstart
) {
1457 /* The Behaviour panel. Accelerators used: [acgo] w4yltf */
1459 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1460 bartitle(&cp
, "Configure the behaviour of PuTTY's window",
1462 beginbox(&cp
, NULL
, IDC_BOX_BEHAVIOUR1
);
1463 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
1464 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
1465 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
1466 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
1467 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
1468 checkbox(&cp
, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER
);
1472 if (panel
== translationpanelstart
) {
1473 /* The Translation panel. Accelerators used: [acgo] rxbepus */
1475 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1476 bartitle(&cp
, "Options controlling character set translation",
1477 IDC_TITLE_TRANSLATION
);
1478 beginbox(&cp
, "Character set translation on received data",
1479 IDC_BOX_TRANSLATION1
);
1480 combobox(&cp
, "&Received data assumed to be in which character set:",
1481 IDC_CODEPAGESTATIC
, IDC_CODEPAGE
);
1483 beginbox(&cp
, "Enable character set translation on input data",
1484 IDC_BOX_TRANSLATION2
);
1485 checkbox(&cp
, "Cap&s Lock acts as Cyrillic switch",
1488 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
1489 IDC_BOX_TRANSLATION3
);
1491 "Handling of line drawing characters:", IDC_VTSTATIC
,
1492 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
1493 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
1494 "Use font in O&EM mode only", IDC_VTOEMONLY
,
1495 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1496 IDC_VTPOORMAN
, "&Unicode mode", IDC_VTUNICODE
, NULL
);
1500 if (panel
== selectionpanelstart
) {
1501 /* The Selection panel. Accelerators used: [acgo] df wxp hst nr */
1503 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1504 bartitle(&cp
, "Options controlling copy and paste",
1505 IDC_TITLE_SELECTION
);
1506 beginbox(&cp
, "Translation of pasted characters",
1507 IDC_BOX_SELECTION1
);
1509 "&Don't translate line drawing chars into +, - and |",
1512 "Paste to clipboard in RT&F as well as plain text",
1515 beginbox(&cp
, "Control which mouse button does which thing",
1516 IDC_BOX_SELECTION2
);
1517 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1518 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1519 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1522 "Shift overrides a&pplication's use of mouse",
1525 "Default selection mode (Alt+drag does the other one):",
1526 IDC_SELTYPESTATIC
, 2,
1527 "&Normal", IDC_SELTYPELEX
,
1528 "&Rectangular block", IDC_SELTYPERECT
, NULL
);
1530 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1531 IDC_BOX_SELECTION3
);
1532 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1533 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1534 "&to class", IDC_CCSTATIC2
);
1538 if (panel
== colourspanelstart
) {
1539 /* The Colours panel. Accelerators used: [acgo] blum */
1541 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1542 bartitle(&cp
, "Options controlling use of colours",
1544 beginbox(&cp
, "General options for colour usage",
1546 checkbox(&cp
, "&Bolded text is a different colour",
1548 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1550 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1552 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1553 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1554 "&Modify...", IDC_CHANGE
,
1555 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1556 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1557 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1561 if (panel
== connectionpanelstart
) {
1562 /* The Connection panel. Accelerators used: [acgo] tukn */
1564 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1565 bartitle(&cp
, "Options controlling the connection",
1566 IDC_TITLE_CONNECTION
);
1568 beginbox(&cp
, "Data to send to the server",
1569 IDC_BOX_CONNECTION1
);
1570 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
,
1572 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
,
1576 beginbox(&cp
, "Adjust telnet session.", IDC_BOX_CONNECTION1
);
1577 checkbox(&cp
, "Keyboard sends telnet Backspace and Interrupt",
1581 beginbox(&cp
, "Sending of null packets to keep session active",
1582 IDC_BOX_CONNECTION2
);
1583 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1584 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1587 beginbox(&cp
, "Low-level TCP connection options",
1588 IDC_BOX_CONNECTION3
);
1589 checkbox(&cp
, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1595 if (panel
== telnetpanelstart
) {
1596 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
1598 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1600 bartitle(&cp
, "Options controlling Telnet connections",
1602 beginbox(&cp
, "Data to send to the server", IDC_BOX_TELNET1
);
1603 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
,
1605 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1606 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
, "Va&lue",
1607 IDC_VALSTATIC
, IDC_VALEDIT
, IDC_ENVLIST
, "A&dd",
1608 IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1610 beginbox(&cp
, "Telnet protocol adjustments", IDC_BOX_TELNET2
);
1611 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:",
1612 IDC_EMSTATIC
, 2, "&BSD (commonplace)", IDC_EMBSD
,
1613 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1614 radioline(&cp
, "&Telnet negotiation mode:", IDC_ACTSTATIC
, 2,
1615 "Passive", IDC_TPASSIVE
, "Active",
1617 checkbox(&cp
, "&Keyboard sends telnet Backspace and Interrupt",
1623 if (panel
== rloginpanelstart
) {
1624 /* The Rlogin panel. Accelerators used: [acgo] sl */
1626 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1628 bartitle(&cp
, "Options controlling Rlogin connections",
1630 beginbox(&cp
, "Data to send to the server", IDC_BOX_RLOGIN1
);
1631 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
,
1633 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
,
1634 IDC_RLLUSEREDIT
, 50);
1639 if (panel
== sshpanelstart
) {
1640 /* The SSH panel. Accelerators used: [acgo] r pe12i sd */
1642 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1644 bartitle(&cp
, "Options controlling SSH connections",
1646 beginbox(&cp
, "Data to send to the server", IDC_BOX_SSH1
);
1648 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1651 beginbox(&cp
, "Protocol options", IDC_BOX_SSH2
);
1652 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1653 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1654 radioline(&cp
, "Preferred SSH protocol version:",
1655 IDC_SSHPROTSTATIC
, 2,
1656 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1657 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1660 beginbox(&cp
, "Encryption options", IDC_BOX_SSH3
);
1661 prefslist(&cipherlist
, &cp
, "Encryption cipher &selection policy:",
1662 IDC_CIPHERSTATIC2
, IDC_CIPHERLIST
, IDC_CIPHERUP
,
1664 checkbox(&cp
, "Enable non-standard use of single-&DES in SSH 2",
1670 if (panel
== sshauthpanelstart
) {
1671 /* The SSH authentication panel. Accelerators used: [acgo] m fkiw */
1673 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1675 bartitle(&cp
, "Options controlling SSH authentication",
1677 beginbox(&cp
, "Authentication methods",
1679 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
1681 checkbox(&cp
, "Attempt \"keyboard-&interactive\" authentication"
1682 " (SSH2)", IDC_AUTHKI
);
1684 beginbox(&cp
, "Authentication parameters",
1686 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1687 checkbox(&cp
, "Allow attempted changes of &username in SSH2",
1689 editbutton(&cp
, "Private &key file for authentication:",
1690 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...",
1696 if (panel
== tunnelspanelstart
) {
1697 /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */
1699 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1701 bartitle(&cp
, "Options controlling SSH tunnelling",
1703 beginbox(&cp
, "X11 forwarding", IDC_BOX_TUNNELS1
);
1704 checkbox(&cp
, "&Enable X11 forwarding", IDC_X11_FORWARD
);
1705 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1706 IDC_X11_DISPLAY
, 50, NULL
);
1708 beginbox(&cp
, "Port forwarding", IDC_BOX_TUNNELS2
);
1709 checkbox(&cp
, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL
);
1710 staticbtn(&cp
, "Forwarded ports:", IDC_PFWDSTATIC
,
1711 "&Remove", IDC_PFWDREMOVE
);
1712 fwdsetter(&cp
, IDC_PFWDLIST
,
1713 "Add new forwarded port:", IDC_PFWDSTATIC2
,
1714 "&Source port", IDC_SPORTSTATIC
, IDC_SPORTEDIT
,
1715 "Dest&ination", IDC_DPORTSTATIC
, IDC_DPORTEDIT
,
1716 "A&dd", IDC_PFWDADD
);
1717 bareradioline(&cp
, 2,
1718 "&Local", IDC_PFWDLOCAL
, "Re&mote", IDC_PFWDREMOTE
, NULL
);
1726 * Helper function to load the session selected in SESSLIST
1727 * if any, as this is done in more than one place in
1728 * GenericMainDlgProc(). 0 => failure.
1730 static int load_selected_session(HWND hwnd
)
1732 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1733 LB_GETCURSEL
, 0, 0);
1739 isdef
= !strcmp(sessions
[n
], "Default Settings");
1740 load_settings(sessions
[n
], !isdef
, &cfg
);
1741 init_dlg_ctrls(hwnd
, TRUE
);
1743 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1745 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1746 /* Restore the selection, which will have been clobbered by
1747 * SESSEDIT handling. */
1748 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
, n
, 0);
1753 * This function is the configuration box.
1755 static int GenericMainDlgProc(HWND hwnd
, UINT msg
,
1756 WPARAM wParam
, LPARAM lParam
, int dlgtype
)
1759 struct treeview_faff tvfaff
;
1762 char filename
[sizeof(cfg
.keyfile
)];
1765 char fontstatic
[256];
1767 struct servent
*service
;
1769 static UINT draglistmsg
= WM_NULL
;
1774 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1776 SetWindowLong(hwnd
, GWL_EXSTYLE
,
1777 GetWindowLong(hwnd
, GWL_EXSTYLE
) | WS_EX_CONTEXTHELP
);
1779 HWND item
= GetDlgItem(hwnd
, IDC_HELPBTN
);
1781 DestroyWindow(item
);
1783 requested_help
= FALSE
;
1784 SendMessage(hwnd
, WM_SETICON
, (WPARAM
) ICON_BIG
,
1785 (LPARAM
) LoadIcon(hinst
, MAKEINTRESOURCE(IDI_CFGICON
)));
1787 * Centre the window.
1789 { /* centre the window */
1792 hw
= GetDesktopWindow();
1793 if (GetWindowRect(hw
, &rs
) && GetWindowRect(hwnd
, &rd
))
1795 (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
) / 2,
1796 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
) / 2,
1797 rd
.right
- rd
.left
, rd
.bottom
- rd
.top
, TRUE
);
1801 * Create the tree view.
1809 r
.right
= r
.left
+ 75;
1811 r
.bottom
= r
.top
+ 10;
1812 MapDialogRect(hwnd
, &r
);
1813 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1814 WS_CHILD
| WS_VISIBLE
,
1816 r
.right
- r
.left
, r
.bottom
- r
.top
,
1817 hwnd
, (HMENU
) IDCX_TVSTATIC
, hinst
,
1819 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1820 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1823 r
.right
= r
.left
+ 75;
1825 r
.bottom
= r
.top
+ 219;
1826 MapDialogRect(hwnd
, &r
);
1827 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1828 WS_CHILD
| WS_VISIBLE
|
1829 WS_TABSTOP
| TVS_HASLINES
|
1830 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
1832 TVS_SHOWSELALWAYS
, r
.left
, r
.top
,
1833 r
.right
- r
.left
, r
.bottom
- r
.top
,
1834 hwnd
, (HMENU
) IDCX_TREEVIEW
, hinst
,
1836 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1837 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1838 tvfaff
.treeview
= treeview
;
1839 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1843 * Set up the tree view contents.
1845 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1846 treeview_insert(&tvfaff
, 1, "Logging");
1847 treeview_insert(&tvfaff
, 0, "Terminal");
1848 treeview_insert(&tvfaff
, 1, "Keyboard");
1849 treeview_insert(&tvfaff
, 1, "Bell");
1850 treeview_insert(&tvfaff
, 0, "Window");
1851 treeview_insert(&tvfaff
, 1, "Appearance");
1852 treeview_insert(&tvfaff
, 1, "Behaviour");
1853 treeview_insert(&tvfaff
, 1, "Translation");
1854 treeview_insert(&tvfaff
, 1, "Selection");
1855 treeview_insert(&tvfaff
, 1, "Colours");
1856 treeview_insert(&tvfaff
, 0, "Connection");
1858 treeview_insert(&tvfaff
, 1, "Telnet");
1859 treeview_insert(&tvfaff
, 1, "Rlogin");
1860 if (backends
[3].backend
!= NULL
) {
1861 treeview_insert(&tvfaff
, 1, "SSH");
1862 /* XXX long name is ugly */
1863 /* XXX make it closed by default? */
1864 treeview_insert(&tvfaff
, 2, "Auth");
1865 treeview_insert(&tvfaff
, 2, "Tunnels");
1870 * Put the treeview selection on to the Session panel. This
1871 * should also cause creation of the relevant controls.
1873 TreeView_SelectItem(treeview
, hsession
);
1876 * Set focus into the first available control.
1880 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1882 ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1886 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1887 sesslist_has_focus
= 0;
1891 * Button release should trigger WM_OK if there was a
1892 * previous double click on the session list.
1896 SendMessage(hwnd
, WM_COMMAND
, IDOK
, 0);
1899 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1900 ((LPNMHDR
) lParam
)->code
== TVN_SELCHANGED
) {
1902 TreeView_GetSelection(((LPNMHDR
) lParam
)->hwndFrom
);
1907 SendMessage (hwnd
, WM_SETREDRAW
, FALSE
, 0);
1910 item
.pszText
= buffer
;
1911 item
.cchTextMax
= sizeof(buffer
);
1912 item
.mask
= TVIF_TEXT
;
1913 TreeView_GetItem(((LPNMHDR
) lParam
)->hwndFrom
, &item
);
1914 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1915 HWND item
= GetDlgItem(hwnd
, j
);
1917 DestroyWindow(item
);
1919 if (!strcmp(buffer
, "Session"))
1920 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1921 if (!strcmp(buffer
, "Logging"))
1922 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1923 if (!strcmp(buffer
, "Keyboard"))
1924 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1925 if (!strcmp(buffer
, "Terminal"))
1926 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1927 if (!strcmp(buffer
, "Bell"))
1928 create_controls(hwnd
, dlgtype
, bellpanelstart
);
1929 if (!strcmp(buffer
, "Window"))
1930 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1931 if (!strcmp(buffer
, "Appearance"))
1932 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1933 if (!strcmp(buffer
, "Behaviour"))
1934 create_controls(hwnd
, dlgtype
, behaviourpanelstart
);
1935 if (!strcmp(buffer
, "Tunnels"))
1936 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1937 if (!strcmp(buffer
, "Connection"))
1938 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1939 if (!strcmp(buffer
, "Telnet"))
1940 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1941 if (!strcmp(buffer
, "Rlogin"))
1942 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1943 if (!strcmp(buffer
, "SSH"))
1944 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1945 if (!strcmp(buffer
, "Auth"))
1946 create_controls(hwnd
, dlgtype
, sshauthpanelstart
);
1947 if (!strcmp(buffer
, "Selection"))
1948 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1949 if (!strcmp(buffer
, "Colours"))
1950 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1951 if (!strcmp(buffer
, "Translation"))
1952 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1954 init_dlg_ctrls(hwnd
, FALSE
);
1956 SendMessage (hwnd
, WM_SETREDRAW
, TRUE
, 0);
1957 InvalidateRect (hwnd
, NULL
, TRUE
);
1959 SetFocus(((LPNMHDR
) lParam
)->hwndFrom
); /* ensure focus stays */
1965 * Only process WM_COMMAND once the dialog is fully formed.
1967 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1)
1968 switch (LOWORD(wParam
)) {
1970 /* Behaviour of the "Open" button is different if the
1971 * session list has focus, *unless* the user just
1972 * double-clicked... */
1973 if (sesslist_has_focus
&& !readytogo
) {
1974 if (!load_selected_session(hwnd
)) {
1979 /* If at this point we have a valid session, go! */
1981 if (requested_help
) {
1982 WinHelp(hwnd
, help_path
, HELP_QUIT
, 0);
1983 requested_help
= FALSE
;
1990 if (HIWORD(wParam
) == BN_CLICKED
||
1991 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1993 WinHelp(hwnd
, help_path
,
1994 help_has_contents ? HELP_FINDER
: HELP_CONTENTS
,
1996 requested_help
= TRUE
;
2001 if (requested_help
) {
2002 WinHelp(hwnd
, help_path
, HELP_QUIT
, 0);
2003 requested_help
= FALSE
;
2007 case IDC_PROTTELNET
:
2008 case IDC_PROTRLOGIN
:
2011 if (HIWORD(wParam
) == BN_CLICKED
||
2012 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2013 int i
= IsDlgButtonChecked(hwnd
, IDC_PROTSSH
);
2014 int j
= IsDlgButtonChecked(hwnd
, IDC_PROTTELNET
);
2015 int k
= IsDlgButtonChecked(hwnd
, IDC_PROTRLOGIN
);
2017 i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
:
2019 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22)
2020 || (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23)
2021 || (cfg
.protocol
== PROT_RLOGIN
2022 && cfg
.port
!= 513)) {
2023 cfg
.port
= i ?
22 : j ?
23 : 513;
2024 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
2029 if (HIWORD(wParam
) == EN_CHANGE
)
2030 GetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
,
2031 sizeof(cfg
.host
) - 1);
2034 if (HIWORD(wParam
) == EN_CHANGE
) {
2035 GetDlgItemText(hwnd
, IDC_PORT
, portname
, 31);
2036 if (isdigit(portname
[0]))
2037 MyGetDlgItemInt(hwnd
, IDC_PORT
, &cfg
.port
);
2039 service
= getservbyname(portname
, NULL
);
2041 cfg
.port
= ntohs(service
->s_port
);
2048 if (HIWORD(wParam
) == EN_CHANGE
) {
2049 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
2051 GetDlgItemText(hwnd
, IDC_SESSEDIT
,
2052 savedsession
, sizeof(savedsession
) - 1);
2053 savedsession
[sizeof(savedsession
) - 1] = '\0';
2057 if (HIWORD(wParam
) == BN_CLICKED
||
2058 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2063 GetDlgItemText(hwnd
, IDC_SESSEDIT
, str
,
2066 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2067 LB_GETCURSEL
, 0, 0);
2072 strcpy(str
, sessions
[n
]);
2074 save_settings(str
, !!strcmp(str
, "Default Settings"),
2076 get_sesslist(FALSE
);
2078 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2080 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
2082 for (i
= 0; i
< nsessions
; i
++)
2083 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2085 (LPARAM
) (sessions
[i
]));
2086 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
2088 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2090 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
2096 if (LOWORD(wParam
) == IDC_SESSLIST
) {
2097 if (HIWORD(wParam
) == LBN_SETFOCUS
)
2098 sesslist_has_focus
= 1;
2099 else if (HIWORD(wParam
) == LBN_KILLFOCUS
)
2100 sesslist_has_focus
= 0;
2102 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
2103 HIWORD(wParam
) != BN_CLICKED
&&
2104 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2105 if (LOWORD(wParam
) == IDC_SESSLIST
&&
2106 HIWORD(wParam
) != LBN_DBLCLK
) break;
2107 /* Load the session selected in SESSLIST. */
2108 if (load_selected_session(hwnd
) &&
2109 LOWORD(wParam
) == IDC_SESSLIST
) {
2111 * A double-click on a saved session should
2112 * actually start the session, not just load it.
2113 * Unless it's Default Settings or some other
2114 * host-less set of saved settings.
2123 if (HIWORD(wParam
) == BN_CLICKED
||
2124 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2125 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2126 LB_GETCURSEL
, 0, 0);
2127 if (n
== LB_ERR
|| n
== 0) {
2131 del_settings(sessions
[n
]);
2132 get_sesslist(FALSE
);
2134 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2136 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
2138 for (i
= 0; i
< nsessions
; i
++)
2139 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
2141 (LPARAM
) (sessions
[i
]));
2142 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
2144 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
2146 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
2150 if (HIWORD(wParam
) == EN_CHANGE
)
2151 MyGetDlgItemInt(hwnd
, IDC_PINGEDIT
,
2152 &cfg
.ping_interval
);
2155 if (HIWORD(wParam
) == BN_CLICKED
||
2156 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2158 IsDlgButtonChecked(hwnd
, IDC_NODELAY
);
2162 if (HIWORD(wParam
) == BN_CLICKED
||
2163 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2164 cfg
.bksp_is_delete
=
2165 IsDlgButtonChecked(hwnd
, IDC_DEL127
);
2169 if (HIWORD(wParam
) == BN_CLICKED
||
2170 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2172 IsDlgButtonChecked(hwnd
, IDC_HOMERXVT
);
2178 case IDC_FUNCVT100P
:
2180 if (HIWORD(wParam
) == BN_CLICKED
||
2181 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2182 switch (LOWORD(wParam
)) {
2195 case IDC_FUNCVT100P
:
2205 if (HIWORD(wParam
) == BN_CLICKED
||
2206 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2208 IsDlgButtonChecked(hwnd
, IDC_KPAPPLIC
);
2209 cfg
.nethack_keypad
= FALSE
;
2213 if (HIWORD(wParam
) == BN_CLICKED
||
2214 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2215 cfg
.app_keypad
= FALSE
;
2216 cfg
.nethack_keypad
= TRUE
;
2221 if (HIWORD(wParam
) == BN_CLICKED
||
2222 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2224 IsDlgButtonChecked(hwnd
, IDC_CURAPPLIC
);
2227 if (HIWORD(wParam
) == BN_CLICKED
||
2228 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2230 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICC
);
2233 if (HIWORD(wParam
) == BN_CLICKED
||
2234 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2236 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICK
);
2239 if (HIWORD(wParam
) == BN_CLICKED
||
2240 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2241 cfg
.alt_f4
= IsDlgButtonChecked(hwnd
, IDC_ALTF4
);
2244 if (HIWORD(wParam
) == BN_CLICKED
||
2245 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2247 IsDlgButtonChecked(hwnd
, IDC_ALTSPACE
);
2250 if (HIWORD(wParam
) == BN_CLICKED
||
2251 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2253 IsDlgButtonChecked(hwnd
, IDC_ALTONLY
);
2255 case IDC_ECHOBACKEND
:
2258 if (HIWORD(wParam
) == BN_CLICKED
||
2259 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2260 if (LOWORD(wParam
) == IDC_ECHOBACKEND
)
2261 cfg
.localecho
= LD_BACKEND
;
2262 if (LOWORD(wParam
) == IDC_ECHOYES
)
2263 cfg
.localecho
= LD_YES
;
2264 if (LOWORD(wParam
) == IDC_ECHONO
)
2265 cfg
.localecho
= LD_NO
;
2268 case IDC_EDITBACKEND
:
2271 if (HIWORD(wParam
) == BN_CLICKED
||
2272 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2273 if (LOWORD(wParam
) == IDC_EDITBACKEND
)
2274 cfg
.localedit
= LD_BACKEND
;
2275 if (LOWORD(wParam
) == IDC_EDITYES
)
2276 cfg
.localedit
= LD_YES
;
2277 if (LOWORD(wParam
) == IDC_EDITNO
)
2278 cfg
.localedit
= LD_NO
;
2281 case IDC_ANSWEREDIT
:
2282 if (HIWORD(wParam
) == EN_CHANGE
)
2283 GetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
2284 sizeof(cfg
.answerback
) - 1);
2286 case IDC_ALWAYSONTOP
:
2287 if (HIWORD(wParam
) == BN_CLICKED
||
2288 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2290 IsDlgButtonChecked(hwnd
, IDC_ALWAYSONTOP
);
2292 case IDC_FULLSCREENONALTENTER
:
2293 if (HIWORD(wParam
) == BN_CLICKED
||
2294 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2295 cfg
.fullscreenonaltenter
=
2296 IsDlgButtonChecked(hwnd
, IDC_FULLSCREENONALTENTER
);
2299 if (HIWORD(wParam
) == BN_CLICKED
||
2300 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2302 IsDlgButtonChecked(hwnd
, IDC_SCROLLKEY
);
2304 case IDC_SCROLLDISP
:
2305 if (HIWORD(wParam
) == BN_CLICKED
||
2306 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2307 cfg
.scroll_on_disp
=
2308 IsDlgButtonChecked(hwnd
, IDC_SCROLLDISP
);
2310 case IDC_COMPOSEKEY
:
2311 if (HIWORD(wParam
) == BN_CLICKED
||
2312 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2314 IsDlgButtonChecked(hwnd
, IDC_COMPOSEKEY
);
2316 case IDC_CTRLALTKEYS
:
2317 if (HIWORD(wParam
) == BN_CLICKED
||
2318 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2320 IsDlgButtonChecked(hwnd
, IDC_CTRLALTKEYS
);
2323 if (HIWORD(wParam
) == BN_CLICKED
||
2324 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2325 cfg
.telnet_keyboard
=
2326 IsDlgButtonChecked(hwnd
, IDC_TELNETKEY
);
2329 if (HIWORD(wParam
) == BN_CLICKED
||
2330 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2332 IsDlgButtonChecked(hwnd
, IDC_WRAPMODE
);
2335 if (HIWORD(wParam
) == BN_CLICKED
||
2336 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2337 cfg
.dec_om
= IsDlgButtonChecked(hwnd
, IDC_DECOM
);
2340 if (HIWORD(wParam
) == BN_CLICKED
||
2341 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2343 IsDlgButtonChecked(hwnd
, IDC_LFHASCR
);
2346 if (HIWORD(wParam
) == EN_CHANGE
)
2347 MyGetDlgItemInt(hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
2350 if (HIWORD(wParam
) == EN_CHANGE
)
2351 MyGetDlgItemInt(hwnd
, IDC_COLSEDIT
, &cfg
.width
);
2354 if (HIWORD(wParam
) == EN_CHANGE
)
2355 MyGetDlgItemInt(hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
2357 case IDC_CHOOSEFONT
:
2360 lf
.lfHeight
= -MulDiv(cfg
.fontheight
,
2361 GetDeviceCaps(hdc
, LOGPIXELSY
),
2365 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
2366 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
2367 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
2368 lf
.lfCharSet
= cfg
.fontcharset
;
2369 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
2370 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
2371 lf
.lfQuality
= DEFAULT_QUALITY
;
2372 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
2373 strncpy(lf
.lfFaceName
, cfg
.font
,
2374 sizeof(lf
.lfFaceName
) - 1);
2375 lf
.lfFaceName
[sizeof(lf
.lfFaceName
) - 1] = '\0';
2377 cf
.lStructSize
= sizeof(cf
);
2378 cf
.hwndOwner
= hwnd
;
2380 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
2381 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
2383 if (ChooseFont(&cf
)) {
2384 strncpy(cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
) - 1);
2385 cfg
.font
[sizeof(cfg
.font
) - 1] = '\0';
2386 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
2387 cfg
.fontcharset
= lf
.lfCharSet
;
2388 cfg
.fontheight
= cf
.iPointSize
/ 10;
2389 fmtfont(fontstatic
);
2390 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
2393 case IDC_BELL_DISABLED
:
2394 case IDC_BELL_DEFAULT
:
2395 case IDC_BELL_WAVEFILE
:
2396 case IDC_BELL_VISUAL
:
2397 if (HIWORD(wParam
) == BN_CLICKED
||
2398 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2399 if (LOWORD(wParam
) == IDC_BELL_DISABLED
)
2400 cfg
.beep
= BELL_DISABLED
;
2401 if (LOWORD(wParam
) == IDC_BELL_DEFAULT
)
2402 cfg
.beep
= BELL_DEFAULT
;
2403 if (LOWORD(wParam
) == IDC_BELL_WAVEFILE
)
2404 cfg
.beep
= BELL_WAVEFILE
;
2405 if (LOWORD(wParam
) == IDC_BELL_VISUAL
)
2406 cfg
.beep
= BELL_VISUAL
;
2409 case IDC_B_IND_DISABLED
:
2410 case IDC_B_IND_FLASH
:
2411 case IDC_B_IND_STEADY
:
2412 if (HIWORD(wParam
) == BN_CLICKED
||
2413 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2414 if (LOWORD(wParam
) == IDC_B_IND_DISABLED
)
2415 cfg
.beep_ind
= B_IND_DISABLED
;
2416 if (LOWORD(wParam
) == IDC_B_IND_FLASH
)
2417 cfg
.beep_ind
= B_IND_FLASH
;
2418 if (LOWORD(wParam
) == IDC_B_IND_STEADY
)
2419 cfg
.beep_ind
= B_IND_STEADY
;
2422 case IDC_BELL_WAVEBROWSE
:
2423 memset(&of
, 0, sizeof(of
));
2424 #ifdef OPENFILENAME_SIZE_VERSION_400
2425 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2427 of
.lStructSize
= sizeof(of
);
2429 of
.hwndOwner
= hwnd
;
2430 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2431 of
.lpstrCustomFilter
= NULL
;
2432 of
.nFilterIndex
= 1;
2433 of
.lpstrFile
= filename
;
2434 strcpy(filename
, cfg
.bell_wavefile
);
2435 of
.nMaxFile
= sizeof(filename
);
2436 of
.lpstrFileTitle
= NULL
;
2437 of
.lpstrInitialDir
= NULL
;
2438 of
.lpstrTitle
= "Select Bell Sound File";
2440 if (GetOpenFileName(&of
)) {
2441 strcpy(cfg
.bell_wavefile
, filename
);
2442 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2446 case IDC_BELL_WAVEEDIT
:
2447 if (HIWORD(wParam
) == EN_CHANGE
)
2448 GetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2450 sizeof(cfg
.bell_wavefile
) - 1);
2453 if (HIWORD(wParam
) == BN_CLICKED
||
2454 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2456 IsDlgButtonChecked(hwnd
, IDC_BELLOVL
);
2459 if (HIWORD(wParam
) == EN_CHANGE
)
2460 MyGetDlgItemInt(hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
2463 if (HIWORD(wParam
) == EN_CHANGE
)
2464 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
,
2468 if (HIWORD(wParam
) == EN_CHANGE
)
2469 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
,
2473 if (HIWORD(wParam
) == BN_CLICKED
||
2474 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2476 IsDlgButtonChecked(hwnd
, IDC_BLINKTEXT
);
2479 if (HIWORD(wParam
) == BN_CLICKED
||
2480 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2481 cfg
.bce
= IsDlgButtonChecked(hwnd
, IDC_BCE
);
2484 if (HIWORD(wParam
) == BN_CLICKED
||
2485 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2486 cfg
.win_name_always
=
2487 IsDlgButtonChecked(hwnd
, IDC_WINNAME
);
2490 if (HIWORD(wParam
) == BN_CLICKED
||
2491 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2493 IsDlgButtonChecked(hwnd
, IDC_HIDEMOUSE
);
2495 case IDC_SUNKENEDGE
:
2496 if (HIWORD(wParam
) == BN_CLICKED
||
2497 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2499 IsDlgButtonChecked(hwnd
, IDC_SUNKENEDGE
);
2502 if (HIWORD(wParam
) == EN_CHANGE
)
2503 MyGetDlgItemInt(hwnd
, IDC_WINBEDIT
,
2504 &cfg
.window_border
);
2505 if (cfg
.window_border
> 32)
2506 cfg
.window_border
= 32;
2509 if (HIWORD(wParam
) == BN_CLICKED
||
2510 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2511 cfg
.cursor_type
= 0;
2514 if (HIWORD(wParam
) == BN_CLICKED
||
2515 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2516 cfg
.cursor_type
= 1;
2519 if (HIWORD(wParam
) == BN_CLICKED
||
2520 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2521 cfg
.cursor_type
= 2;
2524 if (HIWORD(wParam
) == BN_CLICKED
||
2525 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2527 IsDlgButtonChecked(hwnd
, IDC_BLINKCUR
);
2530 if (HIWORD(wParam
) == BN_CLICKED
||
2531 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2533 IsDlgButtonChecked(hwnd
, IDC_SCROLLBAR
);
2535 case IDC_SCROLLBARFULLSCREEN
:
2536 if (HIWORD(wParam
) == BN_CLICKED
||
2537 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2538 cfg
.scrollbar_in_fullscreen
=
2539 IsDlgButtonChecked(hwnd
, IDC_SCROLLBARFULLSCREEN
);
2541 case IDC_RESIZETERM
:
2542 case IDC_RESIZEFONT
:
2543 case IDC_RESIZENONE
:
2544 case IDC_RESIZEEITHER
:
2545 if (HIWORD(wParam
) == BN_CLICKED
||
2546 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2548 IsDlgButtonChecked(hwnd
,
2549 IDC_RESIZETERM
) ? RESIZE_TERM
:
2550 IsDlgButtonChecked(hwnd
,
2551 IDC_RESIZEFONT
) ? RESIZE_FONT
:
2552 IsDlgButtonChecked(hwnd
,
2553 IDC_RESIZEEITHER
) ? RESIZE_EITHER
:
2558 if (HIWORD(wParam
) == EN_CHANGE
)
2559 GetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
2560 sizeof(cfg
.wintitle
) - 1);
2565 if (HIWORD(wParam
) == BN_CLICKED
||
2566 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2568 IsDlgButtonChecked(hwnd
,
2569 IDC_COEALWAYS
) ? COE_ALWAYS
:
2570 IsDlgButtonChecked(hwnd
,
2571 IDC_COENEVER
) ? COE_NEVER
:
2576 if (HIWORD(wParam
) == BN_CLICKED
||
2577 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2579 IsDlgButtonChecked(hwnd
, IDC_CLOSEWARN
);
2582 if (HIWORD(wParam
) == EN_CHANGE
)
2583 GetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
,
2584 sizeof(cfg
.termtype
) - 1);
2587 if (HIWORD(wParam
) == EN_CHANGE
)
2588 GetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
2589 sizeof(cfg
.logfilename
) - 1);
2592 memset(&of
, 0, sizeof(of
));
2593 #ifdef OPENFILENAME_SIZE_VERSION_400
2594 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2596 of
.lStructSize
= sizeof(of
);
2598 of
.hwndOwner
= hwnd
;
2599 of
.lpstrFilter
= "All Files\0*\0\0\0";
2600 of
.lpstrCustomFilter
= NULL
;
2601 of
.nFilterIndex
= 1;
2602 of
.lpstrFile
= filename
;
2603 strcpy(filename
, cfg
.logfilename
);
2604 of
.nMaxFile
= sizeof(filename
);
2605 of
.lpstrFileTitle
= NULL
;
2606 of
.lpstrInitialDir
= NULL
;
2607 of
.lpstrTitle
= "Select session log file";
2609 if (GetSaveFileName(&of
)) {
2610 strcpy(cfg
.logfilename
, filename
);
2611 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
2615 case IDC_LSTATASCII
:
2617 case IDC_LSTATPACKET
:
2618 if (HIWORD(wParam
) == BN_CLICKED
||
2619 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2620 if (IsDlgButtonChecked(hwnd
, IDC_LSTATOFF
))
2621 cfg
.logtype
= LGTYP_NONE
;
2622 if (IsDlgButtonChecked(hwnd
, IDC_LSTATASCII
))
2623 cfg
.logtype
= LGTYP_ASCII
;
2624 if (IsDlgButtonChecked(hwnd
, IDC_LSTATRAW
))
2625 cfg
.logtype
= LGTYP_DEBUG
;
2626 if (IsDlgButtonChecked(hwnd
, IDC_LSTATPACKET
))
2627 cfg
.logtype
= LGTYP_PACKETS
;
2633 if (HIWORD(wParam
) == BN_CLICKED
||
2634 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2635 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXASK
))
2636 cfg
.logxfovr
= LGXF_ASK
;
2637 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXAPN
))
2638 cfg
.logxfovr
= LGXF_APN
;
2639 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXOVR
))
2640 cfg
.logxfovr
= LGXF_OVR
;
2645 if (HIWORD(wParam
) == EN_CHANGE
)
2646 GetDlgItemText(hwnd
, LOWORD(wParam
), cfg
.termspeed
,
2647 sizeof(cfg
.termspeed
) - 1);
2650 if (HIWORD(wParam
) == EN_CHANGE
)
2651 GetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
,
2652 sizeof(cfg
.username
) - 1);
2654 case IDC_RLLUSEREDIT
:
2655 if (HIWORD(wParam
) == EN_CHANGE
)
2656 GetDlgItemText(hwnd
, IDC_RLLUSEREDIT
,
2658 sizeof(cfg
.localusername
) - 1);
2662 cfg
.rfc_environ
= IsDlgButtonChecked(hwnd
, IDC_EMRFC
);
2666 cfg
.passive_telnet
=
2667 IsDlgButtonChecked(hwnd
, IDC_TPASSIVE
);
2670 if (HIWORD(wParam
) == BN_CLICKED
||
2671 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2672 char str
[sizeof(cfg
.environmt
)];
2674 GetDlgItemText(hwnd
, IDC_VAREDIT
, str
,
2680 p
= str
+ strlen(str
);
2682 GetDlgItemText(hwnd
, IDC_VALEDIT
, p
,
2683 sizeof(str
) - 1 - (p
- str
));
2694 if ((p
- cfg
.environmt
) + strlen(str
) + 2 <
2695 sizeof(cfg
.environmt
)) {
2697 p
[strlen(str
) + 1] = '\0';
2698 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
2700 SetDlgItemText(hwnd
, IDC_VAREDIT
, "");
2701 SetDlgItemText(hwnd
, IDC_VALEDIT
, "");
2703 MessageBox(hwnd
, "Environment too big",
2704 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2709 if (HIWORD(wParam
) != BN_CLICKED
&&
2710 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2712 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0,
2719 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
2746 if (HIWORD(wParam
) == BN_CLICKED
||
2747 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2748 cfg
.nopty
= IsDlgButtonChecked(hwnd
, IDC_NOPTY
);
2751 if (HIWORD(wParam
) == BN_CLICKED
||
2752 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2754 IsDlgButtonChecked(hwnd
, IDC_COMPRESS
);
2757 if (HIWORD(wParam
) == BN_CLICKED
||
2758 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2760 IsDlgButtonChecked(hwnd
, IDC_BUGGYMAC
);
2763 if (HIWORD(wParam
) == BN_CLICKED
||
2764 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2766 IsDlgButtonChecked(hwnd
, IDC_SSH2DES
);
2769 if (HIWORD(wParam
) == BN_CLICKED
||
2770 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2772 IsDlgButtonChecked(hwnd
, IDC_AGENTFWD
);
2774 case IDC_CHANGEUSER
:
2775 if (HIWORD(wParam
) == BN_CLICKED
||
2776 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2777 cfg
.change_username
=
2778 IsDlgButtonChecked(hwnd
, IDC_CHANGEUSER
);
2780 case IDC_CIPHERLIST
:
2783 handle_prefslist(&cipherlist
,
2784 cfg
.ssh_cipherlist
, CIPHER_MAX
,
2785 0, hwnd
, wParam
, lParam
);
2789 if (HIWORD(wParam
) == BN_CLICKED
||
2790 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2791 if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT1
))
2793 else if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT2
))
2798 if (HIWORD(wParam
) == BN_CLICKED
||
2799 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2801 IsDlgButtonChecked(hwnd
, IDC_AUTHTIS
);
2804 if (HIWORD(wParam
) == BN_CLICKED
||
2805 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2807 IsDlgButtonChecked(hwnd
, IDC_AUTHKI
);
2810 if (HIWORD(wParam
) == EN_CHANGE
)
2811 GetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
2812 sizeof(cfg
.keyfile
) - 1);
2815 if (HIWORD(wParam
) == EN_CHANGE
)
2816 GetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
2817 sizeof(cfg
.remote_cmd
) - 1);
2820 memset(&of
, 0, sizeof(of
));
2821 #ifdef OPENFILENAME_SIZE_VERSION_400
2822 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2824 of
.lStructSize
= sizeof(of
);
2826 of
.hwndOwner
= hwnd
;
2827 of
.lpstrFilter
= "All Files\0*\0\0\0";
2828 of
.lpstrCustomFilter
= NULL
;
2829 of
.nFilterIndex
= 1;
2830 of
.lpstrFile
= filename
;
2831 strcpy(filename
, cfg
.keyfile
);
2832 of
.nMaxFile
= sizeof(filename
);
2833 of
.lpstrFileTitle
= NULL
;
2834 of
.lpstrInitialDir
= NULL
;
2835 of
.lpstrTitle
= "Select Private Key File";
2837 if (GetOpenFileName(&of
)) {
2838 strcpy(cfg
.keyfile
, filename
);
2839 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
2843 cfg
.rawcnp
= IsDlgButtonChecked(hwnd
, IDC_RAWCNP
);
2846 cfg
.rtf_paste
= IsDlgButtonChecked(hwnd
, IDC_RTFPASTE
);
2850 cfg
.mouse_is_xterm
= IsDlgButtonChecked(hwnd
, IDC_MBXTERM
);
2852 case IDC_SELTYPELEX
:
2853 case IDC_SELTYPERECT
:
2854 cfg
.rect_select
= IsDlgButtonChecked(hwnd
, IDC_SELTYPERECT
);
2856 case IDC_MOUSEOVERRIDE
:
2857 cfg
.mouse_override
= IsDlgButtonChecked(hwnd
, IDC_MOUSEOVERRIDE
);
2863 int n
= GetDlgItemInt(hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
2868 for (i
= 0; i
< 128; i
++)
2869 if (SendDlgItemMessage
2870 (hwnd
, IDC_CCLIST
, LB_GETSEL
, i
, 0)) {
2872 cfg
.wordness
[i
] = n
;
2873 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2874 LB_DELETESTRING
, i
, 0);
2875 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
2876 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ',
2878 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2885 case IDC_BOLDCOLOUR
:
2886 if (HIWORD(wParam
) == BN_CLICKED
||
2887 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2890 IsDlgButtonChecked(hwnd
, IDC_BOLDCOLOUR
);
2891 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2894 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2896 if (n
!= 12 + 10 * cfg
.bold_colour
) {
2897 for (i
= n
; i
-- > 0;)
2898 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2899 LB_DELETESTRING
, i
, 0);
2900 for (i
= 0; i
< 22; i
++)
2901 if (cfg
.bold_colour
|| permcolour
[i
])
2902 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2904 (LPARAM
) colours
[i
]);
2906 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2908 InvalidateRect(GetDlgItem(hwnd
, IDC_COLOURLIST
), NULL
,
2913 if (HIWORD(wParam
) == BN_CLICKED
||
2914 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2916 IsDlgButtonChecked(hwnd
, IDC_PALETTE
);
2918 case IDC_COLOURLIST
:
2919 if (HIWORD(wParam
) == LBN_DBLCLK
||
2920 HIWORD(wParam
) == LBN_SELCHANGE
) {
2922 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2925 if (!cfg
.bold_colour
)
2926 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2927 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2929 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2931 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2936 if (HIWORD(wParam
) == BN_CLICKED
||
2937 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2938 static CHOOSECOLOR cc
;
2939 static DWORD custom
[16] = { 0 }; /* zero initialisers */
2941 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2944 if (!cfg
.bold_colour
)
2945 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2946 cc
.lStructSize
= sizeof(cc
);
2947 cc
.hwndOwner
= hwnd
;
2948 cc
.hInstance
= (HWND
) hinst
;
2949 cc
.lpCustColors
= custom
;
2951 RGB(cfg
.colours
[i
][0], cfg
.colours
[i
][1],
2953 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
2954 if (ChooseColor(&cc
)) {
2956 (unsigned char) (cc
.rgbResult
& 0xFF);
2958 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
2960 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
2961 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2963 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2965 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2971 if (HIWORD(wParam
) == CBN_SELCHANGE
) {
2972 int index
= SendDlgItemMessage(hwnd
, IDC_CODEPAGE
,
2973 CB_GETCURSEL
, 0, 0);
2974 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_GETLBTEXT
,
2975 index
, (LPARAM
)cfg
.line_codepage
);
2976 } else if (HIWORD(wParam
) == CBN_EDITCHANGE
) {
2977 GetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
,
2978 sizeof(cfg
.line_codepage
) - 1);
2979 } else if (HIWORD(wParam
) == CBN_KILLFOCUS
) {
2980 strcpy(cfg
.line_codepage
,
2981 cp_name(decode_codepage(cfg
.line_codepage
)));
2982 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
2985 case IDC_CAPSLOCKCYR
:
2986 if (HIWORD(wParam
) == BN_CLICKED
||
2987 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2988 cfg
.xlat_capslockcyr
=
2989 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
2992 case IDC_VTXWINDOWS
:
2998 (IsDlgButtonChecked(hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
2999 : IsDlgButtonChecked(hwnd
,
3000 IDC_VTOEMANSI
) ? VT_OEMANSI
:
3001 IsDlgButtonChecked(hwnd
,
3002 IDC_VTOEMONLY
) ? VT_OEMONLY
:
3003 IsDlgButtonChecked(hwnd
,
3004 IDC_VTUNICODE
) ? VT_UNICODE
:
3007 case IDC_X11_FORWARD
:
3008 if (HIWORD(wParam
) == BN_CLICKED
||
3009 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3011 IsDlgButtonChecked(hwnd
, IDC_X11_FORWARD
);
3014 if (HIWORD(wParam
) == BN_CLICKED
||
3015 HIWORD(wParam
) == BN_DOUBLECLICKED
)
3016 cfg
.lport_acceptall
=
3017 IsDlgButtonChecked(hwnd
, IDC_LPORT_ALL
);
3019 case IDC_X11_DISPLAY
:
3020 if (HIWORD(wParam
) == EN_CHANGE
)
3021 GetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
3022 sizeof(cfg
.x11_display
) - 1);
3025 if (HIWORD(wParam
) == BN_CLICKED
||
3026 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
3027 char str
[sizeof(cfg
.portfwd
)];
3029 if (IsDlgButtonChecked(hwnd
, IDC_PFWDLOCAL
))
3033 GetDlgItemText(hwnd
, IDC_SPORTEDIT
, str
+1,
3037 "You need to specify a source port number",
3038 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3041 p
= str
+ strlen(str
);
3043 GetDlgItemText(hwnd
, IDC_DPORTEDIT
, p
,
3044 sizeof(str
) - 1 - (p
- str
));
3045 if (!*p
|| !strchr(p
, ':')) {
3047 "You need to specify a destination address\n"
3048 "in the form \"host.name:port\"",
3049 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3058 if ((p
- cfg
.portfwd
) + strlen(str
) + 2 <
3059 sizeof(cfg
.portfwd
)) {
3061 p
[strlen(str
) + 1] = '\0';
3062 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
,
3064 SetDlgItemText(hwnd
, IDC_SPORTEDIT
, "");
3065 SetDlgItemText(hwnd
, IDC_DPORTEDIT
, "");
3067 MessageBox(hwnd
, "Too many forwardings",
3068 "PuTTY Error", MB_OK
| MB_ICONERROR
);
3072 case IDC_PFWDREMOVE
:
3073 if (HIWORD(wParam
) != BN_CLICKED
&&
3074 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
3075 i
= SendDlgItemMessage(hwnd
, IDC_PFWDLIST
,
3076 LB_GETCURSEL
, 0, 0);
3082 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_DELETESTRING
,
3112 int id
= ((LPHELPINFO
)lParam
)->iCtrlId
;
3113 char *cmd
= help_context_cmd(id
);
3115 WinHelp(hwnd
, help_path
, HELP_COMMAND
, (DWORD
)cmd
);
3116 requested_help
= TRUE
;
3123 if (requested_help
) {
3124 WinHelp(hwnd
, help_path
, HELP_QUIT
, 0);
3125 requested_help
= FALSE
;
3130 /* Grrr Explorer will maximize Dialogs! */
3132 if (wParam
== SIZE_MAXIMIZED
)
3138 * Handle application-defined messages eg. DragListBox
3140 /* First find out what the number is (once). */
3141 if (draglistmsg
== WM_NULL
)
3142 draglistmsg
= RegisterWindowMessage (DRAGLISTMSGSTRING
);
3144 if (msg
== draglistmsg
) {
3145 /* Only process once dialog is fully formed. */
3146 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
3147 case IDC_CIPHERLIST
:
3148 return handle_prefslist(&cipherlist
,
3149 cfg
.ssh_cipherlist
, CIPHER_MAX
,
3150 1, hwnd
, wParam
, lParam
);
3159 static int CALLBACK
MainDlgProc(HWND hwnd
, UINT msg
,
3160 WPARAM wParam
, LPARAM lParam
)
3162 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
3164 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
3165 EnableWindow(hwnd
, 0);
3166 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
3167 EnableWindow(hwnd
, 1);
3168 SetActiveWindow(hwnd
);
3170 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 0);
3173 static int CALLBACK
ReconfDlgProc(HWND hwnd
, UINT msg
,
3174 WPARAM wParam
, LPARAM lParam
)
3176 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 1);
3179 void defuse_showwindow(void)
3182 * Work around the fact that the app's first call to ShowWindow
3183 * will ignore the default in favour of the shell-provided
3188 hwnd
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
3190 ShowWindow(hwnd
, SW_HIDE
);
3191 SetActiveWindow(hwnd
);
3192 DestroyWindow(hwnd
);
3201 savedsession
[0] = '\0';
3203 DialogBox(hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
3204 get_sesslist(FALSE
);
3209 int do_reconfig(HWND hwnd
)
3214 backup_cfg
= cfg
; /* structure copy */
3216 DialogBox(hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
3218 cfg
= backup_cfg
; /* structure copy */
3223 void logevent(char *string
)
3228 if (nevents
>= negsize
) {
3230 events
= srealloc(events
, negsize
* sizeof(*events
));
3234 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t",
3237 events
[nevents
] = smalloc(strlen(timebuf
) + strlen(string
) + 1);
3238 strcpy(events
[nevents
], timebuf
);
3239 strcat(events
[nevents
], string
);
3242 SendDlgItemMessage(logbox
, IDN_LIST
, LB_ADDSTRING
,
3243 0, (LPARAM
) events
[nevents
]);
3244 count
= SendDlgItemMessage(logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
3245 SendDlgItemMessage(logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
- 1, 0);
3250 void showeventlog(HWND hwnd
)
3253 logbox
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
3255 ShowWindow(logbox
, SW_SHOWNORMAL
);
3257 SetActiveWindow(logbox
);
3260 void showabout(HWND hwnd
)
3262 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
3265 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
3266 char *keystr
, char *fingerprint
)
3270 static const char absentmsg
[] =
3271 "The server's host key is not cached in the registry. You\n"
3272 "have no guarantee that the server is the computer you\n"
3274 "The server's key fingerprint is:\n"
3276 "If you trust this host, hit Yes to add the key to\n"
3277 "PuTTY's cache and carry on connecting.\n"
3278 "If you want to carry on connecting just once, without\n"
3279 "adding the key to the cache, hit No.\n"
3280 "If you do not trust this host, hit Cancel to abandon the\n"
3283 static const char wrongmsg
[] =
3284 "WARNING - POTENTIAL SECURITY BREACH!\n"
3286 "The server's host key does not match the one PuTTY has\n"
3287 "cached in the registry. This means that either the\n"
3288 "server administrator has changed the host key, or you\n"
3289 "have actually connected to another computer pretending\n"
3290 "to be the server.\n"
3291 "The new key fingerprint is:\n"
3293 "If you were expecting this change and trust the new key,\n"
3294 "hit Yes to update PuTTY's cache and continue connecting.\n"
3295 "If you want to carry on connecting but without updating\n"
3296 "the cache, hit No.\n"
3297 "If you want to abandon the connection completely, hit\n"
3298 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
3300 static const char mbtitle
[] = "PuTTY Security Alert";
3303 /* sensible fingerprint max size */
3304 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
3305 sizeof(absentmsg
) : sizeof(wrongmsg
))];
3308 * Verify the key against the registry.
3310 ret
= verify_host_key(host
, port
, keytype
, keystr
);
3312 if (ret
== 0) /* success - key matched OK */
3314 if (ret
== 2) { /* key was different */
3316 sprintf(message
, wrongmsg
, fingerprint
);
3317 mbret
= MessageBox(NULL
, message
, mbtitle
,
3318 MB_ICONWARNING
| MB_YESNOCANCEL
);
3320 store_host_key(host
, port
, keytype
, keystr
);
3321 if (mbret
== IDCANCEL
)
3324 if (ret
== 1) { /* key was absent */
3326 sprintf(message
, absentmsg
, fingerprint
);
3327 mbret
= MessageBox(NULL
, message
, mbtitle
,
3328 MB_ICONWARNING
| MB_YESNOCANCEL
);
3330 store_host_key(host
, port
, keytype
, keystr
);
3331 if (mbret
== IDCANCEL
)
3337 * Ask whether the selected cipher is acceptable (since it was
3338 * below the configured 'warn' threshold).
3339 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3341 void askcipher(char *ciphername
, int cs
)
3343 static const char mbtitle
[] = "PuTTY Security Alert";
3344 static const char msg
[] =
3345 "The first %.35scipher supported by the server\n"
3346 "is %.64s, which is below the configured\n"
3347 "warning threshold.\n"
3348 "Do you want to continue with this connection?\n";
3349 /* guessed cipher name + type max length */
3350 char message
[100 + sizeof(msg
)];
3353 sprintf(message
, msg
,
3355 (cs
== 1) ?
"client-to-server " :
3356 "server-to-client ",
3358 mbret
= MessageBox(NULL
, message
, mbtitle
,
3359 MB_ICONWARNING
| MB_YESNO
);
3367 * Ask whether to wipe a session log file before writing to it.
3368 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3370 int askappend(char *filename
)
3372 static const char mbtitle
[] = "PuTTY Log to File";
3373 static const char msgtemplate
[] =
3374 "The session log file \"%.*s\" already exists.\n"
3375 "You can overwrite it with a new session log,\n"
3376 "append your session log to the end of it,\n"
3377 "or disable session logging for this session.\n"
3378 "Hit Yes to wipe the file, No to append to it,\n"
3379 "or Cancel to disable logging.";
3380 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
3382 if (cfg
.logxfovr
!= LGXF_ASK
) {
3383 return ((cfg
.logxfovr
== LGXF_OVR
) ?
2 : 1);
3385 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
3387 mbret
= MessageBox(NULL
, message
, mbtitle
,
3388 MB_ICONQUESTION
| MB_YESNOCANCEL
);
3391 else if (mbret
== IDNO
)
3398 * Warn about the obsolescent key file format.
3400 void old_keyfile_warning(void)
3402 static const char mbtitle
[] = "PuTTY Key File Warning";
3403 static const char message
[] =
3404 "You are loading an SSH 2 private key which has an\n"
3405 "old version of the file format. This means your key\n"
3406 "file is not fully tamperproof. Future versions of\n"
3407 "PuTTY may stop supporting this private key format,\n"
3408 "so we recommend you convert your key to the new\n"
3411 "You can perform this conversion by loading the key\n"
3412 "into PuTTYgen and then saving it again.";
3414 MessageBox(NULL
, message
, mbtitle
, MB_OK
);