15 static char **events
= NULL
;
16 static int nevents
= 0, negsize
= 0;
19 static int sesslist_has_focus
;
21 static struct prefslist cipherlist
;
23 void force_normal(HWND hwnd
)
25 static int recurse
= 0;
33 wp
.length
= sizeof(wp
);
34 if (GetWindowPlacement(hwnd
, &wp
) && wp
.showCmd
== SW_SHOWMAXIMIZED
) {
35 wp
.showCmd
= SW_SHOWNORMAL
;
36 SetWindowPlacement(hwnd
, &wp
);
41 static void MyGetDlgItemInt(HWND hwnd
, int id
, int *result
)
45 n
= GetDlgItemInt(hwnd
, id
, &ok
, FALSE
);
50 static void MyGetDlgItemFlt(HWND hwnd
, int id
, int *result
, int scale
)
54 ok
= GetDlgItemText(hwnd
, id
, text
, sizeof(text
) - 1);
56 *result
= (int) (scale
* atof(text
));
59 static void MySetDlgItemFlt(HWND hwnd
, int id
, double value
)
62 sprintf(text
, "%g", value
);
63 SetDlgItemText(hwnd
, id
, text
);
66 static int CALLBACK
LogProc(HWND hwnd
, UINT msg
,
67 WPARAM wParam
, LPARAM lParam
)
74 static int tabs
[4] = { 78, 108 };
75 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETTABSTOPS
, 2,
78 for (i
= 0; i
< nevents
; i
++)
79 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_ADDSTRING
,
80 0, (LPARAM
) events
[i
]);
83 switch (LOWORD(wParam
)) {
87 SetActiveWindow(GetParent(hwnd
));
91 if (HIWORD(wParam
) == BN_CLICKED
||
92 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
95 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
96 LB_GETSELCOUNT
, 0, 0);
97 if (selcount
== 0) { /* don't even try to copy zero items */
102 selitems
= smalloc(selcount
* sizeof(int));
104 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
111 static unsigned char sel_nl
[] = SEL_NL
;
113 if (count
== 0) { /* can't copy zero stuff */
119 for (i
= 0; i
< count
; i
++)
121 strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
123 clipdata
= smalloc(size
);
126 for (i
= 0; i
< count
; i
++) {
127 char *q
= events
[selitems
[i
]];
128 int qlen
= strlen(q
);
131 memcpy(p
, sel_nl
, sizeof(sel_nl
));
134 write_aclip(clipdata
, size
, TRUE
);
139 for (i
= 0; i
< nevents
; i
++)
140 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
149 SetActiveWindow(GetParent(hwnd
));
156 static int CALLBACK
LicenceProc(HWND hwnd
, UINT msg
,
157 WPARAM wParam
, LPARAM lParam
)
163 switch (LOWORD(wParam
)) {
176 static int CALLBACK
AboutProc(HWND hwnd
, UINT msg
,
177 WPARAM wParam
, LPARAM lParam
)
181 SetDlgItemText(hwnd
, IDA_VERSION
, ver
);
184 switch (LOWORD(wParam
)) {
187 EndDialog(hwnd
, TRUE
);
190 EnableWindow(hwnd
, 0);
191 DialogBox(hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
193 EnableWindow(hwnd
, 1);
194 SetActiveWindow(hwnd
);
198 /* Load web browser */
199 ShellExecute(hwnd
, "open",
200 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
201 0, 0, SW_SHOWDEFAULT
);
206 EndDialog(hwnd
, TRUE
);
213 * Null dialog procedure.
215 static int CALLBACK
NullDlgProc(HWND hwnd
, UINT msg
,
216 WPARAM wParam
, LPARAM lParam
)
221 static char savedsession
[2048];
224 IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
368 IDC_FULLSCREENONALTENTER
,
371 appearancepanelstart
,
372 IDC_TITLE_APPEARANCE
,
392 connectionpanelstart
,
393 IDC_TITLE_CONNECTION
,
501 translationpanelstart
,
502 IDC_TITLE_TRANSLATION
,
503 IDC_BOX_TRANSLATION1
,
504 IDC_BOX_TRANSLATION2
,
540 static const char *const colours
[] = {
541 "Default Foreground", "Default Bold Foreground",
542 "Default Background", "Default Bold Background",
543 "Cursor Text", "Cursor Colour",
544 "ANSI Black", "ANSI Black Bold",
545 "ANSI Red", "ANSI Red Bold",
546 "ANSI Green", "ANSI Green Bold",
547 "ANSI Yellow", "ANSI Yellow Bold",
548 "ANSI Blue", "ANSI Blue Bold",
549 "ANSI Magenta", "ANSI Magenta Bold",
550 "ANSI Cyan", "ANSI Cyan Bold",
551 "ANSI White", "ANSI White Bold"
553 static const int permcolour
[] = {
554 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
555 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
556 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
559 static void fmtfont(char *buf
)
561 sprintf(buf
, "Font: %s, ", cfg
.font
);
563 strcat(buf
, "bold, ");
564 if (cfg
.fontheight
== 0)
565 strcat(buf
, "default height");
567 sprintf(buf
+ strlen(buf
), "%d-point",
568 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
571 /* 2nd arg: NZ => don't redraw session list (use when loading
573 static void init_dlg_ctrls(HWND hwnd
, int keepsess
)
576 char fontstatic
[256];
578 SetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
);
579 SetDlgItemText(hwnd
, IDC_SESSEDIT
, savedsession
);
582 n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
583 for (i
= n
; i
-- > 0;)
584 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_DELETESTRING
, i
, 0);
585 for (i
= 0; i
< nsessions
; i
++)
586 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
587 0, (LPARAM
) (sessions
[i
]));
589 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
590 CheckRadioButton(hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
591 cfg
.protocol
== PROT_SSH ? IDC_PROTSSH
:
592 cfg
.protocol
== PROT_TELNET ? IDC_PROTTELNET
:
594 PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
595 SetDlgItemInt(hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
597 CheckRadioButton(hwnd
, IDC_DEL008
, IDC_DEL127
,
598 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
599 CheckRadioButton(hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
600 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
601 CheckRadioButton(hwnd
, IDC_FUNCTILDE
, IDC_FUNCSCO
,
602 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
603 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
604 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
605 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
606 cfg
.funky_type
== 4 ? IDC_FUNCVT100P
:
607 cfg
.funky_type
== 5 ? IDC_FUNCSCO
: IDC_FUNCTILDE
);
608 CheckDlgButton(hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
609 CheckDlgButton(hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
610 CheckRadioButton(hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
611 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
612 CheckRadioButton(hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
613 cfg
.nethack_keypad ? IDC_KPNH
:
614 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
615 CheckDlgButton(hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
616 CheckDlgButton(hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
617 CheckDlgButton(hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
618 CheckDlgButton(hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
619 CheckDlgButton(hwnd
, IDC_CTRLALTKEYS
, cfg
.ctrlaltkeys
);
620 CheckDlgButton(hwnd
, IDC_TELNETKEY
, cfg
.telnet_keyboard
);
621 CheckRadioButton(hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
622 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
623 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
624 CheckRadioButton(hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
625 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
626 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
627 SetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
);
628 CheckDlgButton(hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
629 CheckDlgButton(hwnd
, IDC_FULLSCREENONALTENTER
, cfg
.fullscreenonaltenter
);
630 CheckDlgButton(hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
631 CheckDlgButton(hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
633 CheckDlgButton(hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
634 CheckDlgButton(hwnd
, IDC_DECOM
, cfg
.dec_om
);
635 CheckDlgButton(hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
636 SetDlgItemInt(hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
637 SetDlgItemInt(hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
638 SetDlgItemInt(hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
640 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
641 CheckRadioButton(hwnd
, IDC_BELL_DISABLED
, IDC_BELL_VISUAL
,
642 cfg
.beep
== BELL_DISABLED ? IDC_BELL_DISABLED
:
643 cfg
.beep
== BELL_DEFAULT ? IDC_BELL_DEFAULT
:
644 cfg
.beep
== BELL_WAVEFILE ? IDC_BELL_WAVEFILE
:
646 BELL_VISUAL ? IDC_BELL_VISUAL
: IDC_BELL_DEFAULT
);
647 CheckRadioButton(hwnd
, IDC_B_IND_DISABLED
, IDC_B_IND_STEADY
,
649 B_IND_DISABLED ? IDC_B_IND_DISABLED
: cfg
.beep_ind
==
650 B_IND_FLASH ? IDC_B_IND_FLASH
: cfg
.beep_ind
==
651 B_IND_STEADY ? IDC_B_IND_STEADY
: IDC_B_IND_DISABLED
);
652 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
653 CheckDlgButton(hwnd
, IDC_BELLOVL
, cfg
.bellovl
);
654 SetDlgItemInt(hwnd
, IDC_BELLOVLN
, cfg
.bellovl_n
, FALSE
);
655 MySetDlgItemFlt(hwnd
, IDC_BELLOVLT
, cfg
.bellovl_t
/ 1000.0);
656 MySetDlgItemFlt(hwnd
, IDC_BELLOVLS
, cfg
.bellovl_s
/ 1000.0);
658 CheckDlgButton(hwnd
, IDC_BCE
, cfg
.bce
);
659 CheckDlgButton(hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
661 SetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
662 CheckDlgButton(hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
663 CheckDlgButton(hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
664 CheckDlgButton(hwnd
, IDC_SUNKENEDGE
, cfg
.sunken_edge
);
665 CheckRadioButton(hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
666 cfg
.cursor_type
== 0 ? IDC_CURBLOCK
:
667 cfg
.cursor_type
== 1 ? IDC_CURUNDER
: IDC_CURVERT
);
668 CheckDlgButton(hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
669 CheckDlgButton(hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
670 CheckDlgButton(hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
671 CheckRadioButton(hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
672 cfg
.close_on_exit
== COE_NORMAL ? IDC_COENORMAL
:
674 COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
675 CheckDlgButton(hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
677 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
678 SetDlgItemText(hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
679 SetDlgItemText(hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
680 SetDlgItemText(hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
681 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
682 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
683 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
684 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
685 cfg
.logtype
== 1 ? IDC_LSTATASCII
: IDC_LSTATRAW
);
686 CheckRadioButton(hwnd
, IDC_LSTATXOVR
, IDC_LSTATXASK
,
687 cfg
.logxfovr
== LGXF_OVR ? IDC_LSTATXOVR
:
688 cfg
.logxfovr
== LGXF_ASK ? IDC_LSTATXASK
:
691 char *p
= cfg
.environmt
;
692 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_RESETCONTENT
, 0, 0);
694 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
700 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
, 0,
705 CheckRadioButton(hwnd
, IDC_EMBSD
, IDC_EMRFC
,
706 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
707 CheckRadioButton(hwnd
, IDC_TPASSIVE
, IDC_TACTIVE
,
708 cfg
.passive_telnet ? IDC_TPASSIVE
: IDC_TACTIVE
);
710 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
711 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
712 CheckDlgButton(hwnd
, IDC_NOPTY
, cfg
.nopty
);
713 CheckDlgButton(hwnd
, IDC_COMPRESS
, cfg
.compression
);
714 CheckDlgButton(hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
715 CheckDlgButton(hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
716 CheckRadioButton(hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
717 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
718 CheckDlgButton(hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
719 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
720 SetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
724 static const struct { char *s
; int c
; } ciphers
[] = {
725 { "3DES", CIPHER_3DES
},
726 { "Blowfish", CIPHER_BLOWFISH
},
727 { "DES (SSH 1 only)", CIPHER_DES
},
728 { "AES (SSH 2 only)", CIPHER_AES
},
729 { "-- warn below here --", CIPHER_WARN
}
732 /* Set up the "selected ciphers" box. */
733 /* (cipherlist assumed to contain all ciphers) */
734 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_RESETCONTENT
, 0, 0);
735 for (i
= 0; i
< CIPHER_MAX
; i
++) {
736 int c
= cfg
.ssh_cipherlist
[i
];
739 for (j
= 0; j
< (sizeof ciphers
) / (sizeof ciphers
[0]); j
++) {
740 if (ciphers
[j
].c
== c
) {
745 pos
= SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_ADDSTRING
,
747 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_SETITEMDATA
,
754 CheckRadioButton(hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
755 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
756 CheckDlgButton(hwnd
, IDC_MOUSEOVERRIDE
, cfg
.mouse_override
);
757 CheckDlgButton(hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
759 static int tabs
[4] = { 25, 61, 96, 128 };
760 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
763 for (i
= 0; i
< 128; i
++) {
765 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
766 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ', cfg
.wordness
[i
]);
767 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
771 CheckDlgButton(hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
772 CheckDlgButton(hwnd
, IDC_PALETTE
, cfg
.try_palette
);
775 n
= SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
776 for (i
= n
; i
-- > 0;)
777 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
778 LB_DELETESTRING
, i
, 0);
779 for (i
= 0; i
< 22; i
++)
780 if (cfg
.bold_colour
|| permcolour
[i
])
781 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
782 (LPARAM
) colours
[i
]);
784 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
785 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
786 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
787 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
792 strcpy(cfg
.line_codepage
, cp_name(decode_codepage(cfg
.line_codepage
)));
793 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_RESETCONTENT
, 0, 0);
794 for (i
= 0; (cp
= cp_enumerate(i
)) != NULL
; i
++) {
795 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_ADDSTRING
,
798 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
801 CheckRadioButton(hwnd
, IDC_VTXWINDOWS
, IDC_VTUNICODE
,
802 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
803 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
804 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
805 cfg
.vtmode
== VT_UNICODE ? IDC_VTUNICODE
:
808 CheckDlgButton(hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
809 SetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
811 CheckDlgButton(hwnd
, IDC_LPORT_ALL
, cfg
.lport_acceptall
);
812 CheckRadioButton(hwnd
, IDC_PFWDLOCAL
, IDC_PFWDREMOTE
, IDC_PFWDLOCAL
);
815 struct treeview_faff
{
820 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
821 int level
, char *text
)
826 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
- 1] : TVI_ROOT
);
827 ins
.hInsertAfter
= faff
->lastat
[level
];
828 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
829 #define INSITEM DUMMYUNIONNAME.item
833 ins
.INSITEM
.mask
= TVIF_TEXT
;
834 ins
.INSITEM
.pszText
= text
;
835 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
837 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
- 1],
839 faff
->lastat
[level
] = newitem
;
840 for (i
= level
+ 1; i
< 4; i
++)
841 faff
->lastat
[i
] = NULL
;
846 * Create the panelfuls of controls in the configuration box.
848 static void create_controls(HWND hwnd
, int dlgtype
, int panel
)
850 if (panel
== sessionpanelstart
) {
851 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
853 ctlposinit(&cp
, hwnd
, 80, 3, 13);
854 bartitle(&cp
, "Basic options for your PuTTY session",
857 beginbox(&cp
, "Specify your connection by host name or IP address",
860 "Host &Name (or IP address)",
861 IDC_HOSTSTATIC
, IDC_HOST
, 75,
862 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
863 if (backends
[3].backend
== NULL
) {
864 /* this is PuTTYtel, so only three protocols available */
865 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 3,
867 "&Telnet", IDC_PROTTELNET
,
868 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
870 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
872 "&Telnet", IDC_PROTTELNET
,
873 "Rlog&in", IDC_PROTRLOGIN
,
882 beginbox(&cp
, "Load, save or delete a stored session",
884 sesssaver(&cp
, "Sav&ed Sessions",
885 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
886 "&Load", IDC_SESSLOAD
,
887 "&Save", IDC_SESSSAVE
, "&Delete", IDC_SESSDEL
, NULL
);
890 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
891 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
892 "Always", IDC_COEALWAYS
,
893 "Never", IDC_COENEVER
,
894 "Only on clean exit", IDC_COENORMAL
, NULL
);
898 if (panel
== loggingpanelstart
) {
899 /* The Logging panel. Accelerators used: [acgo] tplfwe */
901 ctlposinit(&cp
, hwnd
, 80, 3, 13);
902 bartitle(&cp
, "Options controlling session logging",
904 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
906 "Session logging:", IDC_LSTATSTATIC
,
907 "Logging &turned off completely", IDC_LSTATOFF
,
908 "Log &printable output only", IDC_LSTATASCII
,
909 "&Log all session output", IDC_LSTATRAW
, NULL
);
910 editbutton(&cp
, "Log &file name:",
911 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
913 statictext(&cp
, "(Log file name can contain &&Y, &&M, &&D for date,"
914 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN
);
916 "What to do if the log file already &exists:",
917 IDC_LSTATXIST
, "Always overwrite it", IDC_LSTATXOVR
,
918 "Always append to the end of it", IDC_LSTATXAPN
,
919 "Ask the user every time", IDC_LSTATXASK
, NULL
);
923 if (panel
== terminalpanelstart
) {
924 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
926 ctlposinit(&cp
, hwnd
, 80, 3, 13);
927 bartitle(&cp
, "Options controlling the terminal emulation",
929 beginbox(&cp
, "Set various terminal options", IDC_BOX_TERMINAL1
);
930 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
931 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
932 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
933 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
934 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
936 "An&swerback to ^E:", IDC_ANSWERBACK
,
937 IDC_ANSWEREDIT
, 100, NULL
);
940 beginbox(&cp
, "Line discipline options", IDC_BOX_TERMINAL2
);
941 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
942 "Auto", IDC_ECHOBACKEND
,
943 "Force on", IDC_ECHOYES
, "Force off", IDC_ECHONO
, NULL
);
944 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
945 "Auto", IDC_EDITBACKEND
,
946 "Force on", IDC_EDITYES
, "Force off", IDC_EDITNO
, NULL
);
950 if (panel
== bellpanelstart
) {
951 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
953 ctlposinit(&cp
, hwnd
, 80, 3, 13);
954 bartitle(&cp
, "Options controlling the terminal bell",
956 beginbox(&cp
, "Set the style of bell", IDC_BOX_BELL1
);
958 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
959 "None (bell disabled)", IDC_BELL_DISABLED
,
960 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
961 "Play a custom sound file", IDC_BELL_WAVEFILE
,
962 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
963 editbutton(&cp
, "Custom sound file to play as a bell:",
964 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
965 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
966 radioline(&cp
, "Taskbar/caption &indication on bell:",
967 IDC_B_IND_STATIC
, 3, "Disabled", IDC_B_IND_DISABLED
,
968 "Flashing", IDC_B_IND_FLASH
, "Steady", IDC_B_IND_STEADY
,
971 beginbox(&cp
, "Control the bell overload behaviour",
973 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
975 staticedit(&cp
, "Over-use means this &many bells...",
976 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
977 staticedit(&cp
, "... in &this many seconds",
978 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
980 "The bell is re-enabled after a few seconds of silence.",
981 1, IDC_BELLOVLEXPLAIN
);
982 staticedit(&cp
, "Seconds of &silence required", IDC_BELLOVLSSTATIC
,
987 if (panel
== keyboardpanelstart
) {
988 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
990 ctlposinit(&cp
, hwnd
, 80, 3, 13);
992 bartitle(&cp, "Options controlling the effects of keys",
995 beginbox(&cp
, "Change the sequences sent by:", IDC_BOX_KEYBOARD1
);
996 radioline(&cp
, "The &Backspace key", IDC_DELSTATIC
, 2,
997 "Control-H", IDC_DEL008
,
998 "Control-? (127)", IDC_DEL127
, NULL
);
999 radioline(&cp
, "The &Home and End keys", IDC_HOMESTATIC
, 2,
1000 "Standard", IDC_HOMETILDE
, "rxvt", IDC_HOMERXVT
, NULL
);
1001 radioline(&cp
, "The &Function keys and keypad", IDC_FUNCSTATIC
, 3,
1002 "ESC[n~", IDC_FUNCTILDE
,
1003 "Linux", IDC_FUNCLINUX
,
1004 "Xterm R6", IDC_FUNCXTERM
,
1005 "VT400", IDC_FUNCVT400
,
1006 "VT100+", IDC_FUNCVT100P
, "SCO", IDC_FUNCSCO
, NULL
);
1008 beginbox(&cp
, "Application keypad settings:", IDC_BOX_KEYBOARD2
);
1010 "Application c&ursor keys totally disabled",
1012 radioline(&cp
, "Initial state of cu&rsor keys:", IDC_CURSTATIC
, 2,
1013 "Normal", IDC_CURNORMAL
,
1014 "Application", IDC_CURAPPLIC
, NULL
);
1016 "Application ke&ypad keys totally disabled",
1018 radioline(&cp
, "Initial state of &numeric keypad:", IDC_KPSTATIC
,
1019 3, "Normal", IDC_KPNORMAL
, "Application", IDC_KPAPPLIC
,
1020 "NetHack", IDC_KPNH
, NULL
);
1022 beginbox(&cp
, "Enable extra keyboard features:",
1024 checkbox(&cp
, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY
);
1025 checkbox(&cp
, "Control-Alt is &different from AltGr",
1030 if (panel
== windowpanelstart
) {
1031 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt f */
1033 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1034 bartitle(&cp
, "Options controlling PuTTY's window",
1036 beginbox(&cp
, "Set the size of the window", IDC_BOX_WINDOW1
);
1038 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
1039 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50, NULL
);
1040 checkbox(&cp
, "Lock window size against resi&zing", IDC_LOCKSIZE
);
1042 beginbox(&cp
, "Control the scrollback in the window",
1044 staticedit(&cp
, "Lines of &scrollback",
1045 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
1046 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
1047 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
1048 checkbox(&cp
, "Reset scrollback on dis&play activity",
1051 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
1052 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
1053 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
1054 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
1055 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
1056 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
1057 checkbox(&cp
, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER
);
1061 if (panel
== appearancepanelstart
) {
1062 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1064 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1065 bartitle(&cp
, "Options controlling PuTTY's appearance",
1066 IDC_TITLE_APPEARANCE
);
1067 beginbox(&cp
, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1
);
1068 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
1069 "B&lock", IDC_CURBLOCK
,
1070 "&Underline", IDC_CURUNDER
,
1071 "&Vertical line", IDC_CURVERT
, NULL
);
1072 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
1074 beginbox(&cp
, "Set the font used in the terminal window",
1075 IDC_BOX_APPEARANCE2
);
1076 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
1078 beginbox(&cp
, "Adjust the use of the window title",
1079 IDC_BOX_APPEARANCE3
);
1081 "Window &title:", IDC_WINTITLE
, IDC_WINEDIT
, 100, NULL
);
1082 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
1084 beginbox(&cp
, "Adjust the use of the mouse pointer",
1085 IDC_BOX_APPEARANCE4
);
1086 checkbox(&cp
, "Hide mouse &pointer when typing in window",
1089 beginbox(&cp
, "Adjust the window border", IDC_BOX_APPEARANCE5
);
1090 checkbox(&cp
, "&Sunken-edge border (slightly thicker)",
1095 if (panel
== translationpanelstart
) {
1096 /* The Translation panel. Accelerators used: [acgo] rxbepu */
1098 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1099 bartitle(&cp
, "Options controlling character set translation",
1100 IDC_TITLE_TRANSLATION
);
1101 beginbox(&cp
, "Character set translation on received data",
1102 IDC_BOX_TRANSLATION2
);
1103 combobox(&cp
, "&Received data assumed to be in which character set:",
1104 IDC_CODEPAGESTATIC
, IDC_CODEPAGE
);
1106 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
1107 IDC_BOX_TRANSLATION1
);
1109 "Handling of line drawing characters:", IDC_VTSTATIC
,
1110 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
1111 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
1112 "Use font in O&EM mode only", IDC_VTOEMONLY
,
1113 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1114 IDC_VTPOORMAN
, "&Unicode mode", IDC_VTUNICODE
, NULL
);
1118 if (panel
== selectionpanelstart
) {
1119 /* The Selection panel. Accelerators used: [acgo] d wxp hst */
1121 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1122 bartitle(&cp
, "Options controlling copy and paste",
1123 IDC_TITLE_SELECTION
);
1124 beginbox(&cp
, "Translation of pasted characters",
1125 IDC_BOX_SELECTION1
);
1127 "&Don't translate line drawing chars into +, - and |",
1130 beginbox(&cp
, "Control which mouse button does which thing",
1131 IDC_BOX_SELECTION2
);
1132 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1133 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1134 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1137 "Shift overrides a&pplication's use of mouse",
1140 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1141 IDC_BOX_SELECTION3
);
1142 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1143 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1144 "&to class", IDC_CCSTATIC2
);
1148 if (panel
== colourspanelstart
) {
1149 /* The Colours panel. Accelerators used: [acgo] blum */
1151 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1152 bartitle(&cp
, "Options controlling use of colours",
1154 beginbox(&cp
, "General options for colour usage",
1156 checkbox(&cp
, "&Bolded text is a different colour",
1158 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1160 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1162 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1163 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1164 "&Modify...", IDC_CHANGE
,
1165 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1166 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1167 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1171 if (panel
== connectionpanelstart
) {
1172 /* The Connection panel. Accelerators used: [acgo] tuk */
1174 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1175 bartitle(&cp
, "Options controlling the connection",
1176 IDC_TITLE_CONNECTION
);
1178 beginbox(&cp
, "Data to send to the server",
1179 IDC_BOX_CONNECTION1
);
1180 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
,
1182 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
,
1186 beginbox(&cp
, "Adjust telnet session.", IDC_BOX_CONNECTION1
);
1187 checkbox(&cp
, "Keyboard sends telnet Backspace and Interrupt",
1191 beginbox(&cp
, "Sending of null packets to keep session active",
1192 IDC_BOX_CONNECTION2
);
1193 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1194 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1198 if (panel
== telnetpanelstart
) {
1199 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
1201 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1203 bartitle(&cp
, "Options controlling Telnet connections",
1205 beginbox(&cp
, "Data to send to the server", IDC_BOX_TELNET1
);
1206 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
,
1208 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1209 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
, "Va&lue",
1210 IDC_VALSTATIC
, IDC_VALEDIT
, IDC_ENVLIST
, "A&dd",
1211 IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1213 beginbox(&cp
, "Telnet protocol adjustments", IDC_BOX_TELNET2
);
1214 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:",
1215 IDC_EMSTATIC
, 2, "&BSD (commonplace)", IDC_EMBSD
,
1216 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1217 radioline(&cp
, "&Telnet negotiation mode:", IDC_ACTSTATIC
, 2,
1218 "Passive", IDC_TPASSIVE
, "Active",
1220 checkbox(&cp
, "&Keyboard sends telnet Backspace and Interrupt",
1226 if (panel
== rloginpanelstart
) {
1227 /* The Rlogin panel. Accelerators used: [acgo] sl */
1229 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1231 bartitle(&cp
, "Options controlling Rlogin connections",
1233 beginbox(&cp
, "Data to send to the server", IDC_BOX_RLOGIN1
);
1234 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
,
1236 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
,
1237 IDC_RLLUSEREDIT
, 50);
1242 if (panel
== sshpanelstart
) {
1243 /* The SSH panel. Accelerators used: [acgo] r pe12i s */
1245 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1247 bartitle(&cp
, "Options controlling SSH connections",
1249 beginbox(&cp
, "Data to send to the server", IDC_BOX_SSH1
);
1251 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1254 beginbox(&cp
, "Protocol options", IDC_BOX_SSH2
);
1255 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1256 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1257 radioline(&cp
, "Preferred SSH protocol version:",
1258 IDC_SSHPROTSTATIC
, 2,
1259 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1260 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1263 beginbox(&cp
, "Encryption options", IDC_BOX_SSH3
);
1264 prefslist(&cipherlist
, &cp
, "Encryption cipher &selection policy:",
1265 IDC_CIPHERSTATIC2
, IDC_CIPHERLIST
, IDC_CIPHERUP
,
1271 if (panel
== sshauthpanelstart
) {
1272 /* The SSH authentication panel. Accelerators used: [acgo] m fkw */
1274 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1276 bartitle(&cp
, "Options controlling SSH authentication",
1278 beginbox(&cp
, "Authentication methods",
1280 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1283 beginbox(&cp
, "Authentication parameters",
1285 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1286 editbutton(&cp
, "Private &key file for authentication:",
1287 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...",
1293 if (panel
== tunnelspanelstart
) {
1294 /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */
1296 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1298 bartitle(&cp
, "Options controlling SSH tunnelling",
1300 beginbox(&cp
, "X11 forwarding", IDC_BOX_TUNNELS1
);
1301 checkbox(&cp
, "&Enable X11 forwarding", IDC_X11_FORWARD
);
1302 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1303 IDC_X11_DISPLAY
, 50, NULL
);
1305 beginbox(&cp
, "Port forwarding", IDC_BOX_TUNNELS2
);
1306 checkbox(&cp
, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL
);
1307 staticbtn(&cp
, "Forwarded ports:", IDC_PFWDSTATIC
,
1308 "&Remove", IDC_PFWDREMOVE
);
1309 fwdsetter(&cp
, IDC_PFWDLIST
,
1310 "Add new forwarded port:", IDC_PFWDSTATIC2
,
1311 "&Source port", IDC_SPORTSTATIC
, IDC_SPORTEDIT
,
1312 "Dest&ination", IDC_DPORTSTATIC
, IDC_DPORTEDIT
,
1313 "A&dd", IDC_PFWDADD
);
1314 bareradioline(&cp
, 2,
1315 "&Local", IDC_PFWDLOCAL
, "Re&mote", IDC_PFWDREMOTE
, NULL
);
1323 * Helper function to load the session selected in SESSLIST
1324 * if any, as this is done in more than one place in
1325 * GenericMainDlgProc(). 0 => failure.
1327 static int load_selected_session(HWND hwnd
)
1329 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1330 LB_GETCURSEL
, 0, 0);
1336 isdef
= !strcmp(sessions
[n
], "Default Settings");
1337 load_settings(sessions
[n
], !isdef
, &cfg
);
1338 init_dlg_ctrls(hwnd
, TRUE
);
1340 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1342 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1343 /* Restore the selection, which will have been clobbered by
1344 * SESSEDIT handling. */
1345 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
, n
, 0);
1350 * This function is the configuration box.
1352 static int GenericMainDlgProc(HWND hwnd
, UINT msg
,
1353 WPARAM wParam
, LPARAM lParam
, int dlgtype
)
1356 struct treeview_faff tvfaff
;
1359 char filename
[sizeof(cfg
.keyfile
)];
1362 char fontstatic
[256];
1364 struct servent
*service
;
1366 static UINT draglistmsg
= WM_NULL
;
1371 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1372 SendMessage(hwnd
, WM_SETICON
, (WPARAM
) ICON_BIG
,
1373 (LPARAM
) LoadIcon(hinst
, MAKEINTRESOURCE(IDI_CFGICON
)));
1375 * Centre the window.
1377 { /* centre the window */
1380 hw
= GetDesktopWindow();
1381 if (GetWindowRect(hw
, &rs
) && GetWindowRect(hwnd
, &rd
))
1383 (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
) / 2,
1384 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
) / 2,
1385 rd
.right
- rd
.left
, rd
.bottom
- rd
.top
, TRUE
);
1389 * Create the tree view.
1397 r
.right
= r
.left
+ 75;
1399 r
.bottom
= r
.top
+ 10;
1400 MapDialogRect(hwnd
, &r
);
1401 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1402 WS_CHILD
| WS_VISIBLE
,
1404 r
.right
- r
.left
, r
.bottom
- r
.top
,
1405 hwnd
, (HMENU
) IDCX_TVSTATIC
, hinst
,
1407 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1408 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1411 r
.right
= r
.left
+ 75;
1413 r
.bottom
= r
.top
+ 206;
1414 MapDialogRect(hwnd
, &r
);
1415 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1416 WS_CHILD
| WS_VISIBLE
|
1417 WS_TABSTOP
| TVS_HASLINES
|
1418 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
1420 TVS_SHOWSELALWAYS
, r
.left
, r
.top
,
1421 r
.right
- r
.left
, r
.bottom
- r
.top
,
1422 hwnd
, (HMENU
) IDCX_TREEVIEW
, hinst
,
1424 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1425 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1426 tvfaff
.treeview
= treeview
;
1427 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1431 * Set up the tree view contents.
1433 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1434 treeview_insert(&tvfaff
, 1, "Logging");
1435 treeview_insert(&tvfaff
, 0, "Terminal");
1436 treeview_insert(&tvfaff
, 1, "Keyboard");
1437 treeview_insert(&tvfaff
, 1, "Bell");
1438 treeview_insert(&tvfaff
, 0, "Window");
1439 treeview_insert(&tvfaff
, 1, "Appearance");
1440 treeview_insert(&tvfaff
, 1, "Translation");
1441 treeview_insert(&tvfaff
, 1, "Selection");
1442 treeview_insert(&tvfaff
, 1, "Colours");
1443 treeview_insert(&tvfaff
, 0, "Connection");
1445 treeview_insert(&tvfaff
, 1, "Telnet");
1446 treeview_insert(&tvfaff
, 1, "Rlogin");
1447 if (backends
[3].backend
!= NULL
) {
1448 treeview_insert(&tvfaff
, 1, "SSH");
1449 /* XXX long name is ugly */
1450 /* XXX make it closed by default? */
1451 treeview_insert(&tvfaff
, 2, "Auth");
1452 treeview_insert(&tvfaff
, 2, "Tunnels");
1457 * Put the treeview selection on to the Session panel. This
1458 * should also cause creation of the relevant controls.
1460 TreeView_SelectItem(treeview
, hsession
);
1463 * Set focus into the first available control.
1467 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1469 ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1473 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1474 sesslist_has_focus
= 0;
1478 * Button release should trigger WM_OK if there was a
1479 * previous double click on the session list.
1483 SendMessage(hwnd
, WM_COMMAND
, IDOK
, 0);
1486 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1487 ((LPNMHDR
) lParam
)->code
== TVN_SELCHANGED
) {
1489 TreeView_GetSelection(((LPNMHDR
) lParam
)->hwndFrom
);
1494 SendMessage (hwnd
, WM_SETREDRAW
, FALSE
, 0);
1497 item
.pszText
= buffer
;
1498 item
.cchTextMax
= sizeof(buffer
);
1499 item
.mask
= TVIF_TEXT
;
1500 TreeView_GetItem(((LPNMHDR
) lParam
)->hwndFrom
, &item
);
1501 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1502 HWND item
= GetDlgItem(hwnd
, j
);
1504 DestroyWindow(item
);
1506 if (!strcmp(buffer
, "Session"))
1507 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1508 if (!strcmp(buffer
, "Logging"))
1509 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1510 if (!strcmp(buffer
, "Keyboard"))
1511 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1512 if (!strcmp(buffer
, "Terminal"))
1513 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1514 if (!strcmp(buffer
, "Bell"))
1515 create_controls(hwnd
, dlgtype
, bellpanelstart
);
1516 if (!strcmp(buffer
, "Window"))
1517 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1518 if (!strcmp(buffer
, "Appearance"))
1519 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1520 if (!strcmp(buffer
, "Tunnels"))
1521 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1522 if (!strcmp(buffer
, "Connection"))
1523 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1524 if (!strcmp(buffer
, "Telnet"))
1525 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1526 if (!strcmp(buffer
, "Rlogin"))
1527 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1528 if (!strcmp(buffer
, "SSH"))
1529 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1530 if (!strcmp(buffer
, "Auth"))
1531 create_controls(hwnd
, dlgtype
, sshauthpanelstart
);
1532 if (!strcmp(buffer
, "Selection"))
1533 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1534 if (!strcmp(buffer
, "Colours"))
1535 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1536 if (!strcmp(buffer
, "Translation"))
1537 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1539 init_dlg_ctrls(hwnd
, FALSE
);
1541 SendMessage (hwnd
, WM_SETREDRAW
, TRUE
, 0);
1542 InvalidateRect (hwnd
, NULL
, TRUE
);
1544 SetFocus(((LPNMHDR
) lParam
)->hwndFrom
); /* ensure focus stays */
1550 * Only process WM_COMMAND once the dialog is fully formed.
1552 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1)
1553 switch (LOWORD(wParam
)) {
1555 /* Behaviour of the "Open" button is different if the
1556 * session list has focus, *unless* the user just
1557 * double-clicked... */
1558 if (sesslist_has_focus
&& !readytogo
) {
1559 if (!load_selected_session(hwnd
)) {
1564 /* If at this point we have a valid session, go! */
1573 case IDC_PROTTELNET
:
1574 case IDC_PROTRLOGIN
:
1577 if (HIWORD(wParam
) == BN_CLICKED
||
1578 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1579 int i
= IsDlgButtonChecked(hwnd
, IDC_PROTSSH
);
1580 int j
= IsDlgButtonChecked(hwnd
, IDC_PROTTELNET
);
1581 int k
= IsDlgButtonChecked(hwnd
, IDC_PROTRLOGIN
);
1583 i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
:
1585 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22)
1586 || (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23)
1587 || (cfg
.protocol
== PROT_RLOGIN
1588 && cfg
.port
!= 513)) {
1589 cfg
.port
= i ?
22 : j ?
23 : 513;
1590 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1595 if (HIWORD(wParam
) == EN_CHANGE
)
1596 GetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
,
1597 sizeof(cfg
.host
) - 1);
1600 if (HIWORD(wParam
) == EN_CHANGE
) {
1601 GetDlgItemText(hwnd
, IDC_PORT
, portname
, 31);
1602 if (isdigit(portname
[0]))
1603 MyGetDlgItemInt(hwnd
, IDC_PORT
, &cfg
.port
);
1605 service
= getservbyname(portname
, NULL
);
1607 cfg
.port
= ntohs(service
->s_port
);
1614 if (HIWORD(wParam
) == EN_CHANGE
) {
1615 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1617 GetDlgItemText(hwnd
, IDC_SESSEDIT
,
1618 savedsession
, sizeof(savedsession
) - 1);
1619 savedsession
[sizeof(savedsession
) - 1] = '\0';
1623 if (HIWORD(wParam
) == BN_CLICKED
||
1624 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1629 GetDlgItemText(hwnd
, IDC_SESSEDIT
, str
,
1632 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1633 LB_GETCURSEL
, 0, 0);
1638 strcpy(str
, sessions
[n
]);
1640 save_settings(str
, !!strcmp(str
, "Default Settings"),
1642 get_sesslist(FALSE
);
1644 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1646 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1648 for (i
= 0; i
< nsessions
; i
++)
1649 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1651 (LPARAM
) (sessions
[i
]));
1652 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1654 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1656 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1662 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1663 if (HIWORD(wParam
) == LBN_SETFOCUS
)
1664 sesslist_has_focus
= 1;
1665 else if (HIWORD(wParam
) == LBN_KILLFOCUS
)
1666 sesslist_has_focus
= 0;
1668 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1669 HIWORD(wParam
) != BN_CLICKED
&&
1670 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
1671 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1672 HIWORD(wParam
) != LBN_DBLCLK
) break;
1673 /* Load the session selected in SESSLIST. */
1674 if (load_selected_session(hwnd
) &&
1675 LOWORD(wParam
) == IDC_SESSLIST
) {
1677 * A double-click on a saved session should
1678 * actually start the session, not just load it.
1679 * Unless it's Default Settings or some other
1680 * host-less set of saved settings.
1689 if (HIWORD(wParam
) == BN_CLICKED
||
1690 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1691 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1692 LB_GETCURSEL
, 0, 0);
1693 if (n
== LB_ERR
|| n
== 0) {
1697 del_settings(sessions
[n
]);
1698 get_sesslist(FALSE
);
1700 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1702 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1704 for (i
= 0; i
< nsessions
; i
++)
1705 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1707 (LPARAM
) (sessions
[i
]));
1708 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1710 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1712 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1716 if (HIWORD(wParam
) == EN_CHANGE
)
1717 MyGetDlgItemInt(hwnd
, IDC_PINGEDIT
,
1718 &cfg
.ping_interval
);
1722 if (HIWORD(wParam
) == BN_CLICKED
||
1723 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1724 cfg
.bksp_is_delete
=
1725 IsDlgButtonChecked(hwnd
, IDC_DEL127
);
1729 if (HIWORD(wParam
) == BN_CLICKED
||
1730 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1732 IsDlgButtonChecked(hwnd
, IDC_HOMERXVT
);
1738 case IDC_FUNCVT100P
:
1740 if (HIWORD(wParam
) == BN_CLICKED
||
1741 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1742 switch (LOWORD(wParam
)) {
1755 case IDC_FUNCVT100P
:
1765 if (HIWORD(wParam
) == BN_CLICKED
||
1766 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1768 IsDlgButtonChecked(hwnd
, IDC_KPAPPLIC
);
1769 cfg
.nethack_keypad
= FALSE
;
1773 if (HIWORD(wParam
) == BN_CLICKED
||
1774 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1775 cfg
.app_keypad
= FALSE
;
1776 cfg
.nethack_keypad
= TRUE
;
1781 if (HIWORD(wParam
) == BN_CLICKED
||
1782 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1784 IsDlgButtonChecked(hwnd
, IDC_CURAPPLIC
);
1787 if (HIWORD(wParam
) == BN_CLICKED
||
1788 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1790 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICC
);
1793 if (HIWORD(wParam
) == BN_CLICKED
||
1794 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1796 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICK
);
1799 if (HIWORD(wParam
) == BN_CLICKED
||
1800 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1801 cfg
.alt_f4
= IsDlgButtonChecked(hwnd
, IDC_ALTF4
);
1804 if (HIWORD(wParam
) == BN_CLICKED
||
1805 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1807 IsDlgButtonChecked(hwnd
, IDC_ALTSPACE
);
1810 if (HIWORD(wParam
) == BN_CLICKED
||
1811 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1813 IsDlgButtonChecked(hwnd
, IDC_ALTONLY
);
1815 case IDC_ECHOBACKEND
:
1818 if (HIWORD(wParam
) == BN_CLICKED
||
1819 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1820 if (LOWORD(wParam
) == IDC_ECHOBACKEND
)
1821 cfg
.localecho
= LD_BACKEND
;
1822 if (LOWORD(wParam
) == IDC_ECHOYES
)
1823 cfg
.localecho
= LD_YES
;
1824 if (LOWORD(wParam
) == IDC_ECHONO
)
1825 cfg
.localecho
= LD_NO
;
1828 case IDC_EDITBACKEND
:
1831 if (HIWORD(wParam
) == BN_CLICKED
||
1832 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1833 if (LOWORD(wParam
) == IDC_EDITBACKEND
)
1834 cfg
.localedit
= LD_BACKEND
;
1835 if (LOWORD(wParam
) == IDC_EDITYES
)
1836 cfg
.localedit
= LD_YES
;
1837 if (LOWORD(wParam
) == IDC_EDITNO
)
1838 cfg
.localedit
= LD_NO
;
1841 case IDC_ANSWEREDIT
:
1842 if (HIWORD(wParam
) == EN_CHANGE
)
1843 GetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
1844 sizeof(cfg
.answerback
) - 1);
1846 case IDC_ALWAYSONTOP
:
1847 if (HIWORD(wParam
) == BN_CLICKED
||
1848 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1850 IsDlgButtonChecked(hwnd
, IDC_ALWAYSONTOP
);
1852 case IDC_FULLSCREENONALTENTER
:
1853 if (HIWORD(wParam
) == BN_CLICKED
||
1854 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1855 cfg
.fullscreenonaltenter
=
1856 IsDlgButtonChecked(hwnd
, IDC_FULLSCREENONALTENTER
);
1859 if (HIWORD(wParam
) == BN_CLICKED
||
1860 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1862 IsDlgButtonChecked(hwnd
, IDC_SCROLLKEY
);
1864 case IDC_SCROLLDISP
:
1865 if (HIWORD(wParam
) == BN_CLICKED
||
1866 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1867 cfg
.scroll_on_disp
=
1868 IsDlgButtonChecked(hwnd
, IDC_SCROLLDISP
);
1870 case IDC_COMPOSEKEY
:
1871 if (HIWORD(wParam
) == BN_CLICKED
||
1872 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1874 IsDlgButtonChecked(hwnd
, IDC_COMPOSEKEY
);
1876 case IDC_CTRLALTKEYS
:
1877 if (HIWORD(wParam
) == BN_CLICKED
||
1878 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1880 IsDlgButtonChecked(hwnd
, IDC_CTRLALTKEYS
);
1883 if (HIWORD(wParam
) == BN_CLICKED
||
1884 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1885 cfg
.telnet_keyboard
=
1886 IsDlgButtonChecked(hwnd
, IDC_TELNETKEY
);
1889 if (HIWORD(wParam
) == BN_CLICKED
||
1890 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1892 IsDlgButtonChecked(hwnd
, IDC_WRAPMODE
);
1895 if (HIWORD(wParam
) == BN_CLICKED
||
1896 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1897 cfg
.dec_om
= IsDlgButtonChecked(hwnd
, IDC_DECOM
);
1900 if (HIWORD(wParam
) == BN_CLICKED
||
1901 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1903 IsDlgButtonChecked(hwnd
, IDC_LFHASCR
);
1906 if (HIWORD(wParam
) == EN_CHANGE
)
1907 MyGetDlgItemInt(hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1910 if (HIWORD(wParam
) == EN_CHANGE
)
1911 MyGetDlgItemInt(hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1914 if (HIWORD(wParam
) == EN_CHANGE
)
1915 MyGetDlgItemInt(hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1917 case IDC_CHOOSEFONT
:
1920 lf
.lfHeight
= -MulDiv(cfg
.fontheight
,
1921 GetDeviceCaps(hdc
, LOGPIXELSY
),
1925 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1926 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1927 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1928 lf
.lfCharSet
= cfg
.fontcharset
;
1929 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1930 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1931 lf
.lfQuality
= DEFAULT_QUALITY
;
1932 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1933 strncpy(lf
.lfFaceName
, cfg
.font
,
1934 sizeof(lf
.lfFaceName
) - 1);
1935 lf
.lfFaceName
[sizeof(lf
.lfFaceName
) - 1] = '\0';
1937 cf
.lStructSize
= sizeof(cf
);
1938 cf
.hwndOwner
= hwnd
;
1940 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1941 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1943 if (ChooseFont(&cf
)) {
1944 strncpy(cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
) - 1);
1945 cfg
.font
[sizeof(cfg
.font
) - 1] = '\0';
1946 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1947 cfg
.fontcharset
= lf
.lfCharSet
;
1948 cfg
.fontheight
= cf
.iPointSize
/ 10;
1949 fmtfont(fontstatic
);
1950 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
1953 case IDC_BELL_DISABLED
:
1954 case IDC_BELL_DEFAULT
:
1955 case IDC_BELL_WAVEFILE
:
1956 case IDC_BELL_VISUAL
:
1957 if (HIWORD(wParam
) == BN_CLICKED
||
1958 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1959 if (LOWORD(wParam
) == IDC_BELL_DISABLED
)
1960 cfg
.beep
= BELL_DISABLED
;
1961 if (LOWORD(wParam
) == IDC_BELL_DEFAULT
)
1962 cfg
.beep
= BELL_DEFAULT
;
1963 if (LOWORD(wParam
) == IDC_BELL_WAVEFILE
)
1964 cfg
.beep
= BELL_WAVEFILE
;
1965 if (LOWORD(wParam
) == IDC_BELL_VISUAL
)
1966 cfg
.beep
= BELL_VISUAL
;
1969 case IDC_B_IND_DISABLED
:
1970 case IDC_B_IND_FLASH
:
1971 case IDC_B_IND_STEADY
:
1972 if (HIWORD(wParam
) == BN_CLICKED
||
1973 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1974 if (LOWORD(wParam
) == IDC_B_IND_DISABLED
)
1975 cfg
.beep_ind
= B_IND_DISABLED
;
1976 if (LOWORD(wParam
) == IDC_B_IND_FLASH
)
1977 cfg
.beep_ind
= B_IND_FLASH
;
1978 if (LOWORD(wParam
) == IDC_B_IND_STEADY
)
1979 cfg
.beep_ind
= B_IND_STEADY
;
1982 case IDC_BELL_WAVEBROWSE
:
1983 memset(&of
, 0, sizeof(of
));
1984 #ifdef OPENFILENAME_SIZE_VERSION_400
1985 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1987 of
.lStructSize
= sizeof(of
);
1989 of
.hwndOwner
= hwnd
;
1990 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
1991 of
.lpstrCustomFilter
= NULL
;
1992 of
.nFilterIndex
= 1;
1993 of
.lpstrFile
= filename
;
1994 strcpy(filename
, cfg
.bell_wavefile
);
1995 of
.nMaxFile
= sizeof(filename
);
1996 of
.lpstrFileTitle
= NULL
;
1997 of
.lpstrInitialDir
= NULL
;
1998 of
.lpstrTitle
= "Select Bell Sound File";
2000 if (GetOpenFileName(&of
)) {
2001 strcpy(cfg
.bell_wavefile
, filename
);
2002 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2006 case IDC_BELL_WAVEEDIT
:
2007 if (HIWORD(wParam
) == EN_CHANGE
)
2008 GetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2010 sizeof(cfg
.bell_wavefile
) - 1);
2013 if (HIWORD(wParam
) == BN_CLICKED
||
2014 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2016 IsDlgButtonChecked(hwnd
, IDC_BELLOVL
);
2019 if (HIWORD(wParam
) == EN_CHANGE
)
2020 MyGetDlgItemInt(hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
2023 if (HIWORD(wParam
) == EN_CHANGE
)
2024 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
,
2028 if (HIWORD(wParam
) == EN_CHANGE
)
2029 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
,
2033 if (HIWORD(wParam
) == BN_CLICKED
||
2034 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2036 IsDlgButtonChecked(hwnd
, IDC_BLINKTEXT
);
2039 if (HIWORD(wParam
) == BN_CLICKED
||
2040 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2041 cfg
.bce
= IsDlgButtonChecked(hwnd
, IDC_BCE
);
2044 if (HIWORD(wParam
) == BN_CLICKED
||
2045 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2046 cfg
.win_name_always
=
2047 IsDlgButtonChecked(hwnd
, IDC_WINNAME
);
2050 if (HIWORD(wParam
) == BN_CLICKED
||
2051 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2053 IsDlgButtonChecked(hwnd
, IDC_HIDEMOUSE
);
2055 case IDC_SUNKENEDGE
:
2056 if (HIWORD(wParam
) == BN_CLICKED
||
2057 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2059 IsDlgButtonChecked(hwnd
, IDC_SUNKENEDGE
);
2062 if (HIWORD(wParam
) == BN_CLICKED
||
2063 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2064 cfg
.cursor_type
= 0;
2067 if (HIWORD(wParam
) == BN_CLICKED
||
2068 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2069 cfg
.cursor_type
= 1;
2072 if (HIWORD(wParam
) == BN_CLICKED
||
2073 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2074 cfg
.cursor_type
= 2;
2077 if (HIWORD(wParam
) == BN_CLICKED
||
2078 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2080 IsDlgButtonChecked(hwnd
, IDC_BLINKCUR
);
2083 if (HIWORD(wParam
) == BN_CLICKED
||
2084 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2086 IsDlgButtonChecked(hwnd
, IDC_SCROLLBAR
);
2089 if (HIWORD(wParam
) == BN_CLICKED
||
2090 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2092 IsDlgButtonChecked(hwnd
, IDC_LOCKSIZE
);
2095 if (HIWORD(wParam
) == EN_CHANGE
)
2096 GetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
2097 sizeof(cfg
.wintitle
) - 1);
2102 if (HIWORD(wParam
) == BN_CLICKED
||
2103 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2105 IsDlgButtonChecked(hwnd
,
2106 IDC_COEALWAYS
) ? COE_ALWAYS
:
2107 IsDlgButtonChecked(hwnd
,
2108 IDC_COENEVER
) ? COE_NEVER
:
2113 if (HIWORD(wParam
) == BN_CLICKED
||
2114 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2116 IsDlgButtonChecked(hwnd
, IDC_CLOSEWARN
);
2119 if (HIWORD(wParam
) == EN_CHANGE
)
2120 GetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
,
2121 sizeof(cfg
.termtype
) - 1);
2124 if (HIWORD(wParam
) == EN_CHANGE
)
2125 GetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
2126 sizeof(cfg
.logfilename
) - 1);
2129 memset(&of
, 0, sizeof(of
));
2130 #ifdef OPENFILENAME_SIZE_VERSION_400
2131 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2133 of
.lStructSize
= sizeof(of
);
2135 of
.hwndOwner
= hwnd
;
2136 of
.lpstrFilter
= "All Files\0*\0\0\0";
2137 of
.lpstrCustomFilter
= NULL
;
2138 of
.nFilterIndex
= 1;
2139 of
.lpstrFile
= filename
;
2140 strcpy(filename
, cfg
.logfilename
);
2141 of
.nMaxFile
= sizeof(filename
);
2142 of
.lpstrFileTitle
= NULL
;
2143 of
.lpstrInitialDir
= NULL
;
2144 of
.lpstrTitle
= "Select session log file";
2146 if (GetSaveFileName(&of
)) {
2147 strcpy(cfg
.logfilename
, filename
);
2148 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
2152 case IDC_LSTATASCII
:
2154 if (HIWORD(wParam
) == BN_CLICKED
||
2155 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2156 if (IsDlgButtonChecked(hwnd
, IDC_LSTATOFF
))
2158 if (IsDlgButtonChecked(hwnd
, IDC_LSTATASCII
))
2160 if (IsDlgButtonChecked(hwnd
, IDC_LSTATRAW
))
2167 if (HIWORD(wParam
) == BN_CLICKED
||
2168 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2169 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXASK
))
2170 cfg
.logxfovr
= LGXF_ASK
;
2171 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXAPN
))
2172 cfg
.logxfovr
= LGXF_APN
;
2173 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXOVR
))
2174 cfg
.logxfovr
= LGXF_OVR
;
2179 if (HIWORD(wParam
) == EN_CHANGE
)
2180 GetDlgItemText(hwnd
, LOWORD(wParam
), cfg
.termspeed
,
2181 sizeof(cfg
.termspeed
) - 1);
2184 if (HIWORD(wParam
) == EN_CHANGE
)
2185 GetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
,
2186 sizeof(cfg
.username
) - 1);
2188 case IDC_RLLUSEREDIT
:
2189 if (HIWORD(wParam
) == EN_CHANGE
)
2190 GetDlgItemText(hwnd
, IDC_RLLUSEREDIT
,
2192 sizeof(cfg
.localusername
) - 1);
2196 cfg
.rfc_environ
= IsDlgButtonChecked(hwnd
, IDC_EMRFC
);
2200 cfg
.passive_telnet
=
2201 IsDlgButtonChecked(hwnd
, IDC_TPASSIVE
);
2204 if (HIWORD(wParam
) == BN_CLICKED
||
2205 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2206 char str
[sizeof(cfg
.environmt
)];
2208 GetDlgItemText(hwnd
, IDC_VAREDIT
, str
,
2214 p
= str
+ strlen(str
);
2216 GetDlgItemText(hwnd
, IDC_VALEDIT
, p
,
2217 sizeof(str
) - 1 - (p
- str
));
2228 if ((p
- cfg
.environmt
) + strlen(str
) + 2 <
2229 sizeof(cfg
.environmt
)) {
2231 p
[strlen(str
) + 1] = '\0';
2232 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
2234 SetDlgItemText(hwnd
, IDC_VAREDIT
, "");
2235 SetDlgItemText(hwnd
, IDC_VALEDIT
, "");
2237 MessageBox(hwnd
, "Environment too big",
2238 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2243 if (HIWORD(wParam
) != BN_CLICKED
&&
2244 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2246 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0,
2253 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
2280 if (HIWORD(wParam
) == BN_CLICKED
||
2281 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2282 cfg
.nopty
= IsDlgButtonChecked(hwnd
, IDC_NOPTY
);
2285 if (HIWORD(wParam
) == BN_CLICKED
||
2286 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2288 IsDlgButtonChecked(hwnd
, IDC_COMPRESS
);
2291 if (HIWORD(wParam
) == BN_CLICKED
||
2292 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2294 IsDlgButtonChecked(hwnd
, IDC_BUGGYMAC
);
2297 if (HIWORD(wParam
) == BN_CLICKED
||
2298 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2300 IsDlgButtonChecked(hwnd
, IDC_AGENTFWD
);
2302 case IDC_CIPHERLIST
:
2305 handle_prefslist(&cipherlist
,
2306 cfg
.ssh_cipherlist
, CIPHER_MAX
,
2307 0, hwnd
, wParam
, lParam
);
2311 if (HIWORD(wParam
) == BN_CLICKED
||
2312 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2313 if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT1
))
2315 else if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT2
))
2320 if (HIWORD(wParam
) == BN_CLICKED
||
2321 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2323 IsDlgButtonChecked(hwnd
, IDC_AUTHTIS
);
2326 if (HIWORD(wParam
) == EN_CHANGE
)
2327 GetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
2328 sizeof(cfg
.keyfile
) - 1);
2331 if (HIWORD(wParam
) == EN_CHANGE
)
2332 GetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
2333 sizeof(cfg
.remote_cmd
) - 1);
2336 memset(&of
, 0, sizeof(of
));
2337 #ifdef OPENFILENAME_SIZE_VERSION_400
2338 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2340 of
.lStructSize
= sizeof(of
);
2342 of
.hwndOwner
= hwnd
;
2343 of
.lpstrFilter
= "All Files\0*\0\0\0";
2344 of
.lpstrCustomFilter
= NULL
;
2345 of
.nFilterIndex
= 1;
2346 of
.lpstrFile
= filename
;
2347 strcpy(filename
, cfg
.keyfile
);
2348 of
.nMaxFile
= sizeof(filename
);
2349 of
.lpstrFileTitle
= NULL
;
2350 of
.lpstrInitialDir
= NULL
;
2351 of
.lpstrTitle
= "Select Public Key File";
2353 if (GetOpenFileName(&of
)) {
2354 strcpy(cfg
.keyfile
, filename
);
2355 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
2359 cfg
.rawcnp
= IsDlgButtonChecked(hwnd
, IDC_RAWCNP
);
2363 cfg
.mouse_is_xterm
= IsDlgButtonChecked(hwnd
, IDC_MBXTERM
);
2365 case IDC_MOUSEOVERRIDE
:
2366 cfg
.mouse_override
= IsDlgButtonChecked(hwnd
, IDC_MOUSEOVERRIDE
);
2372 int n
= GetDlgItemInt(hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
2377 for (i
= 0; i
< 128; i
++)
2378 if (SendDlgItemMessage
2379 (hwnd
, IDC_CCLIST
, LB_GETSEL
, i
, 0)) {
2381 cfg
.wordness
[i
] = n
;
2382 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2383 LB_DELETESTRING
, i
, 0);
2384 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
2385 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ',
2387 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2394 case IDC_BOLDCOLOUR
:
2395 if (HIWORD(wParam
) == BN_CLICKED
||
2396 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2399 IsDlgButtonChecked(hwnd
, IDC_BOLDCOLOUR
);
2400 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2403 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2405 if (n
!= 12 + 10 * cfg
.bold_colour
) {
2406 for (i
= n
; i
-- > 0;)
2407 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2408 LB_DELETESTRING
, i
, 0);
2409 for (i
= 0; i
< 22; i
++)
2410 if (cfg
.bold_colour
|| permcolour
[i
])
2411 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2413 (LPARAM
) colours
[i
]);
2415 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2417 InvalidateRect(GetDlgItem(hwnd
, IDC_COLOURLIST
), NULL
,
2422 if (HIWORD(wParam
) == BN_CLICKED
||
2423 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2425 IsDlgButtonChecked(hwnd
, IDC_PALETTE
);
2427 case IDC_COLOURLIST
:
2428 if (HIWORD(wParam
) == LBN_DBLCLK
||
2429 HIWORD(wParam
) == LBN_SELCHANGE
) {
2431 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2434 if (!cfg
.bold_colour
)
2435 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2436 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2438 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2440 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2445 if (HIWORD(wParam
) == BN_CLICKED
||
2446 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2447 static CHOOSECOLOR cc
;
2448 static DWORD custom
[16] = { 0 }; /* zero initialisers */
2450 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2453 if (!cfg
.bold_colour
)
2454 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2455 cc
.lStructSize
= sizeof(cc
);
2456 cc
.hwndOwner
= hwnd
;
2457 cc
.hInstance
= (HWND
) hinst
;
2458 cc
.lpCustColors
= custom
;
2460 RGB(cfg
.colours
[i
][0], cfg
.colours
[i
][1],
2462 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
2463 if (ChooseColor(&cc
)) {
2465 (unsigned char) (cc
.rgbResult
& 0xFF);
2467 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
2469 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
2470 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2472 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2474 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2480 if (HIWORD(wParam
) == CBN_SELCHANGE
) {
2481 int index
= SendDlgItemMessage(hwnd
, IDC_CODEPAGE
,
2482 CB_GETCURSEL
, 0, 0);
2483 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_GETLBTEXT
,
2484 index
, (LPARAM
)cfg
.line_codepage
);
2485 } else if (HIWORD(wParam
) == CBN_EDITCHANGE
) {
2486 GetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
,
2487 sizeof(cfg
.line_codepage
) - 1);
2488 } else if (HIWORD(wParam
) == CBN_KILLFOCUS
) {
2489 strcpy(cfg
.line_codepage
,
2490 cp_name(decode_codepage(cfg
.line_codepage
)));
2491 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
2494 case IDC_VTXWINDOWS
:
2500 (IsDlgButtonChecked(hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
2501 : IsDlgButtonChecked(hwnd
,
2502 IDC_VTOEMANSI
) ? VT_OEMANSI
:
2503 IsDlgButtonChecked(hwnd
,
2504 IDC_VTOEMONLY
) ? VT_OEMONLY
:
2505 IsDlgButtonChecked(hwnd
,
2506 IDC_VTUNICODE
) ? VT_UNICODE
:
2509 case IDC_X11_FORWARD
:
2510 if (HIWORD(wParam
) == BN_CLICKED
||
2511 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2513 IsDlgButtonChecked(hwnd
, IDC_X11_FORWARD
);
2516 if (HIWORD(wParam
) == BN_CLICKED
||
2517 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2518 cfg
.lport_acceptall
=
2519 IsDlgButtonChecked(hwnd
, IDC_LPORT_ALL
);
2521 case IDC_X11_DISPLAY
:
2522 if (HIWORD(wParam
) == EN_CHANGE
)
2523 GetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
2524 sizeof(cfg
.x11_display
) - 1);
2527 if (HIWORD(wParam
) == BN_CLICKED
||
2528 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2529 char str
[sizeof(cfg
.portfwd
)];
2531 if (IsDlgButtonChecked(hwnd
, IDC_PFWDLOCAL
))
2535 GetDlgItemText(hwnd
, IDC_SPORTEDIT
, str
+1,
2539 "You need to specify a source port number",
2540 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2543 p
= str
+ strlen(str
);
2545 GetDlgItemText(hwnd
, IDC_DPORTEDIT
, p
,
2546 sizeof(str
) - 1 - (p
- str
));
2547 if (!*p
|| !strchr(p
, ':')) {
2549 "You need to specify a destination address\n"
2550 "in the form \"host.name:port\"",
2551 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2560 if ((p
- cfg
.portfwd
) + strlen(str
) + 2 <
2561 sizeof(cfg
.portfwd
)) {
2563 p
[strlen(str
) + 1] = '\0';
2564 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
,
2566 SetDlgItemText(hwnd
, IDC_SPORTEDIT
, "");
2567 SetDlgItemText(hwnd
, IDC_DPORTEDIT
, "");
2569 MessageBox(hwnd
, "Too many forwardings",
2570 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2574 case IDC_PFWDREMOVE
:
2575 if (HIWORD(wParam
) != BN_CLICKED
&&
2576 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2577 i
= SendDlgItemMessage(hwnd
, IDC_PFWDLIST
,
2578 LB_GETCURSEL
, 0, 0);
2584 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_DELETESTRING
,
2616 /* Grrr Explorer will maximize Dialogs! */
2618 if (wParam
== SIZE_MAXIMIZED
)
2624 * Handle application-defined messages eg. DragListBox
2626 /* First find out what the number is (once). */
2627 if (draglistmsg
== WM_NULL
)
2628 draglistmsg
= RegisterWindowMessage (DRAGLISTMSGSTRING
);
2630 if (msg
== draglistmsg
) {
2631 /* Only process once dialog is fully formed. */
2632 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
2633 case IDC_CIPHERLIST
:
2634 return handle_prefslist(&cipherlist
,
2635 cfg
.ssh_cipherlist
, CIPHER_MAX
,
2636 1, hwnd
, wParam
, lParam
);
2645 static int CALLBACK
MainDlgProc(HWND hwnd
, UINT msg
,
2646 WPARAM wParam
, LPARAM lParam
)
2648 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
2650 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
2651 EnableWindow(hwnd
, 0);
2652 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2653 EnableWindow(hwnd
, 1);
2654 SetActiveWindow(hwnd
);
2656 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 0);
2659 static int CALLBACK
ReconfDlgProc(HWND hwnd
, UINT msg
,
2660 WPARAM wParam
, LPARAM lParam
)
2662 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 1);
2665 void defuse_showwindow(void)
2668 * Work around the fact that the app's first call to ShowWindow
2669 * will ignore the default in favour of the shell-provided
2674 hwnd
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2676 ShowWindow(hwnd
, SW_HIDE
);
2677 SetActiveWindow(hwnd
);
2678 DestroyWindow(hwnd
);
2687 savedsession
[0] = '\0';
2689 DialogBox(hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2690 get_sesslist(FALSE
);
2695 int do_reconfig(HWND hwnd
)
2700 backup_cfg
= cfg
; /* structure copy */
2702 DialogBox(hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2704 cfg
= backup_cfg
; /* structure copy */
2709 void logevent(char *string
)
2714 if (nevents
>= negsize
) {
2716 events
= srealloc(events
, negsize
* sizeof(*events
));
2720 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t",
2723 events
[nevents
] = smalloc(strlen(timebuf
) + strlen(string
) + 1);
2724 strcpy(events
[nevents
], timebuf
);
2725 strcat(events
[nevents
], string
);
2728 SendDlgItemMessage(logbox
, IDN_LIST
, LB_ADDSTRING
,
2729 0, (LPARAM
) events
[nevents
]);
2730 count
= SendDlgItemMessage(logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2731 SendDlgItemMessage(logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
- 1, 0);
2736 void showeventlog(HWND hwnd
)
2739 logbox
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2741 ShowWindow(logbox
, SW_SHOWNORMAL
);
2743 SetActiveWindow(logbox
);
2746 void showabout(HWND hwnd
)
2748 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2751 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2752 char *keystr
, char *fingerprint
)
2756 static const char absentmsg
[] =
2757 "The server's host key is not cached in the registry. You\n"
2758 "have no guarantee that the server is the computer you\n"
2760 "The server's key fingerprint is:\n"
2762 "If you trust this host, hit Yes to add the key to\n"
2763 "PuTTY's cache and carry on connecting.\n"
2764 "If you want to carry on connecting just once, without\n"
2765 "adding the key to the cache, hit No.\n"
2766 "If you do not trust this host, hit Cancel to abandon the\n"
2769 static const char wrongmsg
[] =
2770 "WARNING - POTENTIAL SECURITY BREACH!\n"
2772 "The server's host key does not match the one PuTTY has\n"
2773 "cached in the registry. This means that either the\n"
2774 "server administrator has changed the host key, or you\n"
2775 "have actually connected to another computer pretending\n"
2776 "to be the server.\n"
2777 "The new key fingerprint is:\n"
2779 "If you were expecting this change and trust the new key,\n"
2780 "hit Yes to update PuTTY's cache and continue connecting.\n"
2781 "If you want to carry on connecting but without updating\n"
2782 "the cache, hit No.\n"
2783 "If you want to abandon the connection completely, hit\n"
2784 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
2786 static const char mbtitle
[] = "PuTTY Security Alert";
2789 /* sensible fingerprint max size */
2790 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2791 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2794 * Verify the key against the registry.
2796 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2798 if (ret
== 0) /* success - key matched OK */
2800 if (ret
== 2) { /* key was different */
2802 sprintf(message
, wrongmsg
, fingerprint
);
2803 mbret
= MessageBox(NULL
, message
, mbtitle
,
2804 MB_ICONWARNING
| MB_YESNOCANCEL
);
2806 store_host_key(host
, port
, keytype
, keystr
);
2807 if (mbret
== IDCANCEL
)
2810 if (ret
== 1) { /* key was absent */
2812 sprintf(message
, absentmsg
, fingerprint
);
2813 mbret
= MessageBox(NULL
, message
, mbtitle
,
2814 MB_ICONWARNING
| MB_YESNOCANCEL
);
2816 store_host_key(host
, port
, keytype
, keystr
);
2817 if (mbret
== IDCANCEL
)
2823 * Ask whether the selected cipher is acceptable (since it was
2824 * below the configured 'warn' threshold).
2825 * cs: 0 = both ways, 1 = client->server, 2 = server->client
2827 void askcipher(char *ciphername
, int cs
)
2829 static const char mbtitle
[] = "PuTTY Security Alert";
2830 static const char msg
[] =
2831 "The first %.35scipher supported by the server\n"
2832 "is %.64s, which is below the configured\n"
2833 "warning threshold.\n"
2834 "Do you want to continue with this connection?\n";
2835 /* guessed cipher name + type max length */
2836 char message
[100 + sizeof(msg
)];
2839 sprintf(message
, msg
,
2841 (cs
== 1) ?
"client-to-server " :
2842 "server-to-client ",
2844 mbret
= MessageBox(NULL
, message
, mbtitle
,
2845 MB_ICONWARNING
| MB_YESNO
);
2853 * Ask whether to wipe a session log file before writing to it.
2854 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2856 int askappend(char *filename
)
2858 static const char mbtitle
[] = "PuTTY Log to File";
2859 static const char msgtemplate
[] =
2860 "The session log file \"%.*s\" already exists.\n"
2861 "You can overwrite it with a new session log,\n"
2862 "append your session log to the end of it,\n"
2863 "or disable session logging for this session.\n"
2864 "Hit Yes to wipe the file, No to append to it,\n"
2865 "or Cancel to disable logging.";
2866 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2868 if (cfg
.logxfovr
!= LGXF_ASK
) {
2869 return ((cfg
.logxfovr
== LGXF_OVR
) ?
2 : 1);
2871 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2873 mbret
= MessageBox(NULL
, message
, mbtitle
,
2874 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2877 else if (mbret
== IDNO
)