15 static char **events
= NULL
;
16 static int nevents
= 0, negsize
= 0;
19 static int sesslist_has_focus
;
21 static struct prefslist cipherlist
;
23 void force_normal(HWND hwnd
)
25 static int recurse
= 0;
33 wp
.length
= sizeof(wp
);
34 if (GetWindowPlacement(hwnd
, &wp
) && wp
.showCmd
== SW_SHOWMAXIMIZED
) {
35 wp
.showCmd
= SW_SHOWNORMAL
;
36 SetWindowPlacement(hwnd
, &wp
);
41 static void MyGetDlgItemInt(HWND hwnd
, int id
, int *result
)
45 n
= GetDlgItemInt(hwnd
, id
, &ok
, FALSE
);
50 static void MyGetDlgItemFlt(HWND hwnd
, int id
, int *result
, int scale
)
54 ok
= GetDlgItemText(hwnd
, id
, text
, sizeof(text
) - 1);
56 *result
= (int) (scale
* atof(text
));
59 static void MySetDlgItemFlt(HWND hwnd
, int id
, double value
)
62 sprintf(text
, "%g", value
);
63 SetDlgItemText(hwnd
, id
, text
);
66 static int CALLBACK
LogProc(HWND hwnd
, UINT msg
,
67 WPARAM wParam
, LPARAM lParam
)
74 static int tabs
[4] = { 78, 108 };
75 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETTABSTOPS
, 2,
78 for (i
= 0; i
< nevents
; i
++)
79 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_ADDSTRING
,
80 0, (LPARAM
) events
[i
]);
83 switch (LOWORD(wParam
)) {
87 SetActiveWindow(GetParent(hwnd
));
91 if (HIWORD(wParam
) == BN_CLICKED
||
92 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
95 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
96 LB_GETSELCOUNT
, 0, 0);
97 if (selcount
== 0) { /* don't even try to copy zero items */
102 selitems
= smalloc(selcount
* sizeof(int));
104 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
111 static unsigned char sel_nl
[] = SEL_NL
;
113 if (count
== 0) { /* can't copy zero stuff */
119 for (i
= 0; i
< count
; i
++)
121 strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
123 clipdata
= smalloc(size
);
126 for (i
= 0; i
< count
; i
++) {
127 char *q
= events
[selitems
[i
]];
128 int qlen
= strlen(q
);
131 memcpy(p
, sel_nl
, sizeof(sel_nl
));
134 write_aclip(clipdata
, size
, TRUE
);
139 for (i
= 0; i
< nevents
; i
++)
140 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
149 SetActiveWindow(GetParent(hwnd
));
156 static int CALLBACK
LicenceProc(HWND hwnd
, UINT msg
,
157 WPARAM wParam
, LPARAM lParam
)
163 switch (LOWORD(wParam
)) {
176 static int CALLBACK
AboutProc(HWND hwnd
, UINT msg
,
177 WPARAM wParam
, LPARAM lParam
)
181 SetDlgItemText(hwnd
, IDA_VERSION
, ver
);
184 switch (LOWORD(wParam
)) {
187 EndDialog(hwnd
, TRUE
);
190 EnableWindow(hwnd
, 0);
191 DialogBox(hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
193 EnableWindow(hwnd
, 1);
194 SetActiveWindow(hwnd
);
198 /* Load web browser */
199 ShellExecute(hwnd
, "open",
200 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
201 0, 0, SW_SHOWDEFAULT
);
206 EndDialog(hwnd
, TRUE
);
213 * Null dialog procedure.
215 static int CALLBACK
NullDlgProc(HWND hwnd
, UINT msg
,
216 WPARAM wParam
, LPARAM lParam
)
221 static char savedsession
[2048];
224 IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
369 IDC_FULLSCREENONALTENTER
,
372 appearancepanelstart
,
373 IDC_TITLE_APPEARANCE
,
395 connectionpanelstart
,
396 IDC_TITLE_CONNECTION
,
504 translationpanelstart
,
505 IDC_TITLE_TRANSLATION
,
506 IDC_BOX_TRANSLATION1
,
507 IDC_BOX_TRANSLATION2
,
508 IDC_BOX_TRANSLATION3
,
545 static const char *const colours
[] = {
546 "Default Foreground", "Default Bold Foreground",
547 "Default Background", "Default Bold Background",
548 "Cursor Text", "Cursor Colour",
549 "ANSI Black", "ANSI Black Bold",
550 "ANSI Red", "ANSI Red Bold",
551 "ANSI Green", "ANSI Green Bold",
552 "ANSI Yellow", "ANSI Yellow Bold",
553 "ANSI Blue", "ANSI Blue Bold",
554 "ANSI Magenta", "ANSI Magenta Bold",
555 "ANSI Cyan", "ANSI Cyan Bold",
556 "ANSI White", "ANSI White Bold"
558 static const int permcolour
[] = {
559 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
560 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
561 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
564 static void fmtfont(char *buf
)
566 sprintf(buf
, "Font: %s, ", cfg
.font
);
568 strcat(buf
, "bold, ");
569 if (cfg
.fontheight
== 0)
570 strcat(buf
, "default height");
572 sprintf(buf
+ strlen(buf
), "%d-point",
573 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
576 /* 2nd arg: NZ => don't redraw session list (use when loading
578 static void init_dlg_ctrls(HWND hwnd
, int keepsess
)
581 char fontstatic
[256];
583 SetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
);
584 SetDlgItemText(hwnd
, IDC_SESSEDIT
, savedsession
);
587 n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
588 for (i
= n
; i
-- > 0;)
589 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_DELETESTRING
, i
, 0);
590 for (i
= 0; i
< nsessions
; i
++)
591 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
592 0, (LPARAM
) (sessions
[i
]));
594 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
595 CheckRadioButton(hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
596 cfg
.protocol
== PROT_SSH ? IDC_PROTSSH
:
597 cfg
.protocol
== PROT_TELNET ? IDC_PROTTELNET
:
599 PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
600 SetDlgItemInt(hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
602 CheckRadioButton(hwnd
, IDC_DEL008
, IDC_DEL127
,
603 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
604 CheckRadioButton(hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
605 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
606 CheckRadioButton(hwnd
, IDC_FUNCTILDE
, IDC_FUNCSCO
,
607 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
608 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
609 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
610 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
611 cfg
.funky_type
== 4 ? IDC_FUNCVT100P
:
612 cfg
.funky_type
== 5 ? IDC_FUNCSCO
: IDC_FUNCTILDE
);
613 CheckDlgButton(hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
614 CheckDlgButton(hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
615 CheckRadioButton(hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
616 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
617 CheckRadioButton(hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
618 cfg
.nethack_keypad ? IDC_KPNH
:
619 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
620 CheckDlgButton(hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
621 CheckDlgButton(hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
622 CheckDlgButton(hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
623 CheckDlgButton(hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
624 CheckDlgButton(hwnd
, IDC_CTRLALTKEYS
, cfg
.ctrlaltkeys
);
625 CheckDlgButton(hwnd
, IDC_TELNETKEY
, cfg
.telnet_keyboard
);
626 CheckRadioButton(hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
627 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
628 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
629 CheckRadioButton(hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
630 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
631 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
632 SetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
);
633 CheckDlgButton(hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
634 CheckDlgButton(hwnd
, IDC_FULLSCREENONALTENTER
, cfg
.fullscreenonaltenter
);
635 CheckDlgButton(hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
636 CheckDlgButton(hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
638 CheckDlgButton(hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
639 CheckDlgButton(hwnd
, IDC_DECOM
, cfg
.dec_om
);
640 CheckDlgButton(hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
641 SetDlgItemInt(hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
642 SetDlgItemInt(hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
643 SetDlgItemInt(hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
645 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
646 CheckRadioButton(hwnd
, IDC_BELL_DISABLED
, IDC_BELL_VISUAL
,
647 cfg
.beep
== BELL_DISABLED ? IDC_BELL_DISABLED
:
648 cfg
.beep
== BELL_DEFAULT ? IDC_BELL_DEFAULT
:
649 cfg
.beep
== BELL_WAVEFILE ? IDC_BELL_WAVEFILE
:
651 BELL_VISUAL ? IDC_BELL_VISUAL
: IDC_BELL_DEFAULT
);
652 CheckRadioButton(hwnd
, IDC_B_IND_DISABLED
, IDC_B_IND_STEADY
,
654 B_IND_DISABLED ? IDC_B_IND_DISABLED
: cfg
.beep_ind
==
655 B_IND_FLASH ? IDC_B_IND_FLASH
: cfg
.beep_ind
==
656 B_IND_STEADY ? IDC_B_IND_STEADY
: IDC_B_IND_DISABLED
);
657 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
658 CheckDlgButton(hwnd
, IDC_BELLOVL
, cfg
.bellovl
);
659 SetDlgItemInt(hwnd
, IDC_BELLOVLN
, cfg
.bellovl_n
, FALSE
);
660 MySetDlgItemFlt(hwnd
, IDC_BELLOVLT
, cfg
.bellovl_t
/ 1000.0);
661 MySetDlgItemFlt(hwnd
, IDC_BELLOVLS
, cfg
.bellovl_s
/ 1000.0);
663 CheckDlgButton(hwnd
, IDC_BCE
, cfg
.bce
);
664 CheckDlgButton(hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
666 SetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
667 CheckDlgButton(hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
668 CheckDlgButton(hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
669 CheckDlgButton(hwnd
, IDC_SUNKENEDGE
, cfg
.sunken_edge
);
670 SetDlgItemInt(hwnd
, IDC_WINBEDIT
, cfg
.window_border
, FALSE
);
671 CheckRadioButton(hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
672 cfg
.cursor_type
== 0 ? IDC_CURBLOCK
:
673 cfg
.cursor_type
== 1 ? IDC_CURUNDER
: IDC_CURVERT
);
674 CheckDlgButton(hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
675 CheckDlgButton(hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
676 CheckDlgButton(hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
677 CheckDlgButton(hwnd
, IDC_LOCKFONT
, cfg
.lockfont
);
678 CheckRadioButton(hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
679 cfg
.close_on_exit
== COE_NORMAL ? IDC_COENORMAL
:
681 COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
682 CheckDlgButton(hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
684 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
685 SetDlgItemText(hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
686 SetDlgItemText(hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
687 SetDlgItemText(hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
688 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
689 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
690 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
691 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
692 cfg
.logtype
== 1 ? IDC_LSTATASCII
: IDC_LSTATRAW
);
693 CheckRadioButton(hwnd
, IDC_LSTATXOVR
, IDC_LSTATXASK
,
694 cfg
.logxfovr
== LGXF_OVR ? IDC_LSTATXOVR
:
695 cfg
.logxfovr
== LGXF_ASK ? IDC_LSTATXASK
:
698 char *p
= cfg
.environmt
;
699 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_RESETCONTENT
, 0, 0);
701 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
707 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
, 0,
712 CheckRadioButton(hwnd
, IDC_EMBSD
, IDC_EMRFC
,
713 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
714 CheckRadioButton(hwnd
, IDC_TPASSIVE
, IDC_TACTIVE
,
715 cfg
.passive_telnet ? IDC_TPASSIVE
: IDC_TACTIVE
);
717 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
718 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
719 CheckDlgButton(hwnd
, IDC_NOPTY
, cfg
.nopty
);
720 CheckDlgButton(hwnd
, IDC_COMPRESS
, cfg
.compression
);
721 CheckDlgButton(hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
722 CheckDlgButton(hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
723 CheckRadioButton(hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
724 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
725 CheckDlgButton(hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
726 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
727 SetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
731 static const struct { char *s
; int c
; } ciphers
[] = {
732 { "3DES", CIPHER_3DES
},
733 { "Blowfish", CIPHER_BLOWFISH
},
734 { "DES (SSH 1 only)", CIPHER_DES
},
735 { "AES (SSH 2 only)", CIPHER_AES
},
736 { "-- warn below here --", CIPHER_WARN
}
739 /* Set up the "selected ciphers" box. */
740 /* (cipherlist assumed to contain all ciphers) */
741 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_RESETCONTENT
, 0, 0);
742 for (i
= 0; i
< CIPHER_MAX
; i
++) {
743 int c
= cfg
.ssh_cipherlist
[i
];
746 for (j
= 0; j
< (sizeof ciphers
) / (sizeof ciphers
[0]); j
++) {
747 if (ciphers
[j
].c
== c
) {
752 pos
= SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_ADDSTRING
,
754 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_SETITEMDATA
,
761 CheckRadioButton(hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
762 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
763 CheckDlgButton(hwnd
, IDC_MOUSEOVERRIDE
, cfg
.mouse_override
);
764 CheckDlgButton(hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
766 static int tabs
[4] = { 25, 61, 96, 128 };
767 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
770 for (i
= 0; i
< 128; i
++) {
772 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
773 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ', cfg
.wordness
[i
]);
774 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
778 CheckDlgButton(hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
779 CheckDlgButton(hwnd
, IDC_PALETTE
, cfg
.try_palette
);
782 n
= SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
783 for (i
= n
; i
-- > 0;)
784 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
785 LB_DELETESTRING
, i
, 0);
786 for (i
= 0; i
< 22; i
++)
787 if (cfg
.bold_colour
|| permcolour
[i
])
788 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
789 (LPARAM
) colours
[i
]);
791 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
792 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
793 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
794 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
799 strcpy(cfg
.line_codepage
, cp_name(decode_codepage(cfg
.line_codepage
)));
800 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_RESETCONTENT
, 0, 0);
801 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
802 for (i
= 0; (cp
= cp_enumerate(i
)) != NULL
; i
++) {
803 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_ADDSTRING
,
806 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
809 CheckRadioButton(hwnd
, IDC_VTXWINDOWS
, IDC_VTUNICODE
,
810 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
811 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
812 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
813 cfg
.vtmode
== VT_UNICODE ? IDC_VTUNICODE
:
816 CheckDlgButton(hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
817 SetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
819 CheckDlgButton(hwnd
, IDC_LPORT_ALL
, cfg
.lport_acceptall
);
820 CheckRadioButton(hwnd
, IDC_PFWDLOCAL
, IDC_PFWDREMOTE
, IDC_PFWDLOCAL
);
823 struct treeview_faff
{
828 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
829 int level
, char *text
)
834 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
- 1] : TVI_ROOT
);
835 ins
.hInsertAfter
= faff
->lastat
[level
];
836 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
837 #define INSITEM DUMMYUNIONNAME.item
841 ins
.INSITEM
.mask
= TVIF_TEXT
;
842 ins
.INSITEM
.pszText
= text
;
843 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
845 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
- 1],
847 faff
->lastat
[level
] = newitem
;
848 for (i
= level
+ 1; i
< 4; i
++)
849 faff
->lastat
[i
] = NULL
;
854 * Create the panelfuls of controls in the configuration box.
856 static void create_controls(HWND hwnd
, int dlgtype
, int panel
)
858 if (panel
== sessionpanelstart
) {
859 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
861 ctlposinit(&cp
, hwnd
, 80, 3, 13);
862 bartitle(&cp
, "Basic options for your PuTTY session",
865 beginbox(&cp
, "Specify your connection by host name or IP address",
868 "Host &Name (or IP address)",
869 IDC_HOSTSTATIC
, IDC_HOST
, 75,
870 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
871 if (backends
[3].backend
== NULL
) {
872 /* this is PuTTYtel, so only three protocols available */
873 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 3,
875 "&Telnet", IDC_PROTTELNET
,
876 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
878 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
880 "&Telnet", IDC_PROTTELNET
,
881 "Rlog&in", IDC_PROTRLOGIN
,
890 beginbox(&cp
, "Load, save or delete a stored session",
892 sesssaver(&cp
, "Sav&ed Sessions",
893 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
894 "&Load", IDC_SESSLOAD
,
895 "&Save", IDC_SESSSAVE
, "&Delete", IDC_SESSDEL
, NULL
);
898 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
899 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
900 "Always", IDC_COEALWAYS
,
901 "Never", IDC_COENEVER
,
902 "Only on clean exit", IDC_COENORMAL
, NULL
);
906 if (panel
== loggingpanelstart
) {
907 /* The Logging panel. Accelerators used: [acgo] tplfwe */
909 ctlposinit(&cp
, hwnd
, 80, 3, 13);
910 bartitle(&cp
, "Options controlling session logging",
912 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
914 "Session logging:", IDC_LSTATSTATIC
,
915 "Logging &turned off completely", IDC_LSTATOFF
,
916 "Log &printable output only", IDC_LSTATASCII
,
917 "&Log all session output", IDC_LSTATRAW
, NULL
);
918 editbutton(&cp
, "Log &file name:",
919 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
921 statictext(&cp
, "(Log file name can contain &&Y, &&M, &&D for date,"
922 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN
);
924 "What to do if the log file already &exists:",
925 IDC_LSTATXIST
, "Always overwrite it", IDC_LSTATXOVR
,
926 "Always append to the end of it", IDC_LSTATXAPN
,
927 "Ask the user every time", IDC_LSTATXASK
, NULL
);
931 if (panel
== terminalpanelstart
) {
932 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
934 ctlposinit(&cp
, hwnd
, 80, 3, 13);
935 bartitle(&cp
, "Options controlling the terminal emulation",
937 beginbox(&cp
, "Set various terminal options", IDC_BOX_TERMINAL1
);
938 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
939 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
940 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
941 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
942 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
944 "An&swerback to ^E:", IDC_ANSWERBACK
,
945 IDC_ANSWEREDIT
, 100, NULL
);
948 beginbox(&cp
, "Line discipline options", IDC_BOX_TERMINAL2
);
949 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
950 "Auto", IDC_ECHOBACKEND
,
951 "Force on", IDC_ECHOYES
, "Force off", IDC_ECHONO
, NULL
);
952 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
953 "Auto", IDC_EDITBACKEND
,
954 "Force on", IDC_EDITYES
, "Force off", IDC_EDITNO
, NULL
);
958 if (panel
== bellpanelstart
) {
959 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
961 ctlposinit(&cp
, hwnd
, 80, 3, 13);
962 bartitle(&cp
, "Options controlling the terminal bell",
964 beginbox(&cp
, "Set the style of bell", IDC_BOX_BELL1
);
966 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
967 "None (bell disabled)", IDC_BELL_DISABLED
,
968 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
969 "Play a custom sound file", IDC_BELL_WAVEFILE
,
970 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
971 editbutton(&cp
, "Custom sound file to play as a bell:",
972 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
973 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
974 radioline(&cp
, "Taskbar/caption &indication on bell:",
975 IDC_B_IND_STATIC
, 3, "Disabled", IDC_B_IND_DISABLED
,
976 "Flashing", IDC_B_IND_FLASH
, "Steady", IDC_B_IND_STEADY
,
979 beginbox(&cp
, "Control the bell overload behaviour",
981 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
983 staticedit(&cp
, "Over-use means this &many bells...",
984 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
985 staticedit(&cp
, "... in &this many seconds",
986 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
988 "The bell is re-enabled after a few seconds of silence.",
989 1, IDC_BELLOVLEXPLAIN
);
990 staticedit(&cp
, "Seconds of &silence required", IDC_BELLOVLSSTATIC
,
995 if (panel
== keyboardpanelstart
) {
996 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
998 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1000 bartitle(&cp, "Options controlling the effects of keys",
1001 IDC_TITLE_KEYBOARD);
1003 beginbox(&cp
, "Change the sequences sent by:", IDC_BOX_KEYBOARD1
);
1004 radioline(&cp
, "The &Backspace key", IDC_DELSTATIC
, 2,
1005 "Control-H", IDC_DEL008
,
1006 "Control-? (127)", IDC_DEL127
, NULL
);
1007 radioline(&cp
, "The &Home and End keys", IDC_HOMESTATIC
, 2,
1008 "Standard", IDC_HOMETILDE
, "rxvt", IDC_HOMERXVT
, NULL
);
1009 radioline(&cp
, "The &Function keys and keypad", IDC_FUNCSTATIC
, 3,
1010 "ESC[n~", IDC_FUNCTILDE
,
1011 "Linux", IDC_FUNCLINUX
,
1012 "Xterm R6", IDC_FUNCXTERM
,
1013 "VT400", IDC_FUNCVT400
,
1014 "VT100+", IDC_FUNCVT100P
, "SCO", IDC_FUNCSCO
, NULL
);
1016 beginbox(&cp
, "Application keypad settings:", IDC_BOX_KEYBOARD2
);
1018 "Application c&ursor keys totally disabled",
1020 radioline(&cp
, "Initial state of cu&rsor keys:", IDC_CURSTATIC
, 2,
1021 "Normal", IDC_CURNORMAL
,
1022 "Application", IDC_CURAPPLIC
, NULL
);
1024 "Application ke&ypad keys totally disabled",
1026 radioline(&cp
, "Initial state of &numeric keypad:", IDC_KPSTATIC
,
1027 3, "Normal", IDC_KPNORMAL
, "Application", IDC_KPAPPLIC
,
1028 "NetHack", IDC_KPNH
, NULL
);
1030 beginbox(&cp
, "Enable extra keyboard features:",
1032 checkbox(&cp
, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY
);
1033 checkbox(&cp
, "Control-Alt is &different from AltGr",
1038 if (panel
== windowpanelstart
) {
1039 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt f */
1041 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1042 bartitle(&cp
, "Options controlling PuTTY's window",
1044 beginbox(&cp
, "Set the size of the window", IDC_BOX_WINDOW1
);
1046 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
1047 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50, NULL
);
1048 checkbox(&cp
, "Lock terminal size against resi&zing", IDC_LOCKSIZE
);
1049 checkbox(&cp
, "Lock font size against resi&zing", IDC_LOCKFONT
);
1051 beginbox(&cp
, "Control the scrollback in the window",
1053 staticedit(&cp
, "Lines of &scrollback",
1054 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
1055 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
1056 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
1057 checkbox(&cp
, "Reset scrollback on dis&play activity",
1060 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
1061 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
1062 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
1063 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
1064 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
1065 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
1066 checkbox(&cp
, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER
);
1070 if (panel
== appearancepanelstart
) {
1071 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1073 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1074 /* bartitle(&cp, "Options controlling PuTTY's appearance",
1075 IDC_TITLE_APPEARANCE); */
1076 beginbox(&cp
, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1
);
1077 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
1078 "B&lock", IDC_CURBLOCK
,
1079 "&Underline", IDC_CURUNDER
,
1080 "&Vertical line", IDC_CURVERT
, NULL
);
1081 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
1083 beginbox(&cp
, "Set the font used in the terminal window",
1084 IDC_BOX_APPEARANCE2
);
1085 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
1087 beginbox(&cp
, "Adjust the use of the window title",
1088 IDC_BOX_APPEARANCE3
);
1090 "Window &title:", IDC_WINTITLE
, IDC_WINEDIT
, 100, NULL
);
1091 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
1093 beginbox(&cp
, "Adjust the use of the mouse pointer",
1094 IDC_BOX_APPEARANCE4
);
1095 checkbox(&cp
, "Hide mouse &pointer when typing in window",
1098 beginbox(&cp
, "Adjust the window border", IDC_BOX_APPEARANCE5
);
1099 checkbox(&cp
, "&Sunken-edge border (slightly thicker)",
1101 staticedit(&cp
, "Gap between text and window edge",
1102 IDC_WINBSTATIC
, IDC_WINBEDIT
, 20);
1106 if (panel
== translationpanelstart
) {
1107 /* The Translation panel. Accelerators used: [acgo] rxbepus */
1109 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1110 bartitle(&cp
, "Options controlling character set translation",
1111 IDC_TITLE_TRANSLATION
);
1112 beginbox(&cp
, "Character set translation on received data",
1113 IDC_BOX_TRANSLATION1
);
1114 combobox(&cp
, "&Received data assumed to be in which character set:",
1115 IDC_CODEPAGESTATIC
, IDC_CODEPAGE
);
1117 beginbox(&cp
, "Enable character set translation on input data",
1118 IDC_BOX_TRANSLATION2
);
1119 checkbox(&cp
, "Cap&s Lock acts as Cyrillic switch",
1122 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
1123 IDC_BOX_TRANSLATION3
);
1125 "Handling of line drawing characters:", IDC_VTSTATIC
,
1126 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
1127 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
1128 "Use font in O&EM mode only", IDC_VTOEMONLY
,
1129 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1130 IDC_VTPOORMAN
, "&Unicode mode", IDC_VTUNICODE
, NULL
);
1134 if (panel
== selectionpanelstart
) {
1135 /* The Selection panel. Accelerators used: [acgo] d wxp hst */
1137 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1138 bartitle(&cp
, "Options controlling copy and paste",
1139 IDC_TITLE_SELECTION
);
1140 beginbox(&cp
, "Translation of pasted characters",
1141 IDC_BOX_SELECTION1
);
1143 "&Don't translate line drawing chars into +, - and |",
1146 beginbox(&cp
, "Control which mouse button does which thing",
1147 IDC_BOX_SELECTION2
);
1148 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1149 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1150 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1153 "Shift overrides a&pplication's use of mouse",
1156 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1157 IDC_BOX_SELECTION3
);
1158 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1159 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1160 "&to class", IDC_CCSTATIC2
);
1164 if (panel
== colourspanelstart
) {
1165 /* The Colours panel. Accelerators used: [acgo] blum */
1167 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1168 bartitle(&cp
, "Options controlling use of colours",
1170 beginbox(&cp
, "General options for colour usage",
1172 checkbox(&cp
, "&Bolded text is a different colour",
1174 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1176 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1178 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1179 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1180 "&Modify...", IDC_CHANGE
,
1181 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1182 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1183 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1187 if (panel
== connectionpanelstart
) {
1188 /* The Connection panel. Accelerators used: [acgo] tuk */
1190 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1191 bartitle(&cp
, "Options controlling the connection",
1192 IDC_TITLE_CONNECTION
);
1194 beginbox(&cp
, "Data to send to the server",
1195 IDC_BOX_CONNECTION1
);
1196 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
,
1198 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
,
1202 beginbox(&cp
, "Adjust telnet session.", IDC_BOX_CONNECTION1
);
1203 checkbox(&cp
, "Keyboard sends telnet Backspace and Interrupt",
1207 beginbox(&cp
, "Sending of null packets to keep session active",
1208 IDC_BOX_CONNECTION2
);
1209 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1210 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1214 if (panel
== telnetpanelstart
) {
1215 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
1217 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1219 bartitle(&cp
, "Options controlling Telnet connections",
1221 beginbox(&cp
, "Data to send to the server", IDC_BOX_TELNET1
);
1222 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
,
1224 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1225 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
, "Va&lue",
1226 IDC_VALSTATIC
, IDC_VALEDIT
, IDC_ENVLIST
, "A&dd",
1227 IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1229 beginbox(&cp
, "Telnet protocol adjustments", IDC_BOX_TELNET2
);
1230 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:",
1231 IDC_EMSTATIC
, 2, "&BSD (commonplace)", IDC_EMBSD
,
1232 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1233 radioline(&cp
, "&Telnet negotiation mode:", IDC_ACTSTATIC
, 2,
1234 "Passive", IDC_TPASSIVE
, "Active",
1236 checkbox(&cp
, "&Keyboard sends telnet Backspace and Interrupt",
1242 if (panel
== rloginpanelstart
) {
1243 /* The Rlogin panel. Accelerators used: [acgo] sl */
1245 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1247 bartitle(&cp
, "Options controlling Rlogin connections",
1249 beginbox(&cp
, "Data to send to the server", IDC_BOX_RLOGIN1
);
1250 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
,
1252 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
,
1253 IDC_RLLUSEREDIT
, 50);
1258 if (panel
== sshpanelstart
) {
1259 /* The SSH panel. Accelerators used: [acgo] r pe12i s */
1261 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1263 bartitle(&cp
, "Options controlling SSH connections",
1265 beginbox(&cp
, "Data to send to the server", IDC_BOX_SSH1
);
1267 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1270 beginbox(&cp
, "Protocol options", IDC_BOX_SSH2
);
1271 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1272 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1273 radioline(&cp
, "Preferred SSH protocol version:",
1274 IDC_SSHPROTSTATIC
, 2,
1275 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1276 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1279 beginbox(&cp
, "Encryption options", IDC_BOX_SSH3
);
1280 prefslist(&cipherlist
, &cp
, "Encryption cipher &selection policy:",
1281 IDC_CIPHERSTATIC2
, IDC_CIPHERLIST
, IDC_CIPHERUP
,
1287 if (panel
== sshauthpanelstart
) {
1288 /* The SSH authentication panel. Accelerators used: [acgo] m fkw */
1290 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1292 bartitle(&cp
, "Options controlling SSH authentication",
1294 beginbox(&cp
, "Authentication methods",
1296 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1299 beginbox(&cp
, "Authentication parameters",
1301 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1302 editbutton(&cp
, "Private &key file for authentication:",
1303 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...",
1309 if (panel
== tunnelspanelstart
) {
1310 /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */
1312 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1314 bartitle(&cp
, "Options controlling SSH tunnelling",
1316 beginbox(&cp
, "X11 forwarding", IDC_BOX_TUNNELS1
);
1317 checkbox(&cp
, "&Enable X11 forwarding", IDC_X11_FORWARD
);
1318 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1319 IDC_X11_DISPLAY
, 50, NULL
);
1321 beginbox(&cp
, "Port forwarding", IDC_BOX_TUNNELS2
);
1322 checkbox(&cp
, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL
);
1323 staticbtn(&cp
, "Forwarded ports:", IDC_PFWDSTATIC
,
1324 "&Remove", IDC_PFWDREMOVE
);
1325 fwdsetter(&cp
, IDC_PFWDLIST
,
1326 "Add new forwarded port:", IDC_PFWDSTATIC2
,
1327 "&Source port", IDC_SPORTSTATIC
, IDC_SPORTEDIT
,
1328 "Dest&ination", IDC_DPORTSTATIC
, IDC_DPORTEDIT
,
1329 "A&dd", IDC_PFWDADD
);
1330 bareradioline(&cp
, 2,
1331 "&Local", IDC_PFWDLOCAL
, "Re&mote", IDC_PFWDREMOTE
, NULL
);
1339 * Helper function to load the session selected in SESSLIST
1340 * if any, as this is done in more than one place in
1341 * GenericMainDlgProc(). 0 => failure.
1343 static int load_selected_session(HWND hwnd
)
1345 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1346 LB_GETCURSEL
, 0, 0);
1352 isdef
= !strcmp(sessions
[n
], "Default Settings");
1353 load_settings(sessions
[n
], !isdef
, &cfg
);
1354 init_dlg_ctrls(hwnd
, TRUE
);
1356 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1358 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1359 /* Restore the selection, which will have been clobbered by
1360 * SESSEDIT handling. */
1361 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
, n
, 0);
1366 * This function is the configuration box.
1368 static int GenericMainDlgProc(HWND hwnd
, UINT msg
,
1369 WPARAM wParam
, LPARAM lParam
, int dlgtype
)
1372 struct treeview_faff tvfaff
;
1375 char filename
[sizeof(cfg
.keyfile
)];
1378 char fontstatic
[256];
1380 struct servent
*service
;
1382 static UINT draglistmsg
= WM_NULL
;
1387 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1388 SendMessage(hwnd
, WM_SETICON
, (WPARAM
) ICON_BIG
,
1389 (LPARAM
) LoadIcon(hinst
, MAKEINTRESOURCE(IDI_CFGICON
)));
1391 * Centre the window.
1393 { /* centre the window */
1396 hw
= GetDesktopWindow();
1397 if (GetWindowRect(hw
, &rs
) && GetWindowRect(hwnd
, &rd
))
1399 (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
) / 2,
1400 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
) / 2,
1401 rd
.right
- rd
.left
, rd
.bottom
- rd
.top
, TRUE
);
1405 * Create the tree view.
1413 r
.right
= r
.left
+ 75;
1415 r
.bottom
= r
.top
+ 10;
1416 MapDialogRect(hwnd
, &r
);
1417 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1418 WS_CHILD
| WS_VISIBLE
,
1420 r
.right
- r
.left
, r
.bottom
- r
.top
,
1421 hwnd
, (HMENU
) IDCX_TVSTATIC
, hinst
,
1423 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1424 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1427 r
.right
= r
.left
+ 75;
1429 r
.bottom
= r
.top
+ 206;
1430 MapDialogRect(hwnd
, &r
);
1431 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1432 WS_CHILD
| WS_VISIBLE
|
1433 WS_TABSTOP
| TVS_HASLINES
|
1434 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
1436 TVS_SHOWSELALWAYS
, r
.left
, r
.top
,
1437 r
.right
- r
.left
, r
.bottom
- r
.top
,
1438 hwnd
, (HMENU
) IDCX_TREEVIEW
, hinst
,
1440 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1441 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1442 tvfaff
.treeview
= treeview
;
1443 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1447 * Set up the tree view contents.
1449 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1450 treeview_insert(&tvfaff
, 1, "Logging");
1451 treeview_insert(&tvfaff
, 0, "Terminal");
1452 treeview_insert(&tvfaff
, 1, "Keyboard");
1453 treeview_insert(&tvfaff
, 1, "Bell");
1454 treeview_insert(&tvfaff
, 0, "Window");
1455 treeview_insert(&tvfaff
, 1, "Appearance");
1456 treeview_insert(&tvfaff
, 1, "Translation");
1457 treeview_insert(&tvfaff
, 1, "Selection");
1458 treeview_insert(&tvfaff
, 1, "Colours");
1459 treeview_insert(&tvfaff
, 0, "Connection");
1461 treeview_insert(&tvfaff
, 1, "Telnet");
1462 treeview_insert(&tvfaff
, 1, "Rlogin");
1463 if (backends
[3].backend
!= NULL
) {
1464 treeview_insert(&tvfaff
, 1, "SSH");
1465 /* XXX long name is ugly */
1466 /* XXX make it closed by default? */
1467 treeview_insert(&tvfaff
, 2, "Auth");
1468 treeview_insert(&tvfaff
, 2, "Tunnels");
1473 * Put the treeview selection on to the Session panel. This
1474 * should also cause creation of the relevant controls.
1476 TreeView_SelectItem(treeview
, hsession
);
1479 * Set focus into the first available control.
1483 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1485 ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1489 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1490 sesslist_has_focus
= 0;
1494 * Button release should trigger WM_OK if there was a
1495 * previous double click on the session list.
1499 SendMessage(hwnd
, WM_COMMAND
, IDOK
, 0);
1502 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1503 ((LPNMHDR
) lParam
)->code
== TVN_SELCHANGED
) {
1505 TreeView_GetSelection(((LPNMHDR
) lParam
)->hwndFrom
);
1510 SendMessage (hwnd
, WM_SETREDRAW
, FALSE
, 0);
1513 item
.pszText
= buffer
;
1514 item
.cchTextMax
= sizeof(buffer
);
1515 item
.mask
= TVIF_TEXT
;
1516 TreeView_GetItem(((LPNMHDR
) lParam
)->hwndFrom
, &item
);
1517 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1518 HWND item
= GetDlgItem(hwnd
, j
);
1520 DestroyWindow(item
);
1522 if (!strcmp(buffer
, "Session"))
1523 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1524 if (!strcmp(buffer
, "Logging"))
1525 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1526 if (!strcmp(buffer
, "Keyboard"))
1527 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1528 if (!strcmp(buffer
, "Terminal"))
1529 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1530 if (!strcmp(buffer
, "Bell"))
1531 create_controls(hwnd
, dlgtype
, bellpanelstart
);
1532 if (!strcmp(buffer
, "Window"))
1533 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1534 if (!strcmp(buffer
, "Appearance"))
1535 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1536 if (!strcmp(buffer
, "Tunnels"))
1537 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1538 if (!strcmp(buffer
, "Connection"))
1539 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1540 if (!strcmp(buffer
, "Telnet"))
1541 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1542 if (!strcmp(buffer
, "Rlogin"))
1543 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1544 if (!strcmp(buffer
, "SSH"))
1545 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1546 if (!strcmp(buffer
, "Auth"))
1547 create_controls(hwnd
, dlgtype
, sshauthpanelstart
);
1548 if (!strcmp(buffer
, "Selection"))
1549 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1550 if (!strcmp(buffer
, "Colours"))
1551 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1552 if (!strcmp(buffer
, "Translation"))
1553 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1555 init_dlg_ctrls(hwnd
, FALSE
);
1557 SendMessage (hwnd
, WM_SETREDRAW
, TRUE
, 0);
1558 InvalidateRect (hwnd
, NULL
, TRUE
);
1560 SetFocus(((LPNMHDR
) lParam
)->hwndFrom
); /* ensure focus stays */
1566 * Only process WM_COMMAND once the dialog is fully formed.
1568 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1)
1569 switch (LOWORD(wParam
)) {
1571 /* Behaviour of the "Open" button is different if the
1572 * session list has focus, *unless* the user just
1573 * double-clicked... */
1574 if (sesslist_has_focus
&& !readytogo
) {
1575 if (!load_selected_session(hwnd
)) {
1580 /* If at this point we have a valid session, go! */
1589 case IDC_PROTTELNET
:
1590 case IDC_PROTRLOGIN
:
1593 if (HIWORD(wParam
) == BN_CLICKED
||
1594 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1595 int i
= IsDlgButtonChecked(hwnd
, IDC_PROTSSH
);
1596 int j
= IsDlgButtonChecked(hwnd
, IDC_PROTTELNET
);
1597 int k
= IsDlgButtonChecked(hwnd
, IDC_PROTRLOGIN
);
1599 i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
:
1601 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22)
1602 || (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23)
1603 || (cfg
.protocol
== PROT_RLOGIN
1604 && cfg
.port
!= 513)) {
1605 cfg
.port
= i ?
22 : j ?
23 : 513;
1606 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1611 if (HIWORD(wParam
) == EN_CHANGE
)
1612 GetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
,
1613 sizeof(cfg
.host
) - 1);
1616 if (HIWORD(wParam
) == EN_CHANGE
) {
1617 GetDlgItemText(hwnd
, IDC_PORT
, portname
, 31);
1618 if (isdigit(portname
[0]))
1619 MyGetDlgItemInt(hwnd
, IDC_PORT
, &cfg
.port
);
1621 service
= getservbyname(portname
, NULL
);
1623 cfg
.port
= ntohs(service
->s_port
);
1630 if (HIWORD(wParam
) == EN_CHANGE
) {
1631 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1633 GetDlgItemText(hwnd
, IDC_SESSEDIT
,
1634 savedsession
, sizeof(savedsession
) - 1);
1635 savedsession
[sizeof(savedsession
) - 1] = '\0';
1639 if (HIWORD(wParam
) == BN_CLICKED
||
1640 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1645 GetDlgItemText(hwnd
, IDC_SESSEDIT
, str
,
1648 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1649 LB_GETCURSEL
, 0, 0);
1654 strcpy(str
, sessions
[n
]);
1656 save_settings(str
, !!strcmp(str
, "Default Settings"),
1658 get_sesslist(FALSE
);
1660 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1662 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1664 for (i
= 0; i
< nsessions
; i
++)
1665 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1667 (LPARAM
) (sessions
[i
]));
1668 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1670 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1672 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1678 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1679 if (HIWORD(wParam
) == LBN_SETFOCUS
)
1680 sesslist_has_focus
= 1;
1681 else if (HIWORD(wParam
) == LBN_KILLFOCUS
)
1682 sesslist_has_focus
= 0;
1684 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1685 HIWORD(wParam
) != BN_CLICKED
&&
1686 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
1687 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1688 HIWORD(wParam
) != LBN_DBLCLK
) break;
1689 /* Load the session selected in SESSLIST. */
1690 if (load_selected_session(hwnd
) &&
1691 LOWORD(wParam
) == IDC_SESSLIST
) {
1693 * A double-click on a saved session should
1694 * actually start the session, not just load it.
1695 * Unless it's Default Settings or some other
1696 * host-less set of saved settings.
1705 if (HIWORD(wParam
) == BN_CLICKED
||
1706 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1707 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1708 LB_GETCURSEL
, 0, 0);
1709 if (n
== LB_ERR
|| n
== 0) {
1713 del_settings(sessions
[n
]);
1714 get_sesslist(FALSE
);
1716 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1718 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1720 for (i
= 0; i
< nsessions
; i
++)
1721 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1723 (LPARAM
) (sessions
[i
]));
1724 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1726 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1728 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1732 if (HIWORD(wParam
) == EN_CHANGE
)
1733 MyGetDlgItemInt(hwnd
, IDC_PINGEDIT
,
1734 &cfg
.ping_interval
);
1738 if (HIWORD(wParam
) == BN_CLICKED
||
1739 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1740 cfg
.bksp_is_delete
=
1741 IsDlgButtonChecked(hwnd
, IDC_DEL127
);
1745 if (HIWORD(wParam
) == BN_CLICKED
||
1746 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1748 IsDlgButtonChecked(hwnd
, IDC_HOMERXVT
);
1754 case IDC_FUNCVT100P
:
1756 if (HIWORD(wParam
) == BN_CLICKED
||
1757 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1758 switch (LOWORD(wParam
)) {
1771 case IDC_FUNCVT100P
:
1781 if (HIWORD(wParam
) == BN_CLICKED
||
1782 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1784 IsDlgButtonChecked(hwnd
, IDC_KPAPPLIC
);
1785 cfg
.nethack_keypad
= FALSE
;
1789 if (HIWORD(wParam
) == BN_CLICKED
||
1790 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1791 cfg
.app_keypad
= FALSE
;
1792 cfg
.nethack_keypad
= TRUE
;
1797 if (HIWORD(wParam
) == BN_CLICKED
||
1798 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1800 IsDlgButtonChecked(hwnd
, IDC_CURAPPLIC
);
1803 if (HIWORD(wParam
) == BN_CLICKED
||
1804 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1806 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICC
);
1809 if (HIWORD(wParam
) == BN_CLICKED
||
1810 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1812 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICK
);
1815 if (HIWORD(wParam
) == BN_CLICKED
||
1816 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1817 cfg
.alt_f4
= IsDlgButtonChecked(hwnd
, IDC_ALTF4
);
1820 if (HIWORD(wParam
) == BN_CLICKED
||
1821 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1823 IsDlgButtonChecked(hwnd
, IDC_ALTSPACE
);
1826 if (HIWORD(wParam
) == BN_CLICKED
||
1827 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1829 IsDlgButtonChecked(hwnd
, IDC_ALTONLY
);
1831 case IDC_ECHOBACKEND
:
1834 if (HIWORD(wParam
) == BN_CLICKED
||
1835 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1836 if (LOWORD(wParam
) == IDC_ECHOBACKEND
)
1837 cfg
.localecho
= LD_BACKEND
;
1838 if (LOWORD(wParam
) == IDC_ECHOYES
)
1839 cfg
.localecho
= LD_YES
;
1840 if (LOWORD(wParam
) == IDC_ECHONO
)
1841 cfg
.localecho
= LD_NO
;
1844 case IDC_EDITBACKEND
:
1847 if (HIWORD(wParam
) == BN_CLICKED
||
1848 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1849 if (LOWORD(wParam
) == IDC_EDITBACKEND
)
1850 cfg
.localedit
= LD_BACKEND
;
1851 if (LOWORD(wParam
) == IDC_EDITYES
)
1852 cfg
.localedit
= LD_YES
;
1853 if (LOWORD(wParam
) == IDC_EDITNO
)
1854 cfg
.localedit
= LD_NO
;
1857 case IDC_ANSWEREDIT
:
1858 if (HIWORD(wParam
) == EN_CHANGE
)
1859 GetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
1860 sizeof(cfg
.answerback
) - 1);
1862 case IDC_ALWAYSONTOP
:
1863 if (HIWORD(wParam
) == BN_CLICKED
||
1864 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1866 IsDlgButtonChecked(hwnd
, IDC_ALWAYSONTOP
);
1868 case IDC_FULLSCREENONALTENTER
:
1869 if (HIWORD(wParam
) == BN_CLICKED
||
1870 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1871 cfg
.fullscreenonaltenter
=
1872 IsDlgButtonChecked(hwnd
, IDC_FULLSCREENONALTENTER
);
1875 if (HIWORD(wParam
) == BN_CLICKED
||
1876 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1878 IsDlgButtonChecked(hwnd
, IDC_SCROLLKEY
);
1880 case IDC_SCROLLDISP
:
1881 if (HIWORD(wParam
) == BN_CLICKED
||
1882 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1883 cfg
.scroll_on_disp
=
1884 IsDlgButtonChecked(hwnd
, IDC_SCROLLDISP
);
1886 case IDC_COMPOSEKEY
:
1887 if (HIWORD(wParam
) == BN_CLICKED
||
1888 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1890 IsDlgButtonChecked(hwnd
, IDC_COMPOSEKEY
);
1892 case IDC_CTRLALTKEYS
:
1893 if (HIWORD(wParam
) == BN_CLICKED
||
1894 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1896 IsDlgButtonChecked(hwnd
, IDC_CTRLALTKEYS
);
1899 if (HIWORD(wParam
) == BN_CLICKED
||
1900 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1901 cfg
.telnet_keyboard
=
1902 IsDlgButtonChecked(hwnd
, IDC_TELNETKEY
);
1905 if (HIWORD(wParam
) == BN_CLICKED
||
1906 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1908 IsDlgButtonChecked(hwnd
, IDC_WRAPMODE
);
1911 if (HIWORD(wParam
) == BN_CLICKED
||
1912 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1913 cfg
.dec_om
= IsDlgButtonChecked(hwnd
, IDC_DECOM
);
1916 if (HIWORD(wParam
) == BN_CLICKED
||
1917 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1919 IsDlgButtonChecked(hwnd
, IDC_LFHASCR
);
1922 if (HIWORD(wParam
) == EN_CHANGE
)
1923 MyGetDlgItemInt(hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1926 if (HIWORD(wParam
) == EN_CHANGE
)
1927 MyGetDlgItemInt(hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1930 if (HIWORD(wParam
) == EN_CHANGE
)
1931 MyGetDlgItemInt(hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1933 case IDC_CHOOSEFONT
:
1936 lf
.lfHeight
= -MulDiv(cfg
.fontheight
,
1937 GetDeviceCaps(hdc
, LOGPIXELSY
),
1941 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1942 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1943 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1944 lf
.lfCharSet
= cfg
.fontcharset
;
1945 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1946 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1947 lf
.lfQuality
= DEFAULT_QUALITY
;
1948 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1949 strncpy(lf
.lfFaceName
, cfg
.font
,
1950 sizeof(lf
.lfFaceName
) - 1);
1951 lf
.lfFaceName
[sizeof(lf
.lfFaceName
) - 1] = '\0';
1953 cf
.lStructSize
= sizeof(cf
);
1954 cf
.hwndOwner
= hwnd
;
1956 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1957 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1959 if (ChooseFont(&cf
)) {
1960 strncpy(cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
) - 1);
1961 cfg
.font
[sizeof(cfg
.font
) - 1] = '\0';
1962 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1963 cfg
.fontcharset
= lf
.lfCharSet
;
1964 cfg
.fontheight
= cf
.iPointSize
/ 10;
1965 fmtfont(fontstatic
);
1966 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
1969 case IDC_BELL_DISABLED
:
1970 case IDC_BELL_DEFAULT
:
1971 case IDC_BELL_WAVEFILE
:
1972 case IDC_BELL_VISUAL
:
1973 if (HIWORD(wParam
) == BN_CLICKED
||
1974 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1975 if (LOWORD(wParam
) == IDC_BELL_DISABLED
)
1976 cfg
.beep
= BELL_DISABLED
;
1977 if (LOWORD(wParam
) == IDC_BELL_DEFAULT
)
1978 cfg
.beep
= BELL_DEFAULT
;
1979 if (LOWORD(wParam
) == IDC_BELL_WAVEFILE
)
1980 cfg
.beep
= BELL_WAVEFILE
;
1981 if (LOWORD(wParam
) == IDC_BELL_VISUAL
)
1982 cfg
.beep
= BELL_VISUAL
;
1985 case IDC_B_IND_DISABLED
:
1986 case IDC_B_IND_FLASH
:
1987 case IDC_B_IND_STEADY
:
1988 if (HIWORD(wParam
) == BN_CLICKED
||
1989 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1990 if (LOWORD(wParam
) == IDC_B_IND_DISABLED
)
1991 cfg
.beep_ind
= B_IND_DISABLED
;
1992 if (LOWORD(wParam
) == IDC_B_IND_FLASH
)
1993 cfg
.beep_ind
= B_IND_FLASH
;
1994 if (LOWORD(wParam
) == IDC_B_IND_STEADY
)
1995 cfg
.beep_ind
= B_IND_STEADY
;
1998 case IDC_BELL_WAVEBROWSE
:
1999 memset(&of
, 0, sizeof(of
));
2000 #ifdef OPENFILENAME_SIZE_VERSION_400
2001 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2003 of
.lStructSize
= sizeof(of
);
2005 of
.hwndOwner
= hwnd
;
2006 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2007 of
.lpstrCustomFilter
= NULL
;
2008 of
.nFilterIndex
= 1;
2009 of
.lpstrFile
= filename
;
2010 strcpy(filename
, cfg
.bell_wavefile
);
2011 of
.nMaxFile
= sizeof(filename
);
2012 of
.lpstrFileTitle
= NULL
;
2013 of
.lpstrInitialDir
= NULL
;
2014 of
.lpstrTitle
= "Select Bell Sound File";
2016 if (GetOpenFileName(&of
)) {
2017 strcpy(cfg
.bell_wavefile
, filename
);
2018 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2022 case IDC_BELL_WAVEEDIT
:
2023 if (HIWORD(wParam
) == EN_CHANGE
)
2024 GetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2026 sizeof(cfg
.bell_wavefile
) - 1);
2029 if (HIWORD(wParam
) == BN_CLICKED
||
2030 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2032 IsDlgButtonChecked(hwnd
, IDC_BELLOVL
);
2035 if (HIWORD(wParam
) == EN_CHANGE
)
2036 MyGetDlgItemInt(hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
2039 if (HIWORD(wParam
) == EN_CHANGE
)
2040 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
,
2044 if (HIWORD(wParam
) == EN_CHANGE
)
2045 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
,
2049 if (HIWORD(wParam
) == BN_CLICKED
||
2050 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2052 IsDlgButtonChecked(hwnd
, IDC_BLINKTEXT
);
2055 if (HIWORD(wParam
) == BN_CLICKED
||
2056 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2057 cfg
.bce
= IsDlgButtonChecked(hwnd
, IDC_BCE
);
2060 if (HIWORD(wParam
) == BN_CLICKED
||
2061 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2062 cfg
.win_name_always
=
2063 IsDlgButtonChecked(hwnd
, IDC_WINNAME
);
2066 if (HIWORD(wParam
) == BN_CLICKED
||
2067 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2069 IsDlgButtonChecked(hwnd
, IDC_HIDEMOUSE
);
2071 case IDC_SUNKENEDGE
:
2072 if (HIWORD(wParam
) == BN_CLICKED
||
2073 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2075 IsDlgButtonChecked(hwnd
, IDC_SUNKENEDGE
);
2078 if (HIWORD(wParam
) == EN_CHANGE
)
2079 MyGetDlgItemInt(hwnd
, IDC_WINBEDIT
,
2080 &cfg
.window_border
);
2081 if (cfg
.window_border
> 32)
2082 cfg
.window_border
= 32;
2085 if (HIWORD(wParam
) == BN_CLICKED
||
2086 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2087 cfg
.cursor_type
= 0;
2090 if (HIWORD(wParam
) == BN_CLICKED
||
2091 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2092 cfg
.cursor_type
= 1;
2095 if (HIWORD(wParam
) == BN_CLICKED
||
2096 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2097 cfg
.cursor_type
= 2;
2100 if (HIWORD(wParam
) == BN_CLICKED
||
2101 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2103 IsDlgButtonChecked(hwnd
, IDC_BLINKCUR
);
2106 if (HIWORD(wParam
) == BN_CLICKED
||
2107 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2109 IsDlgButtonChecked(hwnd
, IDC_SCROLLBAR
);
2112 if (HIWORD(wParam
) == BN_CLICKED
||
2113 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2115 IsDlgButtonChecked(hwnd
, IDC_LOCKSIZE
);
2118 if (HIWORD(wParam
) == BN_CLICKED
||
2119 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2121 IsDlgButtonChecked(hwnd
, IDC_LOCKFONT
);
2124 if (HIWORD(wParam
) == EN_CHANGE
)
2125 GetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
2126 sizeof(cfg
.wintitle
) - 1);
2131 if (HIWORD(wParam
) == BN_CLICKED
||
2132 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2134 IsDlgButtonChecked(hwnd
,
2135 IDC_COEALWAYS
) ? COE_ALWAYS
:
2136 IsDlgButtonChecked(hwnd
,
2137 IDC_COENEVER
) ? COE_NEVER
:
2142 if (HIWORD(wParam
) == BN_CLICKED
||
2143 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2145 IsDlgButtonChecked(hwnd
, IDC_CLOSEWARN
);
2148 if (HIWORD(wParam
) == EN_CHANGE
)
2149 GetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
,
2150 sizeof(cfg
.termtype
) - 1);
2153 if (HIWORD(wParam
) == EN_CHANGE
)
2154 GetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
2155 sizeof(cfg
.logfilename
) - 1);
2158 memset(&of
, 0, sizeof(of
));
2159 #ifdef OPENFILENAME_SIZE_VERSION_400
2160 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2162 of
.lStructSize
= sizeof(of
);
2164 of
.hwndOwner
= hwnd
;
2165 of
.lpstrFilter
= "All Files\0*\0\0\0";
2166 of
.lpstrCustomFilter
= NULL
;
2167 of
.nFilterIndex
= 1;
2168 of
.lpstrFile
= filename
;
2169 strcpy(filename
, cfg
.logfilename
);
2170 of
.nMaxFile
= sizeof(filename
);
2171 of
.lpstrFileTitle
= NULL
;
2172 of
.lpstrInitialDir
= NULL
;
2173 of
.lpstrTitle
= "Select session log file";
2175 if (GetSaveFileName(&of
)) {
2176 strcpy(cfg
.logfilename
, filename
);
2177 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
2181 case IDC_LSTATASCII
:
2183 if (HIWORD(wParam
) == BN_CLICKED
||
2184 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2185 if (IsDlgButtonChecked(hwnd
, IDC_LSTATOFF
))
2187 if (IsDlgButtonChecked(hwnd
, IDC_LSTATASCII
))
2189 if (IsDlgButtonChecked(hwnd
, IDC_LSTATRAW
))
2196 if (HIWORD(wParam
) == BN_CLICKED
||
2197 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2198 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXASK
))
2199 cfg
.logxfovr
= LGXF_ASK
;
2200 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXAPN
))
2201 cfg
.logxfovr
= LGXF_APN
;
2202 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXOVR
))
2203 cfg
.logxfovr
= LGXF_OVR
;
2208 if (HIWORD(wParam
) == EN_CHANGE
)
2209 GetDlgItemText(hwnd
, LOWORD(wParam
), cfg
.termspeed
,
2210 sizeof(cfg
.termspeed
) - 1);
2213 if (HIWORD(wParam
) == EN_CHANGE
)
2214 GetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
,
2215 sizeof(cfg
.username
) - 1);
2217 case IDC_RLLUSEREDIT
:
2218 if (HIWORD(wParam
) == EN_CHANGE
)
2219 GetDlgItemText(hwnd
, IDC_RLLUSEREDIT
,
2221 sizeof(cfg
.localusername
) - 1);
2225 cfg
.rfc_environ
= IsDlgButtonChecked(hwnd
, IDC_EMRFC
);
2229 cfg
.passive_telnet
=
2230 IsDlgButtonChecked(hwnd
, IDC_TPASSIVE
);
2233 if (HIWORD(wParam
) == BN_CLICKED
||
2234 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2235 char str
[sizeof(cfg
.environmt
)];
2237 GetDlgItemText(hwnd
, IDC_VAREDIT
, str
,
2243 p
= str
+ strlen(str
);
2245 GetDlgItemText(hwnd
, IDC_VALEDIT
, p
,
2246 sizeof(str
) - 1 - (p
- str
));
2257 if ((p
- cfg
.environmt
) + strlen(str
) + 2 <
2258 sizeof(cfg
.environmt
)) {
2260 p
[strlen(str
) + 1] = '\0';
2261 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
2263 SetDlgItemText(hwnd
, IDC_VAREDIT
, "");
2264 SetDlgItemText(hwnd
, IDC_VALEDIT
, "");
2266 MessageBox(hwnd
, "Environment too big",
2267 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2272 if (HIWORD(wParam
) != BN_CLICKED
&&
2273 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2275 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0,
2282 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
2309 if (HIWORD(wParam
) == BN_CLICKED
||
2310 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2311 cfg
.nopty
= IsDlgButtonChecked(hwnd
, IDC_NOPTY
);
2314 if (HIWORD(wParam
) == BN_CLICKED
||
2315 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2317 IsDlgButtonChecked(hwnd
, IDC_COMPRESS
);
2320 if (HIWORD(wParam
) == BN_CLICKED
||
2321 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2323 IsDlgButtonChecked(hwnd
, IDC_BUGGYMAC
);
2326 if (HIWORD(wParam
) == BN_CLICKED
||
2327 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2329 IsDlgButtonChecked(hwnd
, IDC_AGENTFWD
);
2331 case IDC_CIPHERLIST
:
2334 handle_prefslist(&cipherlist
,
2335 cfg
.ssh_cipherlist
, CIPHER_MAX
,
2336 0, hwnd
, wParam
, lParam
);
2340 if (HIWORD(wParam
) == BN_CLICKED
||
2341 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2342 if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT1
))
2344 else if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT2
))
2349 if (HIWORD(wParam
) == BN_CLICKED
||
2350 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2352 IsDlgButtonChecked(hwnd
, IDC_AUTHTIS
);
2355 if (HIWORD(wParam
) == EN_CHANGE
)
2356 GetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
2357 sizeof(cfg
.keyfile
) - 1);
2360 if (HIWORD(wParam
) == EN_CHANGE
)
2361 GetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
2362 sizeof(cfg
.remote_cmd
) - 1);
2365 memset(&of
, 0, sizeof(of
));
2366 #ifdef OPENFILENAME_SIZE_VERSION_400
2367 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2369 of
.lStructSize
= sizeof(of
);
2371 of
.hwndOwner
= hwnd
;
2372 of
.lpstrFilter
= "All Files\0*\0\0\0";
2373 of
.lpstrCustomFilter
= NULL
;
2374 of
.nFilterIndex
= 1;
2375 of
.lpstrFile
= filename
;
2376 strcpy(filename
, cfg
.keyfile
);
2377 of
.nMaxFile
= sizeof(filename
);
2378 of
.lpstrFileTitle
= NULL
;
2379 of
.lpstrInitialDir
= NULL
;
2380 of
.lpstrTitle
= "Select Public Key File";
2382 if (GetOpenFileName(&of
)) {
2383 strcpy(cfg
.keyfile
, filename
);
2384 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
2388 cfg
.rawcnp
= IsDlgButtonChecked(hwnd
, IDC_RAWCNP
);
2392 cfg
.mouse_is_xterm
= IsDlgButtonChecked(hwnd
, IDC_MBXTERM
);
2394 case IDC_MOUSEOVERRIDE
:
2395 cfg
.mouse_override
= IsDlgButtonChecked(hwnd
, IDC_MOUSEOVERRIDE
);
2401 int n
= GetDlgItemInt(hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
2406 for (i
= 0; i
< 128; i
++)
2407 if (SendDlgItemMessage
2408 (hwnd
, IDC_CCLIST
, LB_GETSEL
, i
, 0)) {
2410 cfg
.wordness
[i
] = n
;
2411 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2412 LB_DELETESTRING
, i
, 0);
2413 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
2414 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ',
2416 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2423 case IDC_BOLDCOLOUR
:
2424 if (HIWORD(wParam
) == BN_CLICKED
||
2425 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2428 IsDlgButtonChecked(hwnd
, IDC_BOLDCOLOUR
);
2429 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2432 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2434 if (n
!= 12 + 10 * cfg
.bold_colour
) {
2435 for (i
= n
; i
-- > 0;)
2436 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2437 LB_DELETESTRING
, i
, 0);
2438 for (i
= 0; i
< 22; i
++)
2439 if (cfg
.bold_colour
|| permcolour
[i
])
2440 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2442 (LPARAM
) colours
[i
]);
2444 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2446 InvalidateRect(GetDlgItem(hwnd
, IDC_COLOURLIST
), NULL
,
2451 if (HIWORD(wParam
) == BN_CLICKED
||
2452 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2454 IsDlgButtonChecked(hwnd
, IDC_PALETTE
);
2456 case IDC_COLOURLIST
:
2457 if (HIWORD(wParam
) == LBN_DBLCLK
||
2458 HIWORD(wParam
) == LBN_SELCHANGE
) {
2460 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2463 if (!cfg
.bold_colour
)
2464 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2465 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2467 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2469 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2474 if (HIWORD(wParam
) == BN_CLICKED
||
2475 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2476 static CHOOSECOLOR cc
;
2477 static DWORD custom
[16] = { 0 }; /* zero initialisers */
2479 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2482 if (!cfg
.bold_colour
)
2483 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2484 cc
.lStructSize
= sizeof(cc
);
2485 cc
.hwndOwner
= hwnd
;
2486 cc
.hInstance
= (HWND
) hinst
;
2487 cc
.lpCustColors
= custom
;
2489 RGB(cfg
.colours
[i
][0], cfg
.colours
[i
][1],
2491 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
2492 if (ChooseColor(&cc
)) {
2494 (unsigned char) (cc
.rgbResult
& 0xFF);
2496 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
2498 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
2499 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2501 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2503 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2509 if (HIWORD(wParam
) == CBN_SELCHANGE
) {
2510 int index
= SendDlgItemMessage(hwnd
, IDC_CODEPAGE
,
2511 CB_GETCURSEL
, 0, 0);
2512 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_GETLBTEXT
,
2513 index
, (LPARAM
)cfg
.line_codepage
);
2514 } else if (HIWORD(wParam
) == CBN_EDITCHANGE
) {
2515 GetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
,
2516 sizeof(cfg
.line_codepage
) - 1);
2517 } else if (HIWORD(wParam
) == CBN_KILLFOCUS
) {
2518 strcpy(cfg
.line_codepage
,
2519 cp_name(decode_codepage(cfg
.line_codepage
)));
2520 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
2523 case IDC_CAPSLOCKCYR
:
2524 if (HIWORD(wParam
) == BN_CLICKED
||
2525 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2526 cfg
.xlat_capslockcyr
=
2527 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
2530 case IDC_VTXWINDOWS
:
2536 (IsDlgButtonChecked(hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
2537 : IsDlgButtonChecked(hwnd
,
2538 IDC_VTOEMANSI
) ? VT_OEMANSI
:
2539 IsDlgButtonChecked(hwnd
,
2540 IDC_VTOEMONLY
) ? VT_OEMONLY
:
2541 IsDlgButtonChecked(hwnd
,
2542 IDC_VTUNICODE
) ? VT_UNICODE
:
2545 case IDC_X11_FORWARD
:
2546 if (HIWORD(wParam
) == BN_CLICKED
||
2547 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2549 IsDlgButtonChecked(hwnd
, IDC_X11_FORWARD
);
2552 if (HIWORD(wParam
) == BN_CLICKED
||
2553 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2554 cfg
.lport_acceptall
=
2555 IsDlgButtonChecked(hwnd
, IDC_LPORT_ALL
);
2557 case IDC_X11_DISPLAY
:
2558 if (HIWORD(wParam
) == EN_CHANGE
)
2559 GetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
2560 sizeof(cfg
.x11_display
) - 1);
2563 if (HIWORD(wParam
) == BN_CLICKED
||
2564 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2565 char str
[sizeof(cfg
.portfwd
)];
2567 if (IsDlgButtonChecked(hwnd
, IDC_PFWDLOCAL
))
2571 GetDlgItemText(hwnd
, IDC_SPORTEDIT
, str
+1,
2575 "You need to specify a source port number",
2576 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2579 p
= str
+ strlen(str
);
2581 GetDlgItemText(hwnd
, IDC_DPORTEDIT
, p
,
2582 sizeof(str
) - 1 - (p
- str
));
2583 if (!*p
|| !strchr(p
, ':')) {
2585 "You need to specify a destination address\n"
2586 "in the form \"host.name:port\"",
2587 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2596 if ((p
- cfg
.portfwd
) + strlen(str
) + 2 <
2597 sizeof(cfg
.portfwd
)) {
2599 p
[strlen(str
) + 1] = '\0';
2600 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
,
2602 SetDlgItemText(hwnd
, IDC_SPORTEDIT
, "");
2603 SetDlgItemText(hwnd
, IDC_DPORTEDIT
, "");
2605 MessageBox(hwnd
, "Too many forwardings",
2606 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2610 case IDC_PFWDREMOVE
:
2611 if (HIWORD(wParam
) != BN_CLICKED
&&
2612 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2613 i
= SendDlgItemMessage(hwnd
, IDC_PFWDLIST
,
2614 LB_GETCURSEL
, 0, 0);
2620 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_DELETESTRING
,
2652 /* Grrr Explorer will maximize Dialogs! */
2654 if (wParam
== SIZE_MAXIMIZED
)
2660 * Handle application-defined messages eg. DragListBox
2662 /* First find out what the number is (once). */
2663 if (draglistmsg
== WM_NULL
)
2664 draglistmsg
= RegisterWindowMessage (DRAGLISTMSGSTRING
);
2666 if (msg
== draglistmsg
) {
2667 /* Only process once dialog is fully formed. */
2668 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
2669 case IDC_CIPHERLIST
:
2670 return handle_prefslist(&cipherlist
,
2671 cfg
.ssh_cipherlist
, CIPHER_MAX
,
2672 1, hwnd
, wParam
, lParam
);
2681 static int CALLBACK
MainDlgProc(HWND hwnd
, UINT msg
,
2682 WPARAM wParam
, LPARAM lParam
)
2684 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
2686 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
2687 EnableWindow(hwnd
, 0);
2688 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2689 EnableWindow(hwnd
, 1);
2690 SetActiveWindow(hwnd
);
2692 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 0);
2695 static int CALLBACK
ReconfDlgProc(HWND hwnd
, UINT msg
,
2696 WPARAM wParam
, LPARAM lParam
)
2698 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 1);
2701 void defuse_showwindow(void)
2704 * Work around the fact that the app's first call to ShowWindow
2705 * will ignore the default in favour of the shell-provided
2710 hwnd
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2712 ShowWindow(hwnd
, SW_HIDE
);
2713 SetActiveWindow(hwnd
);
2714 DestroyWindow(hwnd
);
2723 savedsession
[0] = '\0';
2725 DialogBox(hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2726 get_sesslist(FALSE
);
2731 int do_reconfig(HWND hwnd
)
2736 backup_cfg
= cfg
; /* structure copy */
2738 DialogBox(hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2740 cfg
= backup_cfg
; /* structure copy */
2745 void logevent(char *string
)
2750 if (nevents
>= negsize
) {
2752 events
= srealloc(events
, negsize
* sizeof(*events
));
2756 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t",
2759 events
[nevents
] = smalloc(strlen(timebuf
) + strlen(string
) + 1);
2760 strcpy(events
[nevents
], timebuf
);
2761 strcat(events
[nevents
], string
);
2764 SendDlgItemMessage(logbox
, IDN_LIST
, LB_ADDSTRING
,
2765 0, (LPARAM
) events
[nevents
]);
2766 count
= SendDlgItemMessage(logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2767 SendDlgItemMessage(logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
- 1, 0);
2772 void showeventlog(HWND hwnd
)
2775 logbox
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2777 ShowWindow(logbox
, SW_SHOWNORMAL
);
2779 SetActiveWindow(logbox
);
2782 void showabout(HWND hwnd
)
2784 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2787 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2788 char *keystr
, char *fingerprint
)
2792 static const char absentmsg
[] =
2793 "The server's host key is not cached in the registry. You\n"
2794 "have no guarantee that the server is the computer you\n"
2796 "The server's key fingerprint is:\n"
2798 "If you trust this host, hit Yes to add the key to\n"
2799 "PuTTY's cache and carry on connecting.\n"
2800 "If you want to carry on connecting just once, without\n"
2801 "adding the key to the cache, hit No.\n"
2802 "If you do not trust this host, hit Cancel to abandon the\n"
2805 static const char wrongmsg
[] =
2806 "WARNING - POTENTIAL SECURITY BREACH!\n"
2808 "The server's host key does not match the one PuTTY has\n"
2809 "cached in the registry. This means that either the\n"
2810 "server administrator has changed the host key, or you\n"
2811 "have actually connected to another computer pretending\n"
2812 "to be the server.\n"
2813 "The new key fingerprint is:\n"
2815 "If you were expecting this change and trust the new key,\n"
2816 "hit Yes to update PuTTY's cache and continue connecting.\n"
2817 "If you want to carry on connecting but without updating\n"
2818 "the cache, hit No.\n"
2819 "If you want to abandon the connection completely, hit\n"
2820 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
2822 static const char mbtitle
[] = "PuTTY Security Alert";
2825 /* sensible fingerprint max size */
2826 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2827 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2830 * Verify the key against the registry.
2832 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2834 if (ret
== 0) /* success - key matched OK */
2836 if (ret
== 2) { /* key was different */
2838 sprintf(message
, wrongmsg
, fingerprint
);
2839 mbret
= MessageBox(NULL
, message
, mbtitle
,
2840 MB_ICONWARNING
| MB_YESNOCANCEL
);
2842 store_host_key(host
, port
, keytype
, keystr
);
2843 if (mbret
== IDCANCEL
)
2846 if (ret
== 1) { /* key was absent */
2848 sprintf(message
, absentmsg
, fingerprint
);
2849 mbret
= MessageBox(NULL
, message
, mbtitle
,
2850 MB_ICONWARNING
| MB_YESNOCANCEL
);
2852 store_host_key(host
, port
, keytype
, keystr
);
2853 if (mbret
== IDCANCEL
)
2859 * Ask whether the selected cipher is acceptable (since it was
2860 * below the configured 'warn' threshold).
2861 * cs: 0 = both ways, 1 = client->server, 2 = server->client
2863 void askcipher(char *ciphername
, int cs
)
2865 static const char mbtitle
[] = "PuTTY Security Alert";
2866 static const char msg
[] =
2867 "The first %.35scipher supported by the server\n"
2868 "is %.64s, which is below the configured\n"
2869 "warning threshold.\n"
2870 "Do you want to continue with this connection?\n";
2871 /* guessed cipher name + type max length */
2872 char message
[100 + sizeof(msg
)];
2875 sprintf(message
, msg
,
2877 (cs
== 1) ?
"client-to-server " :
2878 "server-to-client ",
2880 mbret
= MessageBox(NULL
, message
, mbtitle
,
2881 MB_ICONWARNING
| MB_YESNO
);
2889 * Ask whether to wipe a session log file before writing to it.
2890 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2892 int askappend(char *filename
)
2894 static const char mbtitle
[] = "PuTTY Log to File";
2895 static const char msgtemplate
[] =
2896 "The session log file \"%.*s\" already exists.\n"
2897 "You can overwrite it with a new session log,\n"
2898 "append your session log to the end of it,\n"
2899 "or disable session logging for this session.\n"
2900 "Hit Yes to wipe the file, No to append to it,\n"
2901 "or Cancel to disable logging.";
2902 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2904 if (cfg
.logxfovr
!= LGXF_ASK
) {
2905 return ((cfg
.logxfovr
== LGXF_OVR
) ?
2 : 1);
2907 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2909 mbret
= MessageBox(NULL
, message
, mbtitle
,
2910 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2913 else if (mbret
== IDNO
)