15 static char **events
= NULL
;
16 static int nevents
= 0, negsize
= 0;
20 void force_normal(HWND hwnd
)
22 static int recurse
= 0;
29 wp
.length
= sizeof(wp
);
30 if (GetWindowPlacement(hwnd
, &wp
) && wp
.showCmd
== SW_SHOWMAXIMIZED
)
32 wp
.showCmd
= SW_SHOWNORMAL
;
33 SetWindowPlacement(hwnd
, &wp
);
38 static void MyGetDlgItemInt (HWND hwnd
, int id
, int *result
) {
41 n
= GetDlgItemInt (hwnd
, id
, &ok
, FALSE
);
46 static void MyGetDlgItemFlt (HWND hwnd
, int id
, int *result
, int scale
) {
49 ok
= GetDlgItemText (hwnd
, id
, text
, sizeof(text
)-1);
51 *result
= (int) (scale
* atof(text
));
54 static void MySetDlgItemFlt (HWND hwnd
, int id
, double value
) {
56 sprintf(text
, "%g", value
);
57 SetDlgItemText (hwnd
, id
, text
);
60 static int CALLBACK
LogProc (HWND hwnd
, UINT msg
,
61 WPARAM wParam
, LPARAM lParam
) {
67 static int tabs
[4] = {78, 108};
68 SendDlgItemMessage (hwnd
, IDN_LIST
, LB_SETTABSTOPS
, 2,
71 for (i
=0; i
<nevents
; i
++)
72 SendDlgItemMessage (hwnd
, IDN_LIST
, LB_ADDSTRING
,
73 0, (LPARAM
)events
[i
]);
76 switch (LOWORD(wParam
)) {
80 SetActiveWindow(GetParent(hwnd
));
84 if (HIWORD(wParam
) == BN_CLICKED
||
85 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
88 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
89 LB_GETSELCOUNT
, 0, 0);
90 if (selcount
== 0) { /* don't even try to copy zero items */
95 selitems
= smalloc(selcount
* sizeof(int));
97 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
99 selcount
, (LPARAM
)selitems
);
103 static unsigned char sel_nl
[] = SEL_NL
;
105 if (count
== 0) { /* can't copy zero stuff */
111 for (i
= 0; i
< count
; i
++)
112 size
+= strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
114 clipdata
= smalloc(size
);
117 for (i
= 0; i
< count
; i
++) {
118 char *q
= events
[selitems
[i
]];
119 int qlen
= strlen(q
);
122 memcpy(p
, sel_nl
, sizeof(sel_nl
));
125 write_clip(clipdata
, size
, TRUE
);
130 for (i
= 0; i
< nevents
; i
++)
131 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
140 SetActiveWindow(GetParent(hwnd
));
141 DestroyWindow (hwnd
);
147 static int CALLBACK
LicenceProc (HWND hwnd
, UINT msg
,
148 WPARAM wParam
, LPARAM lParam
) {
153 switch (LOWORD(wParam
)) {
166 static int CALLBACK
AboutProc (HWND hwnd
, UINT msg
,
167 WPARAM wParam
, LPARAM lParam
) {
170 SetDlgItemText (hwnd
, IDA_VERSION
, ver
);
173 switch (LOWORD(wParam
)) {
176 EndDialog(hwnd
, TRUE
);
179 EnableWindow(hwnd
, 0);
180 DialogBox (hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
182 EnableWindow(hwnd
, 1);
183 SetActiveWindow(hwnd
);
187 /* Load web browser */
188 ShellExecute(hwnd
, "open",
189 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
190 0, 0, SW_SHOWDEFAULT
);
195 EndDialog(hwnd
, TRUE
);
202 * Null dialog procedure.
204 static int CALLBACK
NullDlgProc (HWND hwnd
, UINT msg
,
205 WPARAM wParam
, LPARAM lParam
) {
209 static char savedsession
[2048];
211 enum { IDCX_ABOUT
= IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
351 appearancepanelstart
,
352 IDC_TITLE_APPEARANCE
,
370 connectionpanelstart
,
371 IDC_TITLE_CONNECTION
,
469 translationpanelstart
,
470 IDC_TITLE_TRANSLATION
,
471 IDC_BOX_TRANSLATION1
,
472 IDC_BOX_TRANSLATION2
,
473 IDC_BOX_TRANSLATION3
,
498 static const char *const colours
[] = {
499 "Default Foreground", "Default Bold Foreground",
500 "Default Background", "Default Bold Background",
501 "Cursor Text", "Cursor Colour",
502 "ANSI Black", "ANSI Black Bold",
503 "ANSI Red", "ANSI Red Bold",
504 "ANSI Green", "ANSI Green Bold",
505 "ANSI Yellow", "ANSI Yellow Bold",
506 "ANSI Blue", "ANSI Blue Bold",
507 "ANSI Magenta", "ANSI Magenta Bold",
508 "ANSI Cyan", "ANSI Cyan Bold",
509 "ANSI White", "ANSI White Bold"
511 static const int permcolour
[] = {
512 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
513 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
514 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
517 static void fmtfont (char *buf
) {
518 sprintf (buf
, "Font: %s, ", cfg
.font
);
520 strcat(buf
, "bold, ");
521 if (cfg
.fontheight
== 0)
522 strcat (buf
, "default height");
524 sprintf (buf
+strlen(buf
), "%d-point",
525 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
528 static void init_dlg_ctrls(HWND hwnd
) {
530 char fontstatic
[256];
532 SetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
);
533 SetDlgItemText (hwnd
, IDC_SESSEDIT
, savedsession
);
536 n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
538 SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
539 LB_DELETESTRING
, i
, 0);
540 for (i
= 0; i
< nsessions
; i
++)
541 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
542 0, (LPARAM
) (sessions
[i
]));
544 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
545 CheckRadioButton (hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
546 cfg
.protocol
==PROT_SSH ? IDC_PROTSSH
:
547 cfg
.protocol
==PROT_TELNET ? IDC_PROTTELNET
:
548 cfg
.protocol
==PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
549 SetDlgItemInt (hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
551 CheckRadioButton (hwnd
, IDC_DEL008
, IDC_DEL127
,
552 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
553 CheckRadioButton (hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
554 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
555 CheckRadioButton (hwnd
, IDC_FUNCTILDE
, IDC_FUNCSCO
,
556 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
557 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
558 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
559 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
560 cfg
.funky_type
== 4 ? IDC_FUNCVT100P
:
561 cfg
.funky_type
== 5 ? IDC_FUNCSCO
:
563 CheckDlgButton (hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
564 CheckDlgButton (hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
565 CheckRadioButton (hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
566 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
567 CheckRadioButton (hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
568 cfg
.nethack_keypad ? IDC_KPNH
:
569 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
570 CheckDlgButton (hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
571 CheckDlgButton (hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
572 CheckDlgButton (hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
573 CheckDlgButton (hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
574 CheckDlgButton (hwnd
, IDC_CTRLALTKEYS
, cfg
.ctrlaltkeys
);
575 CheckRadioButton (hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
576 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
577 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
578 CheckRadioButton (hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
579 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
580 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
581 SetDlgItemText (hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
);
582 CheckDlgButton (hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
583 CheckDlgButton (hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
584 CheckDlgButton (hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
586 CheckDlgButton (hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
587 CheckDlgButton (hwnd
, IDC_DECOM
, cfg
.dec_om
);
588 CheckDlgButton (hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
589 SetDlgItemInt (hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
590 SetDlgItemInt (hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
591 SetDlgItemInt (hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
592 fmtfont (fontstatic
);
593 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
594 CheckRadioButton (hwnd
, IDC_BELL_DISABLED
, IDC_BELL_VISUAL
,
595 cfg
.beep
==BELL_DISABLED ? IDC_BELL_DISABLED
:
596 cfg
.beep
==BELL_DEFAULT ? IDC_BELL_DEFAULT
:
597 cfg
.beep
==BELL_WAVEFILE ? IDC_BELL_WAVEFILE
:
598 cfg
.beep
==BELL_VISUAL ? IDC_BELL_VISUAL
: IDC_BELL_DEFAULT
);
599 SetDlgItemText (hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
600 CheckDlgButton (hwnd
, IDC_BELLOVL
, cfg
.bellovl
);
601 SetDlgItemInt (hwnd
, IDC_BELLOVLN
, cfg
.bellovl_n
, FALSE
);
602 MySetDlgItemFlt (hwnd
, IDC_BELLOVLT
, cfg
.bellovl_t
/ 1000.0);
603 MySetDlgItemFlt (hwnd
, IDC_BELLOVLS
, cfg
.bellovl_s
/ 1000.0);
605 CheckDlgButton (hwnd
, IDC_BCE
, cfg
.bce
);
606 CheckDlgButton (hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
608 SetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
609 CheckDlgButton (hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
610 CheckDlgButton (hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
611 CheckRadioButton (hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
612 cfg
.cursor_type
==0 ? IDC_CURBLOCK
:
613 cfg
.cursor_type
==1 ? IDC_CURUNDER
: IDC_CURVERT
);
614 CheckDlgButton (hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
615 CheckDlgButton (hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
616 CheckDlgButton (hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
617 CheckRadioButton (hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
618 cfg
.close_on_exit
==COE_NORMAL ? IDC_COENORMAL
:
619 cfg
.close_on_exit
==COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
620 CheckDlgButton (hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
622 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
623 SetDlgItemText (hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
624 SetDlgItemText (hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
625 SetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
626 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
627 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
628 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
629 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
630 cfg
.logtype
== 1 ? IDC_LSTATASCII
:
632 CheckRadioButton(hwnd
, IDC_LSTATXOVR
, IDC_LSTATXASK
,
633 cfg
.logxfovr
== LGXF_OVR ? IDC_LSTATXOVR
:
634 cfg
.logxfovr
== LGXF_ASK ? IDC_LSTATXASK
:
637 char *p
= cfg
.environmt
;
639 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
644 CheckRadioButton (hwnd
, IDC_EMBSD
, IDC_EMRFC
,
645 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
647 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
648 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
649 CheckDlgButton (hwnd
, IDC_NOPTY
, cfg
.nopty
);
650 CheckDlgButton (hwnd
, IDC_COMPRESS
, cfg
.compression
);
651 CheckDlgButton (hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
652 CheckDlgButton (hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
653 CheckRadioButton (hwnd
, IDC_CIPHER3DES
, IDC_CIPHERAES
,
654 cfg
.cipher
== CIPHER_BLOWFISH ? IDC_CIPHERBLOWF
:
655 cfg
.cipher
== CIPHER_DES ? IDC_CIPHERDES
:
656 cfg
.cipher
== CIPHER_AES ? IDC_CIPHERAES
:
658 CheckRadioButton (hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
659 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
660 CheckDlgButton (hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
661 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
662 SetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
664 CheckRadioButton (hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
665 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
666 CheckDlgButton (hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
668 static int tabs
[4] = {25, 61, 96, 128};
669 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
672 for (i
=0; i
<256; i
++) {
674 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
675 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
677 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
681 CheckDlgButton (hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
682 CheckDlgButton (hwnd
, IDC_PALETTE
, cfg
.try_palette
);
685 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
687 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
688 LB_DELETESTRING
, i
, 0);
690 if (cfg
.bold_colour
|| permcolour
[i
])
691 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
692 (LPARAM
) colours
[i
]);
694 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
695 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
696 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
697 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
699 CheckRadioButton (hwnd
, IDC_NOXLAT
, IDC_88592CP852
,
700 cfg
.xlat_88592w1250 ? IDC_88592WIN1250
:
701 cfg
.xlat_88592cp852 ? IDC_88592CP852
:
702 cfg
.xlat_enablekoiwin ? IDC_KOI8WIN1251
:
704 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
705 CheckRadioButton (hwnd
, IDC_VTXWINDOWS
, IDC_VTPOORMAN
,
706 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
707 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
708 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
711 CheckDlgButton (hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
712 SetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
715 struct treeview_faff
{
720 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
721 int level
, char *text
) {
725 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
-1] : TVI_ROOT
);
726 ins
.hInsertAfter
= faff
->lastat
[level
];
727 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
728 #define INSITEM DUMMYUNIONNAME.item
732 ins
.INSITEM
.mask
= TVIF_TEXT
;
733 ins
.INSITEM
.pszText
= text
;
734 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
736 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
-1], TVE_EXPAND
);
737 faff
->lastat
[level
] = newitem
;
738 for (i
= level
+1; i
< 4; i
++) faff
->lastat
[i
] = NULL
;
743 * Create the panelfuls of controls in the configuration box.
745 static void create_controls(HWND hwnd
, int dlgtype
, int panel
) {
746 if (panel
== sessionpanelstart
) {
747 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
749 ctlposinit(&cp
, hwnd
, 80, 3, 13);
750 bartitle(&cp
, "Basic options for your PuTTY session",
753 beginbox(&cp
, "Specify your connection by host name",
756 "Host &Name", IDC_HOSTSTATIC
, IDC_HOST
, 75,
757 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
758 if (backends
[3].backend
== NULL
) {
759 /* this is PuTTYtel, so only three protocols available */
760 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
762 "&Telnet", IDC_PROTTELNET
,
763 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
765 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
767 "&Telnet", IDC_PROTTELNET
,
768 "Rlog&in", IDC_PROTRLOGIN
,
777 beginbox(&cp
, "Load, save or delete a stored session",
779 sesssaver(&cp
, "Sav&ed Sessions",
780 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
781 "&Load", IDC_SESSLOAD
,
782 "&Save", IDC_SESSSAVE
,
783 "&Delete", IDC_SESSDEL
, NULL
);
786 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
787 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
788 "Always", IDC_COEALWAYS
,
789 "Never", IDC_COENEVER
,
790 "Only on clean exit", IDC_COENORMAL
, NULL
);
794 if (panel
== loggingpanelstart
) {
795 /* The Logging panel. Accelerators used: [acgo] tplfwes */
797 ctlposinit(&cp
, hwnd
, 80, 3, 13);
798 bartitle(&cp
, "Options controlling session logging",
800 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
802 "Session logging:", IDC_LSTATSTATIC
,
803 "Logging &turned off completely", IDC_LSTATOFF
,
804 "Log &printable output only", IDC_LSTATASCII
,
805 "&Log all session output", IDC_LSTATRAW
, NULL
);
806 editbutton(&cp
, "Log &file name:",
807 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
810 "What to do if the log file already &exists:", IDC_LSTATXIST
,
811 "Always overwrite it", IDC_LSTATXOVR
,
812 "Always append to the end of it", IDC_LSTATXAPN
,
813 "Ask the user every time", IDC_LSTATXASK
, NULL
);
817 if (panel
== terminalpanelstart
) {
818 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
820 ctlposinit(&cp
, hwnd
, 80, 3, 13);
821 bartitle(&cp
, "Options controlling the terminal emulation",
823 beginbox(&cp
, "Set various terminal options",
825 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
826 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
827 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
828 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
829 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
831 "An&swerback to ^E:", IDC_ANSWERBACK
,
832 IDC_ANSWEREDIT
, 100, NULL
);
835 beginbox(&cp
, "Line discipline options",
837 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
838 "Auto", IDC_ECHOBACKEND
,
839 "Force on", IDC_ECHOYES
,
840 "Force off", IDC_ECHONO
, NULL
);
841 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
842 "Auto", IDC_EDITBACKEND
,
843 "Force on", IDC_EDITYES
,
844 "Force off", IDC_EDITNO
, NULL
);
848 if (panel
== bellpanelstart
) {
849 /* The Bell panel. Accelerators used: [acgo] bdsm wt */
851 ctlposinit(&cp
, hwnd
, 80, 3, 13);
852 bartitle(&cp
, "Options controlling the terminal bell",
854 beginbox(&cp
, "Set the style of bell",
857 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
858 "None (bell disabled)", IDC_BELL_DISABLED
,
859 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
860 "Play a custom sound file", IDC_BELL_WAVEFILE
,
861 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
862 editbutton(&cp
, "Custom sound file to play as a bell:",
863 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
864 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
866 beginbox(&cp
, "Control the bell overload behaviour",
868 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
870 staticedit(&cp
, "Over-use means this &many bells...",
871 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
872 staticedit(&cp
, "... in &this many seconds",
873 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
874 statictext(&cp
, "The bell is re-enabled after a few seconds of silence.",
876 staticedit(&cp
, "Seconds of &silence required",
877 IDC_BELLOVLSSTATIC
, IDC_BELLOVLS
, 20);
881 if (panel
== keyboardpanelstart
) {
882 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
884 ctlposinit(&cp
, hwnd
, 80, 3, 13);
886 bartitle(&cp, "Options controlling the effects of keys",
889 beginbox(&cp
, "Change the sequences sent by:",
891 radioline(&cp
, "The &Backspace key", IDC_DELSTATIC
, 2,
892 "Control-H", IDC_DEL008
,
893 "Control-? (127)", IDC_DEL127
, NULL
);
894 radioline(&cp
, "The &Home and End keys", IDC_HOMESTATIC
, 2,
895 "Standard", IDC_HOMETILDE
,
896 "rxvt", IDC_HOMERXVT
, NULL
);
897 radioline(&cp
, "The &Function keys and keypad", IDC_FUNCSTATIC
, 3,
898 "ESC[n~", IDC_FUNCTILDE
,
899 "Linux", IDC_FUNCLINUX
,
900 "Xterm R6", IDC_FUNCXTERM
,
901 "VT400", IDC_FUNCVT400
,
902 "VT100+", IDC_FUNCVT100P
,
903 "SCO", IDC_FUNCSCO
, NULL
);
905 beginbox(&cp
, "Application keypad settings:",
908 "Application c&ursor keys totally disabled",
910 radioline(&cp
, "Initial state of cu&rsor keys:", IDC_CURSTATIC
, 2,
911 "Normal", IDC_CURNORMAL
,
912 "Application", IDC_CURAPPLIC
, NULL
);
914 "Application ke&ypad keys totally disabled",
916 radioline(&cp
, "Initial state of &numeric keypad:", IDC_KPSTATIC
, 3,
917 "Normal", IDC_KPNORMAL
,
918 "Application", IDC_KPAPPLIC
,
919 "NetHack", IDC_KPNH
, NULL
);
921 beginbox(&cp
, "Enable extra keyboard features:",
923 checkbox(&cp
, "AltGr ac&ts as Compose key",
925 checkbox(&cp
, "Control-Alt is &different from AltGr",
930 if (panel
== windowpanelstart
) {
931 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
933 ctlposinit(&cp
, hwnd
, 80, 3, 13);
934 bartitle(&cp
, "Options controlling PuTTY's window",
936 beginbox(&cp
, "Set the size of the window",
939 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
940 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50,
942 checkbox(&cp
, "Lock window size against resi&zing", IDC_LOCKSIZE
);
944 beginbox(&cp
, "Control the scrollback in the window",
946 staticedit(&cp
, "Lines of &scrollback",
947 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
948 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
949 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
950 checkbox(&cp
, "Reset scrollback on dis&play activity",
953 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
954 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
955 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
956 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
957 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
958 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
962 if (panel
== appearancepanelstart
) {
963 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p */
965 ctlposinit(&cp
, hwnd
, 80, 3, 13);
966 bartitle(&cp
, "Options controlling PuTTY's appearance",
967 IDC_TITLE_APPEARANCE
);
968 beginbox(&cp
, "Adjust the use of the cursor",
969 IDC_BOX_APPEARANCE1
);
970 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
971 "B&lock", IDC_CURBLOCK
,
972 "&Underline", IDC_CURUNDER
,
973 "&Vertical line", IDC_CURVERT
,
975 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
977 beginbox(&cp
, "Set the font used in the terminal window",
978 IDC_BOX_APPEARANCE2
);
979 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
981 beginbox(&cp
, "Adjust the use of the window title",
982 IDC_BOX_APPEARANCE3
);
984 "Window &title:", IDC_WINTITLE
,
985 IDC_WINEDIT
, 100, NULL
);
986 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
988 beginbox(&cp
, "Adjust the use of the mouse pointer",
989 IDC_BOX_APPEARANCE4
);
990 checkbox(&cp
, "Hide mouse &pointer when typing in window",
995 if (panel
== translationpanelstart
) {
996 /* The Translation panel. Accelerators used: [acgo] xbep t s */
998 ctlposinit(&cp
, hwnd
, 80, 3, 13);
999 bartitle(&cp
, "Options controlling character set translation",
1000 IDC_TITLE_TRANSLATION
);
1001 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
1002 IDC_BOX_TRANSLATION1
);
1004 "Handling of line drawing characters:", IDC_VTSTATIC
,
1005 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
1006 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
1007 "Use font in O&EM mode only", IDC_VTOEMONLY
,
1008 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
1009 IDC_VTPOORMAN
, NULL
);
1011 beginbox(&cp
, "Enable character set translation on received data",
1012 IDC_BOX_TRANSLATION2
);
1014 "Character set &translation:", IDC_XLATSTATIC
,
1016 "KOI8 / Win-1251", IDC_KOI8WIN1251
,
1017 "ISO-8859-2 / Win-1250", IDC_88592WIN1250
,
1018 "ISO-8859-2 / CP852", IDC_88592CP852
, NULL
);
1020 beginbox(&cp
, "Enable character set translation on input data",
1021 IDC_BOX_TRANSLATION3
);
1022 checkbox(&cp
, "CAP&S LOCK acts as cyrillic switch",
1027 if (panel
== selectionpanelstart
) {
1028 /* The Selection panel. Accelerators used: [acgo] d wx hst */
1030 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1031 bartitle(&cp
, "Options controlling copy and paste",
1032 IDC_TITLE_SELECTION
);
1033 beginbox(&cp
, "Translation of pasted characters",
1034 IDC_BOX_SELECTION1
);
1035 checkbox(&cp
, "&Don't translate line drawing chars into +, - and |",
1038 beginbox(&cp
, "Control which mouse button does which thing",
1039 IDC_BOX_SELECTION2
);
1040 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1041 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1042 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1045 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1046 IDC_BOX_SELECTION3
);
1047 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1048 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1049 "&to class", IDC_CCSTATIC2
);
1053 if (panel
== colourspanelstart
) {
1054 /* The Colours panel. Accelerators used: [acgo] blum */
1056 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1057 bartitle(&cp
, "Options controlling use of colours",
1059 beginbox(&cp
, "General options for colour usage",
1061 checkbox(&cp
, "&Bolded text is a different colour", IDC_BOLDCOLOUR
);
1062 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1064 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1066 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1067 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1068 "&Modify...", IDC_CHANGE
,
1069 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1070 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1071 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1075 if (panel
== connectionpanelstart
) {
1076 /* The Connection panel. Accelerators used: [acgo] tuk */
1078 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1079 bartitle(&cp
, "Options controlling the connection", IDC_TITLE_CONNECTION
);
1081 beginbox(&cp
, "Data to send to the server",
1082 IDC_BOX_CONNECTION1
);
1083 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
, IDC_TTEDIT
, 50);
1084 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
, IDC_LOGEDIT
, 50);
1087 beginbox(&cp
, "Sending of null packets to keep session active",
1088 IDC_BOX_CONNECTION2
);
1089 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1090 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1094 if (panel
== telnetpanelstart
) {
1095 /* The Telnet panel. Accelerators used: [acgo] svldr bf */
1097 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1099 bartitle(&cp
, "Options controlling Telnet connections", IDC_TITLE_TELNET
);
1100 beginbox(&cp
, "Data to send to the server",
1102 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
, IDC_TSEDIT
, 50);
1103 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1104 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
,
1105 "Va&lue", IDC_VALSTATIC
, IDC_VALEDIT
,
1107 "A&dd", IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1109 beginbox(&cp
, "Telnet protocol adjustments",
1111 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC
, 2,
1112 "&BSD (commonplace)", IDC_EMBSD
,
1113 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1118 if (panel
== rloginpanelstart
) {
1119 /* The Rlogin panel. Accelerators used: [acgo] sl */
1121 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1123 bartitle(&cp
, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN
);
1124 beginbox(&cp
, "Data to send to the server",
1126 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
, IDC_R_TSEDIT
, 50);
1127 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
, IDC_RLLUSEREDIT
, 50);
1132 if (panel
== sshpanelstart
) {
1133 /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bds i */
1135 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1137 bartitle(&cp
, "Options controlling SSH connections", IDC_TITLE_SSH
);
1138 beginbox(&cp
, "Data to send to the server",
1141 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1144 beginbox(&cp
, "Authentication options",
1146 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1148 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1149 editbutton(&cp
, "Private &key file for authentication:",
1150 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...", IDC_PKBUTTON
);
1152 beginbox(&cp
, "Protocol options",
1154 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1155 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1156 radioline(&cp
, "Preferred SSH protocol version:",
1157 IDC_SSHPROTSTATIC
, 2,
1158 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1159 radioline(&cp
, "Preferred encryption algorithm:", IDC_CIPHERSTATIC
, 4,
1160 "&3DES", IDC_CIPHER3DES
,
1161 "&Blowfish", IDC_CIPHERBLOWF
,
1162 "&DES", IDC_CIPHERDES
,
1163 "AE&S", IDC_CIPHERAES
,
1165 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1171 if (panel
== tunnelspanelstart
) {
1172 /* The Tunnels panel. Accelerators used: [acgo] ex */
1174 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1176 bartitle(&cp
, "Options controlling SSH tunnelling",
1178 beginbox(&cp
, "X11 forwarding options",
1180 checkbox(&cp
, "&Enable X11 forwarding",
1182 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1183 IDC_X11_DISPLAY
, 50, NULL
);
1190 * This function is the configuration box.
1192 static int GenericMainDlgProc (HWND hwnd
, UINT msg
,
1193 WPARAM wParam
, LPARAM lParam
,
1196 struct treeview_faff tvfaff
;
1199 char filename
[sizeof(cfg
.keyfile
)];
1202 char fontstatic
[256];
1204 struct servent
* service
;
1210 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1212 * Centre the window.
1214 { /* centre the window */
1217 hw
= GetDesktopWindow();
1218 if (GetWindowRect (hw
, &rs
) && GetWindowRect (hwnd
, &rd
))
1219 MoveWindow (hwnd
, (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
)/2,
1220 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
)/2,
1221 rd
.right
-rd
.left
, rd
.bottom
-rd
.top
, TRUE
);
1225 * Create the tree view.
1232 r
.left
= 3; r
.right
= r
.left
+ 75;
1233 r
.top
= 3; r
.bottom
= r
.top
+ 10;
1234 MapDialogRect(hwnd
, &r
);
1235 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1236 WS_CHILD
| WS_VISIBLE
,
1238 r
.right
-r
.left
, r
.bottom
-r
.top
,
1239 hwnd
, (HMENU
)IDCX_TVSTATIC
, hinst
, NULL
);
1240 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1241 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1243 r
.left
= 3; r
.right
= r
.left
+ 75;
1244 r
.top
= 13; r
.bottom
= r
.top
+ 206;
1245 MapDialogRect(hwnd
, &r
);
1246 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1247 WS_CHILD
| WS_VISIBLE
|
1248 WS_TABSTOP
| TVS_HASLINES
|
1249 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
|
1250 TVS_LINESATROOT
| TVS_SHOWSELALWAYS
,
1252 r
.right
-r
.left
, r
.bottom
-r
.top
,
1253 hwnd
, (HMENU
)IDCX_TREEVIEW
, hinst
, NULL
);
1254 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1255 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1256 tvfaff
.treeview
= treeview
;
1257 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1261 * Set up the tree view contents.
1263 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1264 treeview_insert(&tvfaff
, 1, "Logging");
1265 treeview_insert(&tvfaff
, 0, "Terminal");
1266 treeview_insert(&tvfaff
, 1, "Keyboard");
1267 treeview_insert(&tvfaff
, 1, "Bell");
1268 treeview_insert(&tvfaff
, 0, "Window");
1269 treeview_insert(&tvfaff
, 1, "Appearance");
1270 treeview_insert(&tvfaff
, 1, "Translation");
1271 treeview_insert(&tvfaff
, 1, "Selection");
1272 treeview_insert(&tvfaff
, 1, "Colours");
1273 treeview_insert(&tvfaff
, 0, "Connection");
1275 treeview_insert(&tvfaff
, 1, "Telnet");
1276 treeview_insert(&tvfaff
, 1, "Rlogin");
1277 if (backends
[3].backend
!= NULL
) {
1278 treeview_insert(&tvfaff
, 1, "SSH");
1279 treeview_insert(&tvfaff
, 2, "Tunnels");
1284 * Put the treeview selection on to the Session panel. This
1285 * should also cause creation of the relevant controls.
1287 TreeView_SelectItem(treeview
, hsession
);
1290 * Set focus into the first available control.
1294 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1295 if (!ctl
) ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1299 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1303 * Button release should trigger WM_OK if there was a
1304 * previous double click on the session list.
1308 SendMessage (hwnd
, WM_COMMAND
, IDOK
, 0);
1311 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1312 ((LPNMHDR
)lParam
)->code
== TVN_SELCHANGED
) {
1313 HTREEITEM i
= TreeView_GetSelection(((LPNMHDR
)lParam
)->hwndFrom
);
1318 item
.pszText
= buffer
;
1319 item
.cchTextMax
= sizeof(buffer
);
1320 item
.mask
= TVIF_TEXT
;
1321 TreeView_GetItem(((LPNMHDR
)lParam
)->hwndFrom
, &item
);
1322 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1323 HWND item
= GetDlgItem(hwnd
, j
);
1325 DestroyWindow(item
);
1327 if (!strcmp(buffer
, "Session"))
1328 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1329 if (!strcmp(buffer
, "Logging"))
1330 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1331 if (!strcmp(buffer
, "Keyboard"))
1332 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1333 if (!strcmp(buffer
, "Terminal"))
1334 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1335 if (!strcmp(buffer
, "Bell"))
1336 create_controls(hwnd
, dlgtype
, bellpanelstart
);
1337 if (!strcmp(buffer
, "Window"))
1338 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1339 if (!strcmp(buffer
, "Appearance"))
1340 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1341 if (!strcmp(buffer
, "Tunnels"))
1342 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1343 if (!strcmp(buffer
, "Connection"))
1344 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1345 if (!strcmp(buffer
, "Telnet"))
1346 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1347 if (!strcmp(buffer
, "Rlogin"))
1348 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1349 if (!strcmp(buffer
, "SSH"))
1350 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1351 if (!strcmp(buffer
, "Selection"))
1352 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1353 if (!strcmp(buffer
, "Colours"))
1354 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1355 if (!strcmp(buffer
, "Translation"))
1356 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1358 init_dlg_ctrls(hwnd
);
1360 SetFocus (((LPNMHDR
)lParam
)->hwndFrom
); /* ensure focus stays */
1366 * Only process WM_COMMAND once the dialog is fully formed.
1368 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
1371 EndDialog (hwnd
, 1);
1376 EndDialog (hwnd
, 0);
1378 case IDC_PROTTELNET
:
1379 case IDC_PROTRLOGIN
:
1382 if (HIWORD(wParam
) == BN_CLICKED
||
1383 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1384 int i
= IsDlgButtonChecked (hwnd
, IDC_PROTSSH
);
1385 int j
= IsDlgButtonChecked (hwnd
, IDC_PROTTELNET
);
1386 int k
= IsDlgButtonChecked (hwnd
, IDC_PROTRLOGIN
);
1387 cfg
.protocol
= i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
: PROT_RAW
;
1388 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22) ||
1389 (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23) ||
1390 (cfg
.protocol
== PROT_RLOGIN
&& cfg
.port
!= 513)) {
1391 cfg
.port
= i ?
22 : j ?
23 : 513;
1392 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1397 if (HIWORD(wParam
) == EN_CHANGE
)
1398 GetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
,
1399 sizeof(cfg
.host
)-1);
1402 if (HIWORD(wParam
) == EN_CHANGE
) {
1403 GetDlgItemText (hwnd
, IDC_PORT
, portname
, 31);
1404 if (isdigit(portname
[0]))
1405 MyGetDlgItemInt (hwnd
, IDC_PORT
, &cfg
.port
);
1407 service
= getservbyname(portname
, NULL
);
1408 if (service
) cfg
.port
= ntohs(service
->s_port
);
1414 if (HIWORD(wParam
) == EN_CHANGE
) {
1415 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1417 GetDlgItemText (hwnd
, IDC_SESSEDIT
,
1418 savedsession
, sizeof(savedsession
)-1);
1419 savedsession
[sizeof(savedsession
)-1] = '\0';
1423 if (HIWORD(wParam
) == BN_CLICKED
||
1424 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1429 GetDlgItemText (hwnd
, IDC_SESSEDIT
, str
, sizeof(str
)-1);
1431 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1432 LB_GETCURSEL
, 0, 0);
1437 strcpy (str
, sessions
[n
]);
1439 save_settings (str
, !!strcmp(str
, "Default Settings"), &cfg
);
1440 get_sesslist (FALSE
);
1441 get_sesslist (TRUE
);
1442 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1444 for (i
= 0; i
< nsessions
; i
++)
1445 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1446 0, (LPARAM
) (sessions
[i
]));
1447 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1453 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1454 HIWORD(wParam
) != BN_CLICKED
&&
1455 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1457 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1458 HIWORD(wParam
) != LBN_DBLCLK
)
1461 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1462 LB_GETCURSEL
, 0, 0);
1468 isdef
= !strcmp(sessions
[n
], "Default Settings");
1469 load_settings (sessions
[n
], !isdef
, &cfg
);
1470 init_dlg_ctrls(hwnd
);
1472 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1474 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1476 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1478 * A double-click on a saved session should
1479 * actually start the session, not just load it.
1480 * Unless it's Default Settings or some other
1481 * host-less set of saved settings.
1490 if (HIWORD(wParam
) == BN_CLICKED
||
1491 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1492 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1493 LB_GETCURSEL
, 0, 0);
1494 if (n
== LB_ERR
|| n
== 0) {
1498 del_settings(sessions
[n
]);
1499 get_sesslist (FALSE
);
1500 get_sesslist (TRUE
);
1501 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1503 for (i
= 0; i
< nsessions
; i
++)
1504 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1505 0, (LPARAM
) (sessions
[i
]));
1506 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1510 if (HIWORD(wParam
) == EN_CHANGE
)
1511 MyGetDlgItemInt (hwnd
, IDC_PINGEDIT
, &cfg
.ping_interval
);
1515 if (HIWORD(wParam
) == BN_CLICKED
||
1516 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1517 cfg
.bksp_is_delete
= IsDlgButtonChecked (hwnd
, IDC_DEL127
);
1521 if (HIWORD(wParam
) == BN_CLICKED
||
1522 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1523 cfg
.rxvt_homeend
= IsDlgButtonChecked (hwnd
, IDC_HOMERXVT
);
1529 case IDC_FUNCVT100P
:
1531 if (HIWORD(wParam
) == BN_CLICKED
||
1532 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1533 switch (LOWORD(wParam
)) {
1534 case IDC_FUNCTILDE
: cfg
.funky_type
= 0; break;
1535 case IDC_FUNCLINUX
: cfg
.funky_type
= 1; break;
1536 case IDC_FUNCXTERM
: cfg
.funky_type
= 2; break;
1537 case IDC_FUNCVT400
: cfg
.funky_type
= 3; break;
1538 case IDC_FUNCVT100P
: cfg
.funky_type
= 4; break;
1539 case IDC_FUNCSCO
: cfg
.funky_type
= 5; break;
1544 if (HIWORD(wParam
) == BN_CLICKED
||
1545 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1546 cfg
.app_keypad
= IsDlgButtonChecked (hwnd
, IDC_KPAPPLIC
);
1547 cfg
.nethack_keypad
= FALSE
;
1551 if (HIWORD(wParam
) == BN_CLICKED
||
1552 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1553 cfg
.app_keypad
= FALSE
;
1554 cfg
.nethack_keypad
= TRUE
;
1559 if (HIWORD(wParam
) == BN_CLICKED
||
1560 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1561 cfg
.app_cursor
= IsDlgButtonChecked (hwnd
, IDC_CURAPPLIC
);
1564 if (HIWORD(wParam
) == BN_CLICKED
||
1565 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1566 cfg
.no_applic_c
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICC
);
1569 if (HIWORD(wParam
) == BN_CLICKED
||
1570 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1571 cfg
.no_applic_k
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICK
);
1574 if (HIWORD(wParam
) == BN_CLICKED
||
1575 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1576 cfg
.alt_f4
= IsDlgButtonChecked (hwnd
, IDC_ALTF4
);
1579 if (HIWORD(wParam
) == BN_CLICKED
||
1580 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1581 cfg
.alt_space
= IsDlgButtonChecked (hwnd
, IDC_ALTSPACE
);
1584 if (HIWORD(wParam
) == BN_CLICKED
||
1585 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1586 cfg
.alt_only
= IsDlgButtonChecked (hwnd
, IDC_ALTONLY
);
1588 case IDC_ECHOBACKEND
:
1591 if (HIWORD(wParam
) == BN_CLICKED
||
1592 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1593 if (LOWORD(wParam
)==IDC_ECHOBACKEND
) cfg
.localecho
=LD_BACKEND
;
1594 if (LOWORD(wParam
)==IDC_ECHOYES
) cfg
.localecho
=LD_YES
;
1595 if (LOWORD(wParam
)==IDC_ECHONO
) cfg
.localecho
=LD_NO
;
1598 case IDC_EDITBACKEND
:
1601 if (HIWORD(wParam
) == BN_CLICKED
||
1602 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1603 if (LOWORD(wParam
)==IDC_EDITBACKEND
) cfg
.localedit
=LD_BACKEND
;
1604 if (LOWORD(wParam
)==IDC_EDITYES
) cfg
.localedit
=LD_YES
;
1605 if (LOWORD(wParam
)==IDC_EDITNO
) cfg
.localedit
=LD_NO
;
1608 case IDC_ANSWEREDIT
:
1609 if (HIWORD(wParam
) == EN_CHANGE
)
1610 GetDlgItemText (hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
1611 sizeof(cfg
.answerback
)-1);
1613 case IDC_ALWAYSONTOP
:
1614 if (HIWORD(wParam
) == BN_CLICKED
||
1615 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1616 cfg
.alwaysontop
= IsDlgButtonChecked (hwnd
, IDC_ALWAYSONTOP
);
1619 if (HIWORD(wParam
) == BN_CLICKED
||
1620 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1621 cfg
.scroll_on_key
= IsDlgButtonChecked (hwnd
, IDC_SCROLLKEY
);
1623 case IDC_SCROLLDISP
:
1624 if (HIWORD(wParam
) == BN_CLICKED
||
1625 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1626 cfg
.scroll_on_disp
= IsDlgButtonChecked (hwnd
, IDC_SCROLLDISP
);
1628 case IDC_COMPOSEKEY
:
1629 if (HIWORD(wParam
) == BN_CLICKED
||
1630 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1631 cfg
.compose_key
= IsDlgButtonChecked (hwnd
, IDC_COMPOSEKEY
);
1633 case IDC_CTRLALTKEYS
:
1634 if (HIWORD(wParam
) == BN_CLICKED
||
1635 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1636 cfg
.ctrlaltkeys
= IsDlgButtonChecked (hwnd
, IDC_CTRLALTKEYS
);
1639 if (HIWORD(wParam
) == BN_CLICKED
||
1640 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1641 cfg
.wrap_mode
= IsDlgButtonChecked (hwnd
, IDC_WRAPMODE
);
1644 if (HIWORD(wParam
) == BN_CLICKED
||
1645 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1646 cfg
.dec_om
= IsDlgButtonChecked (hwnd
, IDC_DECOM
);
1649 if (HIWORD(wParam
) == BN_CLICKED
||
1650 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1651 cfg
.lfhascr
= IsDlgButtonChecked (hwnd
, IDC_LFHASCR
);
1654 if (HIWORD(wParam
) == EN_CHANGE
)
1655 MyGetDlgItemInt (hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1658 if (HIWORD(wParam
) == EN_CHANGE
)
1659 MyGetDlgItemInt (hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1662 if (HIWORD(wParam
) == EN_CHANGE
)
1663 MyGetDlgItemInt (hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1665 case IDC_CHOOSEFONT
:
1666 lf
.lfHeight
= cfg
.fontheight
;
1667 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1668 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1669 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1670 lf
.lfCharSet
= cfg
.fontcharset
;
1671 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1672 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1673 lf
.lfQuality
= DEFAULT_QUALITY
;
1674 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1675 strncpy (lf
.lfFaceName
, cfg
.font
, sizeof(lf
.lfFaceName
)-1);
1676 lf
.lfFaceName
[sizeof(lf
.lfFaceName
)-1] = '\0';
1678 cf
.lStructSize
= sizeof(cf
);
1679 cf
.hwndOwner
= hwnd
;
1681 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1682 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1684 if (ChooseFont (&cf
)) {
1685 strncpy (cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
)-1);
1686 cfg
.font
[sizeof(cfg
.font
)-1] = '\0';
1687 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1688 cfg
.fontcharset
= lf
.lfCharSet
;
1689 cfg
.fontheight
= cf
.iPointSize
/ 10;
1690 fmtfont (fontstatic
);
1691 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
1694 case IDC_BELL_DISABLED
:
1695 case IDC_BELL_DEFAULT
:
1696 case IDC_BELL_WAVEFILE
:
1697 case IDC_BELL_VISUAL
:
1698 if (HIWORD(wParam
) == BN_CLICKED
||
1699 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1700 if (LOWORD(wParam
)==IDC_BELL_DISABLED
) cfg
.beep
= BELL_DISABLED
;
1701 if (LOWORD(wParam
)==IDC_BELL_DEFAULT
) cfg
.beep
= BELL_DEFAULT
;
1702 if (LOWORD(wParam
)==IDC_BELL_WAVEFILE
) cfg
.beep
= BELL_WAVEFILE
;
1703 if (LOWORD(wParam
)==IDC_BELL_VISUAL
) cfg
.beep
= BELL_VISUAL
;
1706 case IDC_BELL_WAVEBROWSE
:
1707 memset(&of
, 0, sizeof(of
));
1708 #ifdef OPENFILENAME_SIZE_VERSION_400
1709 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1711 of
.lStructSize
= sizeof(of
);
1713 of
.hwndOwner
= hwnd
;
1714 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
1715 of
.lpstrCustomFilter
= NULL
;
1716 of
.nFilterIndex
= 1;
1717 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.bell_wavefile
);
1718 of
.nMaxFile
= sizeof(filename
);
1719 of
.lpstrFileTitle
= NULL
;
1720 of
.lpstrInitialDir
= NULL
;
1721 of
.lpstrTitle
= "Select Bell Sound File";
1723 if (GetOpenFileName(&of
)) {
1724 strcpy(cfg
.bell_wavefile
, filename
);
1725 SetDlgItemText (hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
1728 case IDC_BELL_WAVEEDIT
:
1729 if (HIWORD(wParam
) == EN_CHANGE
)
1730 GetDlgItemText (hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
,
1731 sizeof(cfg
.bell_wavefile
)-1);
1734 if (HIWORD(wParam
) == BN_CLICKED
||
1735 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1736 cfg
.bellovl
= IsDlgButtonChecked (hwnd
, IDC_BELLOVL
);
1739 if (HIWORD(wParam
) == EN_CHANGE
)
1740 MyGetDlgItemInt (hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
1743 if (HIWORD(wParam
) == EN_CHANGE
)
1744 MyGetDlgItemFlt (hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
, 1000);
1747 if (HIWORD(wParam
) == EN_CHANGE
)
1748 MyGetDlgItemFlt (hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
, 1000);
1751 if (HIWORD(wParam
) == BN_CLICKED
||
1752 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1753 cfg
.blinktext
= IsDlgButtonChecked (hwnd
, IDC_BLINKTEXT
);
1756 if (HIWORD(wParam
) == BN_CLICKED
||
1757 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1758 cfg
.bce
= IsDlgButtonChecked (hwnd
, IDC_BCE
);
1761 if (HIWORD(wParam
) == BN_CLICKED
||
1762 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1763 cfg
.win_name_always
= IsDlgButtonChecked (hwnd
, IDC_WINNAME
);
1766 if (HIWORD(wParam
) == BN_CLICKED
||
1767 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1768 cfg
.hide_mouseptr
= IsDlgButtonChecked (hwnd
, IDC_HIDEMOUSE
);
1771 if (HIWORD(wParam
) == BN_CLICKED
||
1772 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1773 cfg
.cursor_type
= 0;
1776 if (HIWORD(wParam
) == BN_CLICKED
||
1777 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1778 cfg
.cursor_type
= 1;
1781 if (HIWORD(wParam
) == BN_CLICKED
||
1782 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1783 cfg
.cursor_type
= 2;
1786 if (HIWORD(wParam
) == BN_CLICKED
||
1787 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1788 cfg
.blink_cur
= IsDlgButtonChecked (hwnd
, IDC_BLINKCUR
);
1791 if (HIWORD(wParam
) == BN_CLICKED
||
1792 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1793 cfg
.scrollbar
= IsDlgButtonChecked (hwnd
, IDC_SCROLLBAR
);
1796 if (HIWORD(wParam
) == BN_CLICKED
||
1797 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1798 cfg
.locksize
= IsDlgButtonChecked (hwnd
, IDC_LOCKSIZE
);
1801 if (HIWORD(wParam
) == EN_CHANGE
)
1802 GetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
1803 sizeof(cfg
.wintitle
)-1);
1808 if (HIWORD(wParam
) == BN_CLICKED
||
1809 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1810 cfg
.close_on_exit
= IsDlgButtonChecked (hwnd
, IDC_COEALWAYS
) ? COE_ALWAYS
:
1811 IsDlgButtonChecked (hwnd
, IDC_COENEVER
) ? COE_NEVER
:
1816 if (HIWORD(wParam
) == BN_CLICKED
||
1817 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1818 cfg
.warn_on_close
= IsDlgButtonChecked (hwnd
, IDC_CLOSEWARN
);
1821 if (HIWORD(wParam
) == EN_CHANGE
)
1822 GetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
,
1823 sizeof(cfg
.termtype
)-1);
1826 if (HIWORD(wParam
) == EN_CHANGE
)
1827 GetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
1828 sizeof(cfg
.logfilename
)-1);
1831 memset(&of
, 0, sizeof(of
));
1832 #ifdef OPENFILENAME_SIZE_VERSION_400
1833 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1835 of
.lStructSize
= sizeof(of
);
1837 of
.hwndOwner
= hwnd
;
1838 of
.lpstrFilter
= "All Files\0*\0\0\0";
1839 of
.lpstrCustomFilter
= NULL
;
1840 of
.nFilterIndex
= 1;
1841 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.logfilename
);
1842 of
.nMaxFile
= sizeof(filename
);
1843 of
.lpstrFileTitle
= NULL
;
1844 of
.lpstrInitialDir
= NULL
;
1845 of
.lpstrTitle
= "Select session log file";
1847 if (GetSaveFileName(&of
)) {
1848 strcpy(cfg
.logfilename
, filename
);
1849 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
1853 case IDC_LSTATASCII
:
1855 if (HIWORD(wParam
) == BN_CLICKED
||
1856 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1857 if (IsDlgButtonChecked (hwnd
, IDC_LSTATOFF
)) cfg
.logtype
= 0;
1858 if (IsDlgButtonChecked (hwnd
, IDC_LSTATASCII
)) cfg
.logtype
= 1;
1859 if (IsDlgButtonChecked (hwnd
, IDC_LSTATRAW
)) cfg
.logtype
= 2;
1865 if (HIWORD(wParam
) == BN_CLICKED
||
1866 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1867 if (IsDlgButtonChecked (hwnd
, IDC_LSTATXASK
)) cfg
.logxfovr
= LGXF_ASK
;
1868 if (IsDlgButtonChecked (hwnd
, IDC_LSTATXAPN
)) cfg
.logxfovr
= LGXF_APN
;
1869 if (IsDlgButtonChecked (hwnd
, IDC_LSTATXOVR
)) cfg
.logxfovr
= LGXF_OVR
;
1874 if (HIWORD(wParam
) == EN_CHANGE
)
1875 GetDlgItemText (hwnd
, LOWORD(wParam
), cfg
.termspeed
,
1876 sizeof(cfg
.termspeed
)-1);
1879 if (HIWORD(wParam
) == EN_CHANGE
)
1880 GetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
,
1881 sizeof(cfg
.username
)-1);
1883 case IDC_RLLUSEREDIT
:
1884 if (HIWORD(wParam
) == EN_CHANGE
)
1885 GetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
,
1886 sizeof(cfg
.localusername
)-1);
1890 cfg
.rfc_environ
= IsDlgButtonChecked (hwnd
, IDC_EMRFC
);
1893 if (HIWORD(wParam
) == BN_CLICKED
||
1894 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1895 char str
[sizeof(cfg
.environmt
)];
1897 GetDlgItemText (hwnd
, IDC_VAREDIT
, str
, sizeof(str
)-1);
1902 p
= str
+ strlen(str
);
1904 GetDlgItemText (hwnd
, IDC_VALEDIT
, p
, sizeof(str
)-1-(p
-str
));
1914 if ((p
-cfg
.environmt
) + strlen(str
) + 2 < sizeof(cfg
.environmt
)) {
1916 p
[strlen(str
)+1] = '\0';
1917 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
1919 SetDlgItemText (hwnd
, IDC_VAREDIT
, "");
1920 SetDlgItemText (hwnd
, IDC_VALEDIT
, "");
1922 MessageBox(hwnd
, "Environment too big", "PuTTY Error",
1923 MB_OK
| MB_ICONERROR
);
1928 if (HIWORD(wParam
) != BN_CLICKED
&&
1929 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1931 i
= SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0, 0);
1937 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
1962 if (HIWORD(wParam
) == BN_CLICKED
||
1963 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1964 cfg
.nopty
= IsDlgButtonChecked (hwnd
, IDC_NOPTY
);
1967 if (HIWORD(wParam
) == BN_CLICKED
||
1968 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1969 cfg
.compression
= IsDlgButtonChecked (hwnd
, IDC_COMPRESS
);
1972 if (HIWORD(wParam
) == BN_CLICKED
||
1973 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1974 cfg
.buggymac
= IsDlgButtonChecked (hwnd
, IDC_BUGGYMAC
);
1977 if (HIWORD(wParam
) == BN_CLICKED
||
1978 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1979 cfg
.agentfwd
= IsDlgButtonChecked (hwnd
, IDC_AGENTFWD
);
1981 case IDC_CIPHER3DES
:
1982 case IDC_CIPHERBLOWF
:
1985 if (HIWORD(wParam
) == BN_CLICKED
||
1986 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1987 if (IsDlgButtonChecked (hwnd
, IDC_CIPHER3DES
))
1988 cfg
.cipher
= CIPHER_3DES
;
1989 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERBLOWF
))
1990 cfg
.cipher
= CIPHER_BLOWFISH
;
1991 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERDES
))
1992 cfg
.cipher
= CIPHER_DES
;
1993 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERAES
))
1994 cfg
.cipher
= CIPHER_AES
;
1999 if (HIWORD(wParam
) == BN_CLICKED
||
2000 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2001 if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT1
))
2003 else if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT2
))
2008 if (HIWORD(wParam
) == BN_CLICKED
||
2009 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2010 cfg
.try_tis_auth
= IsDlgButtonChecked (hwnd
, IDC_AUTHTIS
);
2013 if (HIWORD(wParam
) == EN_CHANGE
)
2014 GetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
2015 sizeof(cfg
.keyfile
)-1);
2018 if (HIWORD(wParam
) == EN_CHANGE
)
2019 GetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
2020 sizeof(cfg
.remote_cmd
)-1);
2023 memset(&of
, 0, sizeof(of
));
2024 #ifdef OPENFILENAME_SIZE_VERSION_400
2025 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
2027 of
.lStructSize
= sizeof(of
);
2029 of
.hwndOwner
= hwnd
;
2030 of
.lpstrFilter
= "All Files\0*\0\0\0";
2031 of
.lpstrCustomFilter
= NULL
;
2032 of
.nFilterIndex
= 1;
2033 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
2034 of
.nMaxFile
= sizeof(filename
);
2035 of
.lpstrFileTitle
= NULL
;
2036 of
.lpstrInitialDir
= NULL
;
2037 of
.lpstrTitle
= "Select Public Key File";
2039 if (GetOpenFileName(&of
)) {
2040 strcpy(cfg
.keyfile
, filename
);
2041 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
2045 cfg
.rawcnp
= IsDlgButtonChecked (hwnd
, IDC_RAWCNP
);
2048 cfg
.mouse_is_xterm
= IsDlgButtonChecked (hwnd
, IDC_MBXTERM
);
2054 int n
= GetDlgItemInt (hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
2059 for (i
=0; i
<256; i
++)
2060 if (SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_GETSEL
,
2063 cfg
.wordness
[i
] = n
;
2064 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
2065 LB_DELETESTRING
, i
, 0);
2066 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
2067 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
2069 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
2076 case IDC_BOLDCOLOUR
:
2077 if (HIWORD(wParam
) == BN_CLICKED
||
2078 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2080 cfg
.bold_colour
= IsDlgButtonChecked (hwnd
, IDC_BOLDCOLOUR
);
2081 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
2082 if (n
!= 12+10*cfg
.bold_colour
) {
2084 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
2085 LB_DELETESTRING
, i
, 0);
2086 for (i
=0; i
<22; i
++)
2087 if (cfg
.bold_colour
|| permcolour
[i
])
2088 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
2090 (LPARAM
) colours
[i
]);
2095 if (HIWORD(wParam
) == BN_CLICKED
||
2096 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2097 cfg
.try_palette
= IsDlgButtonChecked (hwnd
, IDC_PALETTE
);
2099 case IDC_COLOURLIST
:
2100 if (HIWORD(wParam
) == LBN_DBLCLK
||
2101 HIWORD(wParam
) == LBN_SELCHANGE
) {
2102 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
2104 if (!cfg
.bold_colour
)
2105 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
2106 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0], FALSE
);
2107 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1], FALSE
);
2108 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2], FALSE
);
2112 if (HIWORD(wParam
) == BN_CLICKED
||
2113 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2114 static CHOOSECOLOR cc
;
2115 static DWORD custom
[16] = {0}; /* zero initialisers */
2116 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
2118 if (!cfg
.bold_colour
)
2119 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
2120 cc
.lStructSize
= sizeof(cc
);
2121 cc
.hwndOwner
= hwnd
;
2122 cc
.hInstance
= (HWND
)hinst
;
2123 cc
.lpCustColors
= custom
;
2124 cc
.rgbResult
= RGB (cfg
.colours
[i
][0], cfg
.colours
[i
][1],
2126 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
2127 if (ChooseColor(&cc
)) {
2129 (unsigned char) (cc
.rgbResult
& 0xFF);
2131 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
2133 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
2134 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2136 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2138 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2144 case IDC_KOI8WIN1251
:
2145 case IDC_88592WIN1250
:
2146 case IDC_88592CP852
:
2147 cfg
.xlat_enablekoiwin
=
2148 IsDlgButtonChecked (hwnd
, IDC_KOI8WIN1251
);
2149 cfg
.xlat_88592w1250
=
2150 IsDlgButtonChecked (hwnd
, IDC_88592WIN1250
);
2151 cfg
.xlat_88592cp852
=
2152 IsDlgButtonChecked (hwnd
, IDC_88592CP852
);
2154 case IDC_CAPSLOCKCYR
:
2155 if (HIWORD(wParam
) == BN_CLICKED
||
2156 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2157 cfg
.xlat_capslockcyr
=
2158 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
2161 case IDC_VTXWINDOWS
:
2166 (IsDlgButtonChecked (hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
:
2167 IsDlgButtonChecked (hwnd
, IDC_VTOEMANSI
) ? VT_OEMANSI
:
2168 IsDlgButtonChecked (hwnd
, IDC_VTOEMONLY
) ? VT_OEMONLY
:
2171 case IDC_X11_FORWARD
:
2172 if (HIWORD(wParam
) == BN_CLICKED
||
2173 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2174 cfg
.x11_forward
= IsDlgButtonChecked (hwnd
, IDC_X11_FORWARD
);
2176 case IDC_X11_DISPLAY
:
2177 if (HIWORD(wParam
) == EN_CHANGE
)
2178 GetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
2179 sizeof(cfg
.x11_display
)-1);
2184 EndDialog (hwnd
, 0);
2187 /* Grrr Explorer will maximize Dialogs! */
2189 if (wParam
== SIZE_MAXIMIZED
)
2196 static int CALLBACK
MainDlgProc (HWND hwnd
, UINT msg
,
2197 WPARAM wParam
, LPARAM lParam
) {
2198 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
2200 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
2201 EnableWindow(hwnd
, 0);
2202 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2203 GetParent(hwnd
), AboutProc
);
2204 EnableWindow(hwnd
, 1);
2205 SetActiveWindow(hwnd
);
2207 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 0);
2210 static int CALLBACK
ReconfDlgProc (HWND hwnd
, UINT msg
,
2211 WPARAM wParam
, LPARAM lParam
) {
2212 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 1);
2215 void defuse_showwindow(void) {
2217 * Work around the fact that the app's first call to ShowWindow
2218 * will ignore the default in favour of the shell-provided
2223 hwnd
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2225 ShowWindow(hwnd
, SW_HIDE
);
2226 DestroyWindow(hwnd
);
2230 int do_config (void) {
2234 savedsession
[0] = '\0';
2235 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2236 get_sesslist(FALSE
);
2241 int do_reconfig (HWND hwnd
) {
2245 backup_cfg
= cfg
; /* structure copy */
2246 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2248 cfg
= backup_cfg
; /* structure copy */
2253 void logevent (char *string
) {
2257 if (nevents
>= negsize
) {
2259 events
= srealloc (events
, negsize
* sizeof(*events
));
2263 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t", localtime(&t
));
2265 events
[nevents
] = smalloc(strlen(timebuf
)+strlen(string
)+1);
2266 strcpy(events
[nevents
], timebuf
);
2267 strcat(events
[nevents
], string
);
2270 SendDlgItemMessage (logbox
, IDN_LIST
, LB_ADDSTRING
,
2271 0, (LPARAM
)events
[nevents
]);
2272 count
= SendDlgItemMessage (logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2273 SendDlgItemMessage (logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
-1, 0);
2278 void showeventlog (HWND hwnd
) {
2280 logbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2282 ShowWindow (logbox
, SW_SHOWNORMAL
);
2284 SetActiveWindow(logbox
);
2287 void showabout (HWND hwnd
) {
2288 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),hwnd
, AboutProc
);
2291 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2292 char *keystr
, char *fingerprint
) {
2295 static const char absentmsg
[] =
2296 "The server's host key is not cached in the registry. You\n"
2297 "have no guarantee that the server is the computer you\n"
2299 "The server's key fingerprint is:\n"
2301 "If you trust this host, hit Yes to add the key to\n"
2302 "PuTTY's cache and carry on connecting.\n"
2303 "If you do not trust this host, hit No to abandon the\n"
2306 static const char wrongmsg
[] =
2307 "WARNING - POTENTIAL SECURITY BREACH!\n"
2309 "The server's host key does not match the one PuTTY has\n"
2310 "cached in the registry. This means that either the\n"
2311 "server administrator has changed the host key, or you\n"
2312 "have actually connected to another computer pretending\n"
2313 "to be the server.\n"
2314 "The new key fingerprint is:\n"
2316 "If you were expecting this change and trust the new key,\n"
2317 "hit Yes to update PuTTY's cache and continue connecting.\n"
2318 "If you want to carry on connecting but without updating\n"
2319 "the cache, hit No.\n"
2320 "If you want to abandon the connection completely, hit\n"
2321 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2324 static const char mbtitle
[] = "PuTTY Security Alert";
2327 char message
[160+ /* sensible fingerprint max size */
2328 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2329 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2332 * Verify the key against the registry.
2334 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2336 if (ret
== 0) /* success - key matched OK */
2338 if (ret
== 2) { /* key was different */
2340 sprintf(message
, wrongmsg
, fingerprint
);
2341 mbret
= MessageBox(NULL
, message
, mbtitle
,
2342 MB_ICONWARNING
| MB_YESNOCANCEL
);
2344 store_host_key(host
, port
, keytype
, keystr
);
2345 if (mbret
== IDCANCEL
)
2348 if (ret
== 1) { /* key was absent */
2350 sprintf(message
, absentmsg
, fingerprint
);
2351 mbret
= MessageBox(NULL
, message
, mbtitle
,
2352 MB_ICONWARNING
| MB_YESNO
);
2355 store_host_key(host
, port
, keytype
, keystr
);
2360 * Ask whether to wipe a session log file before writing to it.
2361 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2363 int askappend(char *filename
) {
2364 static const char mbtitle
[] = "PuTTY Log to File";
2365 static const char msgtemplate
[] =
2366 "The session log file \"%.*s\" already exists.\n"
2367 "You can overwrite it with a new session log,\n"
2368 "append your session log to the end of it,\n"
2369 "or disable session logging for this session.\n"
2370 "Hit Yes to wipe the file, No to append to it,\n"
2371 "or Cancel to disable logging.";
2372 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2374 if ( cfg
.logxfovr
!= LGXF_ASK
) {
2375 return ( (cfg
.logxfovr
==LGXF_OVR
) ?
2 : 1);
2377 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2379 mbret
= MessageBox(NULL
, message
, mbtitle
,
2380 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2383 else if (mbret
== IDNO
)