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
);
753 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_RESETCONTENT
, 0, 0);
754 for (i
= 0; (cp
= cp_enumerate(i
)) != NULL
; i
++) {
755 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_ADDSTRING
,
757 if (!strcmp(cp
, cfg
.line_codepage
))
760 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_SETCURSEL
, index
, 0);
763 CheckRadioButton(hwnd
, IDC_VTXWINDOWS
, IDC_VTUNICODE
,
764 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
765 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
766 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
767 cfg
.vtmode
== VT_UNICODE ? IDC_VTUNICODE
:
770 CheckDlgButton(hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
771 SetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
773 CheckDlgButton(hwnd
, IDC_LPORT_ALL
, cfg
.lport_acceptall
);
774 CheckRadioButton(hwnd
, IDC_PFWDLOCAL
, IDC_PFWDREMOTE
, IDC_PFWDLOCAL
);
777 struct treeview_faff
{
782 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
783 int level
, char *text
)
788 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
- 1] : TVI_ROOT
);
789 ins
.hInsertAfter
= faff
->lastat
[level
];
790 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
791 #define INSITEM DUMMYUNIONNAME.item
795 ins
.INSITEM
.mask
= TVIF_TEXT
;
796 ins
.INSITEM
.pszText
= text
;
797 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
799 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
- 1],
801 faff
->lastat
[level
] = newitem
;
802 for (i
= level
+ 1; i
< 4; i
++)
803 faff
->lastat
[i
] = NULL
;
808 * Create the panelfuls of controls in the configuration box.
810 static void create_controls(HWND hwnd
, int dlgtype
, int panel
)
812 if (panel
== sessionpanelstart
) {
813 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
815 ctlposinit(&cp
, hwnd
, 80, 3, 13);
816 bartitle(&cp
, "Basic options for your PuTTY session",
819 beginbox(&cp
, "Specify your connection by host name or IP address",
822 "Host &Name (or IP address)",
823 IDC_HOSTSTATIC
, IDC_HOST
, 75,
824 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
825 if (backends
[3].backend
== NULL
) {
826 /* this is PuTTYtel, so only three protocols available */
827 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 3,
829 "&Telnet", IDC_PROTTELNET
,
830 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
832 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
834 "&Telnet", IDC_PROTTELNET
,
835 "Rlog&in", IDC_PROTRLOGIN
,
844 beginbox(&cp
, "Load, save or delete a stored session",
846 sesssaver(&cp
, "Sav&ed Sessions",
847 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
848 "&Load", IDC_SESSLOAD
,
849 "&Save", IDC_SESSSAVE
, "&Delete", IDC_SESSDEL
, NULL
);
852 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
853 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
854 "Always", IDC_COEALWAYS
,
855 "Never", IDC_COENEVER
,
856 "Only on clean exit", IDC_COENORMAL
, NULL
);
860 if (panel
== loggingpanelstart
) {
861 /* The Logging panel. Accelerators used: [acgo] tplfwe */
863 ctlposinit(&cp
, hwnd
, 80, 3, 13);
864 bartitle(&cp
, "Options controlling session logging",
866 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
868 "Session logging:", IDC_LSTATSTATIC
,
869 "Logging &turned off completely", IDC_LSTATOFF
,
870 "Log &printable output only", IDC_LSTATASCII
,
871 "&Log all session output", IDC_LSTATRAW
, NULL
);
872 editbutton(&cp
, "Log &file name:",
873 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
876 "What to do if the log file already &exists:",
877 IDC_LSTATXIST
, "Always overwrite it", IDC_LSTATXOVR
,
878 "Always append to the end of it", IDC_LSTATXAPN
,
879 "Ask the user every time", IDC_LSTATXASK
, NULL
);
883 if (panel
== terminalpanelstart
) {
884 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
886 ctlposinit(&cp
, hwnd
, 80, 3, 13);
887 bartitle(&cp
, "Options controlling the terminal emulation",
889 beginbox(&cp
, "Set various terminal options", IDC_BOX_TERMINAL1
);
890 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
891 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
892 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
893 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
894 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
896 "An&swerback to ^E:", IDC_ANSWERBACK
,
897 IDC_ANSWEREDIT
, 100, NULL
);
900 beginbox(&cp
, "Line discipline options", IDC_BOX_TERMINAL2
);
901 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
902 "Auto", IDC_ECHOBACKEND
,
903 "Force on", IDC_ECHOYES
, "Force off", IDC_ECHONO
, NULL
);
904 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
905 "Auto", IDC_EDITBACKEND
,
906 "Force on", IDC_EDITYES
, "Force off", IDC_EDITNO
, NULL
);
910 if (panel
== bellpanelstart
) {
911 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
913 ctlposinit(&cp
, hwnd
, 80, 3, 13);
914 bartitle(&cp
, "Options controlling the terminal bell",
916 beginbox(&cp
, "Set the style of bell", IDC_BOX_BELL1
);
918 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
919 "None (bell disabled)", IDC_BELL_DISABLED
,
920 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
921 "Play a custom sound file", IDC_BELL_WAVEFILE
,
922 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
923 editbutton(&cp
, "Custom sound file to play as a bell:",
924 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
925 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
926 radioline(&cp
, "Taskbar/caption &indication on bell:",
927 IDC_B_IND_STATIC
, 3, "Disabled", IDC_B_IND_DISABLED
,
928 "Flashing", IDC_B_IND_FLASH
, "Steady", IDC_B_IND_STEADY
,
931 beginbox(&cp
, "Control the bell overload behaviour",
933 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
935 staticedit(&cp
, "Over-use means this &many bells...",
936 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
937 staticedit(&cp
, "... in &this many seconds",
938 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
940 "The bell is re-enabled after a few seconds of silence.",
942 staticedit(&cp
, "Seconds of &silence required", IDC_BELLOVLSSTATIC
,
947 if (panel
== keyboardpanelstart
) {
948 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
950 ctlposinit(&cp
, hwnd
, 80, 3, 13);
952 bartitle(&cp, "Options controlling the effects of keys",
955 beginbox(&cp
, "Change the sequences sent by:", IDC_BOX_KEYBOARD1
);
956 radioline(&cp
, "The &Backspace key", IDC_DELSTATIC
, 2,
957 "Control-H", IDC_DEL008
,
958 "Control-? (127)", IDC_DEL127
, NULL
);
959 radioline(&cp
, "The &Home and End keys", IDC_HOMESTATIC
, 2,
960 "Standard", IDC_HOMETILDE
, "rxvt", IDC_HOMERXVT
, NULL
);
961 radioline(&cp
, "The &Function keys and keypad", IDC_FUNCSTATIC
, 3,
962 "ESC[n~", IDC_FUNCTILDE
,
963 "Linux", IDC_FUNCLINUX
,
964 "Xterm R6", IDC_FUNCXTERM
,
965 "VT400", IDC_FUNCVT400
,
966 "VT100+", IDC_FUNCVT100P
, "SCO", IDC_FUNCSCO
, NULL
);
968 beginbox(&cp
, "Application keypad settings:", IDC_BOX_KEYBOARD2
);
970 "Application c&ursor keys totally disabled",
972 radioline(&cp
, "Initial state of cu&rsor keys:", IDC_CURSTATIC
, 2,
973 "Normal", IDC_CURNORMAL
,
974 "Application", IDC_CURAPPLIC
, NULL
);
976 "Application ke&ypad keys totally disabled",
978 radioline(&cp
, "Initial state of &numeric keypad:", IDC_KPSTATIC
,
979 3, "Normal", IDC_KPNORMAL
, "Application", IDC_KPAPPLIC
,
980 "NetHack", IDC_KPNH
, NULL
);
982 beginbox(&cp
, "Enable extra keyboard features:",
984 checkbox(&cp
, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY
);
985 checkbox(&cp
, "Control-Alt is &different from AltGr",
990 if (panel
== windowpanelstart
) {
991 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
993 ctlposinit(&cp
, hwnd
, 80, 3, 13);
994 bartitle(&cp
, "Options controlling PuTTY's window",
996 beginbox(&cp
, "Set the size of the window", IDC_BOX_WINDOW1
);
998 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
999 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50, NULL
);
1000 checkbox(&cp
, "Lock window size against resi&zing", IDC_LOCKSIZE
);
1002 beginbox(&cp
, "Control the scrollback in the window",
1004 staticedit(&cp
, "Lines of &scrollback",
1005 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
1006 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
1007 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
1008 checkbox(&cp
, "Reset scrollback on dis&play activity",
1011 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
1012 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
1013 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
1014 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
1015 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
1016 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
1020 if (panel
== appearancepanelstart
) {
1021 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1023 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1024 bartitle(&cp
, "Options controlling PuTTY's appearance",
1025 IDC_TITLE_APPEARANCE
);
1026 beginbox(&cp
, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1
);
1027 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
1028 "B&lock", IDC_CURBLOCK
,
1029 "&Underline", IDC_CURUNDER
,
1030 "&Vertical line", IDC_CURVERT
, NULL
);
1031 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
1033 beginbox(&cp
, "Set the font used in the terminal window",
1034 IDC_BOX_APPEARANCE2
);
1035 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
1037 beginbox(&cp
, "Adjust the use of the window title",
1038 IDC_BOX_APPEARANCE3
);
1040 "Window &title:", IDC_WINTITLE
, IDC_WINEDIT
, 100, NULL
);
1041 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
1043 beginbox(&cp
, "Adjust the use of the mouse pointer",
1044 IDC_BOX_APPEARANCE4
);
1045 checkbox(&cp
, "Hide mouse &pointer when typing in window",
1048 beginbox(&cp
, "Adjust the window border", IDC_BOX_APPEARANCE5
);
1049 checkbox(&cp
, "&Sunken-edge border (slightly thicker)",
1054 if (panel
== translationpanelstart
) {
1055 /* The Translation panel. Accelerators used: [acgo] xbep t s */
1057 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1058 bartitle(&cp
, "Options controlling character set translation",
1059 IDC_TITLE_TRANSLATION
);
1060 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
1061 IDC_BOX_TRANSLATION1
);
1063 "Handling of line drawing characters:", IDC_VTSTATIC
,
1064 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
1065 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
1066 "Use font in O&EM mode only", IDC_VTOEMONLY
,
1067 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1068 IDC_VTPOORMAN
, "&Unicode mode", IDC_VTUNICODE
, NULL
);
1070 beginbox(&cp
, "Character set translation on received data",
1071 IDC_BOX_TRANSLATION2
);
1073 "Received data assumed to be in which character set:",
1074 IDC_CODEPAGESTATIC
, IDC_CODEPAGE
);
1078 if (panel
== selectionpanelstart
) {
1079 /* The Selection panel. Accelerators used: [acgo] d wx hst */
1081 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1082 bartitle(&cp
, "Options controlling copy and paste",
1083 IDC_TITLE_SELECTION
);
1084 beginbox(&cp
, "Translation of pasted characters",
1085 IDC_BOX_SELECTION1
);
1087 "&Don't translate line drawing chars into +, - and |",
1090 beginbox(&cp
, "Control which mouse button does which thing",
1091 IDC_BOX_SELECTION2
);
1092 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1093 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1094 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1097 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1098 IDC_BOX_SELECTION3
);
1099 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1100 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1101 "&to class", IDC_CCSTATIC2
);
1105 if (panel
== colourspanelstart
) {
1106 /* The Colours panel. Accelerators used: [acgo] blum */
1108 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1109 bartitle(&cp
, "Options controlling use of colours",
1111 beginbox(&cp
, "General options for colour usage",
1113 checkbox(&cp
, "&Bolded text is a different colour",
1115 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1117 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1119 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1120 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1121 "&Modify...", IDC_CHANGE
,
1122 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1123 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1124 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1128 if (panel
== connectionpanelstart
) {
1129 /* The Connection panel. Accelerators used: [acgo] tuk */
1131 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1132 bartitle(&cp
, "Options controlling the connection",
1133 IDC_TITLE_CONNECTION
);
1135 beginbox(&cp
, "Data to send to the server",
1136 IDC_BOX_CONNECTION1
);
1137 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
,
1139 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
,
1143 beginbox(&cp
, "Adjust telnet session.", IDC_BOX_CONNECTION1
);
1144 checkbox(&cp
, "Keyboard sends telnet Backspace and Interrupt",
1148 beginbox(&cp
, "Sending of null packets to keep session active",
1149 IDC_BOX_CONNECTION2
);
1150 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1151 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1155 if (panel
== telnetpanelstart
) {
1156 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
1158 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1160 bartitle(&cp
, "Options controlling Telnet connections",
1162 beginbox(&cp
, "Data to send to the server", IDC_BOX_TELNET1
);
1163 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
,
1165 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1166 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
, "Va&lue",
1167 IDC_VALSTATIC
, IDC_VALEDIT
, IDC_ENVLIST
, "A&dd",
1168 IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1170 beginbox(&cp
, "Telnet protocol adjustments", IDC_BOX_TELNET2
);
1171 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:",
1172 IDC_EMSTATIC
, 2, "&BSD (commonplace)", IDC_EMBSD
,
1173 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1174 radioline(&cp
, "&Telnet negotiation mode:", IDC_ACTSTATIC
, 2,
1175 "Passive", IDC_TPASSIVE
, "Active",
1177 checkbox(&cp
, "&Keyboard sends telnet Backspace and Interrupt",
1183 if (panel
== rloginpanelstart
) {
1184 /* The Rlogin panel. Accelerators used: [acgo] sl */
1186 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1188 bartitle(&cp
, "Options controlling Rlogin connections",
1190 beginbox(&cp
, "Data to send to the server", IDC_BOX_RLOGIN1
);
1191 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
,
1193 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
,
1194 IDC_RLLUSEREDIT
, 50);
1199 if (panel
== sshpanelstart
) {
1200 /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bds i */
1202 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1204 bartitle(&cp
, "Options controlling SSH connections",
1206 beginbox(&cp
, "Data to send to the server", IDC_BOX_SSH1
);
1208 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1211 beginbox(&cp
, "Authentication options", IDC_BOX_SSH2
);
1212 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1214 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1215 editbutton(&cp
, "Private &key file for authentication:",
1216 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...",
1219 beginbox(&cp
, "Protocol options", IDC_BOX_SSH3
);
1220 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1221 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1222 radioline(&cp
, "Preferred SSH protocol version:",
1223 IDC_SSHPROTSTATIC
, 2,
1224 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1225 radioline(&cp
, "Preferred encryption algorithm:",
1226 IDC_CIPHERSTATIC
, 4, "&3DES", IDC_CIPHER3DES
,
1227 "&Blowfish", IDC_CIPHERBLOWF
, "&DES", IDC_CIPHERDES
,
1228 "AE&S", IDC_CIPHERAES
, NULL
);
1229 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1235 if (panel
== tunnelspanelstart
) {
1236 /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */
1238 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1240 bartitle(&cp
, "Options controlling SSH tunnelling",
1242 beginbox(&cp
, "X11 forwarding", IDC_BOX_TUNNELS1
);
1243 checkbox(&cp
, "&Enable X11 forwarding", IDC_X11_FORWARD
);
1244 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1245 IDC_X11_DISPLAY
, 50, NULL
);
1247 beginbox(&cp
, "Port forwarding", IDC_BOX_TUNNELS2
);
1248 checkbox(&cp
, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL
);
1249 staticbtn(&cp
, "Forwarded ports:", IDC_PFWDSTATIC
,
1250 "&Remove", IDC_PFWDREMOVE
);
1251 fwdsetter(&cp
, IDC_PFWDLIST
,
1252 "Add new forwarded port:", IDC_PFWDSTATIC2
,
1253 "&Source port", IDC_SPORTSTATIC
, IDC_SPORTEDIT
,
1254 "Dest&ination", IDC_DPORTSTATIC
, IDC_DPORTEDIT
,
1255 "A&dd", IDC_PFWDADD
);
1256 bareradioline(&cp
, 2,
1257 "&Local", IDC_PFWDLOCAL
, "Re&mote", IDC_PFWDREMOTE
, NULL
);
1265 * Helper function to load the session selected in SESSLIST
1266 * if any, as this is done in more than one place in
1267 * GenericMainDlgProc(). 0 => failure.
1269 static int load_selected_session(HWND hwnd
)
1271 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1272 LB_GETCURSEL
, 0, 0);
1278 isdef
= !strcmp(sessions
[n
], "Default Settings");
1279 load_settings(sessions
[n
], !isdef
, &cfg
);
1280 init_dlg_ctrls(hwnd
, TRUE
);
1282 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1284 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1285 /* Restore the selection, which will have been clobbered by
1286 * SESSEDIT handling. */
1287 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
, n
, 0);
1292 * This function is the configuration box.
1294 static int GenericMainDlgProc(HWND hwnd
, UINT msg
,
1295 WPARAM wParam
, LPARAM lParam
, int dlgtype
)
1298 struct treeview_faff tvfaff
;
1301 char filename
[sizeof(cfg
.keyfile
)];
1304 char fontstatic
[256];
1306 struct servent
*service
;
1312 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1313 SendMessage(hwnd
, WM_SETICON
, (WPARAM
) ICON_BIG
,
1314 (LPARAM
) LoadIcon(hinst
, MAKEINTRESOURCE(IDI_CFGICON
)));
1316 * Centre the window.
1318 { /* centre the window */
1321 hw
= GetDesktopWindow();
1322 if (GetWindowRect(hw
, &rs
) && GetWindowRect(hwnd
, &rd
))
1324 (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
) / 2,
1325 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
) / 2,
1326 rd
.right
- rd
.left
, rd
.bottom
- rd
.top
, TRUE
);
1330 * Create the tree view.
1338 r
.right
= r
.left
+ 75;
1340 r
.bottom
= r
.top
+ 10;
1341 MapDialogRect(hwnd
, &r
);
1342 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1343 WS_CHILD
| WS_VISIBLE
,
1345 r
.right
- r
.left
, r
.bottom
- r
.top
,
1346 hwnd
, (HMENU
) IDCX_TVSTATIC
, hinst
,
1348 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1349 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1352 r
.right
= r
.left
+ 75;
1354 r
.bottom
= r
.top
+ 206;
1355 MapDialogRect(hwnd
, &r
);
1356 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1357 WS_CHILD
| WS_VISIBLE
|
1358 WS_TABSTOP
| TVS_HASLINES
|
1359 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
1361 TVS_SHOWSELALWAYS
, r
.left
, r
.top
,
1362 r
.right
- r
.left
, r
.bottom
- r
.top
,
1363 hwnd
, (HMENU
) IDCX_TREEVIEW
, hinst
,
1365 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1366 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1367 tvfaff
.treeview
= treeview
;
1368 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1372 * Set up the tree view contents.
1374 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1375 treeview_insert(&tvfaff
, 1, "Logging");
1376 treeview_insert(&tvfaff
, 0, "Terminal");
1377 treeview_insert(&tvfaff
, 1, "Keyboard");
1378 treeview_insert(&tvfaff
, 1, "Bell");
1379 treeview_insert(&tvfaff
, 0, "Window");
1380 treeview_insert(&tvfaff
, 1, "Appearance");
1381 treeview_insert(&tvfaff
, 1, "Translation");
1382 treeview_insert(&tvfaff
, 1, "Selection");
1383 treeview_insert(&tvfaff
, 1, "Colours");
1384 treeview_insert(&tvfaff
, 0, "Connection");
1386 treeview_insert(&tvfaff
, 1, "Telnet");
1387 treeview_insert(&tvfaff
, 1, "Rlogin");
1388 if (backends
[3].backend
!= NULL
) {
1389 treeview_insert(&tvfaff
, 1, "SSH");
1390 treeview_insert(&tvfaff
, 2, "Tunnels");
1395 * Put the treeview selection on to the Session panel. This
1396 * should also cause creation of the relevant controls.
1398 TreeView_SelectItem(treeview
, hsession
);
1401 * Set focus into the first available control.
1405 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1407 ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1411 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1412 sesslist_has_focus
= 0;
1416 * Button release should trigger WM_OK if there was a
1417 * previous double click on the session list.
1421 SendMessage(hwnd
, WM_COMMAND
, IDOK
, 0);
1424 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1425 ((LPNMHDR
) lParam
)->code
== TVN_SELCHANGED
) {
1427 TreeView_GetSelection(((LPNMHDR
) lParam
)->hwndFrom
);
1432 item
.pszText
= buffer
;
1433 item
.cchTextMax
= sizeof(buffer
);
1434 item
.mask
= TVIF_TEXT
;
1435 TreeView_GetItem(((LPNMHDR
) lParam
)->hwndFrom
, &item
);
1436 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1437 HWND item
= GetDlgItem(hwnd
, j
);
1439 DestroyWindow(item
);
1441 if (!strcmp(buffer
, "Session"))
1442 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1443 if (!strcmp(buffer
, "Logging"))
1444 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1445 if (!strcmp(buffer
, "Keyboard"))
1446 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1447 if (!strcmp(buffer
, "Terminal"))
1448 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1449 if (!strcmp(buffer
, "Bell"))
1450 create_controls(hwnd
, dlgtype
, bellpanelstart
);
1451 if (!strcmp(buffer
, "Window"))
1452 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1453 if (!strcmp(buffer
, "Appearance"))
1454 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1455 if (!strcmp(buffer
, "Tunnels"))
1456 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1457 if (!strcmp(buffer
, "Connection"))
1458 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1459 if (!strcmp(buffer
, "Telnet"))
1460 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1461 if (!strcmp(buffer
, "Rlogin"))
1462 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1463 if (!strcmp(buffer
, "SSH"))
1464 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1465 if (!strcmp(buffer
, "Selection"))
1466 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1467 if (!strcmp(buffer
, "Colours"))
1468 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1469 if (!strcmp(buffer
, "Translation"))
1470 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1472 init_dlg_ctrls(hwnd
, FALSE
);
1474 SetFocus(((LPNMHDR
) lParam
)->hwndFrom
); /* ensure focus stays */
1480 * Only process WM_COMMAND once the dialog is fully formed.
1482 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1)
1483 switch (LOWORD(wParam
)) {
1485 /* Behaviour of the "Open" button is different if the
1486 * session list has focus, *unless* the user just
1487 * double-clicked... */
1488 if (sesslist_has_focus
&& !readytogo
) {
1489 if (!load_selected_session(hwnd
)) {
1494 /* If at this point we have a valid session, go! */
1503 case IDC_PROTTELNET
:
1504 case IDC_PROTRLOGIN
:
1507 if (HIWORD(wParam
) == BN_CLICKED
||
1508 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1509 int i
= IsDlgButtonChecked(hwnd
, IDC_PROTSSH
);
1510 int j
= IsDlgButtonChecked(hwnd
, IDC_PROTTELNET
);
1511 int k
= IsDlgButtonChecked(hwnd
, IDC_PROTRLOGIN
);
1513 i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
:
1515 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22)
1516 || (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23)
1517 || (cfg
.protocol
== PROT_RLOGIN
1518 && cfg
.port
!= 513)) {
1519 cfg
.port
= i ?
22 : j ?
23 : 513;
1520 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1525 if (HIWORD(wParam
) == EN_CHANGE
)
1526 GetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
,
1527 sizeof(cfg
.host
) - 1);
1530 if (HIWORD(wParam
) == EN_CHANGE
) {
1531 GetDlgItemText(hwnd
, IDC_PORT
, portname
, 31);
1532 if (isdigit(portname
[0]))
1533 MyGetDlgItemInt(hwnd
, IDC_PORT
, &cfg
.port
);
1535 service
= getservbyname(portname
, NULL
);
1537 cfg
.port
= ntohs(service
->s_port
);
1544 if (HIWORD(wParam
) == EN_CHANGE
) {
1545 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1547 GetDlgItemText(hwnd
, IDC_SESSEDIT
,
1548 savedsession
, sizeof(savedsession
) - 1);
1549 savedsession
[sizeof(savedsession
) - 1] = '\0';
1553 if (HIWORD(wParam
) == BN_CLICKED
||
1554 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1559 GetDlgItemText(hwnd
, IDC_SESSEDIT
, str
,
1562 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1563 LB_GETCURSEL
, 0, 0);
1568 strcpy(str
, sessions
[n
]);
1570 save_settings(str
, !!strcmp(str
, "Default Settings"),
1572 get_sesslist(FALSE
);
1574 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1576 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1578 for (i
= 0; i
< nsessions
; i
++)
1579 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1581 (LPARAM
) (sessions
[i
]));
1582 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1584 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1586 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1592 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1593 if (HIWORD(wParam
) == LBN_SETFOCUS
)
1594 sesslist_has_focus
= 1;
1595 else if (HIWORD(wParam
) == LBN_KILLFOCUS
)
1596 sesslist_has_focus
= 0;
1598 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1599 HIWORD(wParam
) != BN_CLICKED
&&
1600 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
1601 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1602 HIWORD(wParam
) != LBN_DBLCLK
) break;
1603 /* Load the session selected in SESSLIST. */
1604 if (load_selected_session(hwnd
) &&
1605 LOWORD(wParam
) == IDC_SESSLIST
) {
1607 * A double-click on a saved session should
1608 * actually start the session, not just load it.
1609 * Unless it's Default Settings or some other
1610 * host-less set of saved settings.
1619 if (HIWORD(wParam
) == BN_CLICKED
||
1620 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1621 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1622 LB_GETCURSEL
, 0, 0);
1623 if (n
== LB_ERR
|| n
== 0) {
1627 del_settings(sessions
[n
]);
1628 get_sesslist(FALSE
);
1630 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1632 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1634 for (i
= 0; i
< nsessions
; i
++)
1635 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1637 (LPARAM
) (sessions
[i
]));
1638 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1640 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1642 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1646 if (HIWORD(wParam
) == EN_CHANGE
)
1647 MyGetDlgItemInt(hwnd
, IDC_PINGEDIT
,
1648 &cfg
.ping_interval
);
1652 if (HIWORD(wParam
) == BN_CLICKED
||
1653 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1654 cfg
.bksp_is_delete
=
1655 IsDlgButtonChecked(hwnd
, IDC_DEL127
);
1659 if (HIWORD(wParam
) == BN_CLICKED
||
1660 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1662 IsDlgButtonChecked(hwnd
, IDC_HOMERXVT
);
1668 case IDC_FUNCVT100P
:
1670 if (HIWORD(wParam
) == BN_CLICKED
||
1671 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1672 switch (LOWORD(wParam
)) {
1685 case IDC_FUNCVT100P
:
1695 if (HIWORD(wParam
) == BN_CLICKED
||
1696 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1698 IsDlgButtonChecked(hwnd
, IDC_KPAPPLIC
);
1699 cfg
.nethack_keypad
= FALSE
;
1703 if (HIWORD(wParam
) == BN_CLICKED
||
1704 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1705 cfg
.app_keypad
= FALSE
;
1706 cfg
.nethack_keypad
= TRUE
;
1711 if (HIWORD(wParam
) == BN_CLICKED
||
1712 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1714 IsDlgButtonChecked(hwnd
, IDC_CURAPPLIC
);
1717 if (HIWORD(wParam
) == BN_CLICKED
||
1718 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1720 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICC
);
1723 if (HIWORD(wParam
) == BN_CLICKED
||
1724 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1726 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICK
);
1729 if (HIWORD(wParam
) == BN_CLICKED
||
1730 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1731 cfg
.alt_f4
= IsDlgButtonChecked(hwnd
, IDC_ALTF4
);
1734 if (HIWORD(wParam
) == BN_CLICKED
||
1735 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1737 IsDlgButtonChecked(hwnd
, IDC_ALTSPACE
);
1740 if (HIWORD(wParam
) == BN_CLICKED
||
1741 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1743 IsDlgButtonChecked(hwnd
, IDC_ALTONLY
);
1745 case IDC_ECHOBACKEND
:
1748 if (HIWORD(wParam
) == BN_CLICKED
||
1749 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1750 if (LOWORD(wParam
) == IDC_ECHOBACKEND
)
1751 cfg
.localecho
= LD_BACKEND
;
1752 if (LOWORD(wParam
) == IDC_ECHOYES
)
1753 cfg
.localecho
= LD_YES
;
1754 if (LOWORD(wParam
) == IDC_ECHONO
)
1755 cfg
.localecho
= LD_NO
;
1758 case IDC_EDITBACKEND
:
1761 if (HIWORD(wParam
) == BN_CLICKED
||
1762 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1763 if (LOWORD(wParam
) == IDC_EDITBACKEND
)
1764 cfg
.localedit
= LD_BACKEND
;
1765 if (LOWORD(wParam
) == IDC_EDITYES
)
1766 cfg
.localedit
= LD_YES
;
1767 if (LOWORD(wParam
) == IDC_EDITNO
)
1768 cfg
.localedit
= LD_NO
;
1771 case IDC_ANSWEREDIT
:
1772 if (HIWORD(wParam
) == EN_CHANGE
)
1773 GetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
1774 sizeof(cfg
.answerback
) - 1);
1776 case IDC_ALWAYSONTOP
:
1777 if (HIWORD(wParam
) == BN_CLICKED
||
1778 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1780 IsDlgButtonChecked(hwnd
, IDC_ALWAYSONTOP
);
1783 if (HIWORD(wParam
) == BN_CLICKED
||
1784 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1786 IsDlgButtonChecked(hwnd
, IDC_SCROLLKEY
);
1788 case IDC_SCROLLDISP
:
1789 if (HIWORD(wParam
) == BN_CLICKED
||
1790 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1791 cfg
.scroll_on_disp
=
1792 IsDlgButtonChecked(hwnd
, IDC_SCROLLDISP
);
1794 case IDC_COMPOSEKEY
:
1795 if (HIWORD(wParam
) == BN_CLICKED
||
1796 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1798 IsDlgButtonChecked(hwnd
, IDC_COMPOSEKEY
);
1800 case IDC_CTRLALTKEYS
:
1801 if (HIWORD(wParam
) == BN_CLICKED
||
1802 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1804 IsDlgButtonChecked(hwnd
, IDC_CTRLALTKEYS
);
1807 if (HIWORD(wParam
) == BN_CLICKED
||
1808 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1809 cfg
.telnet_keyboard
=
1810 IsDlgButtonChecked(hwnd
, IDC_TELNETKEY
);
1813 if (HIWORD(wParam
) == BN_CLICKED
||
1814 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1816 IsDlgButtonChecked(hwnd
, IDC_WRAPMODE
);
1819 if (HIWORD(wParam
) == BN_CLICKED
||
1820 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1821 cfg
.dec_om
= IsDlgButtonChecked(hwnd
, IDC_DECOM
);
1824 if (HIWORD(wParam
) == BN_CLICKED
||
1825 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1827 IsDlgButtonChecked(hwnd
, IDC_LFHASCR
);
1830 if (HIWORD(wParam
) == EN_CHANGE
)
1831 MyGetDlgItemInt(hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1834 if (HIWORD(wParam
) == EN_CHANGE
)
1835 MyGetDlgItemInt(hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1838 if (HIWORD(wParam
) == EN_CHANGE
)
1839 MyGetDlgItemInt(hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1841 case IDC_CHOOSEFONT
:
1844 lf
.lfHeight
= -MulDiv(cfg
.fontheight
,
1845 GetDeviceCaps(hdc
, LOGPIXELSY
),
1849 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1850 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1851 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1852 lf
.lfCharSet
= cfg
.fontcharset
;
1853 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1854 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1855 lf
.lfQuality
= DEFAULT_QUALITY
;
1856 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1857 strncpy(lf
.lfFaceName
, cfg
.font
,
1858 sizeof(lf
.lfFaceName
) - 1);
1859 lf
.lfFaceName
[sizeof(lf
.lfFaceName
) - 1] = '\0';
1861 cf
.lStructSize
= sizeof(cf
);
1862 cf
.hwndOwner
= hwnd
;
1864 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1865 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1867 if (ChooseFont(&cf
)) {
1868 strncpy(cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
) - 1);
1869 cfg
.font
[sizeof(cfg
.font
) - 1] = '\0';
1870 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1871 cfg
.fontcharset
= lf
.lfCharSet
;
1872 cfg
.fontheight
= cf
.iPointSize
/ 10;
1873 fmtfont(fontstatic
);
1874 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
1877 case IDC_BELL_DISABLED
:
1878 case IDC_BELL_DEFAULT
:
1879 case IDC_BELL_WAVEFILE
:
1880 case IDC_BELL_VISUAL
:
1881 if (HIWORD(wParam
) == BN_CLICKED
||
1882 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1883 if (LOWORD(wParam
) == IDC_BELL_DISABLED
)
1884 cfg
.beep
= BELL_DISABLED
;
1885 if (LOWORD(wParam
) == IDC_BELL_DEFAULT
)
1886 cfg
.beep
= BELL_DEFAULT
;
1887 if (LOWORD(wParam
) == IDC_BELL_WAVEFILE
)
1888 cfg
.beep
= BELL_WAVEFILE
;
1889 if (LOWORD(wParam
) == IDC_BELL_VISUAL
)
1890 cfg
.beep
= BELL_VISUAL
;
1893 case IDC_B_IND_DISABLED
:
1894 case IDC_B_IND_FLASH
:
1895 case IDC_B_IND_STEADY
:
1896 if (HIWORD(wParam
) == BN_CLICKED
||
1897 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1898 if (LOWORD(wParam
) == IDC_B_IND_DISABLED
)
1899 cfg
.beep_ind
= B_IND_DISABLED
;
1900 if (LOWORD(wParam
) == IDC_B_IND_FLASH
)
1901 cfg
.beep_ind
= B_IND_FLASH
;
1902 if (LOWORD(wParam
) == IDC_B_IND_STEADY
)
1903 cfg
.beep_ind
= B_IND_STEADY
;
1906 case IDC_BELL_WAVEBROWSE
:
1907 memset(&of
, 0, sizeof(of
));
1908 #ifdef OPENFILENAME_SIZE_VERSION_400
1909 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1911 of
.lStructSize
= sizeof(of
);
1913 of
.hwndOwner
= hwnd
;
1914 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
1915 of
.lpstrCustomFilter
= NULL
;
1916 of
.nFilterIndex
= 1;
1917 of
.lpstrFile
= filename
;
1918 strcpy(filename
, cfg
.bell_wavefile
);
1919 of
.nMaxFile
= sizeof(filename
);
1920 of
.lpstrFileTitle
= NULL
;
1921 of
.lpstrInitialDir
= NULL
;
1922 of
.lpstrTitle
= "Select Bell Sound File";
1924 if (GetOpenFileName(&of
)) {
1925 strcpy(cfg
.bell_wavefile
, filename
);
1926 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
1930 case IDC_BELL_WAVEEDIT
:
1931 if (HIWORD(wParam
) == EN_CHANGE
)
1932 GetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
1934 sizeof(cfg
.bell_wavefile
) - 1);
1937 if (HIWORD(wParam
) == BN_CLICKED
||
1938 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1940 IsDlgButtonChecked(hwnd
, IDC_BELLOVL
);
1943 if (HIWORD(wParam
) == EN_CHANGE
)
1944 MyGetDlgItemInt(hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
1947 if (HIWORD(wParam
) == EN_CHANGE
)
1948 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
,
1952 if (HIWORD(wParam
) == EN_CHANGE
)
1953 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
,
1957 if (HIWORD(wParam
) == BN_CLICKED
||
1958 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1960 IsDlgButtonChecked(hwnd
, IDC_BLINKTEXT
);
1963 if (HIWORD(wParam
) == BN_CLICKED
||
1964 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1965 cfg
.bce
= IsDlgButtonChecked(hwnd
, IDC_BCE
);
1968 if (HIWORD(wParam
) == BN_CLICKED
||
1969 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1970 cfg
.win_name_always
=
1971 IsDlgButtonChecked(hwnd
, IDC_WINNAME
);
1974 if (HIWORD(wParam
) == BN_CLICKED
||
1975 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1977 IsDlgButtonChecked(hwnd
, IDC_HIDEMOUSE
);
1979 case IDC_SUNKENEDGE
:
1980 if (HIWORD(wParam
) == BN_CLICKED
||
1981 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1983 IsDlgButtonChecked(hwnd
, IDC_SUNKENEDGE
);
1986 if (HIWORD(wParam
) == BN_CLICKED
||
1987 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1988 cfg
.cursor_type
= 0;
1991 if (HIWORD(wParam
) == BN_CLICKED
||
1992 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1993 cfg
.cursor_type
= 1;
1996 if (HIWORD(wParam
) == BN_CLICKED
||
1997 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1998 cfg
.cursor_type
= 2;
2001 if (HIWORD(wParam
) == BN_CLICKED
||
2002 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2004 IsDlgButtonChecked(hwnd
, IDC_BLINKCUR
);
2007 if (HIWORD(wParam
) == BN_CLICKED
||
2008 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2010 IsDlgButtonChecked(hwnd
, IDC_SCROLLBAR
);
2013 if (HIWORD(wParam
) == BN_CLICKED
||
2014 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2016 IsDlgButtonChecked(hwnd
, IDC_LOCKSIZE
);
2019 if (HIWORD(wParam
) == EN_CHANGE
)
2020 GetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
2021 sizeof(cfg
.wintitle
) - 1);
2026 if (HIWORD(wParam
) == BN_CLICKED
||
2027 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2029 IsDlgButtonChecked(hwnd
,
2030 IDC_COEALWAYS
) ? COE_ALWAYS
:
2031 IsDlgButtonChecked(hwnd
,
2032 IDC_COENEVER
) ? COE_NEVER
:
2037 if (HIWORD(wParam
) == BN_CLICKED
||
2038 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2040 IsDlgButtonChecked(hwnd
, IDC_CLOSEWARN
);
2043 if (HIWORD(wParam
) == EN_CHANGE
)
2044 GetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
,
2045 sizeof(cfg
.termtype
) - 1);
2048 if (HIWORD(wParam
) == EN_CHANGE
)
2049 GetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
2050 sizeof(cfg
.logfilename
) - 1);
2053 memset(&of
, 0, sizeof(of
));
2054 #ifdef OPENFILENAME_SIZE_VERSION_400
2055 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2057 of
.lStructSize
= sizeof(of
);
2059 of
.hwndOwner
= hwnd
;
2060 of
.lpstrFilter
= "All Files\0*\0\0\0";
2061 of
.lpstrCustomFilter
= NULL
;
2062 of
.nFilterIndex
= 1;
2063 of
.lpstrFile
= filename
;
2064 strcpy(filename
, cfg
.logfilename
);
2065 of
.nMaxFile
= sizeof(filename
);
2066 of
.lpstrFileTitle
= NULL
;
2067 of
.lpstrInitialDir
= NULL
;
2068 of
.lpstrTitle
= "Select session log file";
2070 if (GetSaveFileName(&of
)) {
2071 strcpy(cfg
.logfilename
, filename
);
2072 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
2076 case IDC_LSTATASCII
:
2078 if (HIWORD(wParam
) == BN_CLICKED
||
2079 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2080 if (IsDlgButtonChecked(hwnd
, IDC_LSTATOFF
))
2082 if (IsDlgButtonChecked(hwnd
, IDC_LSTATASCII
))
2084 if (IsDlgButtonChecked(hwnd
, IDC_LSTATRAW
))
2091 if (HIWORD(wParam
) == BN_CLICKED
||
2092 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2093 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXASK
))
2094 cfg
.logxfovr
= LGXF_ASK
;
2095 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXAPN
))
2096 cfg
.logxfovr
= LGXF_APN
;
2097 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXOVR
))
2098 cfg
.logxfovr
= LGXF_OVR
;
2103 if (HIWORD(wParam
) == EN_CHANGE
)
2104 GetDlgItemText(hwnd
, LOWORD(wParam
), cfg
.termspeed
,
2105 sizeof(cfg
.termspeed
) - 1);
2108 if (HIWORD(wParam
) == EN_CHANGE
)
2109 GetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
,
2110 sizeof(cfg
.username
) - 1);
2112 case IDC_RLLUSEREDIT
:
2113 if (HIWORD(wParam
) == EN_CHANGE
)
2114 GetDlgItemText(hwnd
, IDC_RLLUSEREDIT
,
2116 sizeof(cfg
.localusername
) - 1);
2120 cfg
.rfc_environ
= IsDlgButtonChecked(hwnd
, IDC_EMRFC
);
2124 cfg
.passive_telnet
=
2125 IsDlgButtonChecked(hwnd
, IDC_TPASSIVE
);
2128 if (HIWORD(wParam
) == BN_CLICKED
||
2129 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2130 char str
[sizeof(cfg
.environmt
)];
2132 GetDlgItemText(hwnd
, IDC_VAREDIT
, str
,
2138 p
= str
+ strlen(str
);
2140 GetDlgItemText(hwnd
, IDC_VALEDIT
, p
,
2141 sizeof(str
) - 1 - (p
- str
));
2152 if ((p
- cfg
.environmt
) + strlen(str
) + 2 <
2153 sizeof(cfg
.environmt
)) {
2155 p
[strlen(str
) + 1] = '\0';
2156 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
2158 SetDlgItemText(hwnd
, IDC_VAREDIT
, "");
2159 SetDlgItemText(hwnd
, IDC_VALEDIT
, "");
2161 MessageBox(hwnd
, "Environment too big",
2162 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2167 if (HIWORD(wParam
) != BN_CLICKED
&&
2168 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2170 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0,
2177 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
2204 if (HIWORD(wParam
) == BN_CLICKED
||
2205 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2206 cfg
.nopty
= IsDlgButtonChecked(hwnd
, IDC_NOPTY
);
2209 if (HIWORD(wParam
) == BN_CLICKED
||
2210 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2212 IsDlgButtonChecked(hwnd
, IDC_COMPRESS
);
2215 if (HIWORD(wParam
) == BN_CLICKED
||
2216 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2218 IsDlgButtonChecked(hwnd
, IDC_BUGGYMAC
);
2221 if (HIWORD(wParam
) == BN_CLICKED
||
2222 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2224 IsDlgButtonChecked(hwnd
, IDC_AGENTFWD
);
2226 case IDC_CIPHER3DES
:
2227 case IDC_CIPHERBLOWF
:
2230 if (HIWORD(wParam
) == BN_CLICKED
||
2231 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2232 if (IsDlgButtonChecked(hwnd
, IDC_CIPHER3DES
))
2233 cfg
.cipher
= CIPHER_3DES
;
2234 else if (IsDlgButtonChecked(hwnd
, IDC_CIPHERBLOWF
))
2235 cfg
.cipher
= CIPHER_BLOWFISH
;
2236 else if (IsDlgButtonChecked(hwnd
, IDC_CIPHERDES
))
2237 cfg
.cipher
= CIPHER_DES
;
2238 else if (IsDlgButtonChecked(hwnd
, IDC_CIPHERAES
))
2239 cfg
.cipher
= CIPHER_AES
;
2244 if (HIWORD(wParam
) == BN_CLICKED
||
2245 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2246 if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT1
))
2248 else if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT2
))
2253 if (HIWORD(wParam
) == BN_CLICKED
||
2254 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2256 IsDlgButtonChecked(hwnd
, IDC_AUTHTIS
);
2259 if (HIWORD(wParam
) == EN_CHANGE
)
2260 GetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
2261 sizeof(cfg
.keyfile
) - 1);
2264 if (HIWORD(wParam
) == EN_CHANGE
)
2265 GetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
2266 sizeof(cfg
.remote_cmd
) - 1);
2269 memset(&of
, 0, sizeof(of
));
2270 #ifdef OPENFILENAME_SIZE_VERSION_400
2271 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2273 of
.lStructSize
= sizeof(of
);
2275 of
.hwndOwner
= hwnd
;
2276 of
.lpstrFilter
= "All Files\0*\0\0\0";
2277 of
.lpstrCustomFilter
= NULL
;
2278 of
.nFilterIndex
= 1;
2279 of
.lpstrFile
= filename
;
2280 strcpy(filename
, cfg
.keyfile
);
2281 of
.nMaxFile
= sizeof(filename
);
2282 of
.lpstrFileTitle
= NULL
;
2283 of
.lpstrInitialDir
= NULL
;
2284 of
.lpstrTitle
= "Select Public Key File";
2286 if (GetOpenFileName(&of
)) {
2287 strcpy(cfg
.keyfile
, filename
);
2288 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
2292 cfg
.rawcnp
= IsDlgButtonChecked(hwnd
, IDC_RAWCNP
);
2295 cfg
.mouse_is_xterm
= IsDlgButtonChecked(hwnd
, IDC_MBXTERM
);
2301 int n
= GetDlgItemInt(hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
2306 for (i
= 0; i
< 128; i
++)
2307 if (SendDlgItemMessage
2308 (hwnd
, IDC_CCLIST
, LB_GETSEL
, i
, 0)) {
2310 cfg
.wordness
[i
] = n
;
2311 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2312 LB_DELETESTRING
, i
, 0);
2313 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
2314 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ',
2316 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2323 case IDC_BOLDCOLOUR
:
2324 if (HIWORD(wParam
) == BN_CLICKED
||
2325 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2328 IsDlgButtonChecked(hwnd
, IDC_BOLDCOLOUR
);
2329 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2332 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2334 if (n
!= 12 + 10 * cfg
.bold_colour
) {
2335 for (i
= n
; i
-- > 0;)
2336 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2337 LB_DELETESTRING
, i
, 0);
2338 for (i
= 0; i
< 22; i
++)
2339 if (cfg
.bold_colour
|| permcolour
[i
])
2340 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2342 (LPARAM
) colours
[i
]);
2344 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2346 InvalidateRect(GetDlgItem(hwnd
, IDC_COLOURLIST
), NULL
,
2351 if (HIWORD(wParam
) == BN_CLICKED
||
2352 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2354 IsDlgButtonChecked(hwnd
, IDC_PALETTE
);
2356 case IDC_COLOURLIST
:
2357 if (HIWORD(wParam
) == LBN_DBLCLK
||
2358 HIWORD(wParam
) == LBN_SELCHANGE
) {
2360 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2363 if (!cfg
.bold_colour
)
2364 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2365 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2367 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2369 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2374 if (HIWORD(wParam
) == BN_CLICKED
||
2375 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2376 static CHOOSECOLOR cc
;
2377 static DWORD custom
[16] = { 0 }; /* zero initialisers */
2379 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2382 if (!cfg
.bold_colour
)
2383 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2384 cc
.lStructSize
= sizeof(cc
);
2385 cc
.hwndOwner
= hwnd
;
2386 cc
.hInstance
= (HWND
) hinst
;
2387 cc
.lpCustColors
= custom
;
2389 RGB(cfg
.colours
[i
][0], cfg
.colours
[i
][1],
2391 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
2392 if (ChooseColor(&cc
)) {
2394 (unsigned char) (cc
.rgbResult
& 0xFF);
2396 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
2398 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
2399 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2401 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2403 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2409 if (HIWORD(wParam
) == CBN_SELCHANGE
) {
2410 int index
= SendDlgItemMessage(hwnd
, IDC_CODEPAGE
,
2411 CB_GETCURSEL
, 0, 0);
2412 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_GETLBTEXT
,
2413 index
, (LPARAM
)cfg
.line_codepage
);
2416 case IDC_VTXWINDOWS
:
2422 (IsDlgButtonChecked(hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
2423 : IsDlgButtonChecked(hwnd
,
2424 IDC_VTOEMANSI
) ? VT_OEMANSI
:
2425 IsDlgButtonChecked(hwnd
,
2426 IDC_VTOEMONLY
) ? VT_OEMONLY
:
2427 IsDlgButtonChecked(hwnd
,
2428 IDC_VTUNICODE
) ? VT_UNICODE
:
2431 case IDC_X11_FORWARD
:
2432 if (HIWORD(wParam
) == BN_CLICKED
||
2433 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2435 IsDlgButtonChecked(hwnd
, IDC_X11_FORWARD
);
2438 if (HIWORD(wParam
) == BN_CLICKED
||
2439 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2440 cfg
.lport_acceptall
=
2441 IsDlgButtonChecked(hwnd
, IDC_LPORT_ALL
);
2443 case IDC_X11_DISPLAY
:
2444 if (HIWORD(wParam
) == EN_CHANGE
)
2445 GetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
2446 sizeof(cfg
.x11_display
) - 1);
2449 if (HIWORD(wParam
) == BN_CLICKED
||
2450 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2451 char str
[sizeof(cfg
.portfwd
)];
2453 if (IsDlgButtonChecked(hwnd
, IDC_PFWDLOCAL
))
2457 GetDlgItemText(hwnd
, IDC_SPORTEDIT
, str
+1,
2461 "You need to specify a source port number",
2462 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2465 p
= str
+ strlen(str
);
2467 GetDlgItemText(hwnd
, IDC_DPORTEDIT
, p
,
2468 sizeof(str
) - 1 - (p
- str
));
2469 if (!*p
|| !strchr(p
, ':')) {
2471 "You need to specify a destination address\n"
2472 "in the form \"host.name:port\"",
2473 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2482 if ((p
- cfg
.portfwd
) + strlen(str
) + 2 <
2483 sizeof(cfg
.portfwd
)) {
2485 p
[strlen(str
) + 1] = '\0';
2486 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
,
2488 SetDlgItemText(hwnd
, IDC_SPORTEDIT
, "");
2489 SetDlgItemText(hwnd
, IDC_DPORTEDIT
, "");
2491 MessageBox(hwnd
, "Too many forwardings",
2492 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2496 case IDC_PFWDREMOVE
:
2497 if (HIWORD(wParam
) != BN_CLICKED
&&
2498 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2499 i
= SendDlgItemMessage(hwnd
, IDC_PFWDLIST
,
2500 LB_GETCURSEL
, 0, 0);
2506 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_DELETESTRING
,
2538 /* Grrr Explorer will maximize Dialogs! */
2540 if (wParam
== SIZE_MAXIMIZED
)
2547 static int CALLBACK
MainDlgProc(HWND hwnd
, UINT msg
,
2548 WPARAM wParam
, LPARAM lParam
)
2550 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
2552 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
2553 EnableWindow(hwnd
, 0);
2554 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2555 EnableWindow(hwnd
, 1);
2556 SetActiveWindow(hwnd
);
2558 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 0);
2561 static int CALLBACK
ReconfDlgProc(HWND hwnd
, UINT msg
,
2562 WPARAM wParam
, LPARAM lParam
)
2564 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 1);
2567 void defuse_showwindow(void)
2570 * Work around the fact that the app's first call to ShowWindow
2571 * will ignore the default in favour of the shell-provided
2576 hwnd
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2578 ShowWindow(hwnd
, SW_HIDE
);
2579 SetActiveWindow(hwnd
);
2580 DestroyWindow(hwnd
);
2589 savedsession
[0] = '\0';
2591 DialogBox(hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2592 get_sesslist(FALSE
);
2597 int do_reconfig(HWND hwnd
)
2602 backup_cfg
= cfg
; /* structure copy */
2604 DialogBox(hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2606 cfg
= backup_cfg
; /* structure copy */
2611 void logevent(char *string
)
2616 if (nevents
>= negsize
) {
2618 events
= srealloc(events
, negsize
* sizeof(*events
));
2622 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t",
2625 events
[nevents
] = smalloc(strlen(timebuf
) + strlen(string
) + 1);
2626 strcpy(events
[nevents
], timebuf
);
2627 strcat(events
[nevents
], string
);
2630 SendDlgItemMessage(logbox
, IDN_LIST
, LB_ADDSTRING
,
2631 0, (LPARAM
) events
[nevents
]);
2632 count
= SendDlgItemMessage(logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2633 SendDlgItemMessage(logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
- 1, 0);
2638 void showeventlog(HWND hwnd
)
2641 logbox
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2643 ShowWindow(logbox
, SW_SHOWNORMAL
);
2645 SetActiveWindow(logbox
);
2648 void showabout(HWND hwnd
)
2650 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2653 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2654 char *keystr
, char *fingerprint
)
2658 static const char absentmsg
[] =
2659 "The server's host key is not cached in the registry. You\n"
2660 "have no guarantee that the server is the computer you\n"
2662 "The server's key fingerprint is:\n"
2664 "If you trust this host, hit Yes to add the key to\n"
2665 "PuTTY's cache and carry on connecting.\n"
2666 "If you want to carry on connecting just once, without\n"
2667 "adding the key to the cache, hit No.\n"
2668 "If you do not trust this host, hit Cancel to abandon the\n"
2671 static const char wrongmsg
[] =
2672 "WARNING - POTENTIAL SECURITY BREACH!\n"
2674 "The server's host key does not match the one PuTTY has\n"
2675 "cached in the registry. This means that either the\n"
2676 "server administrator has changed the host key, or you\n"
2677 "have actually connected to another computer pretending\n"
2678 "to be the server.\n"
2679 "The new key fingerprint is:\n"
2681 "If you were expecting this change and trust the new key,\n"
2682 "hit Yes to update PuTTY's cache and continue connecting.\n"
2683 "If you want to carry on connecting but without updating\n"
2684 "the cache, hit No.\n"
2685 "If you want to abandon the connection completely, hit\n"
2686 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
2688 static const char mbtitle
[] = "PuTTY Security Alert";
2691 /* sensible fingerprint max size */
2692 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2693 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2696 * Verify the key against the registry.
2698 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2700 if (ret
== 0) /* success - key matched OK */
2702 if (ret
== 2) { /* key was different */
2704 sprintf(message
, wrongmsg
, fingerprint
);
2705 mbret
= MessageBox(NULL
, message
, mbtitle
,
2706 MB_ICONWARNING
| MB_YESNOCANCEL
);
2708 store_host_key(host
, port
, keytype
, keystr
);
2709 if (mbret
== IDCANCEL
)
2712 if (ret
== 1) { /* key was absent */
2714 sprintf(message
, absentmsg
, fingerprint
);
2715 mbret
= MessageBox(NULL
, message
, mbtitle
,
2716 MB_ICONWARNING
| MB_YESNOCANCEL
);
2718 store_host_key(host
, port
, keytype
, keystr
);
2719 if (mbret
== IDCANCEL
)
2725 * Ask whether to wipe a session log file before writing to it.
2726 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2728 int askappend(char *filename
)
2730 static const char mbtitle
[] = "PuTTY Log to File";
2731 static const char msgtemplate
[] =
2732 "The session log file \"%.*s\" already exists.\n"
2733 "You can overwrite it with a new session log,\n"
2734 "append your session log to the end of it,\n"
2735 "or disable session logging for this session.\n"
2736 "Hit Yes to wipe the file, No to append to it,\n"
2737 "or Cancel to disable logging.";
2738 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2740 if (cfg
.logxfovr
!= LGXF_ASK
) {
2741 return ((cfg
.logxfovr
== LGXF_OVR
) ?
2 : 1);
2743 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2745 mbret
= MessageBox(NULL
, message
, mbtitle
,
2746 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2749 else if (mbret
== IDNO
)