15 static char **events
= NULL
;
16 static int nevents
= 0, negsize
= 0;
19 static int sesslist_has_focus
;
21 void force_normal(HWND hwnd
)
23 static int recurse
= 0;
31 wp
.length
= sizeof(wp
);
32 if (GetWindowPlacement(hwnd
, &wp
) && wp
.showCmd
== SW_SHOWMAXIMIZED
) {
33 wp
.showCmd
= SW_SHOWNORMAL
;
34 SetWindowPlacement(hwnd
, &wp
);
39 static void MyGetDlgItemInt(HWND hwnd
, int id
, int *result
)
43 n
= GetDlgItemInt(hwnd
, id
, &ok
, FALSE
);
48 static void MyGetDlgItemFlt(HWND hwnd
, int id
, int *result
, int scale
)
52 ok
= GetDlgItemText(hwnd
, id
, text
, sizeof(text
) - 1);
54 *result
= (int) (scale
* atof(text
));
57 static void MySetDlgItemFlt(HWND hwnd
, int id
, double value
)
60 sprintf(text
, "%g", value
);
61 SetDlgItemText(hwnd
, id
, text
);
64 static int CALLBACK
LogProc(HWND hwnd
, UINT msg
,
65 WPARAM wParam
, LPARAM lParam
)
72 static int tabs
[4] = { 78, 108 };
73 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETTABSTOPS
, 2,
76 for (i
= 0; i
< nevents
; i
++)
77 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_ADDSTRING
,
78 0, (LPARAM
) events
[i
]);
81 switch (LOWORD(wParam
)) {
85 SetActiveWindow(GetParent(hwnd
));
89 if (HIWORD(wParam
) == BN_CLICKED
||
90 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
93 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
94 LB_GETSELCOUNT
, 0, 0);
95 if (selcount
== 0) { /* don't even try to copy zero items */
100 selitems
= smalloc(selcount
* sizeof(int));
102 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
109 static unsigned char sel_nl
[] = SEL_NL
;
111 if (count
== 0) { /* can't copy zero stuff */
117 for (i
= 0; i
< count
; i
++)
119 strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
121 clipdata
= smalloc(size
);
124 for (i
= 0; i
< count
; i
++) {
125 char *q
= events
[selitems
[i
]];
126 int qlen
= strlen(q
);
129 memcpy(p
, sel_nl
, sizeof(sel_nl
));
132 write_aclip(clipdata
, size
, TRUE
);
137 for (i
= 0; i
< nevents
; i
++)
138 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
147 SetActiveWindow(GetParent(hwnd
));
154 static int CALLBACK
LicenceProc(HWND hwnd
, UINT msg
,
155 WPARAM wParam
, LPARAM lParam
)
161 switch (LOWORD(wParam
)) {
174 static int CALLBACK
AboutProc(HWND hwnd
, UINT msg
,
175 WPARAM wParam
, LPARAM lParam
)
179 SetDlgItemText(hwnd
, IDA_VERSION
, ver
);
182 switch (LOWORD(wParam
)) {
185 EndDialog(hwnd
, TRUE
);
188 EnableWindow(hwnd
, 0);
189 DialogBox(hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
191 EnableWindow(hwnd
, 1);
192 SetActiveWindow(hwnd
);
196 /* Load web browser */
197 ShellExecute(hwnd
, "open",
198 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
199 0, 0, SW_SHOWDEFAULT
);
204 EndDialog(hwnd
, TRUE
);
211 * Null dialog procedure.
213 static int CALLBACK
NullDlgProc(HWND hwnd
, UINT msg
,
214 WPARAM wParam
, LPARAM lParam
)
219 static char savedsession
[2048];
222 IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
367 appearancepanelstart
,
368 IDC_TITLE_APPEARANCE
,
388 connectionpanelstart
,
389 IDC_TITLE_CONNECTION
,
490 translationpanelstart
,
491 IDC_TITLE_TRANSLATION
,
492 IDC_BOX_TRANSLATION1
,
493 IDC_BOX_TRANSLATION2
,
529 static const char *const colours
[] = {
530 "Default Foreground", "Default Bold Foreground",
531 "Default Background", "Default Bold Background",
532 "Cursor Text", "Cursor Colour",
533 "ANSI Black", "ANSI Black Bold",
534 "ANSI Red", "ANSI Red Bold",
535 "ANSI Green", "ANSI Green Bold",
536 "ANSI Yellow", "ANSI Yellow Bold",
537 "ANSI Blue", "ANSI Blue Bold",
538 "ANSI Magenta", "ANSI Magenta Bold",
539 "ANSI Cyan", "ANSI Cyan Bold",
540 "ANSI White", "ANSI White Bold"
542 static const int permcolour
[] = {
543 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
544 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
545 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
548 static void fmtfont(char *buf
)
550 sprintf(buf
, "Font: %s, ", cfg
.font
);
552 strcat(buf
, "bold, ");
553 if (cfg
.fontheight
== 0)
554 strcat(buf
, "default height");
556 sprintf(buf
+ strlen(buf
), "%d-point",
557 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
560 /* 2nd arg: NZ => don't redraw session list (use when loading
562 static void init_dlg_ctrls(HWND hwnd
, int keepsess
)
565 char fontstatic
[256];
567 SetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
);
568 SetDlgItemText(hwnd
, IDC_SESSEDIT
, savedsession
);
571 n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
572 for (i
= n
; i
-- > 0;)
573 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_DELETESTRING
, i
, 0);
574 for (i
= 0; i
< nsessions
; i
++)
575 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
576 0, (LPARAM
) (sessions
[i
]));
578 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
579 CheckRadioButton(hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
580 cfg
.protocol
== PROT_SSH ? IDC_PROTSSH
:
581 cfg
.protocol
== PROT_TELNET ? IDC_PROTTELNET
:
583 PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
584 SetDlgItemInt(hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
586 CheckRadioButton(hwnd
, IDC_DEL008
, IDC_DEL127
,
587 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
588 CheckRadioButton(hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
589 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
590 CheckRadioButton(hwnd
, IDC_FUNCTILDE
, IDC_FUNCSCO
,
591 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
592 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
593 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
594 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
595 cfg
.funky_type
== 4 ? IDC_FUNCVT100P
:
596 cfg
.funky_type
== 5 ? IDC_FUNCSCO
: IDC_FUNCTILDE
);
597 CheckDlgButton(hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
598 CheckDlgButton(hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
599 CheckRadioButton(hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
600 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
601 CheckRadioButton(hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
602 cfg
.nethack_keypad ? IDC_KPNH
:
603 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
604 CheckDlgButton(hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
605 CheckDlgButton(hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
606 CheckDlgButton(hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
607 CheckDlgButton(hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
608 CheckDlgButton(hwnd
, IDC_CTRLALTKEYS
, cfg
.ctrlaltkeys
);
609 CheckDlgButton(hwnd
, IDC_TELNETKEY
, cfg
.telnet_keyboard
);
610 CheckRadioButton(hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
611 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
612 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
613 CheckRadioButton(hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
614 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
615 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
616 SetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
);
617 CheckDlgButton(hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
618 CheckDlgButton(hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
619 CheckDlgButton(hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
621 CheckDlgButton(hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
622 CheckDlgButton(hwnd
, IDC_DECOM
, cfg
.dec_om
);
623 CheckDlgButton(hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
624 SetDlgItemInt(hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
625 SetDlgItemInt(hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
626 SetDlgItemInt(hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
628 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
629 CheckRadioButton(hwnd
, IDC_BELL_DISABLED
, IDC_BELL_VISUAL
,
630 cfg
.beep
== BELL_DISABLED ? IDC_BELL_DISABLED
:
631 cfg
.beep
== BELL_DEFAULT ? IDC_BELL_DEFAULT
:
632 cfg
.beep
== BELL_WAVEFILE ? IDC_BELL_WAVEFILE
:
634 BELL_VISUAL ? IDC_BELL_VISUAL
: IDC_BELL_DEFAULT
);
635 CheckRadioButton(hwnd
, IDC_B_IND_DISABLED
, IDC_B_IND_STEADY
,
637 B_IND_DISABLED ? IDC_B_IND_DISABLED
: cfg
.beep_ind
==
638 B_IND_FLASH ? IDC_B_IND_FLASH
: cfg
.beep_ind
==
639 B_IND_STEADY ? IDC_B_IND_STEADY
: IDC_B_IND_DISABLED
);
640 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
641 CheckDlgButton(hwnd
, IDC_BELLOVL
, cfg
.bellovl
);
642 SetDlgItemInt(hwnd
, IDC_BELLOVLN
, cfg
.bellovl_n
, FALSE
);
643 MySetDlgItemFlt(hwnd
, IDC_BELLOVLT
, cfg
.bellovl_t
/ 1000.0);
644 MySetDlgItemFlt(hwnd
, IDC_BELLOVLS
, cfg
.bellovl_s
/ 1000.0);
646 CheckDlgButton(hwnd
, IDC_BCE
, cfg
.bce
);
647 CheckDlgButton(hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
649 SetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
650 CheckDlgButton(hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
651 CheckDlgButton(hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
652 CheckDlgButton(hwnd
, IDC_SUNKENEDGE
, cfg
.sunken_edge
);
653 CheckRadioButton(hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
654 cfg
.cursor_type
== 0 ? IDC_CURBLOCK
:
655 cfg
.cursor_type
== 1 ? IDC_CURUNDER
: IDC_CURVERT
);
656 CheckDlgButton(hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
657 CheckDlgButton(hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
658 CheckDlgButton(hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
659 CheckRadioButton(hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
660 cfg
.close_on_exit
== COE_NORMAL ? IDC_COENORMAL
:
662 COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
663 CheckDlgButton(hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
665 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
666 SetDlgItemText(hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
667 SetDlgItemText(hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
668 SetDlgItemText(hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
669 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
670 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
671 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
672 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
673 cfg
.logtype
== 1 ? IDC_LSTATASCII
: IDC_LSTATRAW
);
674 CheckRadioButton(hwnd
, IDC_LSTATXOVR
, IDC_LSTATXASK
,
675 cfg
.logxfovr
== LGXF_OVR ? IDC_LSTATXOVR
:
676 cfg
.logxfovr
== LGXF_ASK ? IDC_LSTATXASK
:
679 char *p
= cfg
.environmt
;
680 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_RESETCONTENT
, 0, 0);
682 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
688 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
, 0,
693 CheckRadioButton(hwnd
, IDC_EMBSD
, IDC_EMRFC
,
694 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
695 CheckRadioButton(hwnd
, IDC_TPASSIVE
, IDC_TACTIVE
,
696 cfg
.passive_telnet ? IDC_TPASSIVE
: IDC_TACTIVE
);
698 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
699 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
700 CheckDlgButton(hwnd
, IDC_NOPTY
, cfg
.nopty
);
701 CheckDlgButton(hwnd
, IDC_COMPRESS
, cfg
.compression
);
702 CheckDlgButton(hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
703 CheckDlgButton(hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
704 CheckRadioButton(hwnd
, IDC_CIPHER3DES
, IDC_CIPHERAES
,
705 cfg
.cipher
== CIPHER_BLOWFISH ? IDC_CIPHERBLOWF
:
706 cfg
.cipher
== CIPHER_DES ? IDC_CIPHERDES
:
707 cfg
.cipher
== CIPHER_AES ? IDC_CIPHERAES
:
709 CheckRadioButton(hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
710 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
711 CheckDlgButton(hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
712 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
713 SetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
715 CheckRadioButton(hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
716 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
717 CheckDlgButton(hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
719 static int tabs
[4] = { 25, 61, 96, 128 };
720 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
723 for (i
= 0; i
< 128; i
++) {
725 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
726 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ', cfg
.wordness
[i
]);
727 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
731 CheckDlgButton(hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
732 CheckDlgButton(hwnd
, IDC_PALETTE
, cfg
.try_palette
);
735 n
= SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
736 for (i
= n
; i
-- > 0;)
737 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
738 LB_DELETESTRING
, i
, 0);
739 for (i
= 0; i
< 22; i
++)
740 if (cfg
.bold_colour
|| permcolour
[i
])
741 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
742 (LPARAM
) colours
[i
]);
744 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
745 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
746 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
747 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
749 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
750 CheckRadioButton(hwnd
, IDC_VTXWINDOWS
, IDC_VTUNICODE
,
751 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
752 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
753 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
754 cfg
.vtmode
== VT_UNICODE ? IDC_VTUNICODE
:
757 CheckDlgButton(hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
758 SetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
760 CheckDlgButton(hwnd
, IDC_LPORT_ALL
, cfg
.lport_acceptall
);
761 CheckRadioButton(hwnd
, IDC_PFWDLOCAL
, IDC_PFWDREMOTE
, IDC_PFWDLOCAL
);
764 struct treeview_faff
{
769 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
770 int level
, char *text
)
775 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
- 1] : TVI_ROOT
);
776 ins
.hInsertAfter
= faff
->lastat
[level
];
777 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
778 #define INSITEM DUMMYUNIONNAME.item
782 ins
.INSITEM
.mask
= TVIF_TEXT
;
783 ins
.INSITEM
.pszText
= text
;
784 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
786 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
- 1],
788 faff
->lastat
[level
] = newitem
;
789 for (i
= level
+ 1; i
< 4; i
++)
790 faff
->lastat
[i
] = NULL
;
795 * Create the panelfuls of controls in the configuration box.
797 static void create_controls(HWND hwnd
, int dlgtype
, int panel
)
799 if (panel
== sessionpanelstart
) {
800 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
802 ctlposinit(&cp
, hwnd
, 80, 3, 13);
803 bartitle(&cp
, "Basic options for your PuTTY session",
806 beginbox(&cp
, "Specify your connection by host name",
809 "Host &Name", IDC_HOSTSTATIC
, IDC_HOST
, 75,
810 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
811 if (backends
[3].backend
== NULL
) {
812 /* this is PuTTYtel, so only three protocols available */
813 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 3,
815 "&Telnet", IDC_PROTTELNET
,
816 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
818 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
820 "&Telnet", IDC_PROTTELNET
,
821 "Rlog&in", IDC_PROTRLOGIN
,
830 beginbox(&cp
, "Load, save or delete a stored session",
832 sesssaver(&cp
, "Sav&ed Sessions",
833 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
834 "&Load", IDC_SESSLOAD
,
835 "&Save", IDC_SESSSAVE
, "&Delete", IDC_SESSDEL
, NULL
);
838 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
839 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
840 "Always", IDC_COEALWAYS
,
841 "Never", IDC_COENEVER
,
842 "Only on clean exit", IDC_COENORMAL
, NULL
);
846 if (panel
== loggingpanelstart
) {
847 /* The Logging panel. Accelerators used: [acgo] tplfwe */
849 ctlposinit(&cp
, hwnd
, 80, 3, 13);
850 bartitle(&cp
, "Options controlling session logging",
852 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
854 "Session logging:", IDC_LSTATSTATIC
,
855 "Logging &turned off completely", IDC_LSTATOFF
,
856 "Log &printable output only", IDC_LSTATASCII
,
857 "&Log all session output", IDC_LSTATRAW
, NULL
);
858 editbutton(&cp
, "Log &file name:",
859 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
862 "What to do if the log file already &exists:",
863 IDC_LSTATXIST
, "Always overwrite it", IDC_LSTATXOVR
,
864 "Always append to the end of it", IDC_LSTATXAPN
,
865 "Ask the user every time", IDC_LSTATXASK
, NULL
);
869 if (panel
== terminalpanelstart
) {
870 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
872 ctlposinit(&cp
, hwnd
, 80, 3, 13);
873 bartitle(&cp
, "Options controlling the terminal emulation",
875 beginbox(&cp
, "Set various terminal options", IDC_BOX_TERMINAL1
);
876 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
877 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
878 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
879 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
880 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
882 "An&swerback to ^E:", IDC_ANSWERBACK
,
883 IDC_ANSWEREDIT
, 100, NULL
);
886 beginbox(&cp
, "Line discipline options", IDC_BOX_TERMINAL2
);
887 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
888 "Auto", IDC_ECHOBACKEND
,
889 "Force on", IDC_ECHOYES
, "Force off", IDC_ECHONO
, NULL
);
890 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
891 "Auto", IDC_EDITBACKEND
,
892 "Force on", IDC_EDITYES
, "Force off", IDC_EDITNO
, NULL
);
896 if (panel
== bellpanelstart
) {
897 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
899 ctlposinit(&cp
, hwnd
, 80, 3, 13);
900 bartitle(&cp
, "Options controlling the terminal bell",
902 beginbox(&cp
, "Set the style of bell", IDC_BOX_BELL1
);
904 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
905 "None (bell disabled)", IDC_BELL_DISABLED
,
906 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
907 "Play a custom sound file", IDC_BELL_WAVEFILE
,
908 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
909 editbutton(&cp
, "Custom sound file to play as a bell:",
910 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
911 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
912 radioline(&cp
, "Taskbar/caption &indication on bell:",
913 IDC_B_IND_STATIC
, 3, "Disabled", IDC_B_IND_DISABLED
,
914 "Flashing", IDC_B_IND_FLASH
, "Steady", IDC_B_IND_STEADY
,
917 beginbox(&cp
, "Control the bell overload behaviour",
919 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
921 staticedit(&cp
, "Over-use means this &many bells...",
922 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
923 staticedit(&cp
, "... in &this many seconds",
924 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
926 "The bell is re-enabled after a few seconds of silence.",
928 staticedit(&cp
, "Seconds of &silence required", IDC_BELLOVLSSTATIC
,
933 if (panel
== keyboardpanelstart
) {
934 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
936 ctlposinit(&cp
, hwnd
, 80, 3, 13);
938 bartitle(&cp, "Options controlling the effects of keys",
941 beginbox(&cp
, "Change the sequences sent by:", IDC_BOX_KEYBOARD1
);
942 radioline(&cp
, "The &Backspace key", IDC_DELSTATIC
, 2,
943 "Control-H", IDC_DEL008
,
944 "Control-? (127)", IDC_DEL127
, NULL
);
945 radioline(&cp
, "The &Home and End keys", IDC_HOMESTATIC
, 2,
946 "Standard", IDC_HOMETILDE
, "rxvt", IDC_HOMERXVT
, NULL
);
947 radioline(&cp
, "The &Function keys and keypad", IDC_FUNCSTATIC
, 3,
948 "ESC[n~", IDC_FUNCTILDE
,
949 "Linux", IDC_FUNCLINUX
,
950 "Xterm R6", IDC_FUNCXTERM
,
951 "VT400", IDC_FUNCVT400
,
952 "VT100+", IDC_FUNCVT100P
, "SCO", IDC_FUNCSCO
, NULL
);
954 beginbox(&cp
, "Application keypad settings:", IDC_BOX_KEYBOARD2
);
956 "Application c&ursor keys totally disabled",
958 radioline(&cp
, "Initial state of cu&rsor keys:", IDC_CURSTATIC
, 2,
959 "Normal", IDC_CURNORMAL
,
960 "Application", IDC_CURAPPLIC
, NULL
);
962 "Application ke&ypad keys totally disabled",
964 radioline(&cp
, "Initial state of &numeric keypad:", IDC_KPSTATIC
,
965 3, "Normal", IDC_KPNORMAL
, "Application", IDC_KPAPPLIC
,
966 "NetHack", IDC_KPNH
, NULL
);
968 beginbox(&cp
, "Enable extra keyboard features:",
970 checkbox(&cp
, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY
);
971 checkbox(&cp
, "Control-Alt is &different from AltGr",
976 if (panel
== windowpanelstart
) {
977 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
979 ctlposinit(&cp
, hwnd
, 80, 3, 13);
980 bartitle(&cp
, "Options controlling PuTTY's window",
982 beginbox(&cp
, "Set the size of the window", IDC_BOX_WINDOW1
);
984 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
985 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50, NULL
);
986 checkbox(&cp
, "Lock window size against resi&zing", IDC_LOCKSIZE
);
988 beginbox(&cp
, "Control the scrollback in the window",
990 staticedit(&cp
, "Lines of &scrollback",
991 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
992 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
993 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
994 checkbox(&cp
, "Reset scrollback on dis&play activity",
997 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
998 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
999 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
1000 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
1001 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
1002 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
1006 if (panel
== appearancepanelstart
) {
1007 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1009 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1010 bartitle(&cp
, "Options controlling PuTTY's appearance",
1011 IDC_TITLE_APPEARANCE
);
1012 beginbox(&cp
, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1
);
1013 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
1014 "B&lock", IDC_CURBLOCK
,
1015 "&Underline", IDC_CURUNDER
,
1016 "&Vertical line", IDC_CURVERT
, NULL
);
1017 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
1019 beginbox(&cp
, "Set the font used in the terminal window",
1020 IDC_BOX_APPEARANCE2
);
1021 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
1023 beginbox(&cp
, "Adjust the use of the window title",
1024 IDC_BOX_APPEARANCE3
);
1026 "Window &title:", IDC_WINTITLE
, IDC_WINEDIT
, 100, NULL
);
1027 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
1029 beginbox(&cp
, "Adjust the use of the mouse pointer",
1030 IDC_BOX_APPEARANCE4
);
1031 checkbox(&cp
, "Hide mouse &pointer when typing in window",
1034 beginbox(&cp
, "Adjust the window border", IDC_BOX_APPEARANCE5
);
1035 checkbox(&cp
, "&Sunken-edge border (slightly thicker)",
1040 if (panel
== translationpanelstart
) {
1041 /* The Translation panel. Accelerators used: [acgo] xbep t s */
1043 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1044 bartitle(&cp
, "Options controlling character set translation",
1045 IDC_TITLE_TRANSLATION
);
1046 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
1047 IDC_BOX_TRANSLATION1
);
1049 "Handling of line drawing characters:", IDC_VTSTATIC
,
1050 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
1051 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
1052 "Use font in O&EM mode only", IDC_VTOEMONLY
,
1053 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1054 IDC_VTPOORMAN
, "&Unicode mode", IDC_VTUNICODE
, NULL
);
1056 beginbox(&cp
, "Enable character set translation on received data",
1057 IDC_BOX_TRANSLATION2
);
1058 multiedit(&cp
, "Line codepage:", IDC_CODEPAGESTATIC
,
1059 IDC_CODEPAGE
, 100, NULL
);
1063 if (panel
== selectionpanelstart
) {
1064 /* The Selection panel. Accelerators used: [acgo] d wx hst */
1066 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1067 bartitle(&cp
, "Options controlling copy and paste",
1068 IDC_TITLE_SELECTION
);
1069 beginbox(&cp
, "Translation of pasted characters",
1070 IDC_BOX_SELECTION1
);
1072 "&Don't translate line drawing chars into +, - and |",
1075 beginbox(&cp
, "Control which mouse button does which thing",
1076 IDC_BOX_SELECTION2
);
1077 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1078 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1079 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1082 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1083 IDC_BOX_SELECTION3
);
1084 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1085 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1086 "&to class", IDC_CCSTATIC2
);
1090 if (panel
== colourspanelstart
) {
1091 /* The Colours panel. Accelerators used: [acgo] blum */
1093 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1094 bartitle(&cp
, "Options controlling use of colours",
1096 beginbox(&cp
, "General options for colour usage",
1098 checkbox(&cp
, "&Bolded text is a different colour",
1100 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1102 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1104 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1105 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1106 "&Modify...", IDC_CHANGE
,
1107 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1108 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1109 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1113 if (panel
== connectionpanelstart
) {
1114 /* The Connection panel. Accelerators used: [acgo] tuk */
1116 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1117 bartitle(&cp
, "Options controlling the connection",
1118 IDC_TITLE_CONNECTION
);
1120 beginbox(&cp
, "Data to send to the server",
1121 IDC_BOX_CONNECTION1
);
1122 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
,
1124 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
,
1128 beginbox(&cp
, "Adjust telnet session.", IDC_BOX_CONNECTION1
);
1129 checkbox(&cp
, "Keyboard sends telnet Backspace and Interrupt",
1133 beginbox(&cp
, "Sending of null packets to keep session active",
1134 IDC_BOX_CONNECTION2
);
1135 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1136 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1140 if (panel
== telnetpanelstart
) {
1141 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
1143 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1145 bartitle(&cp
, "Options controlling Telnet connections",
1147 beginbox(&cp
, "Data to send to the server", IDC_BOX_TELNET1
);
1148 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
,
1150 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1151 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
, "Va&lue",
1152 IDC_VALSTATIC
, IDC_VALEDIT
, IDC_ENVLIST
, "A&dd",
1153 IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1155 beginbox(&cp
, "Telnet protocol adjustments", IDC_BOX_TELNET2
);
1156 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:",
1157 IDC_EMSTATIC
, 2, "&BSD (commonplace)", IDC_EMBSD
,
1158 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1159 radioline(&cp
, "&Telnet negotiation mode:", IDC_ACTSTATIC
, 2,
1160 "Passive", IDC_TPASSIVE
, "Active",
1162 checkbox(&cp
, "&Keyboard sends telnet Backspace and Interrupt",
1168 if (panel
== rloginpanelstart
) {
1169 /* The Rlogin panel. Accelerators used: [acgo] sl */
1171 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1173 bartitle(&cp
, "Options controlling Rlogin connections",
1175 beginbox(&cp
, "Data to send to the server", IDC_BOX_RLOGIN1
);
1176 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
,
1178 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
,
1179 IDC_RLLUSEREDIT
, 50);
1184 if (panel
== sshpanelstart
) {
1185 /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bds i */
1187 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1189 bartitle(&cp
, "Options controlling SSH connections",
1191 beginbox(&cp
, "Data to send to the server", IDC_BOX_SSH1
);
1193 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1196 beginbox(&cp
, "Authentication options", IDC_BOX_SSH2
);
1197 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1199 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1200 editbutton(&cp
, "Private &key file for authentication:",
1201 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...",
1204 beginbox(&cp
, "Protocol options", IDC_BOX_SSH3
);
1205 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1206 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1207 radioline(&cp
, "Preferred SSH protocol version:",
1208 IDC_SSHPROTSTATIC
, 2,
1209 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1210 radioline(&cp
, "Preferred encryption algorithm:",
1211 IDC_CIPHERSTATIC
, 4, "&3DES", IDC_CIPHER3DES
,
1212 "&Blowfish", IDC_CIPHERBLOWF
, "&DES", IDC_CIPHERDES
,
1213 "AE&S", IDC_CIPHERAES
, NULL
);
1214 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1220 if (panel
== tunnelspanelstart
) {
1221 /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */
1223 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1225 bartitle(&cp
, "Options controlling SSH tunnelling",
1227 beginbox(&cp
, "X11 forwarding", IDC_BOX_TUNNELS1
);
1228 checkbox(&cp
, "&Enable X11 forwarding", IDC_X11_FORWARD
);
1229 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1230 IDC_X11_DISPLAY
, 50, NULL
);
1232 beginbox(&cp
, "Port forwarding", IDC_BOX_TUNNELS2
);
1233 checkbox(&cp
, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL
);
1234 staticbtn(&cp
, "Forwarded ports:", IDC_PFWDSTATIC
,
1235 "&Remove", IDC_PFWDREMOVE
);
1236 fwdsetter(&cp
, IDC_PFWDLIST
,
1237 "Add new forwarded port:", IDC_PFWDSTATIC2
,
1238 "&Source port", IDC_SPORTSTATIC
, IDC_SPORTEDIT
,
1239 "Dest&ination", IDC_DPORTSTATIC
, IDC_DPORTEDIT
,
1240 "A&dd", IDC_PFWDADD
);
1241 bareradioline(&cp
, 2,
1242 "&Local", IDC_PFWDLOCAL
, "Re&mote", IDC_PFWDREMOTE
, NULL
);
1250 * Helper function to load the session selected in SESSLIST
1251 * if any, as this is done in more than one place in
1252 * GenericMainDlgProc(). 0 => failure.
1254 static int load_selected_session(HWND hwnd
)
1256 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1257 LB_GETCURSEL
, 0, 0);
1263 isdef
= !strcmp(sessions
[n
], "Default Settings");
1264 load_settings(sessions
[n
], !isdef
, &cfg
);
1265 init_dlg_ctrls(hwnd
, TRUE
);
1267 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1269 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1270 /* Restore the selection, which will have been clobbered by
1271 * SESSEDIT handling. */
1272 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
, n
, 0);
1277 * This function is the configuration box.
1279 static int GenericMainDlgProc(HWND hwnd
, UINT msg
,
1280 WPARAM wParam
, LPARAM lParam
, int dlgtype
)
1283 struct treeview_faff tvfaff
;
1286 char filename
[sizeof(cfg
.keyfile
)];
1289 char fontstatic
[256];
1291 struct servent
*service
;
1297 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1298 SendMessage(hwnd
, WM_SETICON
, (WPARAM
) ICON_BIG
,
1299 (LPARAM
) LoadIcon(hinst
, MAKEINTRESOURCE(IDI_CFGICON
)));
1301 * Centre the window.
1303 { /* centre the window */
1306 hw
= GetDesktopWindow();
1307 if (GetWindowRect(hw
, &rs
) && GetWindowRect(hwnd
, &rd
))
1309 (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
) / 2,
1310 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
) / 2,
1311 rd
.right
- rd
.left
, rd
.bottom
- rd
.top
, TRUE
);
1315 * Create the tree view.
1323 r
.right
= r
.left
+ 75;
1325 r
.bottom
= r
.top
+ 10;
1326 MapDialogRect(hwnd
, &r
);
1327 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1328 WS_CHILD
| WS_VISIBLE
,
1330 r
.right
- r
.left
, r
.bottom
- r
.top
,
1331 hwnd
, (HMENU
) IDCX_TVSTATIC
, hinst
,
1333 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1334 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1337 r
.right
= r
.left
+ 75;
1339 r
.bottom
= r
.top
+ 206;
1340 MapDialogRect(hwnd
, &r
);
1341 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1342 WS_CHILD
| WS_VISIBLE
|
1343 WS_TABSTOP
| TVS_HASLINES
|
1344 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
1346 TVS_SHOWSELALWAYS
, r
.left
, r
.top
,
1347 r
.right
- r
.left
, r
.bottom
- r
.top
,
1348 hwnd
, (HMENU
) IDCX_TREEVIEW
, hinst
,
1350 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1351 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1352 tvfaff
.treeview
= treeview
;
1353 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1357 * Set up the tree view contents.
1359 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1360 treeview_insert(&tvfaff
, 1, "Logging");
1361 treeview_insert(&tvfaff
, 0, "Terminal");
1362 treeview_insert(&tvfaff
, 1, "Keyboard");
1363 treeview_insert(&tvfaff
, 1, "Bell");
1364 treeview_insert(&tvfaff
, 0, "Window");
1365 treeview_insert(&tvfaff
, 1, "Appearance");
1366 treeview_insert(&tvfaff
, 1, "Translation");
1367 treeview_insert(&tvfaff
, 1, "Selection");
1368 treeview_insert(&tvfaff
, 1, "Colours");
1369 treeview_insert(&tvfaff
, 0, "Connection");
1371 treeview_insert(&tvfaff
, 1, "Telnet");
1372 treeview_insert(&tvfaff
, 1, "Rlogin");
1373 if (backends
[3].backend
!= NULL
) {
1374 treeview_insert(&tvfaff
, 1, "SSH");
1375 treeview_insert(&tvfaff
, 2, "Tunnels");
1380 * Put the treeview selection on to the Session panel. This
1381 * should also cause creation of the relevant controls.
1383 TreeView_SelectItem(treeview
, hsession
);
1386 * Set focus into the first available control.
1390 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1392 ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1396 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1397 sesslist_has_focus
= 0;
1401 * Button release should trigger WM_OK if there was a
1402 * previous double click on the session list.
1406 SendMessage(hwnd
, WM_COMMAND
, IDOK
, 0);
1409 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1410 ((LPNMHDR
) lParam
)->code
== TVN_SELCHANGED
) {
1412 TreeView_GetSelection(((LPNMHDR
) lParam
)->hwndFrom
);
1417 item
.pszText
= buffer
;
1418 item
.cchTextMax
= sizeof(buffer
);
1419 item
.mask
= TVIF_TEXT
;
1420 TreeView_GetItem(((LPNMHDR
) lParam
)->hwndFrom
, &item
);
1421 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1422 HWND item
= GetDlgItem(hwnd
, j
);
1424 DestroyWindow(item
);
1426 if (!strcmp(buffer
, "Session"))
1427 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1428 if (!strcmp(buffer
, "Logging"))
1429 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1430 if (!strcmp(buffer
, "Keyboard"))
1431 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1432 if (!strcmp(buffer
, "Terminal"))
1433 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1434 if (!strcmp(buffer
, "Bell"))
1435 create_controls(hwnd
, dlgtype
, bellpanelstart
);
1436 if (!strcmp(buffer
, "Window"))
1437 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1438 if (!strcmp(buffer
, "Appearance"))
1439 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1440 if (!strcmp(buffer
, "Tunnels"))
1441 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1442 if (!strcmp(buffer
, "Connection"))
1443 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1444 if (!strcmp(buffer
, "Telnet"))
1445 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1446 if (!strcmp(buffer
, "Rlogin"))
1447 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1448 if (!strcmp(buffer
, "SSH"))
1449 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1450 if (!strcmp(buffer
, "Selection"))
1451 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1452 if (!strcmp(buffer
, "Colours"))
1453 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1454 if (!strcmp(buffer
, "Translation"))
1455 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1457 init_dlg_ctrls(hwnd
, FALSE
);
1459 SetFocus(((LPNMHDR
) lParam
)->hwndFrom
); /* ensure focus stays */
1465 * Only process WM_COMMAND once the dialog is fully formed.
1467 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1)
1468 switch (LOWORD(wParam
)) {
1470 /* Behaviour of the "Open" button is different if the
1471 * session list has focus, *unless* the user just
1472 * double-clicked... */
1473 if (sesslist_has_focus
&& !readytogo
) {
1474 if (!load_selected_session(hwnd
)) {
1479 /* If at this point we have a valid session, go! */
1488 case IDC_PROTTELNET
:
1489 case IDC_PROTRLOGIN
:
1492 if (HIWORD(wParam
) == BN_CLICKED
||
1493 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1494 int i
= IsDlgButtonChecked(hwnd
, IDC_PROTSSH
);
1495 int j
= IsDlgButtonChecked(hwnd
, IDC_PROTTELNET
);
1496 int k
= IsDlgButtonChecked(hwnd
, IDC_PROTRLOGIN
);
1498 i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
:
1500 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22)
1501 || (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23)
1502 || (cfg
.protocol
== PROT_RLOGIN
1503 && cfg
.port
!= 513)) {
1504 cfg
.port
= i ?
22 : j ?
23 : 513;
1505 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1510 if (HIWORD(wParam
) == EN_CHANGE
)
1511 GetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
,
1512 sizeof(cfg
.host
) - 1);
1515 if (HIWORD(wParam
) == EN_CHANGE
) {
1516 GetDlgItemText(hwnd
, IDC_PORT
, portname
, 31);
1517 if (isdigit(portname
[0]))
1518 MyGetDlgItemInt(hwnd
, IDC_PORT
, &cfg
.port
);
1520 service
= getservbyname(portname
, NULL
);
1522 cfg
.port
= ntohs(service
->s_port
);
1529 if (HIWORD(wParam
) == EN_CHANGE
) {
1530 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1532 GetDlgItemText(hwnd
, IDC_SESSEDIT
,
1533 savedsession
, sizeof(savedsession
) - 1);
1534 savedsession
[sizeof(savedsession
) - 1] = '\0';
1538 if (HIWORD(wParam
) == BN_CLICKED
||
1539 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1544 GetDlgItemText(hwnd
, IDC_SESSEDIT
, str
,
1547 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1548 LB_GETCURSEL
, 0, 0);
1553 strcpy(str
, sessions
[n
]);
1555 save_settings(str
, !!strcmp(str
, "Default Settings"),
1557 get_sesslist(FALSE
);
1559 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1561 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1563 for (i
= 0; i
< nsessions
; i
++)
1564 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1566 (LPARAM
) (sessions
[i
]));
1567 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1569 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1571 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1577 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1578 if (HIWORD(wParam
) == LBN_SETFOCUS
)
1579 sesslist_has_focus
= 1;
1580 else if (HIWORD(wParam
) == LBN_KILLFOCUS
)
1581 sesslist_has_focus
= 0;
1583 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1584 HIWORD(wParam
) != BN_CLICKED
&&
1585 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
1586 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1587 HIWORD(wParam
) != LBN_DBLCLK
) break;
1588 /* Load the session selected in SESSLIST. */
1589 if (load_selected_session(hwnd
) &&
1590 LOWORD(wParam
) == IDC_SESSLIST
) {
1592 * A double-click on a saved session should
1593 * actually start the session, not just load it.
1594 * Unless it's Default Settings or some other
1595 * host-less set of saved settings.
1604 if (HIWORD(wParam
) == BN_CLICKED
||
1605 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1606 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1607 LB_GETCURSEL
, 0, 0);
1608 if (n
== LB_ERR
|| n
== 0) {
1612 del_settings(sessions
[n
]);
1613 get_sesslist(FALSE
);
1615 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1617 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1619 for (i
= 0; i
< nsessions
; i
++)
1620 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1622 (LPARAM
) (sessions
[i
]));
1623 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1625 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1627 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1631 if (HIWORD(wParam
) == EN_CHANGE
)
1632 MyGetDlgItemInt(hwnd
, IDC_PINGEDIT
,
1633 &cfg
.ping_interval
);
1637 if (HIWORD(wParam
) == BN_CLICKED
||
1638 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1639 cfg
.bksp_is_delete
=
1640 IsDlgButtonChecked(hwnd
, IDC_DEL127
);
1644 if (HIWORD(wParam
) == BN_CLICKED
||
1645 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1647 IsDlgButtonChecked(hwnd
, IDC_HOMERXVT
);
1653 case IDC_FUNCVT100P
:
1655 if (HIWORD(wParam
) == BN_CLICKED
||
1656 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1657 switch (LOWORD(wParam
)) {
1670 case IDC_FUNCVT100P
:
1680 if (HIWORD(wParam
) == BN_CLICKED
||
1681 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1683 IsDlgButtonChecked(hwnd
, IDC_KPAPPLIC
);
1684 cfg
.nethack_keypad
= FALSE
;
1688 if (HIWORD(wParam
) == BN_CLICKED
||
1689 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1690 cfg
.app_keypad
= FALSE
;
1691 cfg
.nethack_keypad
= TRUE
;
1696 if (HIWORD(wParam
) == BN_CLICKED
||
1697 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1699 IsDlgButtonChecked(hwnd
, IDC_CURAPPLIC
);
1702 if (HIWORD(wParam
) == BN_CLICKED
||
1703 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1705 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICC
);
1708 if (HIWORD(wParam
) == BN_CLICKED
||
1709 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1711 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICK
);
1714 if (HIWORD(wParam
) == BN_CLICKED
||
1715 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1716 cfg
.alt_f4
= IsDlgButtonChecked(hwnd
, IDC_ALTF4
);
1719 if (HIWORD(wParam
) == BN_CLICKED
||
1720 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1722 IsDlgButtonChecked(hwnd
, IDC_ALTSPACE
);
1725 if (HIWORD(wParam
) == BN_CLICKED
||
1726 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1728 IsDlgButtonChecked(hwnd
, IDC_ALTONLY
);
1730 case IDC_ECHOBACKEND
:
1733 if (HIWORD(wParam
) == BN_CLICKED
||
1734 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1735 if (LOWORD(wParam
) == IDC_ECHOBACKEND
)
1736 cfg
.localecho
= LD_BACKEND
;
1737 if (LOWORD(wParam
) == IDC_ECHOYES
)
1738 cfg
.localecho
= LD_YES
;
1739 if (LOWORD(wParam
) == IDC_ECHONO
)
1740 cfg
.localecho
= LD_NO
;
1743 case IDC_EDITBACKEND
:
1746 if (HIWORD(wParam
) == BN_CLICKED
||
1747 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1748 if (LOWORD(wParam
) == IDC_EDITBACKEND
)
1749 cfg
.localedit
= LD_BACKEND
;
1750 if (LOWORD(wParam
) == IDC_EDITYES
)
1751 cfg
.localedit
= LD_YES
;
1752 if (LOWORD(wParam
) == IDC_EDITNO
)
1753 cfg
.localedit
= LD_NO
;
1756 case IDC_ANSWEREDIT
:
1757 if (HIWORD(wParam
) == EN_CHANGE
)
1758 GetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
1759 sizeof(cfg
.answerback
) - 1);
1761 case IDC_ALWAYSONTOP
:
1762 if (HIWORD(wParam
) == BN_CLICKED
||
1763 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1765 IsDlgButtonChecked(hwnd
, IDC_ALWAYSONTOP
);
1768 if (HIWORD(wParam
) == BN_CLICKED
||
1769 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1771 IsDlgButtonChecked(hwnd
, IDC_SCROLLKEY
);
1773 case IDC_SCROLLDISP
:
1774 if (HIWORD(wParam
) == BN_CLICKED
||
1775 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1776 cfg
.scroll_on_disp
=
1777 IsDlgButtonChecked(hwnd
, IDC_SCROLLDISP
);
1779 case IDC_COMPOSEKEY
:
1780 if (HIWORD(wParam
) == BN_CLICKED
||
1781 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1783 IsDlgButtonChecked(hwnd
, IDC_COMPOSEKEY
);
1785 case IDC_CTRLALTKEYS
:
1786 if (HIWORD(wParam
) == BN_CLICKED
||
1787 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1789 IsDlgButtonChecked(hwnd
, IDC_CTRLALTKEYS
);
1792 if (HIWORD(wParam
) == BN_CLICKED
||
1793 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1794 cfg
.telnet_keyboard
=
1795 IsDlgButtonChecked(hwnd
, IDC_TELNETKEY
);
1798 if (HIWORD(wParam
) == BN_CLICKED
||
1799 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1801 IsDlgButtonChecked(hwnd
, IDC_WRAPMODE
);
1804 if (HIWORD(wParam
) == BN_CLICKED
||
1805 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1806 cfg
.dec_om
= IsDlgButtonChecked(hwnd
, IDC_DECOM
);
1809 if (HIWORD(wParam
) == BN_CLICKED
||
1810 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1812 IsDlgButtonChecked(hwnd
, IDC_LFHASCR
);
1815 if (HIWORD(wParam
) == EN_CHANGE
)
1816 MyGetDlgItemInt(hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1819 if (HIWORD(wParam
) == EN_CHANGE
)
1820 MyGetDlgItemInt(hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1823 if (HIWORD(wParam
) == EN_CHANGE
)
1824 MyGetDlgItemInt(hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1826 case IDC_CHOOSEFONT
:
1829 lf
.lfHeight
= -MulDiv(cfg
.fontheight
,
1830 GetDeviceCaps(hdc
, LOGPIXELSY
),
1834 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1835 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1836 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1837 lf
.lfCharSet
= cfg
.fontcharset
;
1838 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1839 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1840 lf
.lfQuality
= DEFAULT_QUALITY
;
1841 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1842 strncpy(lf
.lfFaceName
, cfg
.font
,
1843 sizeof(lf
.lfFaceName
) - 1);
1844 lf
.lfFaceName
[sizeof(lf
.lfFaceName
) - 1] = '\0';
1846 cf
.lStructSize
= sizeof(cf
);
1847 cf
.hwndOwner
= hwnd
;
1849 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1850 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1852 if (ChooseFont(&cf
)) {
1853 strncpy(cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
) - 1);
1854 cfg
.font
[sizeof(cfg
.font
) - 1] = '\0';
1855 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1856 cfg
.fontcharset
= lf
.lfCharSet
;
1857 cfg
.fontheight
= cf
.iPointSize
/ 10;
1858 fmtfont(fontstatic
);
1859 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
1862 case IDC_BELL_DISABLED
:
1863 case IDC_BELL_DEFAULT
:
1864 case IDC_BELL_WAVEFILE
:
1865 case IDC_BELL_VISUAL
:
1866 if (HIWORD(wParam
) == BN_CLICKED
||
1867 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1868 if (LOWORD(wParam
) == IDC_BELL_DISABLED
)
1869 cfg
.beep
= BELL_DISABLED
;
1870 if (LOWORD(wParam
) == IDC_BELL_DEFAULT
)
1871 cfg
.beep
= BELL_DEFAULT
;
1872 if (LOWORD(wParam
) == IDC_BELL_WAVEFILE
)
1873 cfg
.beep
= BELL_WAVEFILE
;
1874 if (LOWORD(wParam
) == IDC_BELL_VISUAL
)
1875 cfg
.beep
= BELL_VISUAL
;
1878 case IDC_B_IND_DISABLED
:
1879 case IDC_B_IND_FLASH
:
1880 case IDC_B_IND_STEADY
:
1881 if (HIWORD(wParam
) == BN_CLICKED
||
1882 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1883 if (LOWORD(wParam
) == IDC_B_IND_DISABLED
)
1884 cfg
.beep_ind
= B_IND_DISABLED
;
1885 if (LOWORD(wParam
) == IDC_B_IND_FLASH
)
1886 cfg
.beep_ind
= B_IND_FLASH
;
1887 if (LOWORD(wParam
) == IDC_B_IND_STEADY
)
1888 cfg
.beep_ind
= B_IND_STEADY
;
1891 case IDC_BELL_WAVEBROWSE
:
1892 memset(&of
, 0, sizeof(of
));
1893 #ifdef OPENFILENAME_SIZE_VERSION_400
1894 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1896 of
.lStructSize
= sizeof(of
);
1898 of
.hwndOwner
= hwnd
;
1899 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
1900 of
.lpstrCustomFilter
= NULL
;
1901 of
.nFilterIndex
= 1;
1902 of
.lpstrFile
= filename
;
1903 strcpy(filename
, cfg
.bell_wavefile
);
1904 of
.nMaxFile
= sizeof(filename
);
1905 of
.lpstrFileTitle
= NULL
;
1906 of
.lpstrInitialDir
= NULL
;
1907 of
.lpstrTitle
= "Select Bell Sound File";
1909 if (GetOpenFileName(&of
)) {
1910 strcpy(cfg
.bell_wavefile
, filename
);
1911 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
1915 case IDC_BELL_WAVEEDIT
:
1916 if (HIWORD(wParam
) == EN_CHANGE
)
1917 GetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
1919 sizeof(cfg
.bell_wavefile
) - 1);
1922 if (HIWORD(wParam
) == BN_CLICKED
||
1923 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1925 IsDlgButtonChecked(hwnd
, IDC_BELLOVL
);
1928 if (HIWORD(wParam
) == EN_CHANGE
)
1929 MyGetDlgItemInt(hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
1932 if (HIWORD(wParam
) == EN_CHANGE
)
1933 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
,
1937 if (HIWORD(wParam
) == EN_CHANGE
)
1938 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
,
1942 if (HIWORD(wParam
) == BN_CLICKED
||
1943 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1945 IsDlgButtonChecked(hwnd
, IDC_BLINKTEXT
);
1948 if (HIWORD(wParam
) == BN_CLICKED
||
1949 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1950 cfg
.bce
= IsDlgButtonChecked(hwnd
, IDC_BCE
);
1953 if (HIWORD(wParam
) == BN_CLICKED
||
1954 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1955 cfg
.win_name_always
=
1956 IsDlgButtonChecked(hwnd
, IDC_WINNAME
);
1959 if (HIWORD(wParam
) == BN_CLICKED
||
1960 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1962 IsDlgButtonChecked(hwnd
, IDC_HIDEMOUSE
);
1964 case IDC_SUNKENEDGE
:
1965 if (HIWORD(wParam
) == BN_CLICKED
||
1966 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1968 IsDlgButtonChecked(hwnd
, IDC_SUNKENEDGE
);
1971 if (HIWORD(wParam
) == BN_CLICKED
||
1972 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1973 cfg
.cursor_type
= 0;
1976 if (HIWORD(wParam
) == BN_CLICKED
||
1977 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1978 cfg
.cursor_type
= 1;
1981 if (HIWORD(wParam
) == BN_CLICKED
||
1982 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1983 cfg
.cursor_type
= 2;
1986 if (HIWORD(wParam
) == BN_CLICKED
||
1987 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1989 IsDlgButtonChecked(hwnd
, IDC_BLINKCUR
);
1992 if (HIWORD(wParam
) == BN_CLICKED
||
1993 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1995 IsDlgButtonChecked(hwnd
, IDC_SCROLLBAR
);
1998 if (HIWORD(wParam
) == BN_CLICKED
||
1999 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2001 IsDlgButtonChecked(hwnd
, IDC_LOCKSIZE
);
2004 if (HIWORD(wParam
) == EN_CHANGE
)
2005 GetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
2006 sizeof(cfg
.wintitle
) - 1);
2011 if (HIWORD(wParam
) == BN_CLICKED
||
2012 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2014 IsDlgButtonChecked(hwnd
,
2015 IDC_COEALWAYS
) ? COE_ALWAYS
:
2016 IsDlgButtonChecked(hwnd
,
2017 IDC_COENEVER
) ? COE_NEVER
:
2022 if (HIWORD(wParam
) == BN_CLICKED
||
2023 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2025 IsDlgButtonChecked(hwnd
, IDC_CLOSEWARN
);
2028 if (HIWORD(wParam
) == EN_CHANGE
)
2029 GetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
,
2030 sizeof(cfg
.termtype
) - 1);
2033 if (HIWORD(wParam
) == EN_CHANGE
)
2034 GetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
2035 sizeof(cfg
.logfilename
) - 1);
2038 memset(&of
, 0, sizeof(of
));
2039 #ifdef OPENFILENAME_SIZE_VERSION_400
2040 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2042 of
.lStructSize
= sizeof(of
);
2044 of
.hwndOwner
= hwnd
;
2045 of
.lpstrFilter
= "All Files\0*\0\0\0";
2046 of
.lpstrCustomFilter
= NULL
;
2047 of
.nFilterIndex
= 1;
2048 of
.lpstrFile
= filename
;
2049 strcpy(filename
, cfg
.logfilename
);
2050 of
.nMaxFile
= sizeof(filename
);
2051 of
.lpstrFileTitle
= NULL
;
2052 of
.lpstrInitialDir
= NULL
;
2053 of
.lpstrTitle
= "Select session log file";
2055 if (GetSaveFileName(&of
)) {
2056 strcpy(cfg
.logfilename
, filename
);
2057 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
2061 case IDC_LSTATASCII
:
2063 if (HIWORD(wParam
) == BN_CLICKED
||
2064 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2065 if (IsDlgButtonChecked(hwnd
, IDC_LSTATOFF
))
2067 if (IsDlgButtonChecked(hwnd
, IDC_LSTATASCII
))
2069 if (IsDlgButtonChecked(hwnd
, IDC_LSTATRAW
))
2076 if (HIWORD(wParam
) == BN_CLICKED
||
2077 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2078 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXASK
))
2079 cfg
.logxfovr
= LGXF_ASK
;
2080 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXAPN
))
2081 cfg
.logxfovr
= LGXF_APN
;
2082 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXOVR
))
2083 cfg
.logxfovr
= LGXF_OVR
;
2088 if (HIWORD(wParam
) == EN_CHANGE
)
2089 GetDlgItemText(hwnd
, LOWORD(wParam
), cfg
.termspeed
,
2090 sizeof(cfg
.termspeed
) - 1);
2093 if (HIWORD(wParam
) == EN_CHANGE
)
2094 GetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
,
2095 sizeof(cfg
.username
) - 1);
2097 case IDC_RLLUSEREDIT
:
2098 if (HIWORD(wParam
) == EN_CHANGE
)
2099 GetDlgItemText(hwnd
, IDC_RLLUSEREDIT
,
2101 sizeof(cfg
.localusername
) - 1);
2105 cfg
.rfc_environ
= IsDlgButtonChecked(hwnd
, IDC_EMRFC
);
2109 cfg
.passive_telnet
=
2110 IsDlgButtonChecked(hwnd
, IDC_TPASSIVE
);
2113 if (HIWORD(wParam
) == BN_CLICKED
||
2114 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2115 char str
[sizeof(cfg
.environmt
)];
2117 GetDlgItemText(hwnd
, IDC_VAREDIT
, str
,
2123 p
= str
+ strlen(str
);
2125 GetDlgItemText(hwnd
, IDC_VALEDIT
, p
,
2126 sizeof(str
) - 1 - (p
- str
));
2137 if ((p
- cfg
.environmt
) + strlen(str
) + 2 <
2138 sizeof(cfg
.environmt
)) {
2140 p
[strlen(str
) + 1] = '\0';
2141 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
2143 SetDlgItemText(hwnd
, IDC_VAREDIT
, "");
2144 SetDlgItemText(hwnd
, IDC_VALEDIT
, "");
2146 MessageBox(hwnd
, "Environment too big",
2147 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2152 if (HIWORD(wParam
) != BN_CLICKED
&&
2153 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2155 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0,
2162 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
2189 if (HIWORD(wParam
) == BN_CLICKED
||
2190 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2191 cfg
.nopty
= IsDlgButtonChecked(hwnd
, IDC_NOPTY
);
2194 if (HIWORD(wParam
) == BN_CLICKED
||
2195 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2197 IsDlgButtonChecked(hwnd
, IDC_COMPRESS
);
2200 if (HIWORD(wParam
) == BN_CLICKED
||
2201 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2203 IsDlgButtonChecked(hwnd
, IDC_BUGGYMAC
);
2206 if (HIWORD(wParam
) == BN_CLICKED
||
2207 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2209 IsDlgButtonChecked(hwnd
, IDC_AGENTFWD
);
2211 case IDC_CIPHER3DES
:
2212 case IDC_CIPHERBLOWF
:
2215 if (HIWORD(wParam
) == BN_CLICKED
||
2216 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2217 if (IsDlgButtonChecked(hwnd
, IDC_CIPHER3DES
))
2218 cfg
.cipher
= CIPHER_3DES
;
2219 else if (IsDlgButtonChecked(hwnd
, IDC_CIPHERBLOWF
))
2220 cfg
.cipher
= CIPHER_BLOWFISH
;
2221 else if (IsDlgButtonChecked(hwnd
, IDC_CIPHERDES
))
2222 cfg
.cipher
= CIPHER_DES
;
2223 else if (IsDlgButtonChecked(hwnd
, IDC_CIPHERAES
))
2224 cfg
.cipher
= CIPHER_AES
;
2229 if (HIWORD(wParam
) == BN_CLICKED
||
2230 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2231 if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT1
))
2233 else if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT2
))
2238 if (HIWORD(wParam
) == BN_CLICKED
||
2239 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2241 IsDlgButtonChecked(hwnd
, IDC_AUTHTIS
);
2244 if (HIWORD(wParam
) == EN_CHANGE
)
2245 GetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
2246 sizeof(cfg
.keyfile
) - 1);
2249 if (HIWORD(wParam
) == EN_CHANGE
)
2250 GetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
2251 sizeof(cfg
.remote_cmd
) - 1);
2254 memset(&of
, 0, sizeof(of
));
2255 #ifdef OPENFILENAME_SIZE_VERSION_400
2256 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2258 of
.lStructSize
= sizeof(of
);
2260 of
.hwndOwner
= hwnd
;
2261 of
.lpstrFilter
= "All Files\0*\0\0\0";
2262 of
.lpstrCustomFilter
= NULL
;
2263 of
.nFilterIndex
= 1;
2264 of
.lpstrFile
= filename
;
2265 strcpy(filename
, cfg
.keyfile
);
2266 of
.nMaxFile
= sizeof(filename
);
2267 of
.lpstrFileTitle
= NULL
;
2268 of
.lpstrInitialDir
= NULL
;
2269 of
.lpstrTitle
= "Select Public Key File";
2271 if (GetOpenFileName(&of
)) {
2272 strcpy(cfg
.keyfile
, filename
);
2273 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
2277 cfg
.rawcnp
= IsDlgButtonChecked(hwnd
, IDC_RAWCNP
);
2280 cfg
.mouse_is_xterm
= IsDlgButtonChecked(hwnd
, IDC_MBXTERM
);
2286 int n
= GetDlgItemInt(hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
2291 for (i
= 0; i
< 128; i
++)
2292 if (SendDlgItemMessage
2293 (hwnd
, IDC_CCLIST
, LB_GETSEL
, i
, 0)) {
2295 cfg
.wordness
[i
] = n
;
2296 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2297 LB_DELETESTRING
, i
, 0);
2298 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
2299 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ',
2301 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2308 case IDC_BOLDCOLOUR
:
2309 if (HIWORD(wParam
) == BN_CLICKED
||
2310 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2313 IsDlgButtonChecked(hwnd
, IDC_BOLDCOLOUR
);
2314 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2317 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2319 if (n
!= 12 + 10 * cfg
.bold_colour
) {
2320 for (i
= n
; i
-- > 0;)
2321 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2322 LB_DELETESTRING
, i
, 0);
2323 for (i
= 0; i
< 22; i
++)
2324 if (cfg
.bold_colour
|| permcolour
[i
])
2325 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2327 (LPARAM
) colours
[i
]);
2329 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2331 InvalidateRect(GetDlgItem(hwnd
, IDC_COLOURLIST
), NULL
,
2336 if (HIWORD(wParam
) == BN_CLICKED
||
2337 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2339 IsDlgButtonChecked(hwnd
, IDC_PALETTE
);
2341 case IDC_COLOURLIST
:
2342 if (HIWORD(wParam
) == LBN_DBLCLK
||
2343 HIWORD(wParam
) == LBN_SELCHANGE
) {
2345 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2348 if (!cfg
.bold_colour
)
2349 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2350 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2352 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2354 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2359 if (HIWORD(wParam
) == BN_CLICKED
||
2360 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2361 static CHOOSECOLOR cc
;
2362 static DWORD custom
[16] = { 0 }; /* zero initialisers */
2364 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2367 if (!cfg
.bold_colour
)
2368 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2369 cc
.lStructSize
= sizeof(cc
);
2370 cc
.hwndOwner
= hwnd
;
2371 cc
.hInstance
= (HWND
) hinst
;
2372 cc
.lpCustColors
= custom
;
2374 RGB(cfg
.colours
[i
][0], cfg
.colours
[i
][1],
2376 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
2377 if (ChooseColor(&cc
)) {
2379 (unsigned char) (cc
.rgbResult
& 0xFF);
2381 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
2383 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
2384 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2386 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2388 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2394 if (HIWORD(wParam
) == EN_CHANGE
)
2395 GetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
,
2396 sizeof(cfg
.line_codepage
) - 1);
2397 if (HIWORD(wParam
) == EN_KILLFOCUS
) {
2398 int cp
= decode_codepage(cfg
.line_codepage
);
2403 "Unable to identify character set '%s', "
2404 "translation disabled.",
2408 "Character set '%s' is a DBCS, "
2409 "translation is not available.",
2411 MessageBox(hwnd
, buf
, "PuTTY Error",
2412 MB_ICONERROR
| MB_OK
);
2414 strcpy(cfg
.line_codepage
, cp_name(cp
));
2415 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
2418 case IDC_VTXWINDOWS
:
2424 (IsDlgButtonChecked(hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
2425 : IsDlgButtonChecked(hwnd
,
2426 IDC_VTOEMANSI
) ? VT_OEMANSI
:
2427 IsDlgButtonChecked(hwnd
,
2428 IDC_VTOEMONLY
) ? VT_OEMONLY
:
2429 IsDlgButtonChecked(hwnd
,
2430 IDC_VTUNICODE
) ? VT_UNICODE
:
2433 case IDC_X11_FORWARD
:
2434 if (HIWORD(wParam
) == BN_CLICKED
||
2435 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2437 IsDlgButtonChecked(hwnd
, IDC_X11_FORWARD
);
2440 if (HIWORD(wParam
) == BN_CLICKED
||
2441 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2442 cfg
.lport_acceptall
=
2443 IsDlgButtonChecked(hwnd
, IDC_LPORT_ALL
);
2445 case IDC_X11_DISPLAY
:
2446 if (HIWORD(wParam
) == EN_CHANGE
)
2447 GetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
2448 sizeof(cfg
.x11_display
) - 1);
2451 if (HIWORD(wParam
) == BN_CLICKED
||
2452 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2453 char str
[sizeof(cfg
.portfwd
)];
2455 if (IsDlgButtonChecked(hwnd
, IDC_PFWDLOCAL
))
2459 GetDlgItemText(hwnd
, IDC_SPORTEDIT
, str
+1,
2463 "You need to specify a source port number",
2464 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2467 p
= str
+ strlen(str
);
2469 GetDlgItemText(hwnd
, IDC_DPORTEDIT
, p
,
2470 sizeof(str
) - 1 - (p
- str
));
2471 if (!*p
|| !strchr(p
, ':')) {
2473 "You need to specify a destination address\n"
2474 "in the form \"host.name:port\"",
2475 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2484 if ((p
- cfg
.portfwd
) + strlen(str
) + 2 <
2485 sizeof(cfg
.portfwd
)) {
2487 p
[strlen(str
) + 1] = '\0';
2488 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
,
2490 SetDlgItemText(hwnd
, IDC_SPORTEDIT
, "");
2491 SetDlgItemText(hwnd
, IDC_DPORTEDIT
, "");
2493 MessageBox(hwnd
, "Too many forwardings",
2494 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2498 case IDC_PFWDREMOVE
:
2499 if (HIWORD(wParam
) != BN_CLICKED
&&
2500 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2501 i
= SendDlgItemMessage(hwnd
, IDC_PFWDLIST
,
2502 LB_GETCURSEL
, 0, 0);
2508 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_DELETESTRING
,
2540 /* Grrr Explorer will maximize Dialogs! */
2542 if (wParam
== SIZE_MAXIMIZED
)
2549 static int CALLBACK
MainDlgProc(HWND hwnd
, UINT msg
,
2550 WPARAM wParam
, LPARAM lParam
)
2552 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
2554 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
2555 EnableWindow(hwnd
, 0);
2556 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2557 EnableWindow(hwnd
, 1);
2558 SetActiveWindow(hwnd
);
2560 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 0);
2563 static int CALLBACK
ReconfDlgProc(HWND hwnd
, UINT msg
,
2564 WPARAM wParam
, LPARAM lParam
)
2566 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 1);
2569 void defuse_showwindow(void)
2572 * Work around the fact that the app's first call to ShowWindow
2573 * will ignore the default in favour of the shell-provided
2578 hwnd
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2580 ShowWindow(hwnd
, SW_HIDE
);
2581 SetActiveWindow(hwnd
);
2582 DestroyWindow(hwnd
);
2591 savedsession
[0] = '\0';
2593 DialogBox(hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2594 get_sesslist(FALSE
);
2599 int do_reconfig(HWND hwnd
)
2604 backup_cfg
= cfg
; /* structure copy */
2606 DialogBox(hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2608 cfg
= backup_cfg
; /* structure copy */
2613 void logevent(char *string
)
2618 if (nevents
>= negsize
) {
2620 events
= srealloc(events
, negsize
* sizeof(*events
));
2624 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t",
2627 events
[nevents
] = smalloc(strlen(timebuf
) + strlen(string
) + 1);
2628 strcpy(events
[nevents
], timebuf
);
2629 strcat(events
[nevents
], string
);
2632 SendDlgItemMessage(logbox
, IDN_LIST
, LB_ADDSTRING
,
2633 0, (LPARAM
) events
[nevents
]);
2634 count
= SendDlgItemMessage(logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2635 SendDlgItemMessage(logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
- 1, 0);
2640 void showeventlog(HWND hwnd
)
2643 logbox
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2645 ShowWindow(logbox
, SW_SHOWNORMAL
);
2647 SetActiveWindow(logbox
);
2650 void showabout(HWND hwnd
)
2652 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2655 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2656 char *keystr
, char *fingerprint
)
2660 static const char absentmsg
[] =
2661 "The server's host key is not cached in the registry. You\n"
2662 "have no guarantee that the server is the computer you\n"
2664 "The server's key fingerprint is:\n"
2666 "If you trust this host, hit Yes to add the key to\n"
2667 "PuTTY's cache and carry on connecting.\n"
2668 "If you want to carry on connecting just once, without\n"
2669 "adding the key to the cache, hit No.\n"
2670 "If you do not trust this host, hit Cancel to abandon the\n"
2673 static const char wrongmsg
[] =
2674 "WARNING - POTENTIAL SECURITY BREACH!\n"
2676 "The server's host key does not match the one PuTTY has\n"
2677 "cached in the registry. This means that either the\n"
2678 "server administrator has changed the host key, or you\n"
2679 "have actually connected to another computer pretending\n"
2680 "to be the server.\n"
2681 "The new key fingerprint is:\n"
2683 "If you were expecting this change and trust the new key,\n"
2684 "hit Yes to update PuTTY's cache and continue connecting.\n"
2685 "If you want to carry on connecting but without updating\n"
2686 "the cache, hit No.\n"
2687 "If you want to abandon the connection completely, hit\n"
2688 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
2690 static const char mbtitle
[] = "PuTTY Security Alert";
2693 /* sensible fingerprint max size */
2694 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2695 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2698 * Verify the key against the registry.
2700 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2702 if (ret
== 0) /* success - key matched OK */
2704 if (ret
== 2) { /* key was different */
2706 sprintf(message
, wrongmsg
, fingerprint
);
2707 mbret
= MessageBox(NULL
, message
, mbtitle
,
2708 MB_ICONWARNING
| MB_YESNOCANCEL
);
2710 store_host_key(host
, port
, keytype
, keystr
);
2711 if (mbret
== IDCANCEL
)
2714 if (ret
== 1) { /* key was absent */
2716 sprintf(message
, absentmsg
, fingerprint
);
2717 mbret
= MessageBox(NULL
, message
, mbtitle
,
2718 MB_ICONWARNING
| MB_YESNOCANCEL
);
2720 store_host_key(host
, port
, keytype
, keystr
);
2721 if (mbret
== IDCANCEL
)
2727 * Ask whether to wipe a session log file before writing to it.
2728 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2730 int askappend(char *filename
)
2732 static const char mbtitle
[] = "PuTTY Log to File";
2733 static const char msgtemplate
[] =
2734 "The session log file \"%.*s\" already exists.\n"
2735 "You can overwrite it with a new session log,\n"
2736 "append your session log to the end of it,\n"
2737 "or disable session logging for this session.\n"
2738 "Hit Yes to wipe the file, No to append to it,\n"
2739 "or Cancel to disable logging.";
2740 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2742 if (cfg
.logxfovr
!= LGXF_ASK
) {
2743 return ((cfg
.logxfovr
== LGXF_OVR
) ?
2 : 1);
2745 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2747 mbret
= MessageBox(NULL
, message
, mbtitle
,
2748 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2751 else if (mbret
== IDNO
)