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
,
371 IDC_FULLSCREENONALTENTER
,
374 appearancepanelstart
,
375 IDC_TITLE_APPEARANCE
,
397 connectionpanelstart
,
398 IDC_TITLE_CONNECTION
,
506 translationpanelstart
,
507 IDC_TITLE_TRANSLATION
,
508 IDC_BOX_TRANSLATION1
,
509 IDC_BOX_TRANSLATION2
,
510 IDC_BOX_TRANSLATION3
,
547 static const char *const colours
[] = {
548 "Default Foreground", "Default Bold Foreground",
549 "Default Background", "Default Bold Background",
550 "Cursor Text", "Cursor Colour",
551 "ANSI Black", "ANSI Black Bold",
552 "ANSI Red", "ANSI Red Bold",
553 "ANSI Green", "ANSI Green Bold",
554 "ANSI Yellow", "ANSI Yellow Bold",
555 "ANSI Blue", "ANSI Blue Bold",
556 "ANSI Magenta", "ANSI Magenta Bold",
557 "ANSI Cyan", "ANSI Cyan Bold",
558 "ANSI White", "ANSI White Bold"
560 static const int permcolour
[] = {
561 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
562 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
563 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
566 static void fmtfont(char *buf
)
568 sprintf(buf
, "Font: %s, ", cfg
.font
);
570 strcat(buf
, "bold, ");
571 if (cfg
.fontheight
== 0)
572 strcat(buf
, "default height");
574 sprintf(buf
+ strlen(buf
), "%d-point",
575 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
578 /* 2nd arg: NZ => don't redraw session list (use when loading
580 static void init_dlg_ctrls(HWND hwnd
, int keepsess
)
583 char fontstatic
[256];
585 SetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
);
586 SetDlgItemText(hwnd
, IDC_SESSEDIT
, savedsession
);
589 n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
590 for (i
= n
; i
-- > 0;)
591 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_DELETESTRING
, i
, 0);
592 for (i
= 0; i
< nsessions
; i
++)
593 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
594 0, (LPARAM
) (sessions
[i
]));
596 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
597 CheckRadioButton(hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
598 cfg
.protocol
== PROT_SSH ? IDC_PROTSSH
:
599 cfg
.protocol
== PROT_TELNET ? IDC_PROTTELNET
:
601 PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
602 SetDlgItemInt(hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
604 CheckRadioButton(hwnd
, IDC_DEL008
, IDC_DEL127
,
605 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
606 CheckRadioButton(hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
607 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
608 CheckRadioButton(hwnd
, IDC_FUNCTILDE
, IDC_FUNCSCO
,
609 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
610 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
611 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
612 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
613 cfg
.funky_type
== 4 ? IDC_FUNCVT100P
:
614 cfg
.funky_type
== 5 ? IDC_FUNCSCO
: IDC_FUNCTILDE
);
615 CheckDlgButton(hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
616 CheckDlgButton(hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
617 CheckRadioButton(hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
618 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
619 CheckRadioButton(hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
620 cfg
.nethack_keypad ? IDC_KPNH
:
621 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
622 CheckDlgButton(hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
623 CheckDlgButton(hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
624 CheckDlgButton(hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
625 CheckDlgButton(hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
626 CheckDlgButton(hwnd
, IDC_CTRLALTKEYS
, cfg
.ctrlaltkeys
);
627 CheckDlgButton(hwnd
, IDC_TELNETKEY
, cfg
.telnet_keyboard
);
628 CheckRadioButton(hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
629 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
630 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
631 CheckRadioButton(hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
632 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
633 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
634 SetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
);
635 CheckDlgButton(hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
636 CheckDlgButton(hwnd
, IDC_FULLSCREENONALTENTER
, cfg
.fullscreenonaltenter
);
637 CheckDlgButton(hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
638 CheckDlgButton(hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
640 CheckDlgButton(hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
641 CheckDlgButton(hwnd
, IDC_DECOM
, cfg
.dec_om
);
642 CheckDlgButton(hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
643 SetDlgItemInt(hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
644 SetDlgItemInt(hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
645 SetDlgItemInt(hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
647 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
648 CheckRadioButton(hwnd
, IDC_BELL_DISABLED
, IDC_BELL_VISUAL
,
649 cfg
.beep
== BELL_DISABLED ? IDC_BELL_DISABLED
:
650 cfg
.beep
== BELL_DEFAULT ? IDC_BELL_DEFAULT
:
651 cfg
.beep
== BELL_WAVEFILE ? IDC_BELL_WAVEFILE
:
653 BELL_VISUAL ? IDC_BELL_VISUAL
: IDC_BELL_DEFAULT
);
654 CheckRadioButton(hwnd
, IDC_B_IND_DISABLED
, IDC_B_IND_STEADY
,
656 B_IND_DISABLED ? IDC_B_IND_DISABLED
: cfg
.beep_ind
==
657 B_IND_FLASH ? IDC_B_IND_FLASH
: cfg
.beep_ind
==
658 B_IND_STEADY ? IDC_B_IND_STEADY
: IDC_B_IND_DISABLED
);
659 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
660 CheckDlgButton(hwnd
, IDC_BELLOVL
, cfg
.bellovl
);
661 SetDlgItemInt(hwnd
, IDC_BELLOVLN
, cfg
.bellovl_n
, FALSE
);
662 MySetDlgItemFlt(hwnd
, IDC_BELLOVLT
, cfg
.bellovl_t
/ 1000.0);
663 MySetDlgItemFlt(hwnd
, IDC_BELLOVLS
, cfg
.bellovl_s
/ 1000.0);
665 CheckDlgButton(hwnd
, IDC_BCE
, cfg
.bce
);
666 CheckDlgButton(hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
668 SetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
669 CheckDlgButton(hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
670 CheckDlgButton(hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
671 CheckDlgButton(hwnd
, IDC_SUNKENEDGE
, cfg
.sunken_edge
);
672 SetDlgItemInt(hwnd
, IDC_WINBEDIT
, cfg
.window_border
, FALSE
);
673 CheckRadioButton(hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
674 cfg
.cursor_type
== 0 ? IDC_CURBLOCK
:
675 cfg
.cursor_type
== 1 ? IDC_CURUNDER
: IDC_CURVERT
);
676 CheckDlgButton(hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
677 CheckDlgButton(hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
678 CheckRadioButton(hwnd
, IDC_RESIZETERM
, IDC_RESIZENONE
,
679 cfg
.resize_action
== RESIZE_TERM ? IDC_RESIZETERM
:
680 cfg
.resize_action
== RESIZE_FONT ? IDC_RESIZEFONT
:
682 CheckRadioButton(hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
683 cfg
.close_on_exit
== COE_NORMAL ? IDC_COENORMAL
:
685 COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
686 CheckDlgButton(hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
688 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
689 SetDlgItemText(hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
690 SetDlgItemText(hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
691 SetDlgItemText(hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
692 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
693 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
694 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
695 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
696 cfg
.logtype
== 1 ? IDC_LSTATASCII
: IDC_LSTATRAW
);
697 CheckRadioButton(hwnd
, IDC_LSTATXOVR
, IDC_LSTATXASK
,
698 cfg
.logxfovr
== LGXF_OVR ? IDC_LSTATXOVR
:
699 cfg
.logxfovr
== LGXF_ASK ? IDC_LSTATXASK
:
702 char *p
= cfg
.environmt
;
703 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_RESETCONTENT
, 0, 0);
705 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
711 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
, 0,
716 CheckRadioButton(hwnd
, IDC_EMBSD
, IDC_EMRFC
,
717 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
718 CheckRadioButton(hwnd
, IDC_TPASSIVE
, IDC_TACTIVE
,
719 cfg
.passive_telnet ? IDC_TPASSIVE
: IDC_TACTIVE
);
721 SetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
);
722 SetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
);
723 CheckDlgButton(hwnd
, IDC_NOPTY
, cfg
.nopty
);
724 CheckDlgButton(hwnd
, IDC_COMPRESS
, cfg
.compression
);
725 CheckDlgButton(hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
726 CheckDlgButton(hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
727 CheckRadioButton(hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
728 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
729 CheckDlgButton(hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
730 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
731 SetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
735 static const struct { char *s
; int c
; } ciphers
[] = {
736 { "3DES", CIPHER_3DES
},
737 { "Blowfish", CIPHER_BLOWFISH
},
738 { "DES (SSH 1 only)", CIPHER_DES
},
739 { "AES (SSH 2 only)", CIPHER_AES
},
740 { "-- warn below here --", CIPHER_WARN
}
743 /* Set up the "selected ciphers" box. */
744 /* (cipherlist assumed to contain all ciphers) */
745 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_RESETCONTENT
, 0, 0);
746 for (i
= 0; i
< CIPHER_MAX
; i
++) {
747 int c
= cfg
.ssh_cipherlist
[i
];
750 for (j
= 0; j
< (sizeof ciphers
) / (sizeof ciphers
[0]); j
++) {
751 if (ciphers
[j
].c
== c
) {
756 pos
= SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_ADDSTRING
,
758 SendDlgItemMessage(hwnd
, IDC_CIPHERLIST
, LB_SETITEMDATA
,
765 CheckRadioButton(hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
766 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
767 CheckDlgButton(hwnd
, IDC_MOUSEOVERRIDE
, cfg
.mouse_override
);
768 CheckDlgButton(hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
770 static int tabs
[4] = { 25, 61, 96, 128 };
771 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
774 for (i
= 0; i
< 128; i
++) {
776 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
777 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ', cfg
.wordness
[i
]);
778 SendDlgItemMessage(hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
782 CheckDlgButton(hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
783 CheckDlgButton(hwnd
, IDC_PALETTE
, cfg
.try_palette
);
786 n
= SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
787 for (i
= n
; i
-- > 0;)
788 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
789 LB_DELETESTRING
, i
, 0);
790 for (i
= 0; i
< 22; i
++)
791 if (cfg
.bold_colour
|| permcolour
[i
])
792 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
793 (LPARAM
) colours
[i
]);
795 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
796 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
797 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
798 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
803 strcpy(cfg
.line_codepage
, cp_name(decode_codepage(cfg
.line_codepage
)));
804 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_RESETCONTENT
, 0, 0);
805 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
806 for (i
= 0; (cp
= cp_enumerate(i
)) != NULL
; i
++) {
807 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_ADDSTRING
,
810 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
813 CheckRadioButton(hwnd
, IDC_VTXWINDOWS
, IDC_VTUNICODE
,
814 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
815 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
816 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
817 cfg
.vtmode
== VT_UNICODE ? IDC_VTUNICODE
:
820 CheckDlgButton(hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
821 SetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
823 CheckDlgButton(hwnd
, IDC_LPORT_ALL
, cfg
.lport_acceptall
);
824 CheckRadioButton(hwnd
, IDC_PFWDLOCAL
, IDC_PFWDREMOTE
, IDC_PFWDLOCAL
);
827 struct treeview_faff
{
832 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
833 int level
, char *text
)
838 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
- 1] : TVI_ROOT
);
839 ins
.hInsertAfter
= faff
->lastat
[level
];
840 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
841 #define INSITEM DUMMYUNIONNAME.item
845 ins
.INSITEM
.mask
= TVIF_TEXT
;
846 ins
.INSITEM
.pszText
= text
;
847 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
849 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
- 1],
851 faff
->lastat
[level
] = newitem
;
852 for (i
= level
+ 1; i
< 4; i
++)
853 faff
->lastat
[i
] = NULL
;
858 * Create the panelfuls of controls in the configuration box.
860 static void create_controls(HWND hwnd
, int dlgtype
, int panel
)
862 if (panel
== sessionpanelstart
) {
863 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
865 ctlposinit(&cp
, hwnd
, 80, 3, 13);
866 bartitle(&cp
, "Basic options for your PuTTY session",
869 beginbox(&cp
, "Specify your connection by host name or IP address",
872 "Host &Name (or IP address)",
873 IDC_HOSTSTATIC
, IDC_HOST
, 75,
874 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
875 if (backends
[3].backend
== NULL
) {
876 /* this is PuTTYtel, so only three protocols available */
877 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 3,
879 "&Telnet", IDC_PROTTELNET
,
880 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
882 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
884 "&Telnet", IDC_PROTTELNET
,
885 "Rlog&in", IDC_PROTRLOGIN
,
894 beginbox(&cp
, "Load, save or delete a stored session",
896 sesssaver(&cp
, "Sav&ed Sessions",
897 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
898 "&Load", IDC_SESSLOAD
,
899 "&Save", IDC_SESSSAVE
, "&Delete", IDC_SESSDEL
, NULL
);
902 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
903 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
904 "Always", IDC_COEALWAYS
,
905 "Never", IDC_COENEVER
,
906 "Only on clean exit", IDC_COENORMAL
, NULL
);
910 if (panel
== loggingpanelstart
) {
911 /* The Logging panel. Accelerators used: [acgo] tplfwe */
913 ctlposinit(&cp
, hwnd
, 80, 3, 13);
914 bartitle(&cp
, "Options controlling session logging",
916 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
918 "Session logging:", IDC_LSTATSTATIC
,
919 "Logging &turned off completely", IDC_LSTATOFF
,
920 "Log &printable output only", IDC_LSTATASCII
,
921 "&Log all session output", IDC_LSTATRAW
, NULL
);
922 editbutton(&cp
, "Log &file name:",
923 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
925 statictext(&cp
, "(Log file name can contain &&Y, &&M, &&D for date,"
926 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN
);
928 "What to do if the log file already &exists:",
929 IDC_LSTATXIST
, "Always overwrite it", IDC_LSTATXOVR
,
930 "Always append to the end of it", IDC_LSTATXAPN
,
931 "Ask the user every time", IDC_LSTATXASK
, NULL
);
935 if (panel
== terminalpanelstart
) {
936 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
938 ctlposinit(&cp
, hwnd
, 80, 3, 13);
939 bartitle(&cp
, "Options controlling the terminal emulation",
941 beginbox(&cp
, "Set various terminal options", IDC_BOX_TERMINAL1
);
942 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
943 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
944 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
945 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
946 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
948 "An&swerback to ^E:", IDC_ANSWERBACK
,
949 IDC_ANSWEREDIT
, 100, NULL
);
952 beginbox(&cp
, "Line discipline options", IDC_BOX_TERMINAL2
);
953 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
954 "Auto", IDC_ECHOBACKEND
,
955 "Force on", IDC_ECHOYES
, "Force off", IDC_ECHONO
, NULL
);
956 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
957 "Auto", IDC_EDITBACKEND
,
958 "Force on", IDC_EDITYES
, "Force off", IDC_EDITNO
, NULL
);
962 if (panel
== bellpanelstart
) {
963 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
965 ctlposinit(&cp
, hwnd
, 80, 3, 13);
966 bartitle(&cp
, "Options controlling the terminal bell",
968 beginbox(&cp
, "Set the style of bell", IDC_BOX_BELL1
);
970 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
971 "None (bell disabled)", IDC_BELL_DISABLED
,
972 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
973 "Play a custom sound file", IDC_BELL_WAVEFILE
,
974 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
975 editbutton(&cp
, "Custom sound file to play as a bell:",
976 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
977 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
978 radioline(&cp
, "Taskbar/caption &indication on bell:",
979 IDC_B_IND_STATIC
, 3, "Disabled", IDC_B_IND_DISABLED
,
980 "Flashing", IDC_B_IND_FLASH
, "Steady", IDC_B_IND_STEADY
,
983 beginbox(&cp
, "Control the bell overload behaviour",
985 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
987 staticedit(&cp
, "Over-use means this &many bells...",
988 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
989 staticedit(&cp
, "... in &this many seconds",
990 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
992 "The bell is re-enabled after a few seconds of silence.",
993 1, IDC_BELLOVLEXPLAIN
);
994 staticedit(&cp
, "Seconds of &silence required", IDC_BELLOVLSSTATIC
,
999 if (panel
== keyboardpanelstart
) {
1000 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
1002 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1004 bartitle(&cp, "Options controlling the effects of keys",
1005 IDC_TITLE_KEYBOARD);
1007 beginbox(&cp
, "Change the sequences sent by:", IDC_BOX_KEYBOARD1
);
1008 radioline(&cp
, "The &Backspace key", IDC_DELSTATIC
, 2,
1009 "Control-H", IDC_DEL008
,
1010 "Control-? (127)", IDC_DEL127
, NULL
);
1011 radioline(&cp
, "The &Home and End keys", IDC_HOMESTATIC
, 2,
1012 "Standard", IDC_HOMETILDE
, "rxvt", IDC_HOMERXVT
, NULL
);
1013 radioline(&cp
, "The &Function keys and keypad", IDC_FUNCSTATIC
, 3,
1014 "ESC[n~", IDC_FUNCTILDE
,
1015 "Linux", IDC_FUNCLINUX
,
1016 "Xterm R6", IDC_FUNCXTERM
,
1017 "VT400", IDC_FUNCVT400
,
1018 "VT100+", IDC_FUNCVT100P
, "SCO", IDC_FUNCSCO
, NULL
);
1020 beginbox(&cp
, "Application keypad settings:", IDC_BOX_KEYBOARD2
);
1022 "Application c&ursor keys totally disabled",
1024 radioline(&cp
, "Initial state of cu&rsor keys:", IDC_CURSTATIC
, 2,
1025 "Normal", IDC_CURNORMAL
,
1026 "Application", IDC_CURAPPLIC
, NULL
);
1028 "Application ke&ypad keys totally disabled",
1030 radioline(&cp
, "Initial state of &numeric keypad:", IDC_KPSTATIC
,
1031 3, "Normal", IDC_KPNORMAL
, "Application", IDC_KPAPPLIC
,
1032 "NetHack", IDC_KPNH
, NULL
);
1034 beginbox(&cp
, "Enable extra keyboard features:",
1036 checkbox(&cp
, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY
);
1037 checkbox(&cp
, "Control-Alt is &different from AltGr",
1042 if (panel
== windowpanelstart
) {
1043 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt f */
1045 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1046 bartitle(&cp
, "Options controlling PuTTY's window",
1048 beginbox(&cp
, "Set the size of the window", IDC_BOX_WINDOW1
);
1050 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
1051 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50, NULL
);
1052 radioline(&cp
, "Action when the window is resized:", IDC_RESIZESTATIC
,
1053 3, "Resi&ze terminal", IDC_RESIZETERM
,
1054 "Change fo&nt", IDC_RESIZEFONT
,
1055 "Forb&id resizing", IDC_RESIZENONE
, NULL
);
1057 beginbox(&cp
, "Control the scrollback in the window",
1059 staticedit(&cp
, "Lines of &scrollback",
1060 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
1061 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
1062 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
1063 checkbox(&cp
, "Reset scrollback on dis&play activity",
1066 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
1067 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
1068 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
1069 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
1070 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
1071 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
1072 checkbox(&cp
, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER
);
1076 if (panel
== appearancepanelstart
) {
1077 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1079 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1080 /* bartitle(&cp, "Options controlling PuTTY's appearance",
1081 IDC_TITLE_APPEARANCE); */
1082 beginbox(&cp
, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1
);
1083 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
1084 "B&lock", IDC_CURBLOCK
,
1085 "&Underline", IDC_CURUNDER
,
1086 "&Vertical line", IDC_CURVERT
, NULL
);
1087 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
1089 beginbox(&cp
, "Set the font used in the terminal window",
1090 IDC_BOX_APPEARANCE2
);
1091 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
1093 beginbox(&cp
, "Adjust the use of the window title",
1094 IDC_BOX_APPEARANCE3
);
1096 "Window &title:", IDC_WINTITLE
, IDC_WINEDIT
, 100, NULL
);
1097 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
1099 beginbox(&cp
, "Adjust the use of the mouse pointer",
1100 IDC_BOX_APPEARANCE4
);
1101 checkbox(&cp
, "Hide mouse &pointer when typing in window",
1104 beginbox(&cp
, "Adjust the window border", IDC_BOX_APPEARANCE5
);
1105 checkbox(&cp
, "&Sunken-edge border (slightly thicker)",
1107 staticedit(&cp
, "Gap between text and window edge",
1108 IDC_WINBSTATIC
, IDC_WINBEDIT
, 20);
1112 if (panel
== translationpanelstart
) {
1113 /* The Translation panel. Accelerators used: [acgo] rxbepus */
1115 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1116 bartitle(&cp
, "Options controlling character set translation",
1117 IDC_TITLE_TRANSLATION
);
1118 beginbox(&cp
, "Character set translation on received data",
1119 IDC_BOX_TRANSLATION1
);
1120 combobox(&cp
, "&Received data assumed to be in which character set:",
1121 IDC_CODEPAGESTATIC
, IDC_CODEPAGE
);
1123 beginbox(&cp
, "Enable character set translation on input data",
1124 IDC_BOX_TRANSLATION2
);
1125 checkbox(&cp
, "Cap&s Lock acts as Cyrillic switch",
1128 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
1129 IDC_BOX_TRANSLATION3
);
1131 "Handling of line drawing characters:", IDC_VTSTATIC
,
1132 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
1133 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
1134 "Use font in O&EM mode only", IDC_VTOEMONLY
,
1135 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1136 IDC_VTPOORMAN
, "&Unicode mode", IDC_VTUNICODE
, NULL
);
1140 if (panel
== selectionpanelstart
) {
1141 /* The Selection panel. Accelerators used: [acgo] d wxp hst */
1143 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1144 bartitle(&cp
, "Options controlling copy and paste",
1145 IDC_TITLE_SELECTION
);
1146 beginbox(&cp
, "Translation of pasted characters",
1147 IDC_BOX_SELECTION1
);
1149 "&Don't translate line drawing chars into +, - and |",
1152 beginbox(&cp
, "Control which mouse button does which thing",
1153 IDC_BOX_SELECTION2
);
1154 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1155 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1156 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1159 "Shift overrides a&pplication's use of mouse",
1162 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1163 IDC_BOX_SELECTION3
);
1164 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1165 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1166 "&to class", IDC_CCSTATIC2
);
1170 if (panel
== colourspanelstart
) {
1171 /* The Colours panel. Accelerators used: [acgo] blum */
1173 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1174 bartitle(&cp
, "Options controlling use of colours",
1176 beginbox(&cp
, "General options for colour usage",
1178 checkbox(&cp
, "&Bolded text is a different colour",
1180 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1182 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1184 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1185 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1186 "&Modify...", IDC_CHANGE
,
1187 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1188 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1189 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1193 if (panel
== connectionpanelstart
) {
1194 /* The Connection panel. Accelerators used: [acgo] tuk */
1196 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1197 bartitle(&cp
, "Options controlling the connection",
1198 IDC_TITLE_CONNECTION
);
1200 beginbox(&cp
, "Data to send to the server",
1201 IDC_BOX_CONNECTION1
);
1202 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
,
1204 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
,
1208 beginbox(&cp
, "Adjust telnet session.", IDC_BOX_CONNECTION1
);
1209 checkbox(&cp
, "Keyboard sends telnet Backspace and Interrupt",
1213 beginbox(&cp
, "Sending of null packets to keep session active",
1214 IDC_BOX_CONNECTION2
);
1215 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1216 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1220 if (panel
== telnetpanelstart
) {
1221 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
1223 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1225 bartitle(&cp
, "Options controlling Telnet connections",
1227 beginbox(&cp
, "Data to send to the server", IDC_BOX_TELNET1
);
1228 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
,
1230 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1231 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
, "Va&lue",
1232 IDC_VALSTATIC
, IDC_VALEDIT
, IDC_ENVLIST
, "A&dd",
1233 IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1235 beginbox(&cp
, "Telnet protocol adjustments", IDC_BOX_TELNET2
);
1236 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:",
1237 IDC_EMSTATIC
, 2, "&BSD (commonplace)", IDC_EMBSD
,
1238 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1239 radioline(&cp
, "&Telnet negotiation mode:", IDC_ACTSTATIC
, 2,
1240 "Passive", IDC_TPASSIVE
, "Active",
1242 checkbox(&cp
, "&Keyboard sends telnet Backspace and Interrupt",
1248 if (panel
== rloginpanelstart
) {
1249 /* The Rlogin panel. Accelerators used: [acgo] sl */
1251 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1253 bartitle(&cp
, "Options controlling Rlogin connections",
1255 beginbox(&cp
, "Data to send to the server", IDC_BOX_RLOGIN1
);
1256 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
,
1258 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
,
1259 IDC_RLLUSEREDIT
, 50);
1264 if (panel
== sshpanelstart
) {
1265 /* The SSH panel. Accelerators used: [acgo] r pe12i s */
1267 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1269 bartitle(&cp
, "Options controlling SSH connections",
1271 beginbox(&cp
, "Data to send to the server", IDC_BOX_SSH1
);
1273 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1276 beginbox(&cp
, "Protocol options", IDC_BOX_SSH2
);
1277 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1278 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1279 radioline(&cp
, "Preferred SSH protocol version:",
1280 IDC_SSHPROTSTATIC
, 2,
1281 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1282 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1285 beginbox(&cp
, "Encryption options", IDC_BOX_SSH3
);
1286 prefslist(&cipherlist
, &cp
, "Encryption cipher &selection policy:",
1287 IDC_CIPHERSTATIC2
, IDC_CIPHERLIST
, IDC_CIPHERUP
,
1293 if (panel
== sshauthpanelstart
) {
1294 /* The SSH authentication panel. Accelerators used: [acgo] m fkw */
1296 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1298 bartitle(&cp
, "Options controlling SSH authentication",
1300 beginbox(&cp
, "Authentication methods",
1302 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1305 beginbox(&cp
, "Authentication parameters",
1307 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1308 editbutton(&cp
, "Private &key file for authentication:",
1309 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...",
1315 if (panel
== tunnelspanelstart
) {
1316 /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */
1318 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1320 bartitle(&cp
, "Options controlling SSH tunnelling",
1322 beginbox(&cp
, "X11 forwarding", IDC_BOX_TUNNELS1
);
1323 checkbox(&cp
, "&Enable X11 forwarding", IDC_X11_FORWARD
);
1324 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1325 IDC_X11_DISPLAY
, 50, NULL
);
1327 beginbox(&cp
, "Port forwarding", IDC_BOX_TUNNELS2
);
1328 checkbox(&cp
, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL
);
1329 staticbtn(&cp
, "Forwarded ports:", IDC_PFWDSTATIC
,
1330 "&Remove", IDC_PFWDREMOVE
);
1331 fwdsetter(&cp
, IDC_PFWDLIST
,
1332 "Add new forwarded port:", IDC_PFWDSTATIC2
,
1333 "&Source port", IDC_SPORTSTATIC
, IDC_SPORTEDIT
,
1334 "Dest&ination", IDC_DPORTSTATIC
, IDC_DPORTEDIT
,
1335 "A&dd", IDC_PFWDADD
);
1336 bareradioline(&cp
, 2,
1337 "&Local", IDC_PFWDLOCAL
, "Re&mote", IDC_PFWDREMOTE
, NULL
);
1345 * Helper function to load the session selected in SESSLIST
1346 * if any, as this is done in more than one place in
1347 * GenericMainDlgProc(). 0 => failure.
1349 static int load_selected_session(HWND hwnd
)
1351 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1352 LB_GETCURSEL
, 0, 0);
1358 isdef
= !strcmp(sessions
[n
], "Default Settings");
1359 load_settings(sessions
[n
], !isdef
, &cfg
);
1360 init_dlg_ctrls(hwnd
, TRUE
);
1362 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1364 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1365 /* Restore the selection, which will have been clobbered by
1366 * SESSEDIT handling. */
1367 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
, n
, 0);
1372 * This function is the configuration box.
1374 static int GenericMainDlgProc(HWND hwnd
, UINT msg
,
1375 WPARAM wParam
, LPARAM lParam
, int dlgtype
)
1378 struct treeview_faff tvfaff
;
1381 char filename
[sizeof(cfg
.keyfile
)];
1384 char fontstatic
[256];
1386 struct servent
*service
;
1388 static UINT draglistmsg
= WM_NULL
;
1393 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1394 SendMessage(hwnd
, WM_SETICON
, (WPARAM
) ICON_BIG
,
1395 (LPARAM
) LoadIcon(hinst
, MAKEINTRESOURCE(IDI_CFGICON
)));
1397 * Centre the window.
1399 { /* centre the window */
1402 hw
= GetDesktopWindow();
1403 if (GetWindowRect(hw
, &rs
) && GetWindowRect(hwnd
, &rd
))
1405 (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
) / 2,
1406 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
) / 2,
1407 rd
.right
- rd
.left
, rd
.bottom
- rd
.top
, TRUE
);
1411 * Create the tree view.
1419 r
.right
= r
.left
+ 75;
1421 r
.bottom
= r
.top
+ 10;
1422 MapDialogRect(hwnd
, &r
);
1423 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1424 WS_CHILD
| WS_VISIBLE
,
1426 r
.right
- r
.left
, r
.bottom
- r
.top
,
1427 hwnd
, (HMENU
) IDCX_TVSTATIC
, hinst
,
1429 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1430 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1433 r
.right
= r
.left
+ 75;
1435 r
.bottom
= r
.top
+ 206;
1436 MapDialogRect(hwnd
, &r
);
1437 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1438 WS_CHILD
| WS_VISIBLE
|
1439 WS_TABSTOP
| TVS_HASLINES
|
1440 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
1442 TVS_SHOWSELALWAYS
, r
.left
, r
.top
,
1443 r
.right
- r
.left
, r
.bottom
- r
.top
,
1444 hwnd
, (HMENU
) IDCX_TREEVIEW
, hinst
,
1446 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1447 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1448 tvfaff
.treeview
= treeview
;
1449 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1453 * Set up the tree view contents.
1455 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1456 treeview_insert(&tvfaff
, 1, "Logging");
1457 treeview_insert(&tvfaff
, 0, "Terminal");
1458 treeview_insert(&tvfaff
, 1, "Keyboard");
1459 treeview_insert(&tvfaff
, 1, "Bell");
1460 treeview_insert(&tvfaff
, 0, "Window");
1461 treeview_insert(&tvfaff
, 1, "Appearance");
1462 treeview_insert(&tvfaff
, 1, "Translation");
1463 treeview_insert(&tvfaff
, 1, "Selection");
1464 treeview_insert(&tvfaff
, 1, "Colours");
1465 treeview_insert(&tvfaff
, 0, "Connection");
1467 treeview_insert(&tvfaff
, 1, "Telnet");
1468 treeview_insert(&tvfaff
, 1, "Rlogin");
1469 if (backends
[3].backend
!= NULL
) {
1470 treeview_insert(&tvfaff
, 1, "SSH");
1471 /* XXX long name is ugly */
1472 /* XXX make it closed by default? */
1473 treeview_insert(&tvfaff
, 2, "Auth");
1474 treeview_insert(&tvfaff
, 2, "Tunnels");
1479 * Put the treeview selection on to the Session panel. This
1480 * should also cause creation of the relevant controls.
1482 TreeView_SelectItem(treeview
, hsession
);
1485 * Set focus into the first available control.
1489 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1491 ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1495 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1496 sesslist_has_focus
= 0;
1500 * Button release should trigger WM_OK if there was a
1501 * previous double click on the session list.
1505 SendMessage(hwnd
, WM_COMMAND
, IDOK
, 0);
1508 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1509 ((LPNMHDR
) lParam
)->code
== TVN_SELCHANGED
) {
1511 TreeView_GetSelection(((LPNMHDR
) lParam
)->hwndFrom
);
1516 SendMessage (hwnd
, WM_SETREDRAW
, FALSE
, 0);
1519 item
.pszText
= buffer
;
1520 item
.cchTextMax
= sizeof(buffer
);
1521 item
.mask
= TVIF_TEXT
;
1522 TreeView_GetItem(((LPNMHDR
) lParam
)->hwndFrom
, &item
);
1523 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1524 HWND item
= GetDlgItem(hwnd
, j
);
1526 DestroyWindow(item
);
1528 if (!strcmp(buffer
, "Session"))
1529 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1530 if (!strcmp(buffer
, "Logging"))
1531 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1532 if (!strcmp(buffer
, "Keyboard"))
1533 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1534 if (!strcmp(buffer
, "Terminal"))
1535 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1536 if (!strcmp(buffer
, "Bell"))
1537 create_controls(hwnd
, dlgtype
, bellpanelstart
);
1538 if (!strcmp(buffer
, "Window"))
1539 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1540 if (!strcmp(buffer
, "Appearance"))
1541 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1542 if (!strcmp(buffer
, "Tunnels"))
1543 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1544 if (!strcmp(buffer
, "Connection"))
1545 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1546 if (!strcmp(buffer
, "Telnet"))
1547 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1548 if (!strcmp(buffer
, "Rlogin"))
1549 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1550 if (!strcmp(buffer
, "SSH"))
1551 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1552 if (!strcmp(buffer
, "Auth"))
1553 create_controls(hwnd
, dlgtype
, sshauthpanelstart
);
1554 if (!strcmp(buffer
, "Selection"))
1555 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1556 if (!strcmp(buffer
, "Colours"))
1557 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1558 if (!strcmp(buffer
, "Translation"))
1559 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1561 init_dlg_ctrls(hwnd
, FALSE
);
1563 SendMessage (hwnd
, WM_SETREDRAW
, TRUE
, 0);
1564 InvalidateRect (hwnd
, NULL
, TRUE
);
1566 SetFocus(((LPNMHDR
) lParam
)->hwndFrom
); /* ensure focus stays */
1572 * Only process WM_COMMAND once the dialog is fully formed.
1574 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1)
1575 switch (LOWORD(wParam
)) {
1577 /* Behaviour of the "Open" button is different if the
1578 * session list has focus, *unless* the user just
1579 * double-clicked... */
1580 if (sesslist_has_focus
&& !readytogo
) {
1581 if (!load_selected_session(hwnd
)) {
1586 /* If at this point we have a valid session, go! */
1595 case IDC_PROTTELNET
:
1596 case IDC_PROTRLOGIN
:
1599 if (HIWORD(wParam
) == BN_CLICKED
||
1600 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1601 int i
= IsDlgButtonChecked(hwnd
, IDC_PROTSSH
);
1602 int j
= IsDlgButtonChecked(hwnd
, IDC_PROTTELNET
);
1603 int k
= IsDlgButtonChecked(hwnd
, IDC_PROTRLOGIN
);
1605 i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
:
1607 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22)
1608 || (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23)
1609 || (cfg
.protocol
== PROT_RLOGIN
1610 && cfg
.port
!= 513)) {
1611 cfg
.port
= i ?
22 : j ?
23 : 513;
1612 SetDlgItemInt(hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1617 if (HIWORD(wParam
) == EN_CHANGE
)
1618 GetDlgItemText(hwnd
, IDC_HOST
, cfg
.host
,
1619 sizeof(cfg
.host
) - 1);
1622 if (HIWORD(wParam
) == EN_CHANGE
) {
1623 GetDlgItemText(hwnd
, IDC_PORT
, portname
, 31);
1624 if (isdigit(portname
[0]))
1625 MyGetDlgItemInt(hwnd
, IDC_PORT
, &cfg
.port
);
1627 service
= getservbyname(portname
, NULL
);
1629 cfg
.port
= ntohs(service
->s_port
);
1636 if (HIWORD(wParam
) == EN_CHANGE
) {
1637 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1639 GetDlgItemText(hwnd
, IDC_SESSEDIT
,
1640 savedsession
, sizeof(savedsession
) - 1);
1641 savedsession
[sizeof(savedsession
) - 1] = '\0';
1645 if (HIWORD(wParam
) == BN_CLICKED
||
1646 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1651 GetDlgItemText(hwnd
, IDC_SESSEDIT
, str
,
1654 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1655 LB_GETCURSEL
, 0, 0);
1660 strcpy(str
, sessions
[n
]);
1662 save_settings(str
, !!strcmp(str
, "Default Settings"),
1664 get_sesslist(FALSE
);
1666 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1668 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1670 for (i
= 0; i
< nsessions
; i
++)
1671 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1673 (LPARAM
) (sessions
[i
]));
1674 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1676 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1678 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1684 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1685 if (HIWORD(wParam
) == LBN_SETFOCUS
)
1686 sesslist_has_focus
= 1;
1687 else if (HIWORD(wParam
) == LBN_KILLFOCUS
)
1688 sesslist_has_focus
= 0;
1690 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1691 HIWORD(wParam
) != BN_CLICKED
&&
1692 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
1693 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1694 HIWORD(wParam
) != LBN_DBLCLK
) break;
1695 /* Load the session selected in SESSLIST. */
1696 if (load_selected_session(hwnd
) &&
1697 LOWORD(wParam
) == IDC_SESSLIST
) {
1699 * A double-click on a saved session should
1700 * actually start the session, not just load it.
1701 * Unless it's Default Settings or some other
1702 * host-less set of saved settings.
1711 if (HIWORD(wParam
) == BN_CLICKED
||
1712 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1713 int n
= SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1714 LB_GETCURSEL
, 0, 0);
1715 if (n
== LB_ERR
|| n
== 0) {
1719 del_settings(sessions
[n
]);
1720 get_sesslist(FALSE
);
1722 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1724 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1726 for (i
= 0; i
< nsessions
; i
++)
1727 SendDlgItemMessage(hwnd
, IDC_SESSLIST
,
1729 (LPARAM
) (sessions
[i
]));
1730 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1732 SendDlgItemMessage(hwnd
, IDC_SESSLIST
, WM_SETREDRAW
,
1734 InvalidateRect(GetDlgItem(hwnd
, IDC_SESSLIST
), NULL
,
1738 if (HIWORD(wParam
) == EN_CHANGE
)
1739 MyGetDlgItemInt(hwnd
, IDC_PINGEDIT
,
1740 &cfg
.ping_interval
);
1744 if (HIWORD(wParam
) == BN_CLICKED
||
1745 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1746 cfg
.bksp_is_delete
=
1747 IsDlgButtonChecked(hwnd
, IDC_DEL127
);
1751 if (HIWORD(wParam
) == BN_CLICKED
||
1752 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1754 IsDlgButtonChecked(hwnd
, IDC_HOMERXVT
);
1760 case IDC_FUNCVT100P
:
1762 if (HIWORD(wParam
) == BN_CLICKED
||
1763 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1764 switch (LOWORD(wParam
)) {
1777 case IDC_FUNCVT100P
:
1787 if (HIWORD(wParam
) == BN_CLICKED
||
1788 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1790 IsDlgButtonChecked(hwnd
, IDC_KPAPPLIC
);
1791 cfg
.nethack_keypad
= FALSE
;
1795 if (HIWORD(wParam
) == BN_CLICKED
||
1796 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1797 cfg
.app_keypad
= FALSE
;
1798 cfg
.nethack_keypad
= TRUE
;
1803 if (HIWORD(wParam
) == BN_CLICKED
||
1804 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1806 IsDlgButtonChecked(hwnd
, IDC_CURAPPLIC
);
1809 if (HIWORD(wParam
) == BN_CLICKED
||
1810 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1812 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICC
);
1815 if (HIWORD(wParam
) == BN_CLICKED
||
1816 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1818 IsDlgButtonChecked(hwnd
, IDC_NOAPPLICK
);
1821 if (HIWORD(wParam
) == BN_CLICKED
||
1822 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1823 cfg
.alt_f4
= IsDlgButtonChecked(hwnd
, IDC_ALTF4
);
1826 if (HIWORD(wParam
) == BN_CLICKED
||
1827 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1829 IsDlgButtonChecked(hwnd
, IDC_ALTSPACE
);
1832 if (HIWORD(wParam
) == BN_CLICKED
||
1833 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1835 IsDlgButtonChecked(hwnd
, IDC_ALTONLY
);
1837 case IDC_ECHOBACKEND
:
1840 if (HIWORD(wParam
) == BN_CLICKED
||
1841 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1842 if (LOWORD(wParam
) == IDC_ECHOBACKEND
)
1843 cfg
.localecho
= LD_BACKEND
;
1844 if (LOWORD(wParam
) == IDC_ECHOYES
)
1845 cfg
.localecho
= LD_YES
;
1846 if (LOWORD(wParam
) == IDC_ECHONO
)
1847 cfg
.localecho
= LD_NO
;
1850 case IDC_EDITBACKEND
:
1853 if (HIWORD(wParam
) == BN_CLICKED
||
1854 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1855 if (LOWORD(wParam
) == IDC_EDITBACKEND
)
1856 cfg
.localedit
= LD_BACKEND
;
1857 if (LOWORD(wParam
) == IDC_EDITYES
)
1858 cfg
.localedit
= LD_YES
;
1859 if (LOWORD(wParam
) == IDC_EDITNO
)
1860 cfg
.localedit
= LD_NO
;
1863 case IDC_ANSWEREDIT
:
1864 if (HIWORD(wParam
) == EN_CHANGE
)
1865 GetDlgItemText(hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
1866 sizeof(cfg
.answerback
) - 1);
1868 case IDC_ALWAYSONTOP
:
1869 if (HIWORD(wParam
) == BN_CLICKED
||
1870 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1872 IsDlgButtonChecked(hwnd
, IDC_ALWAYSONTOP
);
1874 case IDC_FULLSCREENONALTENTER
:
1875 if (HIWORD(wParam
) == BN_CLICKED
||
1876 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1877 cfg
.fullscreenonaltenter
=
1878 IsDlgButtonChecked(hwnd
, IDC_FULLSCREENONALTENTER
);
1881 if (HIWORD(wParam
) == BN_CLICKED
||
1882 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1884 IsDlgButtonChecked(hwnd
, IDC_SCROLLKEY
);
1886 case IDC_SCROLLDISP
:
1887 if (HIWORD(wParam
) == BN_CLICKED
||
1888 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1889 cfg
.scroll_on_disp
=
1890 IsDlgButtonChecked(hwnd
, IDC_SCROLLDISP
);
1892 case IDC_COMPOSEKEY
:
1893 if (HIWORD(wParam
) == BN_CLICKED
||
1894 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1896 IsDlgButtonChecked(hwnd
, IDC_COMPOSEKEY
);
1898 case IDC_CTRLALTKEYS
:
1899 if (HIWORD(wParam
) == BN_CLICKED
||
1900 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1902 IsDlgButtonChecked(hwnd
, IDC_CTRLALTKEYS
);
1905 if (HIWORD(wParam
) == BN_CLICKED
||
1906 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1907 cfg
.telnet_keyboard
=
1908 IsDlgButtonChecked(hwnd
, IDC_TELNETKEY
);
1911 if (HIWORD(wParam
) == BN_CLICKED
||
1912 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1914 IsDlgButtonChecked(hwnd
, IDC_WRAPMODE
);
1917 if (HIWORD(wParam
) == BN_CLICKED
||
1918 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1919 cfg
.dec_om
= IsDlgButtonChecked(hwnd
, IDC_DECOM
);
1922 if (HIWORD(wParam
) == BN_CLICKED
||
1923 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1925 IsDlgButtonChecked(hwnd
, IDC_LFHASCR
);
1928 if (HIWORD(wParam
) == EN_CHANGE
)
1929 MyGetDlgItemInt(hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1932 if (HIWORD(wParam
) == EN_CHANGE
)
1933 MyGetDlgItemInt(hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1936 if (HIWORD(wParam
) == EN_CHANGE
)
1937 MyGetDlgItemInt(hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1939 case IDC_CHOOSEFONT
:
1942 lf
.lfHeight
= -MulDiv(cfg
.fontheight
,
1943 GetDeviceCaps(hdc
, LOGPIXELSY
),
1947 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1948 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1949 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1950 lf
.lfCharSet
= cfg
.fontcharset
;
1951 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1952 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1953 lf
.lfQuality
= DEFAULT_QUALITY
;
1954 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1955 strncpy(lf
.lfFaceName
, cfg
.font
,
1956 sizeof(lf
.lfFaceName
) - 1);
1957 lf
.lfFaceName
[sizeof(lf
.lfFaceName
) - 1] = '\0';
1959 cf
.lStructSize
= sizeof(cf
);
1960 cf
.hwndOwner
= hwnd
;
1962 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1963 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1965 if (ChooseFont(&cf
)) {
1966 strncpy(cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
) - 1);
1967 cfg
.font
[sizeof(cfg
.font
) - 1] = '\0';
1968 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1969 cfg
.fontcharset
= lf
.lfCharSet
;
1970 cfg
.fontheight
= cf
.iPointSize
/ 10;
1971 fmtfont(fontstatic
);
1972 SetDlgItemText(hwnd
, IDC_FONTSTATIC
, fontstatic
);
1975 case IDC_BELL_DISABLED
:
1976 case IDC_BELL_DEFAULT
:
1977 case IDC_BELL_WAVEFILE
:
1978 case IDC_BELL_VISUAL
:
1979 if (HIWORD(wParam
) == BN_CLICKED
||
1980 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1981 if (LOWORD(wParam
) == IDC_BELL_DISABLED
)
1982 cfg
.beep
= BELL_DISABLED
;
1983 if (LOWORD(wParam
) == IDC_BELL_DEFAULT
)
1984 cfg
.beep
= BELL_DEFAULT
;
1985 if (LOWORD(wParam
) == IDC_BELL_WAVEFILE
)
1986 cfg
.beep
= BELL_WAVEFILE
;
1987 if (LOWORD(wParam
) == IDC_BELL_VISUAL
)
1988 cfg
.beep
= BELL_VISUAL
;
1991 case IDC_B_IND_DISABLED
:
1992 case IDC_B_IND_FLASH
:
1993 case IDC_B_IND_STEADY
:
1994 if (HIWORD(wParam
) == BN_CLICKED
||
1995 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1996 if (LOWORD(wParam
) == IDC_B_IND_DISABLED
)
1997 cfg
.beep_ind
= B_IND_DISABLED
;
1998 if (LOWORD(wParam
) == IDC_B_IND_FLASH
)
1999 cfg
.beep_ind
= B_IND_FLASH
;
2000 if (LOWORD(wParam
) == IDC_B_IND_STEADY
)
2001 cfg
.beep_ind
= B_IND_STEADY
;
2004 case IDC_BELL_WAVEBROWSE
:
2005 memset(&of
, 0, sizeof(of
));
2006 #ifdef OPENFILENAME_SIZE_VERSION_400
2007 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2009 of
.lStructSize
= sizeof(of
);
2011 of
.hwndOwner
= hwnd
;
2012 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2013 of
.lpstrCustomFilter
= NULL
;
2014 of
.nFilterIndex
= 1;
2015 of
.lpstrFile
= filename
;
2016 strcpy(filename
, cfg
.bell_wavefile
);
2017 of
.nMaxFile
= sizeof(filename
);
2018 of
.lpstrFileTitle
= NULL
;
2019 of
.lpstrInitialDir
= NULL
;
2020 of
.lpstrTitle
= "Select Bell Sound File";
2022 if (GetOpenFileName(&of
)) {
2023 strcpy(cfg
.bell_wavefile
, filename
);
2024 SetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2028 case IDC_BELL_WAVEEDIT
:
2029 if (HIWORD(wParam
) == EN_CHANGE
)
2030 GetDlgItemText(hwnd
, IDC_BELL_WAVEEDIT
,
2032 sizeof(cfg
.bell_wavefile
) - 1);
2035 if (HIWORD(wParam
) == BN_CLICKED
||
2036 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2038 IsDlgButtonChecked(hwnd
, IDC_BELLOVL
);
2041 if (HIWORD(wParam
) == EN_CHANGE
)
2042 MyGetDlgItemInt(hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
2045 if (HIWORD(wParam
) == EN_CHANGE
)
2046 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
,
2050 if (HIWORD(wParam
) == EN_CHANGE
)
2051 MyGetDlgItemFlt(hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
,
2055 if (HIWORD(wParam
) == BN_CLICKED
||
2056 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2058 IsDlgButtonChecked(hwnd
, IDC_BLINKTEXT
);
2061 if (HIWORD(wParam
) == BN_CLICKED
||
2062 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2063 cfg
.bce
= IsDlgButtonChecked(hwnd
, IDC_BCE
);
2066 if (HIWORD(wParam
) == BN_CLICKED
||
2067 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2068 cfg
.win_name_always
=
2069 IsDlgButtonChecked(hwnd
, IDC_WINNAME
);
2072 if (HIWORD(wParam
) == BN_CLICKED
||
2073 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2075 IsDlgButtonChecked(hwnd
, IDC_HIDEMOUSE
);
2077 case IDC_SUNKENEDGE
:
2078 if (HIWORD(wParam
) == BN_CLICKED
||
2079 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2081 IsDlgButtonChecked(hwnd
, IDC_SUNKENEDGE
);
2084 if (HIWORD(wParam
) == EN_CHANGE
)
2085 MyGetDlgItemInt(hwnd
, IDC_WINBEDIT
,
2086 &cfg
.window_border
);
2087 if (cfg
.window_border
> 32)
2088 cfg
.window_border
= 32;
2091 if (HIWORD(wParam
) == BN_CLICKED
||
2092 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2093 cfg
.cursor_type
= 0;
2096 if (HIWORD(wParam
) == BN_CLICKED
||
2097 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2098 cfg
.cursor_type
= 1;
2101 if (HIWORD(wParam
) == BN_CLICKED
||
2102 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2103 cfg
.cursor_type
= 2;
2106 if (HIWORD(wParam
) == BN_CLICKED
||
2107 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2109 IsDlgButtonChecked(hwnd
, IDC_BLINKCUR
);
2112 if (HIWORD(wParam
) == BN_CLICKED
||
2113 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2115 IsDlgButtonChecked(hwnd
, IDC_SCROLLBAR
);
2117 case IDC_RESIZETERM
:
2118 case IDC_RESIZEFONT
:
2119 case IDC_RESIZENONE
:
2120 if (HIWORD(wParam
) == BN_CLICKED
||
2121 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2123 IsDlgButtonChecked(hwnd
,
2124 IDC_RESIZETERM
) ? RESIZE_TERM
:
2125 IsDlgButtonChecked(hwnd
,
2126 IDC_RESIZEFONT
) ? RESIZE_FONT
:
2131 if (HIWORD(wParam
) == EN_CHANGE
)
2132 GetDlgItemText(hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
2133 sizeof(cfg
.wintitle
) - 1);
2138 if (HIWORD(wParam
) == BN_CLICKED
||
2139 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2141 IsDlgButtonChecked(hwnd
,
2142 IDC_COEALWAYS
) ? COE_ALWAYS
:
2143 IsDlgButtonChecked(hwnd
,
2144 IDC_COENEVER
) ? COE_NEVER
:
2149 if (HIWORD(wParam
) == BN_CLICKED
||
2150 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2152 IsDlgButtonChecked(hwnd
, IDC_CLOSEWARN
);
2155 if (HIWORD(wParam
) == EN_CHANGE
)
2156 GetDlgItemText(hwnd
, IDC_TTEDIT
, cfg
.termtype
,
2157 sizeof(cfg
.termtype
) - 1);
2160 if (HIWORD(wParam
) == EN_CHANGE
)
2161 GetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
2162 sizeof(cfg
.logfilename
) - 1);
2165 memset(&of
, 0, sizeof(of
));
2166 #ifdef OPENFILENAME_SIZE_VERSION_400
2167 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2169 of
.lStructSize
= sizeof(of
);
2171 of
.hwndOwner
= hwnd
;
2172 of
.lpstrFilter
= "All Files\0*\0\0\0";
2173 of
.lpstrCustomFilter
= NULL
;
2174 of
.nFilterIndex
= 1;
2175 of
.lpstrFile
= filename
;
2176 strcpy(filename
, cfg
.logfilename
);
2177 of
.nMaxFile
= sizeof(filename
);
2178 of
.lpstrFileTitle
= NULL
;
2179 of
.lpstrInitialDir
= NULL
;
2180 of
.lpstrTitle
= "Select session log file";
2182 if (GetSaveFileName(&of
)) {
2183 strcpy(cfg
.logfilename
, filename
);
2184 SetDlgItemText(hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
2188 case IDC_LSTATASCII
:
2190 if (HIWORD(wParam
) == BN_CLICKED
||
2191 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2192 if (IsDlgButtonChecked(hwnd
, IDC_LSTATOFF
))
2194 if (IsDlgButtonChecked(hwnd
, IDC_LSTATASCII
))
2196 if (IsDlgButtonChecked(hwnd
, IDC_LSTATRAW
))
2203 if (HIWORD(wParam
) == BN_CLICKED
||
2204 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2205 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXASK
))
2206 cfg
.logxfovr
= LGXF_ASK
;
2207 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXAPN
))
2208 cfg
.logxfovr
= LGXF_APN
;
2209 if (IsDlgButtonChecked(hwnd
, IDC_LSTATXOVR
))
2210 cfg
.logxfovr
= LGXF_OVR
;
2215 if (HIWORD(wParam
) == EN_CHANGE
)
2216 GetDlgItemText(hwnd
, LOWORD(wParam
), cfg
.termspeed
,
2217 sizeof(cfg
.termspeed
) - 1);
2220 if (HIWORD(wParam
) == EN_CHANGE
)
2221 GetDlgItemText(hwnd
, IDC_LOGEDIT
, cfg
.username
,
2222 sizeof(cfg
.username
) - 1);
2224 case IDC_RLLUSEREDIT
:
2225 if (HIWORD(wParam
) == EN_CHANGE
)
2226 GetDlgItemText(hwnd
, IDC_RLLUSEREDIT
,
2228 sizeof(cfg
.localusername
) - 1);
2232 cfg
.rfc_environ
= IsDlgButtonChecked(hwnd
, IDC_EMRFC
);
2236 cfg
.passive_telnet
=
2237 IsDlgButtonChecked(hwnd
, IDC_TPASSIVE
);
2240 if (HIWORD(wParam
) == BN_CLICKED
||
2241 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2242 char str
[sizeof(cfg
.environmt
)];
2244 GetDlgItemText(hwnd
, IDC_VAREDIT
, str
,
2250 p
= str
+ strlen(str
);
2252 GetDlgItemText(hwnd
, IDC_VALEDIT
, p
,
2253 sizeof(str
) - 1 - (p
- str
));
2264 if ((p
- cfg
.environmt
) + strlen(str
) + 2 <
2265 sizeof(cfg
.environmt
)) {
2267 p
[strlen(str
) + 1] = '\0';
2268 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
2270 SetDlgItemText(hwnd
, IDC_VAREDIT
, "");
2271 SetDlgItemText(hwnd
, IDC_VALEDIT
, "");
2273 MessageBox(hwnd
, "Environment too big",
2274 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2279 if (HIWORD(wParam
) != BN_CLICKED
&&
2280 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2282 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0,
2289 SendDlgItemMessage(hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
2316 if (HIWORD(wParam
) == BN_CLICKED
||
2317 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2318 cfg
.nopty
= IsDlgButtonChecked(hwnd
, IDC_NOPTY
);
2321 if (HIWORD(wParam
) == BN_CLICKED
||
2322 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2324 IsDlgButtonChecked(hwnd
, IDC_COMPRESS
);
2327 if (HIWORD(wParam
) == BN_CLICKED
||
2328 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2330 IsDlgButtonChecked(hwnd
, IDC_BUGGYMAC
);
2333 if (HIWORD(wParam
) == BN_CLICKED
||
2334 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2336 IsDlgButtonChecked(hwnd
, IDC_AGENTFWD
);
2338 case IDC_CIPHERLIST
:
2341 handle_prefslist(&cipherlist
,
2342 cfg
.ssh_cipherlist
, CIPHER_MAX
,
2343 0, hwnd
, wParam
, lParam
);
2347 if (HIWORD(wParam
) == BN_CLICKED
||
2348 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2349 if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT1
))
2351 else if (IsDlgButtonChecked(hwnd
, IDC_SSHPROT2
))
2356 if (HIWORD(wParam
) == BN_CLICKED
||
2357 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2359 IsDlgButtonChecked(hwnd
, IDC_AUTHTIS
);
2362 if (HIWORD(wParam
) == EN_CHANGE
)
2363 GetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
2364 sizeof(cfg
.keyfile
) - 1);
2367 if (HIWORD(wParam
) == EN_CHANGE
)
2368 GetDlgItemText(hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
2369 sizeof(cfg
.remote_cmd
) - 1);
2372 memset(&of
, 0, sizeof(of
));
2373 #ifdef OPENFILENAME_SIZE_VERSION_400
2374 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2376 of
.lStructSize
= sizeof(of
);
2378 of
.hwndOwner
= hwnd
;
2379 of
.lpstrFilter
= "All Files\0*\0\0\0";
2380 of
.lpstrCustomFilter
= NULL
;
2381 of
.nFilterIndex
= 1;
2382 of
.lpstrFile
= filename
;
2383 strcpy(filename
, cfg
.keyfile
);
2384 of
.nMaxFile
= sizeof(filename
);
2385 of
.lpstrFileTitle
= NULL
;
2386 of
.lpstrInitialDir
= NULL
;
2387 of
.lpstrTitle
= "Select Private Key File";
2389 if (GetOpenFileName(&of
)) {
2390 strcpy(cfg
.keyfile
, filename
);
2391 SetDlgItemText(hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
2395 cfg
.rawcnp
= IsDlgButtonChecked(hwnd
, IDC_RAWCNP
);
2399 cfg
.mouse_is_xterm
= IsDlgButtonChecked(hwnd
, IDC_MBXTERM
);
2401 case IDC_MOUSEOVERRIDE
:
2402 cfg
.mouse_override
= IsDlgButtonChecked(hwnd
, IDC_MOUSEOVERRIDE
);
2408 int n
= GetDlgItemInt(hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
2413 for (i
= 0; i
< 128; i
++)
2414 if (SendDlgItemMessage
2415 (hwnd
, IDC_CCLIST
, LB_GETSEL
, i
, 0)) {
2417 cfg
.wordness
[i
] = n
;
2418 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2419 LB_DELETESTRING
, i
, 0);
2420 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
2421 (i
>= 0x21 && i
!= 0x7F) ? i
: ' ',
2423 SendDlgItemMessage(hwnd
, IDC_CCLIST
,
2430 case IDC_BOLDCOLOUR
:
2431 if (HIWORD(wParam
) == BN_CLICKED
||
2432 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2435 IsDlgButtonChecked(hwnd
, IDC_BOLDCOLOUR
);
2436 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2439 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2441 if (n
!= 12 + 10 * cfg
.bold_colour
) {
2442 for (i
= n
; i
-- > 0;)
2443 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2444 LB_DELETESTRING
, i
, 0);
2445 for (i
= 0; i
< 22; i
++)
2446 if (cfg
.bold_colour
|| permcolour
[i
])
2447 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2449 (LPARAM
) colours
[i
]);
2451 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
, WM_SETREDRAW
,
2453 InvalidateRect(GetDlgItem(hwnd
, IDC_COLOURLIST
), NULL
,
2458 if (HIWORD(wParam
) == BN_CLICKED
||
2459 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2461 IsDlgButtonChecked(hwnd
, IDC_PALETTE
);
2463 case IDC_COLOURLIST
:
2464 if (HIWORD(wParam
) == LBN_DBLCLK
||
2465 HIWORD(wParam
) == LBN_SELCHANGE
) {
2467 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2470 if (!cfg
.bold_colour
)
2471 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2472 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2474 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2476 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2481 if (HIWORD(wParam
) == BN_CLICKED
||
2482 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2483 static CHOOSECOLOR cc
;
2484 static DWORD custom
[16] = { 0 }; /* zero initialisers */
2486 SendDlgItemMessage(hwnd
, IDC_COLOURLIST
,
2489 if (!cfg
.bold_colour
)
2490 i
= (i
< 3 ? i
* 2 : i
== 3 ?
5 : i
* 2 - 2);
2491 cc
.lStructSize
= sizeof(cc
);
2492 cc
.hwndOwner
= hwnd
;
2493 cc
.hInstance
= (HWND
) hinst
;
2494 cc
.lpCustColors
= custom
;
2496 RGB(cfg
.colours
[i
][0], cfg
.colours
[i
][1],
2498 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
2499 if (ChooseColor(&cc
)) {
2501 (unsigned char) (cc
.rgbResult
& 0xFF);
2503 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
2505 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
2506 SetDlgItemInt(hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2508 SetDlgItemInt(hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2510 SetDlgItemInt(hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2516 if (HIWORD(wParam
) == CBN_SELCHANGE
) {
2517 int index
= SendDlgItemMessage(hwnd
, IDC_CODEPAGE
,
2518 CB_GETCURSEL
, 0, 0);
2519 SendDlgItemMessage(hwnd
, IDC_CODEPAGE
, CB_GETLBTEXT
,
2520 index
, (LPARAM
)cfg
.line_codepage
);
2521 } else if (HIWORD(wParam
) == CBN_EDITCHANGE
) {
2522 GetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
,
2523 sizeof(cfg
.line_codepage
) - 1);
2524 } else if (HIWORD(wParam
) == CBN_KILLFOCUS
) {
2525 strcpy(cfg
.line_codepage
,
2526 cp_name(decode_codepage(cfg
.line_codepage
)));
2527 SetDlgItemText(hwnd
, IDC_CODEPAGE
, cfg
.line_codepage
);
2530 case IDC_CAPSLOCKCYR
:
2531 if (HIWORD(wParam
) == BN_CLICKED
||
2532 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2533 cfg
.xlat_capslockcyr
=
2534 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
2537 case IDC_VTXWINDOWS
:
2543 (IsDlgButtonChecked(hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
2544 : IsDlgButtonChecked(hwnd
,
2545 IDC_VTOEMANSI
) ? VT_OEMANSI
:
2546 IsDlgButtonChecked(hwnd
,
2547 IDC_VTOEMONLY
) ? VT_OEMONLY
:
2548 IsDlgButtonChecked(hwnd
,
2549 IDC_VTUNICODE
) ? VT_UNICODE
:
2552 case IDC_X11_FORWARD
:
2553 if (HIWORD(wParam
) == BN_CLICKED
||
2554 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2556 IsDlgButtonChecked(hwnd
, IDC_X11_FORWARD
);
2559 if (HIWORD(wParam
) == BN_CLICKED
||
2560 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2561 cfg
.lport_acceptall
=
2562 IsDlgButtonChecked(hwnd
, IDC_LPORT_ALL
);
2564 case IDC_X11_DISPLAY
:
2565 if (HIWORD(wParam
) == EN_CHANGE
)
2566 GetDlgItemText(hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
2567 sizeof(cfg
.x11_display
) - 1);
2570 if (HIWORD(wParam
) == BN_CLICKED
||
2571 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2572 char str
[sizeof(cfg
.portfwd
)];
2574 if (IsDlgButtonChecked(hwnd
, IDC_PFWDLOCAL
))
2578 GetDlgItemText(hwnd
, IDC_SPORTEDIT
, str
+1,
2582 "You need to specify a source port number",
2583 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2586 p
= str
+ strlen(str
);
2588 GetDlgItemText(hwnd
, IDC_DPORTEDIT
, p
,
2589 sizeof(str
) - 1 - (p
- str
));
2590 if (!*p
|| !strchr(p
, ':')) {
2592 "You need to specify a destination address\n"
2593 "in the form \"host.name:port\"",
2594 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2603 if ((p
- cfg
.portfwd
) + strlen(str
) + 2 <
2604 sizeof(cfg
.portfwd
)) {
2606 p
[strlen(str
) + 1] = '\0';
2607 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_ADDSTRING
,
2609 SetDlgItemText(hwnd
, IDC_SPORTEDIT
, "");
2610 SetDlgItemText(hwnd
, IDC_DPORTEDIT
, "");
2612 MessageBox(hwnd
, "Too many forwardings",
2613 "PuTTY Error", MB_OK
| MB_ICONERROR
);
2617 case IDC_PFWDREMOVE
:
2618 if (HIWORD(wParam
) != BN_CLICKED
&&
2619 HIWORD(wParam
) != BN_DOUBLECLICKED
) break;
2620 i
= SendDlgItemMessage(hwnd
, IDC_PFWDLIST
,
2621 LB_GETCURSEL
, 0, 0);
2627 SendDlgItemMessage(hwnd
, IDC_PFWDLIST
, LB_DELETESTRING
,
2659 /* Grrr Explorer will maximize Dialogs! */
2661 if (wParam
== SIZE_MAXIMIZED
)
2667 * Handle application-defined messages eg. DragListBox
2669 /* First find out what the number is (once). */
2670 if (draglistmsg
== WM_NULL
)
2671 draglistmsg
= RegisterWindowMessage (DRAGLISTMSGSTRING
);
2673 if (msg
== draglistmsg
) {
2674 /* Only process once dialog is fully formed. */
2675 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
2676 case IDC_CIPHERLIST
:
2677 return handle_prefslist(&cipherlist
,
2678 cfg
.ssh_cipherlist
, CIPHER_MAX
,
2679 1, hwnd
, wParam
, lParam
);
2688 static int CALLBACK
MainDlgProc(HWND hwnd
, UINT msg
,
2689 WPARAM wParam
, LPARAM lParam
)
2691 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
2693 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
2694 EnableWindow(hwnd
, 0);
2695 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2696 EnableWindow(hwnd
, 1);
2697 SetActiveWindow(hwnd
);
2699 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 0);
2702 static int CALLBACK
ReconfDlgProc(HWND hwnd
, UINT msg
,
2703 WPARAM wParam
, LPARAM lParam
)
2705 return GenericMainDlgProc(hwnd
, msg
, wParam
, lParam
, 1);
2708 void defuse_showwindow(void)
2711 * Work around the fact that the app's first call to ShowWindow
2712 * will ignore the default in favour of the shell-provided
2717 hwnd
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2719 ShowWindow(hwnd
, SW_HIDE
);
2720 SetActiveWindow(hwnd
);
2721 DestroyWindow(hwnd
);
2730 savedsession
[0] = '\0';
2732 DialogBox(hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2733 get_sesslist(FALSE
);
2738 int do_reconfig(HWND hwnd
)
2743 backup_cfg
= cfg
; /* structure copy */
2745 DialogBox(hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2747 cfg
= backup_cfg
; /* structure copy */
2752 void logevent(char *string
)
2757 if (nevents
>= negsize
) {
2759 events
= srealloc(events
, negsize
* sizeof(*events
));
2763 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t",
2766 events
[nevents
] = smalloc(strlen(timebuf
) + strlen(string
) + 1);
2767 strcpy(events
[nevents
], timebuf
);
2768 strcat(events
[nevents
], string
);
2771 SendDlgItemMessage(logbox
, IDN_LIST
, LB_ADDSTRING
,
2772 0, (LPARAM
) events
[nevents
]);
2773 count
= SendDlgItemMessage(logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2774 SendDlgItemMessage(logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
- 1, 0);
2779 void showeventlog(HWND hwnd
)
2782 logbox
= CreateDialog(hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2784 ShowWindow(logbox
, SW_SHOWNORMAL
);
2786 SetActiveWindow(logbox
);
2789 void showabout(HWND hwnd
)
2791 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
), hwnd
, AboutProc
);
2794 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2795 char *keystr
, char *fingerprint
)
2799 static const char absentmsg
[] =
2800 "The server's host key is not cached in the registry. You\n"
2801 "have no guarantee that the server is the computer you\n"
2803 "The server's key fingerprint is:\n"
2805 "If you trust this host, hit Yes to add the key to\n"
2806 "PuTTY's cache and carry on connecting.\n"
2807 "If you want to carry on connecting just once, without\n"
2808 "adding the key to the cache, hit No.\n"
2809 "If you do not trust this host, hit Cancel to abandon the\n"
2812 static const char wrongmsg
[] =
2813 "WARNING - POTENTIAL SECURITY BREACH!\n"
2815 "The server's host key does not match the one PuTTY has\n"
2816 "cached in the registry. This means that either the\n"
2817 "server administrator has changed the host key, or you\n"
2818 "have actually connected to another computer pretending\n"
2819 "to be the server.\n"
2820 "The new key fingerprint is:\n"
2822 "If you were expecting this change and trust the new key,\n"
2823 "hit Yes to update PuTTY's cache and continue connecting.\n"
2824 "If you want to carry on connecting but without updating\n"
2825 "the cache, hit No.\n"
2826 "If you want to abandon the connection completely, hit\n"
2827 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
2829 static const char mbtitle
[] = "PuTTY Security Alert";
2832 /* sensible fingerprint max size */
2833 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2834 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2837 * Verify the key against the registry.
2839 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2841 if (ret
== 0) /* success - key matched OK */
2843 if (ret
== 2) { /* key was different */
2845 sprintf(message
, wrongmsg
, fingerprint
);
2846 mbret
= MessageBox(NULL
, message
, mbtitle
,
2847 MB_ICONWARNING
| MB_YESNOCANCEL
);
2849 store_host_key(host
, port
, keytype
, keystr
);
2850 if (mbret
== IDCANCEL
)
2853 if (ret
== 1) { /* key was absent */
2855 sprintf(message
, absentmsg
, fingerprint
);
2856 mbret
= MessageBox(NULL
, message
, mbtitle
,
2857 MB_ICONWARNING
| MB_YESNOCANCEL
);
2859 store_host_key(host
, port
, keytype
, keystr
);
2860 if (mbret
== IDCANCEL
)
2866 * Ask whether the selected cipher is acceptable (since it was
2867 * below the configured 'warn' threshold).
2868 * cs: 0 = both ways, 1 = client->server, 2 = server->client
2870 void askcipher(char *ciphername
, int cs
)
2872 static const char mbtitle
[] = "PuTTY Security Alert";
2873 static const char msg
[] =
2874 "The first %.35scipher supported by the server\n"
2875 "is %.64s, which is below the configured\n"
2876 "warning threshold.\n"
2877 "Do you want to continue with this connection?\n";
2878 /* guessed cipher name + type max length */
2879 char message
[100 + sizeof(msg
)];
2882 sprintf(message
, msg
,
2884 (cs
== 1) ?
"client-to-server " :
2885 "server-to-client ",
2887 mbret
= MessageBox(NULL
, message
, mbtitle
,
2888 MB_ICONWARNING
| MB_YESNO
);
2896 * Ask whether to wipe a session log file before writing to it.
2897 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2899 int askappend(char *filename
)
2901 static const char mbtitle
[] = "PuTTY Log to File";
2902 static const char msgtemplate
[] =
2903 "The session log file \"%.*s\" already exists.\n"
2904 "You can overwrite it with a new session log,\n"
2905 "append your session log to the end of it,\n"
2906 "or disable session logging for this session.\n"
2907 "Hit Yes to wipe the file, No to append to it,\n"
2908 "or Cancel to disable logging.";
2909 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2911 if (cfg
.logxfovr
!= LGXF_ASK
) {
2912 return ((cfg
.logxfovr
== LGXF_OVR
) ?
2 : 1);
2914 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2916 mbret
= MessageBox(NULL
, message
, mbtitle
,
2917 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2920 else if (mbret
== IDNO
)