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
,
363 IDC_SCROLLBARFULLSCREEN
,
378 IDC_FULLSCREENONALTENTER
,
381 appearancepanelstart
,
382 IDC_TITLE_APPEARANCE
,
404 connectionpanelstart
,
405 IDC_TITLE_CONNECTION
,
521 translationpanelstart
,
522 IDC_TITLE_TRANSLATION
,
523 IDC_BOX_TRANSLATION1
,
524 IDC_BOX_TRANSLATION2
,
525 IDC_BOX_TRANSLATION3
,
562 static const char *const colours
[] = {
563 "Default Foreground", "Default Bold Foreground",
564 "Default Background", "Default Bold Background",
565 "Cursor Text", "Cursor Colour",
566 "ANSI Black", "ANSI Black Bold",
567 "ANSI Red", "ANSI Red Bold",
568 "ANSI Green", "ANSI Green Bold",
569 "ANSI Yellow", "ANSI Yellow Bold",
570 "ANSI Blue", "ANSI Blue Bold",
571 "ANSI Magenta", "ANSI Magenta Bold",
572 "ANSI Cyan", "ANSI Cyan Bold",
573 "ANSI White", "ANSI White Bold"
575 static const int permcolour
[] = {
576 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
577 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
578 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
581 static void fmtfont(char *buf
)
583 sprintf(buf
, "Font: %s, ", cfg
.font
);
585 strcat(buf
, "bold, ");
586 if (cfg
.fontheight
== 0)
587 strcat(buf
, "default height");
589 sprintf(buf
+ strlen(buf
), "%d-point",
590 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
593 /* 2nd arg: NZ => don't redraw session list (use when loading
595 static void init_dlg_ctrls(HWND hwnd
, int keepsess
)
598 char fontstatic
[256];
600 SetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
);
601 SetDlgItemText(hwnd
, IDC_SESSEDIT
, savedsession
);
604 n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
605 for (i
= n
; i
-- > 0;)
606 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_DELETESTRING
, i
, 0);
607 for (i
= 0; i
< nsessions
; i
++)
608 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
609 0, (LPARAM
) (sessions
[i
]));
611 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
612 CheckRadioButton(hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
613 cfg
.protocol
== PROT_SSH ? IDC_PROTSSH
:
614 cfg
.protocol
== PROT_TELNET ? IDC_PROTTELNET
:
616 PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
617 SetDlgItemInt(hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
618 CheckDlgButton(hwnd
, IDC_NODELAY
, cfg
.tcp_nodelay
);
620 CheckRadioButton(hwnd
, IDC_DEL008
, IDC_DEL127
,
621 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
622 CheckRadioButton(hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
623 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
624 CheckRadioButton(hwnd
, IDC_FUNCTILDE
, IDC_FUNCSCO
,
625 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
626 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
627 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
628 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
629 cfg
.funky_type
== 4 ? IDC_FUNCVT100P
:
630 cfg
.funky_type
== 5 ? IDC_FUNCSCO
: IDC_FUNCTILDE
);
631 CheckDlgButton(hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
632 CheckDlgButton(hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
633 CheckRadioButton(hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
634 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
635 CheckRadioButton(hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
636 cfg
.nethack_keypad ? IDC_KPNH
:
637 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
638 CheckDlgButton(hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
639 CheckDlgButton(hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
640 CheckDlgButton(hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
641 CheckDlgButton(hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
642 CheckDlgButton(hwnd
, IDC_CTRLALTKEYS
, cfg
.ctrlaltkeys
);
643 CheckDlgButton(hwnd
, IDC_TELNETKEY
, cfg
.telnet_keyboard
);
644 CheckRadioButton(hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
645 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
646 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
647 CheckRadioButton(hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
648 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
649 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
650 SetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
);
651 CheckDlgButton(hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
652 CheckDlgButton(hwnd
, IDC_FULLSCREENONALTENTER
, cfg
.fullscreenonaltenter
);
653 CheckDlgButton(hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
654 CheckDlgButton(hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
656 CheckDlgButton(hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
657 CheckDlgButton(hwnd
, IDC_DECOM
, cfg
.dec_om
);
658 CheckDlgButton(hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
659 SetDlgItemInt(hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
660 SetDlgItemInt(hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
661 SetDlgItemInt(hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
663 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
664 CheckRadioButton(hwnd
, IDC_BELL_DISABLED
, IDC_BELL_VISUAL
,
665 cfg
.beep
== BELL_DISABLED ? IDC_BELL_DISABLED
:
666 cfg
.beep
== BELL_DEFAULT ? IDC_BELL_DEFAULT
:
667 cfg
.beep
== BELL_WAVEFILE ? IDC_BELL_WAVEFILE
:
669 BELL_VISUAL ? IDC_BELL_VISUAL
: IDC_BELL_DEFAULT
);
670 CheckRadioButton(hwnd
, IDC_B_IND_DISABLED
, IDC_B_IND_STEADY
,
672 B_IND_DISABLED ? IDC_B_IND_DISABLED
: cfg
.beep_ind
==
673 B_IND_FLASH ? IDC_B_IND_FLASH
: cfg
.beep_ind
==
674 B_IND_STEADY ? IDC_B_IND_STEADY
: IDC_B_IND_DISABLED
);
675 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
676 CheckDlgButton(hwnd
, IDC_BELLOVL
, cfg
.bellovl
);
677 SetDlgItemInt(hwnd
, IDC_BELLOVLN
, cfg
.bellovl_n
, FALSE
);
678 MySetDlgItemFlt(hwnd
, IDC_BELLOVLT
, cfg
.bellovl_t
/ 1000.0);
679 MySetDlgItemFlt(hwnd
, IDC_BELLOVLS
, cfg
.bellovl_s
/ 1000.0);
681 CheckDlgButton(hwnd
, IDC_BCE
, cfg
.bce
);
682 CheckDlgButton(hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
684 SetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
685 CheckDlgButton(hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
686 CheckDlgButton(hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
687 CheckDlgButton(hwnd
, IDC_SUNKENEDGE
, cfg
.sunken_edge
);
688 SetDlgItemInt(hwnd
, IDC_WINBEDIT
, cfg
.window_border
, FALSE
);
689 CheckRadioButton(hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
690 cfg
.cursor_type
== 0 ? IDC_CURBLOCK
:
691 cfg
.cursor_type
== 1 ? IDC_CURUNDER
: IDC_CURVERT
);
692 CheckDlgButton(hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
693 CheckDlgButton(hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
694 CheckDlgButton(hwnd
, IDC_SCROLLBARFULLSCREEN
, cfg
.scrollbar_in_fullscreen
);
695 CheckRadioButton(hwnd
, IDC_RESIZETERM
, IDC_RESIZEEITHER
,
696 cfg
.resize_action
== RESIZE_TERM ? IDC_RESIZETERM
:
697 cfg
.resize_action
== RESIZE_FONT ? IDC_RESIZEFONT
:
698 cfg
.resize_action
== RESIZE_EITHER ? IDC_RESIZEEITHER
:
700 CheckRadioButton(hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
701 cfg
.close_on_exit
== COE_NORMAL ? IDC_COENORMAL
:
703 COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
704 CheckDlgButton(hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
706 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
707 SetDlgItemText(hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
708 SetDlgItemText(hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
709 SetDlgItemText(hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
710 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
711 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
712 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
713 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
714 cfg
.logtype
== 1 ? IDC_LSTATASCII
: IDC_LSTATRAW
);
715 CheckRadioButton(hwnd
, IDC_LSTATXOVR
, IDC_LSTATXASK
,
716 cfg
.logxfovr
== LGXF_OVR ? IDC_LSTATXOVR
:
717 cfg
.logxfovr
== LGXF_ASK ? IDC_LSTATXASK
:
720 char *p
= cfg
.environmt
;
721 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_RESETCONTENT
, 0, 0);
723 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
729 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
, 0,
734 CheckRadioButton(hwnd
, IDC_EMBSD
, IDC_EMRFC
,
735 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
736 CheckRadioButton(hwnd
, IDC_TPASSIVE
, IDC_TACTIVE
,
737 cfg
.passive_telnet ? IDC_TPASSIVE
: IDC_TACTIVE
);
739 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
740 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
741 CheckDlgButton(hwnd
, IDC_NOPTY
, cfg
.nopty
);
742 CheckDlgButton(hwnd
, IDC_COMPRESS
, cfg
.compression
);
743 CheckDlgButton(hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
744 CheckDlgButton(hwnd
, IDC_SSH2DES
, cfg
.ssh2_des_cbc
);
745 CheckDlgButton(hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
746 CheckRadioButton(hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
747 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
748 CheckDlgButton(hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
749 CheckDlgButton(hwnd
, IDC_AUTHKI
, cfg
.try_ki_auth
);
750 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
751 SetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
755 static const struct { char *s
; int c
; } ciphers
[] = {
756 { "3DES", CIPHER_3DES
},
757 { "Blowfish", CIPHER_BLOWFISH
},
758 { "DES", CIPHER_DES
},
759 { "AES (SSH 2 only)", CIPHER_AES
},
760 { "-- warn below here --", CIPHER_WARN
}
763 /* Set up the "selected ciphers" box. */
764 /* (cipherlist assumed to contain all ciphers) */
765 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_RESETCONTENT
, 0, 0);
766 for (i
= 0; i
< CIPHER_MAX
; i
++) {
767 int c
= cfg
.ssh_cipherlist
[i
];
770 for (j
= 0; j
< (sizeof ciphers
) / (sizeof ciphers
[0]); j
++) {
771 if (ciphers
[j
].c
== c
) {
776 pos
= SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_ADDSTRING
,
778 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_SETITEMDATA
,
784 CheckRadioButton(hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
785 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
786 CheckRadioButton(hwnd
, IDC_SELTYPELEX
, IDC_SELTYPERECT
,
787 cfg
.rect_select
== 0 ? IDC_SELTYPELEX
: IDC_SELTYPERECT
);
788 CheckDlgButton(hwnd
, IDC_MOUSEOVERRIDE
, cfg
.mouse_override
);
789 CheckDlgButton(hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
790 CheckDlgButton(hwnd
, IDC_RTFPASTE
, cfg
.rtf_paste
);
792 static int tabs
[4] = { 25, 61, 96, 128 };
793 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
796 for (i
= 0; i
< 128; i
++) {
798 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
799 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ', cfg
.wordness
[i
]);
800 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
804 CheckDlgButton(hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
805 CheckDlgButton(hwnd
, IDC_PALETTE
, cfg
.try_palette
);
808 n
= SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
809 for (i
= n
; i
-- > 0;)
810 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
811 LB_DELETESTRING
, i
, 0);
812 for (i
= 0; i
< 22; i
++)
813 if (cfg
.bold_colour
|| permcolour
[i
])
814 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
815 (LPARAM
) colours
[i
]);
817 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
818 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
819 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
820 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
825 strcpy(cfg
.line_codepage
, cp_name(decode_codepage(cfg
.line_codepage
)));
826 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_RESETCONTENT
, 0, 0);
827 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
828 for (i
= 0; (cp
= cp_enumerate(i
)) != NULL
; i
++) {
829 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_ADDSTRING
,
832 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
835 CheckRadioButton(hwnd
, IDC_VTXWINDOWS
, IDC_VTUNICODE
,
836 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
837 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
838 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
839 cfg
.vtmode
== VT_UNICODE ? IDC_VTUNICODE
:
842 CheckDlgButton(hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
843 SetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
845 CheckDlgButton(hwnd
, IDC_LPORT_ALL
, cfg
.lport_acceptall
);
846 CheckRadioButton(hwnd
, IDC_PFWDLOCAL
, IDC_PFWDREMOTE
, IDC_PFWDLOCAL
);
849 struct treeview_faff
{
854 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
855 int level
, char *text
)
860 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
- 1] : TVI_ROOT
);
861 ins
.hInsertAfter
= faff
->lastat
[level
];
862 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
863 #define INSITEM DUMMYUNIONNAME.item
867 ins
.INSITEM
.mask
= TVIF_TEXT
;
868 ins
.INSITEM
.pszText
= text
;
869 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
871 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
- 1],
873 faff
->lastat
[level
] = newitem
;
874 for (i
= level
+ 1; i
< 4; i
++)
875 faff
->lastat
[i
] = NULL
;
880 * Create the panelfuls of controls in the configuration box.
882 static void create_controls(HWND hwnd
, int dlgtype
, int panel
)
884 if (panel
== sessionpanelstart
) {
885 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
887 ctlposinit(&cp
, hwnd
, 80, 3, 13);
888 bartitle(&cp
, "Basic options for your PuTTY session",
891 beginbox(&cp
, "Specify your connection by host name or IP address",
894 "Host &Name (or IP address)",
895 IDC_HOSTSTATIC
, IDC_HOST
, 75,
896 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
897 if (backends
[3].backend
== NULL
) {
898 /* this is PuTTYtel, so only three protocols available */
899 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 3,
901 "&Telnet", IDC_PROTTELNET
,
902 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
904 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
906 "&Telnet", IDC_PROTTELNET
,
907 "Rlog&in", IDC_PROTRLOGIN
,
916 beginbox(&cp
, "Load, save or delete a stored session",
918 sesssaver(&cp
, "Sav&ed Sessions",
919 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
920 "&Load", IDC_SESSLOAD
,
921 "&Save", IDC_SESSSAVE
, "&Delete", IDC_SESSDEL
, NULL
);
924 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
925 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
926 "Always", IDC_COEALWAYS
,
927 "Never", IDC_COENEVER
,
928 "Only on clean exit", IDC_COENORMAL
, NULL
);
932 if (panel
== loggingpanelstart
) {
933 /* The Logging panel. Accelerators used: [acgo] tplfwe */
935 ctlposinit(&cp
, hwnd
, 80, 3, 13);
936 bartitle(&cp
, "Options controlling session logging",
938 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
940 "Session logging:", IDC_LSTATSTATIC
,
941 "Logging &turned off completely", IDC_LSTATOFF
,
942 "Log &printable output only", IDC_LSTATASCII
,
943 "&Log all session output", IDC_LSTATRAW
, NULL
);
944 editbutton(&cp
, "Log &file name:",
945 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
947 statictext(&cp
, "(Log file name can contain &&Y, &&M, &&D for date,"
948 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN
);
950 "What to do if the log file already &exists:",
951 IDC_LSTATXIST
, "Always overwrite it", IDC_LSTATXOVR
,
952 "Always append to the end of it", IDC_LSTATXAPN
,
953 "Ask the user every time", IDC_LSTATXASK
, NULL
);
957 if (panel
== terminalpanelstart
) {
958 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
960 ctlposinit(&cp
, hwnd
, 80, 3, 13);
961 bartitle(&cp
, "Options controlling the terminal emulation",
963 beginbox(&cp
, "Set various terminal options", IDC_BOX_TERMINAL1
);
964 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
965 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
966 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
967 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
968 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
970 "An&swerback to ^E:", IDC_ANSWERBACK
,
971 IDC_ANSWEREDIT
, 100, NULL
);
974 beginbox(&cp
, "Line discipline options", IDC_BOX_TERMINAL2
);
975 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
976 "Auto", IDC_ECHOBACKEND
,
977 "Force on", IDC_ECHOYES
, "Force off", IDC_ECHONO
, NULL
);
978 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
979 "Auto", IDC_EDITBACKEND
,
980 "Force on", IDC_EDITYES
, "Force off", IDC_EDITNO
, NULL
);
984 if (panel
== bellpanelstart
) {
985 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
987 ctlposinit(&cp
, hwnd
, 80, 3, 13);
988 bartitle(&cp
, "Options controlling the terminal bell",
990 beginbox(&cp
, "Set the style of bell", IDC_BOX_BELL1
);
992 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
993 "None (bell disabled)", IDC_BELL_DISABLED
,
994 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
995 "Play a custom sound file", IDC_BELL_WAVEFILE
,
996 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
997 editbutton(&cp
, "Custom sound file to play as a bell:",
998 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
999 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
1000 radioline(&cp
, "Taskbar/caption &indication on bell:",
1001 IDC_B_IND_STATIC
, 3, "Disabled", IDC_B_IND_DISABLED
,
1002 "Flashing", IDC_B_IND_FLASH
, "Steady", IDC_B_IND_STEADY
,
1005 beginbox(&cp
, "Control the bell overload behaviour",
1007 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
1009 staticedit(&cp
, "Over-use means this &many bells...",
1010 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
1011 staticedit(&cp
, "... in &this many seconds",
1012 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
1014 "The bell is re-enabled after a few seconds of silence.",
1015 1, IDC_BELLOVLEXPLAIN
);
1016 staticedit(&cp
, "Seconds of &silence required", IDC_BELLOVLSSTATIC
,
1021 if (panel
== keyboardpanelstart
) {
1022 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
1024 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1025 bartitle(&cp
, "Options controlling the effects of keys",
1026 IDC_TITLE_KEYBOARD
);
1027 beginbox(&cp
, "Change the sequences sent by:", IDC_BOX_KEYBOARD1
);
1028 radioline(&cp
, "The &Backspace key", IDC_DELSTATIC
, 2,
1029 "Control-H", IDC_DEL008
,
1030 "Control-? (127)", IDC_DEL127
, NULL
);
1031 radioline(&cp
, "The &Home and End keys", IDC_HOMESTATIC
, 2,
1032 "Standard", IDC_HOMETILDE
, "rxvt", IDC_HOMERXVT
, NULL
);
1033 radioline(&cp
, "The &Function keys and keypad", IDC_FUNCSTATIC
, 3,
1034 "ESC[n~", IDC_FUNCTILDE
,
1035 "Linux", IDC_FUNCLINUX
,
1036 "Xterm R6", IDC_FUNCXTERM
,
1037 "VT400", IDC_FUNCVT400
,
1038 "VT100+", IDC_FUNCVT100P
, "SCO", IDC_FUNCSCO
, NULL
);
1040 beginbox(&cp
, "Application keypad settings:", IDC_BOX_KEYBOARD2
);
1042 "Application c&ursor keys totally disabled",
1044 radioline(&cp
, "Initial state of cu&rsor keys:", IDC_CURSTATIC
, 2,
1045 "Normal", IDC_CURNORMAL
,
1046 "Application", IDC_CURAPPLIC
, NULL
);
1048 "Application ke&ypad keys totally disabled",
1050 radioline(&cp
, "Initial state of &numeric keypad:", IDC_KPSTATIC
,
1051 3, "Normal", IDC_KPNORMAL
, "Application", IDC_KPAPPLIC
,
1052 "NetHack", IDC_KPNH
, NULL
);
1054 beginbox(&cp
, "Enable extra keyboard features:",
1056 checkbox(&cp
, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY
);
1057 checkbox(&cp
, "Control-Alt is &different from AltGr",
1062 if (panel
== windowpanelstart
) {
1063 /* The Window panel. Accelerators used: [acgo] rmz sdikp */
1065 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1066 bartitle(&cp
, "Options controlling PuTTY's window",
1068 beginbox(&cp
, "Set the size of the window", IDC_BOX_WINDOW1
);
1070 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
1071 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50, NULL
);
1072 radiobig(&cp
, "When window is resi&zed:", IDC_RESIZESTATIC
,
1073 "Change the number of rows and columns", IDC_RESIZETERM
,
1074 "Change the size of the font", IDC_RESIZEFONT
,
1075 "Change font size only when maximised", IDC_RESIZEEITHER
,
1076 "Forbid resizing completely", IDC_RESIZENONE
, NULL
);
1078 beginbox(&cp
, "Control the scrollback in the window",
1080 staticedit(&cp
, "Lines of &scrollback",
1081 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
1082 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
1083 checkbox(&cp
, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN
);
1084 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
1085 checkbox(&cp
, "Reset scrollback on dis&play activity",
1090 if (panel
== appearancepanelstart
) {
1091 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1093 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1094 bartitle(&cp
, "Configure the appearance of PuTTY's window",
1095 IDC_TITLE_APPEARANCE
);
1096 beginbox(&cp
, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1
);
1097 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
1098 "B&lock", IDC_CURBLOCK
,
1099 "&Underline", IDC_CURUNDER
,
1100 "&Vertical line", IDC_CURVERT
, NULL
);
1101 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
1103 beginbox(&cp
, "Set the font used in the terminal window",
1104 IDC_BOX_APPEARANCE2
);
1105 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
1107 beginbox(&cp
, "Adjust the use of the window title",
1108 IDC_BOX_APPEARANCE3
);
1110 "Window &title:", IDC_WINTITLE
, IDC_WINEDIT
, 100, NULL
);
1111 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
1113 beginbox(&cp
, "Adjust the use of the mouse pointer",
1114 IDC_BOX_APPEARANCE4
);
1115 checkbox(&cp
, "Hide mouse &pointer when typing in window",
1118 beginbox(&cp
, "Adjust the window border", IDC_BOX_APPEARANCE5
);
1119 checkbox(&cp
, "&Sunken-edge border (slightly thicker)",
1121 staticedit(&cp
, "Gap between text and window edge",
1122 IDC_WINBSTATIC
, IDC_WINBEDIT
, 20);
1126 if (panel
== behaviourpanelstart
) {
1127 /* The Behaviour panel. Accelerators used: [acgo] w4yltf */
1129 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1130 bartitle(&cp
, "Configure the behaviour of PuTTY's window",
1132 beginbox(&cp
, NULL
, IDC_BOX_BEHAVIOUR1
);
1133 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
1134 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
1135 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
1136 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
1137 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
1138 checkbox(&cp
, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER
);
1142 if (panel
== translationpanelstart
) {
1143 /* The Translation panel. Accelerators used: [acgo] rxbepus */
1145 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1146 bartitle(&cp
, "Options controlling character set translation",
1147 IDC_TITLE_TRANSLATION
);
1148 beginbox(&cp
, "Character set translation on received data",
1149 IDC_BOX_TRANSLATION1
);
1150 combobox(&cp
, "&Received data assumed to be in which character set:",
1151 IDC_CODEPAGESTATIC
, IDC_CODEPAGE
);
1153 beginbox(&cp
, "Enable character set translation on input data",
1154 IDC_BOX_TRANSLATION2
);
1155 checkbox(&cp
, "Cap&s Lock acts as Cyrillic switch",
1158 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
1159 IDC_BOX_TRANSLATION3
);
1161 "Handling of line drawing characters:", IDC_VTSTATIC
,
1162 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
1163 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
1164 "Use font in O&EM mode only", IDC_VTOEMONLY
,
1165 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1166 IDC_VTPOORMAN
, "&Unicode mode", IDC_VTUNICODE
, NULL
);
1170 if (panel
== selectionpanelstart
) {
1171 /* The Selection panel. Accelerators used: [acgo] df wxp hst nr */
1173 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1174 bartitle(&cp
, "Options controlling copy and paste",
1175 IDC_TITLE_SELECTION
);
1176 beginbox(&cp
, "Translation of pasted characters",
1177 IDC_BOX_SELECTION1
);
1179 "&Don't translate line drawing chars into +, - and |",
1182 "Paste to clipboard in RT&F as well as plain text",
1185 beginbox(&cp
, "Control which mouse button does which thing",
1186 IDC_BOX_SELECTION2
);
1187 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1188 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1189 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1192 "Shift overrides a&pplication's use of mouse",
1195 "Default selection mode (Alt+drag does the other one):",
1196 IDC_SELTYPESTATIC
, 2,
1197 "&Normal", IDC_SELTYPELEX
,
1198 "&Rectangular block", IDC_SELTYPERECT
, NULL
);
1200 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1201 IDC_BOX_SELECTION3
);
1202 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1203 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1204 "&to class", IDC_CCSTATIC2
);
1208 if (panel
== colourspanelstart
) {
1209 /* The Colours panel. Accelerators used: [acgo] blum */
1211 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1212 bartitle(&cp
, "Options controlling use of colours",
1214 beginbox(&cp
, "General options for colour usage",
1216 checkbox(&cp
, "&Bolded text is a different colour",
1218 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1220 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1222 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1223 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1224 "&Modify...", IDC_CHANGE
,
1225 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1226 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1227 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1231 if (panel
== connectionpanelstart
) {
1232 /* The Connection panel. Accelerators used: [acgo] tukn */
1234 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1235 bartitle(&cp
, "Options controlling the connection",
1236 IDC_TITLE_CONNECTION
);
1238 beginbox(&cp
, "Data to send to the server",
1239 IDC_BOX_CONNECTION1
);
1240 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
,
1242 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
,
1246 beginbox(&cp
, "Adjust telnet session.", IDC_BOX_CONNECTION1
);
1247 checkbox(&cp
, "Keyboard sends telnet Backspace and Interrupt",
1251 beginbox(&cp
, "Sending of null packets to keep session active",
1252 IDC_BOX_CONNECTION2
);
1253 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1254 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1257 beginbox(&cp
, "Low-level TCP connection options",
1258 IDC_BOX_CONNECTION3
);
1259 checkbox(&cp
, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1265 if (panel
== telnetpanelstart
) {
1266 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
1268 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1270 bartitle(&cp
, "Options controlling Telnet connections",
1272 beginbox(&cp
, "Data to send to the server", IDC_BOX_TELNET1
);
1273 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
,
1275 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1276 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
, "Va&lue",
1277 IDC_VALSTATIC
, IDC_VALEDIT
, IDC_ENVLIST
, "A&dd",
1278 IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1280 beginbox(&cp
, "Telnet protocol adjustments", IDC_BOX_TELNET2
);
1281 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:",
1282 IDC_EMSTATIC
, 2, "&BSD (commonplace)", IDC_EMBSD
,
1283 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1284 radioline(&cp
, "&Telnet negotiation mode:", IDC_ACTSTATIC
, 2,
1285 "Passive", IDC_TPASSIVE
, "Active",
1287 checkbox(&cp
, "&Keyboard sends telnet Backspace and Interrupt",
1293 if (panel
== rloginpanelstart
) {
1294 /* The Rlogin panel. Accelerators used: [acgo] sl */
1296 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1298 bartitle(&cp
, "Options controlling Rlogin connections",
1300 beginbox(&cp
, "Data to send to the server", IDC_BOX_RLOGIN1
);
1301 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
,
1303 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
,
1304 IDC_RLLUSEREDIT
, 50);
1309 if (panel
== sshpanelstart
) {
1310 /* The SSH panel. Accelerators used: [acgo] r pe12i sd */
1312 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1314 bartitle(&cp
, "Options controlling SSH connections",
1316 beginbox(&cp
, "Data to send to the server", IDC_BOX_SSH1
);
1318 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1321 beginbox(&cp
, "Protocol options", IDC_BOX_SSH2
);
1322 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1323 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1324 radioline(&cp
, "Preferred SSH protocol version:",
1325 IDC_SSHPROTSTATIC
, 2,
1326 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1327 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1330 beginbox(&cp
, "Encryption options", IDC_BOX_SSH3
);
1331 prefslist(&cipherlist
, &cp
, "Encryption cipher &selection policy:",
1332 IDC_CIPHERSTATIC2
, IDC_CIPHERLIST
, IDC_CIPHERUP
,
1334 checkbox(&cp
, "Enable non-standard use of single-&DES in SSH 2",
1340 if (panel
== sshauthpanelstart
) {
1341 /* The SSH authentication panel. Accelerators used: [acgo] m fkiw */
1343 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1345 bartitle(&cp
, "Options controlling SSH authentication",
1347 beginbox(&cp
, "Authentication methods",
1349 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
1351 checkbox(&cp
, "Attempt \"keyboard-&interactive\" authentication"
1352 " (SSH2)", IDC_AUTHKI
);
1354 beginbox(&cp
, "Authentication parameters",
1356 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1357 editbutton(&cp
, "Private &key file for authentication:",
1358 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...",
1364 if (panel
== tunnelspanelstart
) {
1365 /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */
1367 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1369 bartitle(&cp
, "Options controlling SSH tunnelling",
1371 beginbox(&cp
, "X11 forwarding", IDC_BOX_TUNNELS1
);
1372 checkbox(&cp
, "&Enable X11 forwarding", IDC_X11_FORWARD
);
1373 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1374 IDC_X11_DISPLAY
, 50, NULL
);
1376 beginbox(&cp
, "Port forwarding", IDC_BOX_TUNNELS2
);
1377 checkbox(&cp
, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL
);
1378 staticbtn(&cp
, "Forwarded ports:", IDC_PFWDSTATIC
,
1379 "&Remove", IDC_PFWDREMOVE
);
1380 fwdsetter(&cp
, IDC_PFWDLIST
,
1381 "Add new forwarded port:", IDC_PFWDSTATIC2
,
1382 "&Source port", IDC_SPORTSTATIC
, IDC_SPORTEDIT
,
1383 "Dest&ination", IDC_DPORTSTATIC
, IDC_DPORTEDIT
,
1384 "A&dd", IDC_PFWDADD
);
1385 bareradioline(&cp
, 2,
1386 "&Local", IDC_PFWDLOCAL
, "Re&mote", IDC_PFWDREMOTE
, NULL
);
1394 * Helper function to load the session selected in SESSLIST
1395 * if any, as this is done in more than one place in
1396 * GenericMainDlgProc(). 0 => failure.
1398 static int load_selected_session(HWND hwnd
)
1400 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1401 LB_GETCURSEL
, 0, 0);
1407 isdef
= !strcmp(sessions
[n
], "Default Settings");
1408 load_settings(sessions
[n
], !isdef
, &cfg
);
1409 init_dlg_ctrls(hwnd
, TRUE
);
1411 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1413 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1414 /* Restore the selection, which will have been clobbered by
1415 * SESSEDIT handling. */
1416 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
, n
, 0);
1421 * This function is the configuration box.
1423 static int GenericMainDlgProc(HWND hwnd
, UINT msg
,
1424 WPARAM wParam
, LPARAM lParam
, int dlgtype
)
1427 struct treeview_faff tvfaff
;
1430 char filename
[sizeof(cfg
.keyfile
)];
1433 char fontstatic
[256];
1435 struct servent
*service
;
1437 static UINT draglistmsg
= WM_NULL
;
1442 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1443 SendMessage(hwnd
, WM_SETICON
, (WPARAM
) ICON_BIG
,
1444 (LPARAM
) LoadIcon(hinst
, MAKEINTRESOURCE(IDI_CFGICON
)));
1446 * Centre the window.
1448 { /* centre the window */
1451 hw
= GetDesktopWindow();
1452 if (GetWindowRect(hw
, &rs
) && GetWindowRect(hwnd
, &rd
))
1454 (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
) / 2,
1455 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
) / 2,
1456 rd
.right
- rd
.left
, rd
.bottom
- rd
.top
, TRUE
);
1460 * Create the tree view.
1468 r
.right
= r
.left
+ 75;
1470 r
.bottom
= r
.top
+ 10;
1471 MapDialogRect(hwnd
, &r
);
1472 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1473 WS_CHILD
| WS_VISIBLE
,
1475 r
.right
- r
.left
, r
.bottom
- r
.top
,
1476 hwnd
, (HMENU
) IDCX_TVSTATIC
, hinst
,
1478 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1479 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1482 r
.right
= r
.left
+ 75;
1484 r
.bottom
= r
.top
+ 219;
1485 MapDialogRect(hwnd
, &r
);
1486 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1487 WS_CHILD
| WS_VISIBLE
|
1488 WS_TABSTOP
| TVS_HASLINES
|
1489 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
1491 TVS_SHOWSELALWAYS
, r
.left
, r
.top
,
1492 r
.right
- r
.left
, r
.bottom
- r
.top
,
1493 hwnd
, (HMENU
) IDCX_TREEVIEW
, hinst
,
1495 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1496 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1497 tvfaff
.treeview
= treeview
;
1498 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1502 * Set up the tree view contents.
1504 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1505 treeview_insert(&tvfaff
, 1, "Logging");
1506 treeview_insert(&tvfaff
, 0, "Terminal");
1507 treeview_insert(&tvfaff
, 1, "Keyboard");
1508 treeview_insert(&tvfaff
, 1, "Bell");
1509 treeview_insert(&tvfaff
, 0, "Window");
1510 treeview_insert(&tvfaff
, 1, "Appearance");
1511 treeview_insert(&tvfaff
, 1, "Behaviour");
1512 treeview_insert(&tvfaff
, 1, "Translation");
1513 treeview_insert(&tvfaff
, 1, "Selection");
1514 treeview_insert(&tvfaff
, 1, "Colours");
1515 treeview_insert(&tvfaff
, 0, "Connection");
1517 treeview_insert(&tvfaff
, 1, "Telnet");
1518 treeview_insert(&tvfaff
, 1, "Rlogin");
1519 if (backends
[3].backend
!= NULL
) {
1520 treeview_insert(&tvfaff
, 1, "SSH");
1521 /* XXX long name is ugly */
1522 /* XXX make it closed by default? */
1523 treeview_insert(&tvfaff
, 2, "Auth");
1524 treeview_insert(&tvfaff
, 2, "Tunnels");
1529 * Put the treeview selection on to the Session panel. This
1530 * should also cause creation of the relevant controls.
1532 TreeView_SelectItem(treeview
, hsession
);
1535 * Set focus into the first available control.
1539 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1541 ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1545 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1546 sesslist_has_focus
= 0;
1550 * Button release should trigger WM_OK if there was a
1551 * previous double click on the session list.
1555 SendMessage(hwnd
, WM_COMMAND
, IDOK
, 0);
1558 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1559 ((LPNMHDR
) lParam
)->code
== TVN_SELCHANGED
) {
1561 TreeView_GetSelection(((LPNMHDR
) lParam
)->hwndFrom
);
1566 SendMessage (hwnd
, WM_SETREDRAW
, FALSE
, 0);
1569 item
.pszText
= buffer
;
1570 item
.cchTextMax
= sizeof(buffer
);
1571 item
.mask
= TVIF_TEXT
;
1572 TreeView_GetItem(((LPNMHDR
) lParam
)->hwndFrom
, &item
);
1573 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1574 HWND item
= GetDlgItem(hwnd
, j
);
1576 DestroyWindow(item
);
1578 if (!strcmp(buffer
, "Session"))
1579 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1580 if (!strcmp(buffer
, "Logging"))
1581 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1582 if (!strcmp(buffer
, "Keyboard"))
1583 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1584 if (!strcmp(buffer
, "Terminal"))
1585 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1586 if (!strcmp(buffer
, "Bell"))
1587 create_controls(hwnd
, dlgtype
, bellpanelstart
);
1588 if (!strcmp(buffer
, "Window"))
1589 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1590 if (!strcmp(buffer
, "Appearance"))
1591 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1592 if (!strcmp(buffer
, "Behaviour"))
1593 create_controls(hwnd
, dlgtype
, behaviourpanelstart
);
1594 if (!strcmp(buffer
, "Tunnels"))
1595 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1596 if (!strcmp(buffer
, "Connection"))
1597 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1598 if (!strcmp(buffer
, "Telnet"))
1599 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1600 if (!strcmp(buffer
, "Rlogin"))
1601 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1602 if (!strcmp(buffer
, "SSH"))
1603 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1604 if (!strcmp(buffer
, "Auth"))
1605 create_controls(hwnd
, dlgtype
, sshauthpanelstart
);
1606 if (!strcmp(buffer
, "Selection"))
1607 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1608 if (!strcmp(buffer
, "Colours"))
1609 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1610 if (!strcmp(buffer
, "Translation"))
1611 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1613 init_dlg_ctrls(hwnd
, FALSE
);
1615 SendMessage (hwnd
, WM_SETREDRAW
, TRUE
, 0);
1616 InvalidateRect (hwnd
, NULL
, TRUE
);
1618 SetFocus(((LPNMHDR
) lParam
)->hwndFrom
); /* ensure focus stays */
1624 * Only process WM_COMMAND once the dialog is fully formed.
1626 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1)
1627 switch (LOWORD(wParam
)) {
1629 /* Behaviour of the "Open" button is different if the
1630 * session list has focus, *unless* the user just
1631 * double-clicked... */
1632 if (sesslist_has_focus
&& !readytogo
) {
1633 if (!load_selected_session(hwnd
)) {
1638 /* If at this point we have a valid session, go! */
1647 case IDC_PROTTELNET
:
1648 case IDC_PROTRLOGIN
:
1651 if (HIWORD(wParam
) == BN_CLICKED
||
1652 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1653 int i
= IsDlgButtonChecked(hwnd
, IDC_PROTSSH
);
1654 int j
= IsDlgButtonChecked(hwnd
, IDC_PROTTELNET
);
1655 int k
= IsDlgButtonChecked(hwnd
, IDC_PROTRLOGIN
);
1657 i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
:
1659 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22)
1660 || (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23)
1661 || (cfg
.protocol
== PROT_RLOGIN
1662 && cfg
.port
!= 513)) {
1663 cfg
.port
= i ?
22 : j ?
23 : 513;
1664 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1669 if (HIWORD(wParam
) == EN_CHANGE
)
1670 GetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
,
1671 sizeof(cfg
.host
) - 1);
1674 if (HIWORD(wParam
) == EN_CHANGE
) {
1675 GetDlgItemText(hwnd
, IDC_PORT
, portname
, 31);
1676 if (isdigit(portname
[0]))
1677 MyGetDlgItemInt(hwnd
, IDC_PORT
, &cfg
.port
);
1679 service
= getservbyname(portname
, NULL
);
1681 cfg
.port
= ntohs(service
->s_port
);
1688 if (HIWORD(wParam
) == EN_CHANGE
) {
1689 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1691 GetDlgItemText(hwnd
, IDC_SESSEDIT
,
1692 savedsession
, sizeof(savedsession
) - 1);
1693 savedsession
[sizeof(savedsession
) - 1] = '\0';
1697 if (HIWORD(wParam
) == BN_CLICKED
||
1698 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1703 GetDlgItemText(hwnd
, IDC_SESSEDIT
, str
,
1706 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1707 LB_GETCURSEL
, 0, 0);
1712 strcpy(str
, sessions
[n
]);
1714 save_settings(str
, !!strcmp(str
, "Default Settings"),
1716 get_sesslist(FALSE
);
1718 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1720 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1722 for (i
= 0; i
< nsessions
; i
++)
1723 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1725 (LPARAM
) (sessions
[i
]));
1726 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1728 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1730 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1736 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1737 if (HIWORD(wParam
) == LBN_SETFOCUS
)
1738 sesslist_has_focus
= 1;
1739 else if (HIWORD(wParam
) == LBN_KILLFOCUS
)
1740 sesslist_has_focus
= 0;
1742 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1743 HIWORD(wParam
) != BN_CLICKED
&&
1744 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
1745 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1746 HIWORD(wParam
) != LBN_DBLCLK
) break;
1747 /* Load the session selected in SESSLIST. */
1748 if (load_selected_session(hwnd
) &&
1749 LOWORD(wParam
) == IDC_SESSLIST
) {
1751 * A double-click on a saved session should
1752 * actually start the session, not just load it.
1753 * Unless it's Default Settings or some other
1754 * host-less set of saved settings.
1763 if (HIWORD(wParam
) == BN_CLICKED
||
1764 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1765 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1766 LB_GETCURSEL
, 0, 0);
1767 if (n
== LB_ERR
|| n
== 0) {
1771 del_settings(sessions
[n
]);
1772 get_sesslist(FALSE
);
1774 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1776 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1778 for (i
= 0; i
< nsessions
; i
++)
1779 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1781 (LPARAM
) (sessions
[i
]));
1782 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1784 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1786 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1790 if (HIWORD(wParam
) == EN_CHANGE
)
1791 MyGetDlgItemInt(hwnd
, IDC_PINGEDIT
,
1792 &cfg
.ping_interval
);
1795 if (HIWORD(wParam
) == BN_CLICKED
||
1796 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1798 IsDlgButtonChecked(hwnd
, IDC_NODELAY
);
1802 if (HIWORD(wParam
) == BN_CLICKED
||
1803 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1804 cfg
.bksp_is_delete
=
1805 IsDlgButtonChecked(hwnd
, IDC_DEL127
);
1809 if (HIWORD(wParam
) == BN_CLICKED
||
1810 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1812 IsDlgButtonChecked(hwnd
, IDC_HOMERXVT
);
1818 case IDC_FUNCVT100P
:
1820 if (HIWORD(wParam
) == BN_CLICKED
||
1821 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1822 switch (LOWORD(wParam
)) {
1835 case IDC_FUNCVT100P
:
1845 if (HIWORD(wParam
) == BN_CLICKED
||
1846 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1848 IsDlgButtonChecked(hwnd
, IDC_KPAPPLIC
);
1849 cfg
.nethack_keypad
= FALSE
;
1853 if (HIWORD(wParam
) == BN_CLICKED
||
1854 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1855 cfg
.app_keypad
= FALSE
;
1856 cfg
.nethack_keypad
= TRUE
;
1861 if (HIWORD(wParam
) == BN_CLICKED
||
1862 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1864 IsDlgButtonChecked(hwnd
, IDC_CURAPPLIC
);
1867 if (HIWORD(wParam
) == BN_CLICKED
||
1868 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1870 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICC
);
1873 if (HIWORD(wParam
) == BN_CLICKED
||
1874 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1876 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICK
);
1879 if (HIWORD(wParam
) == BN_CLICKED
||
1880 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1881 cfg
.alt_f4
= IsDlgButtonChecked(hwnd
, IDC_ALTF4
);
1884 if (HIWORD(wParam
) == BN_CLICKED
||
1885 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1887 IsDlgButtonChecked(hwnd
, IDC_ALTSPACE
);
1890 if (HIWORD(wParam
) == BN_CLICKED
||
1891 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1893 IsDlgButtonChecked(hwnd
, IDC_ALTONLY
);
1895 case IDC_ECHOBACKEND
:
1898 if (HIWORD(wParam
) == BN_CLICKED
||
1899 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1900 if (LOWORD(wParam
) == IDC_ECHOBACKEND
)
1901 cfg
.localecho
= LD_BACKEND
;
1902 if (LOWORD(wParam
) == IDC_ECHOYES
)
1903 cfg
.localecho
= LD_YES
;
1904 if (LOWORD(wParam
) == IDC_ECHONO
)
1905 cfg
.localecho
= LD_NO
;
1908 case IDC_EDITBACKEND
:
1911 if (HIWORD(wParam
) == BN_CLICKED
||
1912 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1913 if (LOWORD(wParam
) == IDC_EDITBACKEND
)
1914 cfg
.localedit
= LD_BACKEND
;
1915 if (LOWORD(wParam
) == IDC_EDITYES
)
1916 cfg
.localedit
= LD_YES
;
1917 if (LOWORD(wParam
) == IDC_EDITNO
)
1918 cfg
.localedit
= LD_NO
;
1921 case IDC_ANSWEREDIT
:
1922 if (HIWORD(wParam
) == EN_CHANGE
)
1923 GetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
1924 sizeof(cfg
.answerback
) - 1);
1926 case IDC_ALWAYSONTOP
:
1927 if (HIWORD(wParam
) == BN_CLICKED
||
1928 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1930 IsDlgButtonChecked(hwnd
, IDC_ALWAYSONTOP
);
1932 case IDC_FULLSCREENONALTENTER
:
1933 if (HIWORD(wParam
) == BN_CLICKED
||
1934 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1935 cfg
.fullscreenonaltenter
=
1936 IsDlgButtonChecked(hwnd
, IDC_FULLSCREENONALTENTER
);
1939 if (HIWORD(wParam
) == BN_CLICKED
||
1940 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1942 IsDlgButtonChecked(hwnd
, IDC_SCROLLKEY
);
1944 case IDC_SCROLLDISP
:
1945 if (HIWORD(wParam
) == BN_CLICKED
||
1946 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1947 cfg
.scroll_on_disp
=
1948 IsDlgButtonChecked(hwnd
, IDC_SCROLLDISP
);
1950 case IDC_COMPOSEKEY
:
1951 if (HIWORD(wParam
) == BN_CLICKED
||
1952 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1954 IsDlgButtonChecked(hwnd
, IDC_COMPOSEKEY
);
1956 case IDC_CTRLALTKEYS
:
1957 if (HIWORD(wParam
) == BN_CLICKED
||
1958 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1960 IsDlgButtonChecked(hwnd
, IDC_CTRLALTKEYS
);
1963 if (HIWORD(wParam
) == BN_CLICKED
||
1964 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1965 cfg
.telnet_keyboard
=
1966 IsDlgButtonChecked(hwnd
, IDC_TELNETKEY
);
1969 if (HIWORD(wParam
) == BN_CLICKED
||
1970 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1972 IsDlgButtonChecked(hwnd
, IDC_WRAPMODE
);
1975 if (HIWORD(wParam
) == BN_CLICKED
||
1976 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1977 cfg
.dec_om
= IsDlgButtonChecked(hwnd
, IDC_DECOM
);
1980 if (HIWORD(wParam
) == BN_CLICKED
||
1981 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1983 IsDlgButtonChecked(hwnd
, IDC_LFHASCR
);
1986 if (HIWORD(wParam
) == EN_CHANGE
)
1987 MyGetDlgItemInt(hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1990 if (HIWORD(wParam
) == EN_CHANGE
)
1991 MyGetDlgItemInt(hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1994 if (HIWORD(wParam
) == EN_CHANGE
)
1995 MyGetDlgItemInt(hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1997 case IDC_CHOOSEFONT
:
2000 lf
.lfHeight
= -MulDiv(cfg
.fontheight
,
2001 GetDeviceCaps(hdc
, LOGPIXELSY
),
2005 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
2006 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
2007 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
2008 lf
.lfCharSet
= cfg
.fontcharset
;
2009 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
2010 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
2011 lf
.lfQuality
= DEFAULT_QUALITY
;
2012 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
2013 strncpy(lf
.lfFaceName
, cfg
.font
,
2014 sizeof(lf
.lfFaceName
) - 1);
2015 lf
.lfFaceName
[sizeof(lf
.lfFaceName
) - 1] = '\0';
2017 cf
.lStructSize
= sizeof(cf
);
2018 cf
.hwndOwner
= hwnd
;
2020 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
2021 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
2023 if (ChooseFont(&cf
)) {
2024 strncpy(cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
) - 1);
2025 cfg
.font
[sizeof(cfg
.font
) - 1] = '\0';
2026 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
2027 cfg
.fontcharset
= lf
.lfCharSet
;
2028 cfg
.fontheight
= cf
.iPointSize
/ 10;
2029 fmtfont(fontstatic
);
2030 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
2033 case IDC_BELL_DISABLED
:
2034 case IDC_BELL_DEFAULT
:
2035 case IDC_BELL_WAVEFILE
:
2036 case IDC_BELL_VISUAL
:
2037 if (HIWORD(wParam
) == BN_CLICKED
||
2038 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2039 if (LOWORD(wParam
) == IDC_BELL_DISABLED
)
2040 cfg
.beep
= BELL_DISABLED
;
2041 if (LOWORD(wParam
) == IDC_BELL_DEFAULT
)
2042 cfg
.beep
= BELL_DEFAULT
;
2043 if (LOWORD(wParam
) == IDC_BELL_WAVEFILE
)
2044 cfg
.beep
= BELL_WAVEFILE
;
2045 if (LOWORD(wParam
) == IDC_BELL_VISUAL
)
2046 cfg
.beep
= BELL_VISUAL
;
2049 case IDC_B_IND_DISABLED
:
2050 case IDC_B_IND_FLASH
:
2051 case IDC_B_IND_STEADY
:
2052 if (HIWORD(wParam
) == BN_CLICKED
||
2053 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2054 if (LOWORD(wParam
) == IDC_B_IND_DISABLED
)
2055 cfg
.beep_ind
= B_IND_DISABLED
;
2056 if (LOWORD(wParam
) == IDC_B_IND_FLASH
)
2057 cfg
.beep_ind
= B_IND_FLASH
;
2058 if (LOWORD(wParam
) == IDC_B_IND_STEADY
)
2059 cfg
.beep_ind
= B_IND_STEADY
;
2062 case IDC_BELL_WAVEBROWSE
:
2063 memset(&of
, 0, sizeof(of
));
2064 #ifdef OPENFILENAME_SIZE_VERSION_400
2065 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2067 of
.lStructSize
= sizeof(of
);
2069 of
.hwndOwner
= hwnd
;
2070 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2071 of
.lpstrCustomFilter
= NULL
;
2072 of
.nFilterIndex
= 1;
2073 of
.lpstrFile
= filename
;
2074 strcpy(filename
, cfg
.bell_wavefile
);
2075 of
.nMaxFile
= sizeof(filename
);
2076 of
.lpstrFileTitle
= NULL
;
2077 of
.lpstrInitialDir
= NULL
;
2078 of
.lpstrTitle
= "Select Bell Sound File";
2080 if (GetOpenFileName(&of
)) {
2081 strcpy(cfg
.bell_wavefile
, filename
);
2082 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2086 case IDC_BELL_WAVEEDIT
:
2087 if (HIWORD(wParam
) == EN_CHANGE
)
2088 GetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2090 sizeof(cfg
.bell_wavefile
) - 1);
2093 if (HIWORD(wParam
) == BN_CLICKED
||
2094 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2096 IsDlgButtonChecked(hwnd
, IDC_BELLOVL
);
2099 if (HIWORD(wParam
) == EN_CHANGE
)
2100 MyGetDlgItemInt(hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
2103 if (HIWORD(wParam
) == EN_CHANGE
)
2104 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
,
2108 if (HIWORD(wParam
) == EN_CHANGE
)
2109 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
,
2113 if (HIWORD(wParam
) == BN_CLICKED
||
2114 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2116 IsDlgButtonChecked(hwnd
, IDC_BLINKTEXT
);
2119 if (HIWORD(wParam
) == BN_CLICKED
||
2120 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2121 cfg
.bce
= IsDlgButtonChecked(hwnd
, IDC_BCE
);
2124 if (HIWORD(wParam
) == BN_CLICKED
||
2125 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2126 cfg
.win_name_always
=
2127 IsDlgButtonChecked(hwnd
, IDC_WINNAME
);
2130 if (HIWORD(wParam
) == BN_CLICKED
||
2131 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2133 IsDlgButtonChecked(hwnd
, IDC_HIDEMOUSE
);
2135 case IDC_SUNKENEDGE
:
2136 if (HIWORD(wParam
) == BN_CLICKED
||
2137 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2139 IsDlgButtonChecked(hwnd
, IDC_SUNKENEDGE
);
2142 if (HIWORD(wParam
) == EN_CHANGE
)
2143 MyGetDlgItemInt(hwnd
, IDC_WINBEDIT
,
2144 &cfg
.window_border
);
2145 if (cfg
.window_border
> 32)
2146 cfg
.window_border
= 32;
2149 if (HIWORD(wParam
) == BN_CLICKED
||
2150 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2151 cfg
.cursor_type
= 0;
2154 if (HIWORD(wParam
) == BN_CLICKED
||
2155 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2156 cfg
.cursor_type
= 1;
2159 if (HIWORD(wParam
) == BN_CLICKED
||
2160 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2161 cfg
.cursor_type
= 2;
2164 if (HIWORD(wParam
) == BN_CLICKED
||
2165 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2167 IsDlgButtonChecked(hwnd
, IDC_BLINKCUR
);
2170 if (HIWORD(wParam
) == BN_CLICKED
||
2171 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2173 IsDlgButtonChecked(hwnd
, IDC_SCROLLBAR
);
2175 case IDC_SCROLLBARFULLSCREEN
:
2176 if (HIWORD(wParam
) == BN_CLICKED
||
2177 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2178 cfg
.scrollbar_in_fullscreen
=
2179 IsDlgButtonChecked(hwnd
, IDC_SCROLLBARFULLSCREEN
);
2181 case IDC_RESIZETERM
:
2182 case IDC_RESIZEFONT
:
2183 case IDC_RESIZENONE
:
2184 case IDC_RESIZEEITHER
:
2185 if (HIWORD(wParam
) == BN_CLICKED
||
2186 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2188 IsDlgButtonChecked(hwnd
,
2189 IDC_RESIZETERM
) ? RESIZE_TERM
:
2190 IsDlgButtonChecked(hwnd
,
2191 IDC_RESIZEFONT
) ? RESIZE_FONT
:
2192 IsDlgButtonChecked(hwnd
,
2193 IDC_RESIZEEITHER
) ? RESIZE_EITHER
:
2198 if (HIWORD(wParam
) == EN_CHANGE
)
2199 GetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
2200 sizeof(cfg
.wintitle
) - 1);
2205 if (HIWORD(wParam
) == BN_CLICKED
||
2206 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2208 IsDlgButtonChecked(hwnd
,
2209 IDC_COEALWAYS
) ? COE_ALWAYS
:
2210 IsDlgButtonChecked(hwnd
,
2211 IDC_COENEVER
) ? COE_NEVER
:
2216 if (HIWORD(wParam
) == BN_CLICKED
||
2217 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2219 IsDlgButtonChecked(hwnd
, IDC_CLOSEWARN
);
2222 if (HIWORD(wParam
) == EN_CHANGE
)
2223 GetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
,
2224 sizeof(cfg
.termtype
) - 1);
2227 if (HIWORD(wParam
) == EN_CHANGE
)
2228 GetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
2229 sizeof(cfg
.logfilename
) - 1);
2232 memset(&of
, 0, sizeof(of
));
2233 #ifdef OPENFILENAME_SIZE_VERSION_400
2234 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2236 of
.lStructSize
= sizeof(of
);
2238 of
.hwndOwner
= hwnd
;
2239 of
.lpstrFilter
= "All Files\0*\0\0\0";
2240 of
.lpstrCustomFilter
= NULL
;
2241 of
.nFilterIndex
= 1;
2242 of
.lpstrFile
= filename
;
2243 strcpy(filename
, cfg
.logfilename
);
2244 of
.nMaxFile
= sizeof(filename
);
2245 of
.lpstrFileTitle
= NULL
;
2246 of
.lpstrInitialDir
= NULL
;
2247 of
.lpstrTitle
= "Select session log file";
2249 if (GetSaveFileName(&of
)) {
2250 strcpy(cfg
.logfilename
, filename
);
2251 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
2255 case IDC_LSTATASCII
:
2257 if (HIWORD(wParam
) == BN_CLICKED
||
2258 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2259 if (IsDlgButtonChecked(hwnd
, IDC_LSTATOFF
))
2261 if (IsDlgButtonChecked(hwnd
, IDC_LSTATASCII
))
2263 if (IsDlgButtonChecked(hwnd
, IDC_LSTATRAW
))
2270 if (HIWORD(wParam
) == BN_CLICKED
||
2271 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2272 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXASK
))
2273 cfg
.logxfovr
= LGXF_ASK
;
2274 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXAPN
))
2275 cfg
.logxfovr
= LGXF_APN
;
2276 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXOVR
))
2277 cfg
.logxfovr
= LGXF_OVR
;
2282 if (HIWORD(wParam
) == EN_CHANGE
)
2283 GetDlgItemText(hwnd
, LOWORD(wParam
), cfg
.termspeed
,
2284 sizeof(cfg
.termspeed
) - 1);
2287 if (HIWORD(wParam
) == EN_CHANGE
)
2288 GetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
,
2289 sizeof(cfg
.username
) - 1);
2291 case IDC_RLLUSEREDIT
:
2292 if (HIWORD(wParam
) == EN_CHANGE
)
2293 GetDlgItemText(hwnd
, IDC_RLLUSEREDIT
,
2295 sizeof(cfg
.localusername
) - 1);
2299 cfg
.rfc_environ
= IsDlgButtonChecked(hwnd
, IDC_EMRFC
);
2303 cfg
.passive_telnet
=
2304 IsDlgButtonChecked(hwnd
, IDC_TPASSIVE
);
2307 if (HIWORD(wParam
) == BN_CLICKED
||
2308 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2309 char str
[sizeof(cfg
.environmt
)];
2311 GetDlgItemText(hwnd
, IDC_VAREDIT
, str
,
2317 p
= str
+ strlen(str
);
2319 GetDlgItemText(hwnd
, IDC_VALEDIT
, p
,
2320 sizeof(str
) - 1 - (p
- str
));
2331 if ((p
- cfg
.environmt
) + strlen(str
) + 2 <
2332 sizeof(cfg
.environmt
)) {
2334 p
[strlen(str
) + 1] = '\0';
2335 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
2337 SetDlgItemText(hwnd
, IDC_VAREDIT
, "");
2338 SetDlgItemText(hwnd
, IDC_VALEDIT
, "");
2340 MessageBox(hwnd
, "Environment too big",
2341 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2346 if (HIWORD(wParam
) != BN_CLICKED
&&
2347 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2349 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0,
2356 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
2383 if (HIWORD(wParam
) == BN_CLICKED
||
2384 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2385 cfg
.nopty
= IsDlgButtonChecked(hwnd
, IDC_NOPTY
);
2388 if (HIWORD(wParam
) == BN_CLICKED
||
2389 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2391 IsDlgButtonChecked(hwnd
, IDC_COMPRESS
);
2394 if (HIWORD(wParam
) == BN_CLICKED
||
2395 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2397 IsDlgButtonChecked(hwnd
, IDC_BUGGYMAC
);
2400 if (HIWORD(wParam
) == BN_CLICKED
||
2401 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2403 IsDlgButtonChecked(hwnd
, IDC_SSH2DES
);
2406 if (HIWORD(wParam
) == BN_CLICKED
||
2407 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2409 IsDlgButtonChecked(hwnd
, IDC_AGENTFWD
);
2411 case IDC_CIPHERLIST
:
2414 handle_prefslist(&cipherlist
,
2415 cfg
.ssh_cipherlist
, CIPHER_MAX
,
2416 0, hwnd
, wParam
, lParam
);
2420 if (HIWORD(wParam
) == BN_CLICKED
||
2421 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2422 if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT1
))
2424 else if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT2
))
2429 if (HIWORD(wParam
) == BN_CLICKED
||
2430 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2432 IsDlgButtonChecked(hwnd
, IDC_AUTHTIS
);
2435 if (HIWORD(wParam
) == BN_CLICKED
||
2436 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2438 IsDlgButtonChecked(hwnd
, IDC_AUTHKI
);
2441 if (HIWORD(wParam
) == EN_CHANGE
)
2442 GetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
2443 sizeof(cfg
.keyfile
) - 1);
2446 if (HIWORD(wParam
) == EN_CHANGE
)
2447 GetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
2448 sizeof(cfg
.remote_cmd
) - 1);
2451 memset(&of
, 0, sizeof(of
));
2452 #ifdef OPENFILENAME_SIZE_VERSION_400
2453 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2455 of
.lStructSize
= sizeof(of
);
2457 of
.hwndOwner
= hwnd
;
2458 of
.lpstrFilter
= "All Files\0*\0\0\0";
2459 of
.lpstrCustomFilter
= NULL
;
2460 of
.nFilterIndex
= 1;
2461 of
.lpstrFile
= filename
;
2462 strcpy(filename
, cfg
.keyfile
);
2463 of
.nMaxFile
= sizeof(filename
);
2464 of
.lpstrFileTitle
= NULL
;
2465 of
.lpstrInitialDir
= NULL
;
2466 of
.lpstrTitle
= "Select Private Key File";
2468 if (GetOpenFileName(&of
)) {
2469 strcpy(cfg
.keyfile
, filename
);
2470 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
2474 cfg
.rawcnp
= IsDlgButtonChecked(hwnd
, IDC_RAWCNP
);
2477 cfg
.rtf_paste
= IsDlgButtonChecked(hwnd
, IDC_RTFPASTE
);
2481 cfg
.mouse_is_xterm
= IsDlgButtonChecked(hwnd
, IDC_MBXTERM
);
2483 case IDC_SELTYPELEX
:
2484 case IDC_SELTYPERECT
:
2485 cfg
.rect_select
= IsDlgButtonChecked(hwnd
, IDC_SELTYPERECT
);
2487 case IDC_MOUSEOVERRIDE
:
2488 cfg
.mouse_override
= IsDlgButtonChecked(hwnd
, IDC_MOUSEOVERRIDE
);
2494 int n
= GetDlgItemInt(hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
2499 for (i
= 0; i
< 128; i
++)
2500 if (SendDlgItemMessage
2501 (hwnd
, IDC_CCLIST
, LB_GETSEL
, i
, 0)) {
2503 cfg
.wordness
[i
] = n
;
2504 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2505 LB_DELETESTRING
, i
, 0);
2506 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
2507 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ',
2509 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2516 case IDC_BOLDCOLOUR
:
2517 if (HIWORD(wParam
) == BN_CLICKED
||
2518 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2521 IsDlgButtonChecked(hwnd
, IDC_BOLDCOLOUR
);
2522 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2525 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2527 if (n
!= 12 + 10 * cfg
.bold_colour
) {
2528 for (i
= n
; i
-- > 0;)
2529 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2530 LB_DELETESTRING
, i
, 0);
2531 for (i
= 0; i
< 22; i
++)
2532 if (cfg
.bold_colour
|| permcolour
[i
])
2533 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2535 (LPARAM
) colours
[i
]);
2537 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2539 InvalidateRect(GetDlgItem(hwnd
, IDC_COLOURLIST
), NULL
,
2544 if (HIWORD(wParam
) == BN_CLICKED
||
2545 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2547 IsDlgButtonChecked(hwnd
, IDC_PALETTE
);
2549 case IDC_COLOURLIST
:
2550 if (HIWORD(wParam
) == LBN_DBLCLK
||
2551 HIWORD(wParam
) == LBN_SELCHANGE
) {
2553 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2556 if (!cfg
.bold_colour
)
2557 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2558 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2560 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2562 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2567 if (HIWORD(wParam
) == BN_CLICKED
||
2568 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2569 static CHOOSECOLOR cc
;
2570 static DWORD custom
[16] = { 0 }; /* zero initialisers */
2572 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2575 if (!cfg
.bold_colour
)
2576 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2577 cc
.lStructSize
= sizeof(cc
);
2578 cc
.hwndOwner
= hwnd
;
2579 cc
.hInstance
= (HWND
) hinst
;
2580 cc
.lpCustColors
= custom
;
2582 RGB(cfg
.colours
[i
][0], cfg
.colours
[i
][1],
2584 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
2585 if (ChooseColor(&cc
)) {
2587 (unsigned char) (cc
.rgbResult
& 0xFF);
2589 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
2591 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
2592 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2594 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2596 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2602 if (HIWORD(wParam
) == CBN_SELCHANGE
) {
2603 int index
= SendDlgItemMessage(hwnd
, IDC_CODEPAGE
,
2604 CB_GETCURSEL
, 0, 0);
2605 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_GETLBTEXT
,
2606 index
, (LPARAM
)cfg
.line_codepage
);
2607 } else if (HIWORD(wParam
) == CBN_EDITCHANGE
) {
2608 GetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
,
2609 sizeof(cfg
.line_codepage
) - 1);
2610 } else if (HIWORD(wParam
) == CBN_KILLFOCUS
) {
2611 strcpy(cfg
.line_codepage
,
2612 cp_name(decode_codepage(cfg
.line_codepage
)));
2613 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
2616 case IDC_CAPSLOCKCYR
:
2617 if (HIWORD(wParam
) == BN_CLICKED
||
2618 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2619 cfg
.xlat_capslockcyr
=
2620 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
2623 case IDC_VTXWINDOWS
:
2629 (IsDlgButtonChecked(hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
2630 : IsDlgButtonChecked(hwnd
,
2631 IDC_VTOEMANSI
) ? VT_OEMANSI
:
2632 IsDlgButtonChecked(hwnd
,
2633 IDC_VTOEMONLY
) ? VT_OEMONLY
:
2634 IsDlgButtonChecked(hwnd
,
2635 IDC_VTUNICODE
) ? VT_UNICODE
:
2638 case IDC_X11_FORWARD
:
2639 if (HIWORD(wParam
) == BN_CLICKED
||
2640 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2642 IsDlgButtonChecked(hwnd
, IDC_X11_FORWARD
);
2645 if (HIWORD(wParam
) == BN_CLICKED
||
2646 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2647 cfg
.lport_acceptall
=
2648 IsDlgButtonChecked(hwnd
, IDC_LPORT_ALL
);
2650 case IDC_X11_DISPLAY
:
2651 if (HIWORD(wParam
) == EN_CHANGE
)
2652 GetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
2653 sizeof(cfg
.x11_display
) - 1);
2656 if (HIWORD(wParam
) == BN_CLICKED
||
2657 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2658 char str
[sizeof(cfg
.portfwd
)];
2660 if (IsDlgButtonChecked(hwnd
, IDC_PFWDLOCAL
))
2664 GetDlgItemText(hwnd
, IDC_SPORTEDIT
, str
+1,
2668 "You need to specify a source port number",
2669 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2672 p
= str
+ strlen(str
);
2674 GetDlgItemText(hwnd
, IDC_DPORTEDIT
, p
,
2675 sizeof(str
) - 1 - (p
- str
));
2676 if (!*p
|| !strchr(p
, ':')) {
2678 "You need to specify a destination address\n"
2679 "in the form \"host.name:port\"",
2680 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2689 if ((p
- cfg
.portfwd
) + strlen(str
) + 2 <
2690 sizeof(cfg
.portfwd
)) {
2692 p
[strlen(str
) + 1] = '\0';
2693 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
,
2695 SetDlgItemText(hwnd
, IDC_SPORTEDIT
, "");
2696 SetDlgItemText(hwnd
, IDC_DPORTEDIT
, "");
2698 MessageBox(hwnd
, "Too many forwardings",
2699 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2703 case IDC_PFWDREMOVE
:
2704 if (HIWORD(wParam
) != BN_CLICKED
&&
2705 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2706 i
= SendDlgItemMessage(hwnd
, IDC_PFWDLIST
,
2707 LB_GETCURSEL
, 0, 0);
2713 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_DELETESTRING
,
2745 /* Grrr Explorer will maximize Dialogs! */
2747 if (wParam
== SIZE_MAXIMIZED
)
2753 * Handle application-defined messages eg. DragListBox
2755 /* First find out what the number is (once). */
2756 if (draglistmsg
== WM_NULL
)
2757 draglistmsg
= RegisterWindowMessage (DRAGLISTMSGSTRING
);
2759 if (msg
== draglistmsg
) {
2760 /* Only process once dialog is fully formed. */
2761 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
2762 case IDC_CIPHERLIST
:
2763 return handle_prefslist(&cipherlist
,
2764 cfg
.ssh_cipherlist
, CIPHER_MAX
,
2765 1, hwnd
, wParam
, lParam
);
2774 static int CALLBACK
MainDlgProc(HWND hwnd
, UINT msg
,
2775 WPARAM wParam
, LPARAM lParam
)
2777 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
2779 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
2780 EnableWindow(hwnd
, 0);
2781 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2782 EnableWindow(hwnd
, 1);
2783 SetActiveWindow(hwnd
);
2785 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 0);
2788 static int CALLBACK
ReconfDlgProc(HWND hwnd
, UINT msg
,
2789 WPARAM wParam
, LPARAM lParam
)
2791 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 1);
2794 void defuse_showwindow(void)
2797 * Work around the fact that the app's first call to ShowWindow
2798 * will ignore the default in favour of the shell-provided
2803 hwnd
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2805 ShowWindow(hwnd
, SW_HIDE
);
2806 SetActiveWindow(hwnd
);
2807 DestroyWindow(hwnd
);
2816 savedsession
[0] = '\0';
2818 DialogBox(hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2819 get_sesslist(FALSE
);
2824 int do_reconfig(HWND hwnd
)
2829 backup_cfg
= cfg
; /* structure copy */
2831 DialogBox(hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2833 cfg
= backup_cfg
; /* structure copy */
2838 void logevent(char *string
)
2843 if (nevents
>= negsize
) {
2845 events
= srealloc(events
, negsize
* sizeof(*events
));
2849 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t",
2852 events
[nevents
] = smalloc(strlen(timebuf
) + strlen(string
) + 1);
2853 strcpy(events
[nevents
], timebuf
);
2854 strcat(events
[nevents
], string
);
2857 SendDlgItemMessage(logbox
, IDN_LIST
, LB_ADDSTRING
,
2858 0, (LPARAM
) events
[nevents
]);
2859 count
= SendDlgItemMessage(logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2860 SendDlgItemMessage(logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
- 1, 0);
2865 void showeventlog(HWND hwnd
)
2868 logbox
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2870 ShowWindow(logbox
, SW_SHOWNORMAL
);
2872 SetActiveWindow(logbox
);
2875 void showabout(HWND hwnd
)
2877 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2880 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2881 char *keystr
, char *fingerprint
)
2885 static const char absentmsg
[] =
2886 "The server's host key is not cached in the registry. You\n"
2887 "have no guarantee that the server is the computer you\n"
2889 "The server's key fingerprint is:\n"
2891 "If you trust this host, hit Yes to add the key to\n"
2892 "PuTTY's cache and carry on connecting.\n"
2893 "If you want to carry on connecting just once, without\n"
2894 "adding the key to the cache, hit No.\n"
2895 "If you do not trust this host, hit Cancel to abandon the\n"
2898 static const char wrongmsg
[] =
2899 "WARNING - POTENTIAL SECURITY BREACH!\n"
2901 "The server's host key does not match the one PuTTY has\n"
2902 "cached in the registry. This means that either the\n"
2903 "server administrator has changed the host key, or you\n"
2904 "have actually connected to another computer pretending\n"
2905 "to be the server.\n"
2906 "The new key fingerprint is:\n"
2908 "If you were expecting this change and trust the new key,\n"
2909 "hit Yes to update PuTTY's cache and continue connecting.\n"
2910 "If you want to carry on connecting but without updating\n"
2911 "the cache, hit No.\n"
2912 "If you want to abandon the connection completely, hit\n"
2913 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
2915 static const char mbtitle
[] = "PuTTY Security Alert";
2918 /* sensible fingerprint max size */
2919 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2920 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2923 * Verify the key against the registry.
2925 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2927 if (ret
== 0) /* success - key matched OK */
2929 if (ret
== 2) { /* key was different */
2931 sprintf(message
, wrongmsg
, fingerprint
);
2932 mbret
= MessageBox(NULL
, message
, mbtitle
,
2933 MB_ICONWARNING
| MB_YESNOCANCEL
);
2935 store_host_key(host
, port
, keytype
, keystr
);
2936 if (mbret
== IDCANCEL
)
2939 if (ret
== 1) { /* key was absent */
2941 sprintf(message
, absentmsg
, fingerprint
);
2942 mbret
= MessageBox(NULL
, message
, mbtitle
,
2943 MB_ICONWARNING
| MB_YESNOCANCEL
);
2945 store_host_key(host
, port
, keytype
, keystr
);
2946 if (mbret
== IDCANCEL
)
2952 * Ask whether the selected cipher is acceptable (since it was
2953 * below the configured 'warn' threshold).
2954 * cs: 0 = both ways, 1 = client->server, 2 = server->client
2956 void askcipher(char *ciphername
, int cs
)
2958 static const char mbtitle
[] = "PuTTY Security Alert";
2959 static const char msg
[] =
2960 "The first %.35scipher supported by the server\n"
2961 "is %.64s, which is below the configured\n"
2962 "warning threshold.\n"
2963 "Do you want to continue with this connection?\n";
2964 /* guessed cipher name + type max length */
2965 char message
[100 + sizeof(msg
)];
2968 sprintf(message
, msg
,
2970 (cs
== 1) ?
"client-to-server " :
2971 "server-to-client ",
2973 mbret
= MessageBox(NULL
, message
, mbtitle
,
2974 MB_ICONWARNING
| MB_YESNO
);
2982 * Ask whether to wipe a session log file before writing to it.
2983 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2985 int askappend(char *filename
)
2987 static const char mbtitle
[] = "PuTTY Log to File";
2988 static const char msgtemplate
[] =
2989 "The session log file \"%.*s\" already exists.\n"
2990 "You can overwrite it with a new session log,\n"
2991 "append your session log to the end of it,\n"
2992 "or disable session logging for this session.\n"
2993 "Hit Yes to wipe the file, No to append to it,\n"
2994 "or Cancel to disable logging.";
2995 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2997 if (cfg
.logxfovr
!= LGXF_ASK
) {
2998 return ((cfg
.logxfovr
== LGXF_OVR
) ?
2 : 1);
3000 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
3002 mbret
= MessageBox(NULL
, message
, mbtitle
,
3003 MB_ICONQUESTION
| MB_YESNOCANCEL
);
3006 else if (mbret
== IDNO
)
3013 * Warn about the obsolescent key file format.
3015 void old_keyfile_warning(void)
3017 static const char mbtitle
[] = "PuTTY Key File Warning";
3018 static const char message
[] =
3019 "You are loading an SSH 2 private key which has an\n"
3020 "old version of the file format. This means your key\n"
3021 "file is not fully tamperproof. Future versions of\n"
3022 "PuTTY may stop supporting this private key format,\n"
3023 "so we recommend you convert your key to the new\n"
3026 "You can perform this conversion by loading the key\n"
3027 "into PuTTYgen and then saving it again.";
3029 MessageBox(NULL
, message
, mbtitle
, MB_OK
);