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 int CALLBACK
LogProc (HWND hwnd
, UINT msg
,
47 WPARAM wParam
, LPARAM lParam
) {
53 static int tabs
[4] = {78, 108};
54 SendDlgItemMessage (hwnd
, IDN_LIST
, LB_SETTABSTOPS
, 2,
57 for (i
=0; i
<nevents
; i
++)
58 SendDlgItemMessage (hwnd
, IDN_LIST
, LB_ADDSTRING
,
59 0, (LPARAM
)events
[i
]);
62 switch (LOWORD(wParam
)) {
66 SetActiveWindow(GetParent(hwnd
));
70 if (HIWORD(wParam
) == BN_CLICKED
||
71 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
74 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
75 LB_GETSELCOUNT
, 0, 0);
76 if (selcount
== 0) { /* don't even try to copy zero items */
81 selitems
= smalloc(selcount
* sizeof(int));
83 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
85 selcount
, (LPARAM
)selitems
);
89 static unsigned char sel_nl
[] = SEL_NL
;
91 if (count
== 0) { /* can't copy zero stuff */
97 for (i
= 0; i
< count
; i
++)
98 size
+= strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
100 clipdata
= smalloc(size
);
103 for (i
= 0; i
< count
; i
++) {
104 char *q
= events
[selitems
[i
]];
105 int qlen
= strlen(q
);
108 memcpy(p
, sel_nl
, sizeof(sel_nl
));
111 write_clip(clipdata
, size
, TRUE
);
116 for (i
= 0; i
< nevents
; i
++)
117 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
126 SetActiveWindow(GetParent(hwnd
));
127 DestroyWindow (hwnd
);
133 static int CALLBACK
LicenceProc (HWND hwnd
, UINT msg
,
134 WPARAM wParam
, LPARAM lParam
) {
139 switch (LOWORD(wParam
)) {
152 static int CALLBACK
AboutProc (HWND hwnd
, UINT msg
,
153 WPARAM wParam
, LPARAM lParam
) {
156 SetDlgItemText (hwnd
, IDA_VERSION
, ver
);
159 switch (LOWORD(wParam
)) {
162 EndDialog(hwnd
, TRUE
);
165 EnableWindow(hwnd
, 0);
166 DialogBox (hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
168 EnableWindow(hwnd
, 1);
169 SetActiveWindow(hwnd
);
173 /* Load web browser */
174 ShellExecute(hwnd
, "open",
175 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
176 0, 0, SW_SHOWDEFAULT
);
181 EndDialog(hwnd
, TRUE
);
188 * Null dialog procedure.
190 static int CALLBACK
NullDlgProc (HWND hwnd
, UINT msg
,
191 WPARAM wParam
, LPARAM lParam
) {
195 static char savedsession
[2048];
197 enum { IDCX_ABOUT
= IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
331 appearancepanelstart
,
332 IDC_TITLE_APPEARANCE
,
350 connectionpanelstart
,
351 IDC_TITLE_CONNECTION
,
449 translationpanelstart
,
450 IDC_TITLE_TRANSLATION
,
451 IDC_BOX_TRANSLATION1
,
452 IDC_BOX_TRANSLATION2
,
453 IDC_BOX_TRANSLATION3
,
478 static const char *const colours
[] = {
479 "Default Foreground", "Default Bold Foreground",
480 "Default Background", "Default Bold Background",
481 "Cursor Text", "Cursor Colour",
482 "ANSI Black", "ANSI Black Bold",
483 "ANSI Red", "ANSI Red Bold",
484 "ANSI Green", "ANSI Green Bold",
485 "ANSI Yellow", "ANSI Yellow Bold",
486 "ANSI Blue", "ANSI Blue Bold",
487 "ANSI Magenta", "ANSI Magenta Bold",
488 "ANSI Cyan", "ANSI Cyan Bold",
489 "ANSI White", "ANSI White Bold"
491 static const int permcolour
[] = {
492 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
493 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
494 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
497 static void fmtfont (char *buf
) {
498 sprintf (buf
, "Font: %s, ", cfg
.font
);
500 strcat(buf
, "bold, ");
501 if (cfg
.fontheight
== 0)
502 strcat (buf
, "default height");
504 sprintf (buf
+strlen(buf
), "%d-point",
505 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
508 static void init_dlg_ctrls(HWND hwnd
) {
510 char fontstatic
[256];
512 SetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
);
513 SetDlgItemText (hwnd
, IDC_SESSEDIT
, savedsession
);
516 n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
518 SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
519 LB_DELETESTRING
, i
, 0);
520 for (i
= 0; i
< nsessions
; i
++)
521 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
522 0, (LPARAM
) (sessions
[i
]));
524 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
525 CheckRadioButton (hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
526 cfg
.protocol
==PROT_SSH ? IDC_PROTSSH
:
527 cfg
.protocol
==PROT_TELNET ? IDC_PROTTELNET
:
528 cfg
.protocol
==PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
529 SetDlgItemInt (hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
531 CheckRadioButton (hwnd
, IDC_DEL008
, IDC_DEL127
,
532 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
533 CheckRadioButton (hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
534 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
535 CheckRadioButton (hwnd
, IDC_FUNCTILDE
, IDC_FUNCVT400
,
536 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
537 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
538 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
539 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
541 CheckDlgButton (hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
542 CheckDlgButton (hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
543 CheckRadioButton (hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
544 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
545 CheckRadioButton (hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
546 cfg
.nethack_keypad ? IDC_KPNH
:
547 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
548 CheckDlgButton (hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
549 CheckDlgButton (hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
550 CheckDlgButton (hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
551 CheckDlgButton (hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
552 CheckDlgButton (hwnd
, IDC_CTRLALTKEYS
, cfg
.ctrlaltkeys
);
553 CheckRadioButton (hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
554 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
555 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
556 CheckRadioButton (hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
557 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
558 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
559 SetDlgItemText (hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
);
560 CheckDlgButton (hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
561 CheckDlgButton (hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
562 CheckDlgButton (hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
564 CheckDlgButton (hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
565 CheckDlgButton (hwnd
, IDC_DECOM
, cfg
.dec_om
);
566 CheckDlgButton (hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
567 SetDlgItemInt (hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
568 SetDlgItemInt (hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
569 SetDlgItemInt (hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
570 fmtfont (fontstatic
);
571 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
572 CheckRadioButton (hwnd
, IDC_BELL_DISABLED
, IDC_BELL_VISUAL
,
573 cfg
.beep
==BELL_DISABLED ? IDC_BELL_DISABLED
:
574 cfg
.beep
==BELL_DEFAULT ? IDC_BELL_DEFAULT
:
575 cfg
.beep
==BELL_WAVEFILE ? IDC_BELL_WAVEFILE
:
576 cfg
.beep
==BELL_VISUAL ? IDC_BELL_VISUAL
: IDC_BELL_DEFAULT
);
577 SetDlgItemText (hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
578 CheckDlgButton (hwnd
, IDC_BELLOVL
, cfg
.bellovl
);
579 SetDlgItemInt (hwnd
, IDC_BELLOVLN
, cfg
.bellovl_n
, FALSE
);
580 SetDlgItemInt (hwnd
, IDC_BELLOVLT
, cfg
.bellovl_t
, FALSE
);
581 SetDlgItemInt (hwnd
, IDC_BELLOVLS
, cfg
.bellovl_s
, FALSE
);
583 CheckDlgButton (hwnd
, IDC_BCE
, cfg
.bce
);
584 CheckDlgButton (hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
586 SetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
587 CheckDlgButton (hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
588 CheckDlgButton (hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
589 CheckRadioButton (hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
590 cfg
.cursor_type
==0 ? IDC_CURBLOCK
:
591 cfg
.cursor_type
==1 ? IDC_CURUNDER
: IDC_CURVERT
);
592 CheckDlgButton (hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
593 CheckDlgButton (hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
594 CheckDlgButton (hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
595 CheckRadioButton (hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
596 cfg
.close_on_exit
==COE_NORMAL ? IDC_COENORMAL
:
597 cfg
.close_on_exit
==COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
598 CheckDlgButton (hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
600 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
601 SetDlgItemText (hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
602 SetDlgItemText (hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
603 SetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
604 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
605 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
606 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
607 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
608 cfg
.logtype
== 1 ? IDC_LSTATASCII
:
611 char *p
= cfg
.environmt
;
613 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
618 CheckRadioButton (hwnd
, IDC_EMBSD
, IDC_EMRFC
,
619 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
621 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
622 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
623 CheckDlgButton (hwnd
, IDC_NOPTY
, cfg
.nopty
);
624 CheckDlgButton (hwnd
, IDC_COMPRESS
, cfg
.compression
);
625 CheckDlgButton (hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
626 CheckDlgButton (hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
627 CheckRadioButton (hwnd
, IDC_CIPHER3DES
, IDC_CIPHERAES
,
628 cfg
.cipher
== CIPHER_BLOWFISH ? IDC_CIPHERBLOWF
:
629 cfg
.cipher
== CIPHER_DES ? IDC_CIPHERDES
:
630 cfg
.cipher
== CIPHER_AES ? IDC_CIPHERAES
:
632 CheckRadioButton (hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
633 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
634 CheckDlgButton (hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
635 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
636 SetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
638 CheckRadioButton (hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
639 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
640 CheckDlgButton (hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
642 static int tabs
[4] = {25, 61, 96, 128};
643 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
646 for (i
=0; i
<256; i
++) {
648 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
649 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
651 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
655 CheckDlgButton (hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
656 CheckDlgButton (hwnd
, IDC_PALETTE
, cfg
.try_palette
);
659 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
661 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
662 LB_DELETESTRING
, i
, 0);
664 if (cfg
.bold_colour
|| permcolour
[i
])
665 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
666 (LPARAM
) colours
[i
]);
668 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
669 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
670 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
671 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
673 CheckRadioButton (hwnd
, IDC_NOXLAT
, IDC_88592CP852
,
674 cfg
.xlat_88592w1250 ? IDC_88592WIN1250
:
675 cfg
.xlat_88592cp852 ? IDC_88592CP852
:
676 cfg
.xlat_enablekoiwin ? IDC_KOI8WIN1251
:
678 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
679 CheckRadioButton (hwnd
, IDC_VTXWINDOWS
, IDC_VTPOORMAN
,
680 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
681 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
682 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
685 CheckDlgButton (hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
686 SetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
689 struct treeview_faff
{
694 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
695 int level
, char *text
) {
699 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
-1] : TVI_ROOT
);
700 ins
.hInsertAfter
= faff
->lastat
[level
];
701 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
702 #define INSITEM DUMMYUNIONNAME.item
706 ins
.INSITEM
.mask
= TVIF_TEXT
;
707 ins
.INSITEM
.pszText
= text
;
708 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
710 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
-1], TVE_EXPAND
);
711 faff
->lastat
[level
] = newitem
;
712 for (i
= level
+1; i
< 4; i
++) faff
->lastat
[i
] = NULL
;
717 * Create the panelfuls of controls in the configuration box.
719 static void create_controls(HWND hwnd
, int dlgtype
, int panel
) {
720 if (panel
== sessionpanelstart
) {
721 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
723 ctlposinit(&cp
, hwnd
, 80, 3, 13);
724 bartitle(&cp
, "Basic options for your PuTTY session",
727 beginbox(&cp
, "Specify your connection by host name",
730 "Host &Name", IDC_HOSTSTATIC
, IDC_HOST
, 75,
731 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
732 if (backends
[3].backend
== NULL
) {
733 /* this is PuTTYtel, so only three protocols available */
734 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
736 "&Telnet", IDC_PROTTELNET
,
737 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
739 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
741 "&Telnet", IDC_PROTTELNET
,
742 "Rlog&in", IDC_PROTRLOGIN
,
751 beginbox(&cp
, "Load, save or delete a stored session",
753 sesssaver(&cp
, "Sav&ed Sessions",
754 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
755 "&Load", IDC_SESSLOAD
,
756 "&Save", IDC_SESSSAVE
,
757 "&Delete", IDC_SESSDEL
, NULL
);
760 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
761 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
762 "Always", IDC_COEALWAYS
,
763 "Never", IDC_COENEVER
,
764 "Only on clean exit", IDC_COENORMAL
, NULL
);
768 if (panel
== loggingpanelstart
) {
769 /* The Logging panel. Accelerators used: [acgo] tplfw */
771 ctlposinit(&cp
, hwnd
, 80, 3, 13);
772 bartitle(&cp
, "Options controlling session logging",
774 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
776 "Session logging:", IDC_LSTATSTATIC
,
777 "Logging &turned off completely", IDC_LSTATOFF
,
778 "Log &printable output only", IDC_LSTATASCII
,
779 "&Log all session output", IDC_LSTATRAW
, NULL
);
780 editbutton(&cp
, "Log &file name:",
781 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
786 if (panel
== terminalpanelstart
) {
787 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
789 ctlposinit(&cp
, hwnd
, 80, 3, 13);
790 bartitle(&cp
, "Options controlling the terminal emulation",
792 beginbox(&cp
, "Set various terminal options",
794 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
795 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
796 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
797 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
798 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
800 "An&swerback to ^E:", IDC_ANSWERBACK
,
801 IDC_ANSWEREDIT
, 100, NULL
);
804 beginbox(&cp
, "Line discipline options",
806 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
807 "Auto", IDC_ECHOBACKEND
,
808 "Force on", IDC_ECHOYES
,
809 "Force off", IDC_ECHONO
, NULL
);
810 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
811 "Auto", IDC_EDITBACKEND
,
812 "Force on", IDC_EDITYES
,
813 "Force off", IDC_EDITNO
, NULL
);
817 if (panel
== bellpanelstart
) {
818 /* The Bell panel. Accelerators used: [acgo] bdsm w */
820 ctlposinit(&cp
, hwnd
, 80, 3, 13);
821 bartitle(&cp
, "Options controlling the terminal bell",
823 beginbox(&cp
, "Set the style of bell",
826 "Action to happen when a &bell occurs:", IDC_BELLSTATIC
,
827 "None (bell disabled)", IDC_BELL_DISABLED
,
828 "Play Windows Default Sound", IDC_BELL_DEFAULT
,
829 "Play a custom sound file", IDC_BELL_WAVEFILE
,
830 "Visual bell (flash window)", IDC_BELL_VISUAL
, NULL
);
831 editbutton(&cp
, "Custom sound file to play as a bell:",
832 IDC_BELL_WAVESTATIC
, IDC_BELL_WAVEEDIT
,
833 "Bro&wse...", IDC_BELL_WAVEBROWSE
);
835 beginbox(&cp
, "Control the bell overload behaviour",
837 checkbox(&cp
, "Bell is temporarily &disabled when over-used",
839 staticedit(&cp
, "Over-use means this &many bells...",
840 IDC_BELLOVLNSTATIC
, IDC_BELLOVLN
, 20);
841 staticedit(&cp
, "... in this many &seconds",
842 IDC_BELLOVLTSTATIC
, IDC_BELLOVLT
, 20);
843 statictext(&cp
, "The bell is re-enabled after a few seconds of silence.",
845 staticedit(&cp
, "Seconds of silence required",
846 IDC_BELLOVLSSTATIC
, IDC_BELLOVLS
, 20);
850 if (panel
== keyboardpanelstart
) {
851 /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxvunpymietd */
853 ctlposinit(&cp
, hwnd
, 80, 3, 13);
854 bartitle(&cp
, "Options controlling the effects of keys",
856 beginbox(&cp
, "Change the sequences sent by:",
858 radioline(&cp
, "The Backspace key", IDC_DELSTATIC
, 2,
859 "Control-&H", IDC_DEL008
,
860 "Control-&? (127)", IDC_DEL127
, NULL
);
861 radioline(&cp
, "The Home and End keys", IDC_HOMESTATIC
, 2,
862 "&Standard", IDC_HOMETILDE
,
863 "&rxvt", IDC_HOMERXVT
, NULL
);
864 radioline(&cp
, "The Function keys and keypad", IDC_FUNCSTATIC
, 4,
865 "ESC[n&~", IDC_FUNCTILDE
,
866 "&Linux", IDC_FUNCLINUX
,
867 "&Xterm R6", IDC_FUNCXTERM
,
868 "&VT400", IDC_FUNCVT400
, NULL
);
870 beginbox(&cp
, "Application keypad settings:",
873 "Application c&ursor keys totally disabled",
875 radioline(&cp
, "Initial state of cursor keys:", IDC_CURSTATIC
, 2,
876 "&Normal", IDC_CURNORMAL
,
877 "A&pplication", IDC_CURAPPLIC
, NULL
);
879 "Application ke&ypad keys totally disabled",
881 radioline(&cp
, "Initial state of numeric keypad:", IDC_KPSTATIC
, 3,
882 "Nor&mal", IDC_KPNORMAL
,
883 "Appl&ication", IDC_KPAPPLIC
,
884 "N&etHack", IDC_KPNH
, NULL
);
886 beginbox(&cp
, "Enable extra keyboard features:",
888 checkbox(&cp
, "AltGr ac&ts as Compose key",
890 checkbox(&cp
, "Control-Alt is &different from AltGr",
895 if (panel
== windowpanelstart
) {
896 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
898 ctlposinit(&cp
, hwnd
, 80, 3, 13);
899 bartitle(&cp
, "Options controlling PuTTY's window",
901 beginbox(&cp
, "Set the size of the window",
904 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
905 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50,
907 checkbox(&cp
, "Lock window size against resi&zing", IDC_LOCKSIZE
);
909 beginbox(&cp
, "Control the scrollback in the window",
911 staticedit(&cp
, "Lines of &scrollback",
912 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
913 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
914 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
915 checkbox(&cp
, "Reset scrollback on dis&play activity",
918 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
919 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
920 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
921 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
922 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
923 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
927 if (panel
== appearancepanelstart
) {
928 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p */
930 ctlposinit(&cp
, hwnd
, 80, 3, 13);
931 bartitle(&cp
, "Options controlling PuTTY's appearance",
932 IDC_TITLE_APPEARANCE
);
933 beginbox(&cp
, "Adjust the use of the cursor",
934 IDC_BOX_APPEARANCE1
);
935 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
936 "B&lock", IDC_CURBLOCK
,
937 "&Underline", IDC_CURUNDER
,
938 "&Vertical line", IDC_CURVERT
,
940 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
942 beginbox(&cp
, "Set the font used in the terminal window",
943 IDC_BOX_APPEARANCE2
);
944 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
946 beginbox(&cp
, "Adjust the use of the window title",
947 IDC_BOX_APPEARANCE3
);
949 "Window &title:", IDC_WINTITLE
,
950 IDC_WINEDIT
, 100, NULL
);
951 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
953 beginbox(&cp
, "Adjust the use of the mouse pointer",
954 IDC_BOX_APPEARANCE4
);
955 checkbox(&cp
, "Hide mouse &pointer when typing in window",
960 if (panel
== translationpanelstart
) {
961 /* The Translation panel. Accelerators used: [acgo] xbep t s */
963 ctlposinit(&cp
, hwnd
, 80, 3, 13);
964 bartitle(&cp
, "Options controlling character set translation",
965 IDC_TITLE_TRANSLATION
);
966 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
967 IDC_BOX_TRANSLATION1
);
969 "Handling of line drawing characters:", IDC_VTSTATIC
,
970 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
971 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
972 "Use font in O&EM mode only", IDC_VTOEMONLY
,
973 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
974 IDC_VTPOORMAN
, NULL
);
976 beginbox(&cp
, "Enable character set translation on received data",
977 IDC_BOX_TRANSLATION2
);
979 "Character set &translation:", IDC_XLATSTATIC
,
981 "KOI8 / Win-1251", IDC_KOI8WIN1251
,
982 "ISO-8859-2 / Win-1250", IDC_88592WIN1250
,
983 "ISO-8859-2 / CP852", IDC_88592CP852
, NULL
);
985 beginbox(&cp
, "Enable character set translation on input data",
986 IDC_BOX_TRANSLATION3
);
987 checkbox(&cp
, "CAP&S LOCK acts as cyrillic switch",
992 if (panel
== selectionpanelstart
) {
993 /* The Selection panel. Accelerators used: [acgo] d wx hst */
995 ctlposinit(&cp
, hwnd
, 80, 3, 13);
996 bartitle(&cp
, "Options controlling copy and paste",
997 IDC_TITLE_SELECTION
);
998 beginbox(&cp
, "Translation of pasted characters",
1000 checkbox(&cp
, "&Don't translate line drawing chars into +, - and |",
1003 beginbox(&cp
, "Control which mouse button does which thing",
1004 IDC_BOX_SELECTION2
);
1005 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
1006 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
1007 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
1010 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
1011 IDC_BOX_SELECTION3
);
1012 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
1013 "&Set", IDC_CCSET
, IDC_CCEDIT
,
1014 "&to class", IDC_CCSTATIC2
);
1018 if (panel
== colourspanelstart
) {
1019 /* The Colours panel. Accelerators used: [acgo] blum */
1021 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1022 bartitle(&cp
, "Options controlling use of colours",
1024 beginbox(&cp
, "General options for colour usage",
1026 checkbox(&cp
, "&Bolded text is a different colour", IDC_BOLDCOLOUR
);
1027 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
1029 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
1031 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
1032 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
1033 "&Modify...", IDC_CHANGE
,
1034 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
1035 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
1036 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
1040 if (panel
== connectionpanelstart
) {
1041 /* The Connection panel. Accelerators used: [acgo] tuk */
1043 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1044 bartitle(&cp
, "Options controlling the connection", IDC_TITLE_CONNECTION
);
1046 beginbox(&cp
, "Data to send to the server",
1047 IDC_BOX_CONNECTION1
);
1048 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
, IDC_TTEDIT
, 50);
1049 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
, IDC_LOGEDIT
, 50);
1052 beginbox(&cp
, "Sending of null packets to keep session active",
1053 IDC_BOX_CONNECTION2
);
1054 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1055 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
1059 if (panel
== telnetpanelstart
) {
1060 /* The Telnet panel. Accelerators used: [acgo] svldr bf */
1062 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1064 bartitle(&cp
, "Options controlling Telnet connections", IDC_TITLE_TELNET
);
1065 beginbox(&cp
, "Data to send to the server",
1067 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
, IDC_TSEDIT
, 50);
1068 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1069 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
,
1070 "Va&lue", IDC_VALSTATIC
, IDC_VALEDIT
,
1072 "A&dd", IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1074 beginbox(&cp
, "Telnet protocol adjustments",
1076 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC
, 2,
1077 "&BSD (commonplace)", IDC_EMBSD
,
1078 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1083 if (panel
== rloginpanelstart
) {
1084 /* The Rlogin panel. Accelerators used: [acgo] sl */
1086 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1088 bartitle(&cp
, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN
);
1089 beginbox(&cp
, "Data to send to the server",
1091 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
, IDC_R_TSEDIT
, 50);
1092 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
, IDC_RLLUSEREDIT
, 50);
1097 if (panel
== sshpanelstart
) {
1098 /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bds i */
1100 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1102 bartitle(&cp
, "Options controlling SSH connections", IDC_TITLE_SSH
);
1103 beginbox(&cp
, "Data to send to the server",
1106 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1109 beginbox(&cp
, "Authentication options",
1111 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1113 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1114 editbutton(&cp
, "Private &key file for authentication:",
1115 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...", IDC_PKBUTTON
);
1117 beginbox(&cp
, "Protocol options",
1119 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1120 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1121 radioline(&cp
, "Preferred SSH protocol version:",
1122 IDC_SSHPROTSTATIC
, 2,
1123 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1124 radioline(&cp
, "Preferred encryption algorithm:", IDC_CIPHERSTATIC
, 4,
1125 "&3DES", IDC_CIPHER3DES
,
1126 "&Blowfish", IDC_CIPHERBLOWF
,
1127 "&DES", IDC_CIPHERDES
,
1128 "AE&S", IDC_CIPHERAES
,
1130 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1136 if (panel
== tunnelspanelstart
) {
1137 /* The Tunnels panel. Accelerators used: [acgo] ex */
1139 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1141 bartitle(&cp
, "Options controlling SSH tunnelling",
1143 beginbox(&cp
, "X11 forwarding options",
1145 checkbox(&cp
, "&Enable X11 forwarding",
1147 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1148 IDC_X11_DISPLAY
, 50, NULL
);
1155 * This function is the configuration box.
1157 static int GenericMainDlgProc (HWND hwnd
, UINT msg
,
1158 WPARAM wParam
, LPARAM lParam
,
1161 struct treeview_faff tvfaff
;
1164 char filename
[sizeof(cfg
.keyfile
)];
1167 char fontstatic
[256];
1169 struct servent
* service
;
1175 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1177 * Centre the window.
1179 { /* centre the window */
1182 hw
= GetDesktopWindow();
1183 if (GetWindowRect (hw
, &rs
) && GetWindowRect (hwnd
, &rd
))
1184 MoveWindow (hwnd
, (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
)/2,
1185 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
)/2,
1186 rd
.right
-rd
.left
, rd
.bottom
-rd
.top
, TRUE
);
1190 * Create the tree view.
1197 r
.left
= 3; r
.right
= r
.left
+ 75;
1198 r
.top
= 3; r
.bottom
= r
.top
+ 10;
1199 MapDialogRect(hwnd
, &r
);
1200 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1201 WS_CHILD
| WS_VISIBLE
,
1203 r
.right
-r
.left
, r
.bottom
-r
.top
,
1204 hwnd
, (HMENU
)IDCX_TVSTATIC
, hinst
, NULL
);
1205 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1206 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1208 r
.left
= 3; r
.right
= r
.left
+ 75;
1209 r
.top
= 13; r
.bottom
= r
.top
+ 206;
1210 MapDialogRect(hwnd
, &r
);
1211 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1212 WS_CHILD
| WS_VISIBLE
|
1213 WS_TABSTOP
| TVS_HASLINES
|
1214 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
|
1215 TVS_LINESATROOT
| TVS_SHOWSELALWAYS
,
1217 r
.right
-r
.left
, r
.bottom
-r
.top
,
1218 hwnd
, (HMENU
)IDCX_TREEVIEW
, hinst
, NULL
);
1219 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1220 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1221 tvfaff
.treeview
= treeview
;
1222 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1226 * Set up the tree view contents.
1228 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1229 treeview_insert(&tvfaff
, 1, "Logging");
1230 treeview_insert(&tvfaff
, 0, "Terminal");
1231 treeview_insert(&tvfaff
, 1, "Keyboard");
1232 treeview_insert(&tvfaff
, 1, "Bell");
1233 treeview_insert(&tvfaff
, 0, "Window");
1234 treeview_insert(&tvfaff
, 1, "Appearance");
1235 treeview_insert(&tvfaff
, 1, "Translation");
1236 treeview_insert(&tvfaff
, 1, "Selection");
1237 treeview_insert(&tvfaff
, 1, "Colours");
1238 treeview_insert(&tvfaff
, 0, "Connection");
1240 treeview_insert(&tvfaff
, 1, "Telnet");
1241 treeview_insert(&tvfaff
, 1, "Rlogin");
1242 if (backends
[3].backend
!= NULL
) {
1243 treeview_insert(&tvfaff
, 1, "SSH");
1244 treeview_insert(&tvfaff
, 2, "Tunnels");
1249 * Put the treeview selection on to the Session panel. This
1250 * should also cause creation of the relevant controls.
1252 TreeView_SelectItem(treeview
, hsession
);
1255 * Set focus into the first available control.
1259 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1260 if (!ctl
) ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1264 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1268 * Button release should trigger WM_OK if there was a
1269 * previous double click on the session list.
1273 SendMessage (hwnd
, WM_COMMAND
, IDOK
, 0);
1276 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1277 ((LPNMHDR
)lParam
)->code
== TVN_SELCHANGED
) {
1278 HTREEITEM i
= TreeView_GetSelection(((LPNMHDR
)lParam
)->hwndFrom
);
1283 item
.pszText
= buffer
;
1284 item
.cchTextMax
= sizeof(buffer
);
1285 item
.mask
= TVIF_TEXT
;
1286 TreeView_GetItem(((LPNMHDR
)lParam
)->hwndFrom
, &item
);
1287 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1288 HWND item
= GetDlgItem(hwnd
, j
);
1290 DestroyWindow(item
);
1292 if (!strcmp(buffer
, "Session"))
1293 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1294 if (!strcmp(buffer
, "Logging"))
1295 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1296 if (!strcmp(buffer
, "Keyboard"))
1297 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1298 if (!strcmp(buffer
, "Terminal"))
1299 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1300 if (!strcmp(buffer
, "Bell"))
1301 create_controls(hwnd
, dlgtype
, bellpanelstart
);
1302 if (!strcmp(buffer
, "Window"))
1303 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1304 if (!strcmp(buffer
, "Appearance"))
1305 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1306 if (!strcmp(buffer
, "Tunnels"))
1307 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1308 if (!strcmp(buffer
, "Connection"))
1309 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1310 if (!strcmp(buffer
, "Telnet"))
1311 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1312 if (!strcmp(buffer
, "Rlogin"))
1313 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1314 if (!strcmp(buffer
, "SSH"))
1315 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1316 if (!strcmp(buffer
, "Selection"))
1317 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1318 if (!strcmp(buffer
, "Colours"))
1319 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1320 if (!strcmp(buffer
, "Translation"))
1321 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1323 init_dlg_ctrls(hwnd
);
1325 SetFocus (((LPNMHDR
)lParam
)->hwndFrom
); /* ensure focus stays */
1331 * Only process WM_COMMAND once the dialog is fully formed.
1333 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
1336 EndDialog (hwnd
, 1);
1341 EndDialog (hwnd
, 0);
1343 case IDC_PROTTELNET
:
1344 case IDC_PROTRLOGIN
:
1347 if (HIWORD(wParam
) == BN_CLICKED
||
1348 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1349 int i
= IsDlgButtonChecked (hwnd
, IDC_PROTSSH
);
1350 int j
= IsDlgButtonChecked (hwnd
, IDC_PROTTELNET
);
1351 int k
= IsDlgButtonChecked (hwnd
, IDC_PROTRLOGIN
);
1352 cfg
.protocol
= i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
: PROT_RAW
;
1353 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22) ||
1354 (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23) ||
1355 (cfg
.protocol
== PROT_RLOGIN
&& cfg
.port
!= 513)) {
1356 cfg
.port
= i ?
22 : j ?
23 : 513;
1357 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1362 if (HIWORD(wParam
) == EN_CHANGE
)
1363 GetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
,
1364 sizeof(cfg
.host
)-1);
1367 if (HIWORD(wParam
) == EN_CHANGE
) {
1368 GetDlgItemText (hwnd
, IDC_PORT
, portname
, 31);
1369 if (isdigit(portname
[0]))
1370 MyGetDlgItemInt (hwnd
, IDC_PORT
, &cfg
.port
);
1372 service
= getservbyname(portname
, NULL
);
1373 if (service
) cfg
.port
= ntohs(service
->s_port
);
1379 if (HIWORD(wParam
) == EN_CHANGE
) {
1380 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1382 GetDlgItemText (hwnd
, IDC_SESSEDIT
,
1383 savedsession
, sizeof(savedsession
)-1);
1384 savedsession
[sizeof(savedsession
)-1] = '\0';
1388 if (HIWORD(wParam
) == BN_CLICKED
||
1389 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1394 GetDlgItemText (hwnd
, IDC_SESSEDIT
, str
, sizeof(str
)-1);
1396 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1397 LB_GETCURSEL
, 0, 0);
1402 strcpy (str
, sessions
[n
]);
1404 save_settings (str
, !!strcmp(str
, "Default Settings"), &cfg
);
1405 get_sesslist (FALSE
);
1406 get_sesslist (TRUE
);
1407 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1409 for (i
= 0; i
< nsessions
; i
++)
1410 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1411 0, (LPARAM
) (sessions
[i
]));
1412 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1418 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1419 HIWORD(wParam
) != BN_CLICKED
&&
1420 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1422 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1423 HIWORD(wParam
) != LBN_DBLCLK
)
1426 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1427 LB_GETCURSEL
, 0, 0);
1433 isdef
= !strcmp(sessions
[n
], "Default Settings");
1434 load_settings (sessions
[n
], !isdef
, &cfg
);
1435 init_dlg_ctrls(hwnd
);
1437 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1439 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1441 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1443 * A double-click on a saved session should
1444 * actually start the session, not just load it.
1445 * Unless it's Default Settings or some other
1446 * host-less set of saved settings.
1455 if (HIWORD(wParam
) == BN_CLICKED
||
1456 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1457 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1458 LB_GETCURSEL
, 0, 0);
1459 if (n
== LB_ERR
|| n
== 0) {
1463 del_settings(sessions
[n
]);
1464 get_sesslist (FALSE
);
1465 get_sesslist (TRUE
);
1466 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1468 for (i
= 0; i
< nsessions
; i
++)
1469 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1470 0, (LPARAM
) (sessions
[i
]));
1471 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1475 if (HIWORD(wParam
) == EN_CHANGE
)
1476 MyGetDlgItemInt (hwnd
, IDC_PINGEDIT
, &cfg
.ping_interval
);
1480 if (HIWORD(wParam
) == BN_CLICKED
||
1481 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1482 cfg
.bksp_is_delete
= IsDlgButtonChecked (hwnd
, IDC_DEL127
);
1486 if (HIWORD(wParam
) == BN_CLICKED
||
1487 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1488 cfg
.rxvt_homeend
= IsDlgButtonChecked (hwnd
, IDC_HOMERXVT
);
1491 if (HIWORD(wParam
) == BN_CLICKED
||
1492 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1496 if (HIWORD(wParam
) == BN_CLICKED
||
1497 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1502 if (HIWORD(wParam
) == BN_CLICKED
||
1503 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1504 cfg
.funky_type
= IsDlgButtonChecked (hwnd
, IDC_FUNCLINUX
);
1508 if (HIWORD(wParam
) == BN_CLICKED
||
1509 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1510 cfg
.app_keypad
= IsDlgButtonChecked (hwnd
, IDC_KPAPPLIC
);
1511 cfg
.nethack_keypad
= FALSE
;
1515 if (HIWORD(wParam
) == BN_CLICKED
||
1516 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1517 cfg
.app_keypad
= FALSE
;
1518 cfg
.nethack_keypad
= TRUE
;
1523 if (HIWORD(wParam
) == BN_CLICKED
||
1524 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1525 cfg
.app_cursor
= IsDlgButtonChecked (hwnd
, IDC_CURAPPLIC
);
1528 if (HIWORD(wParam
) == BN_CLICKED
||
1529 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1530 cfg
.no_applic_c
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICC
);
1533 if (HIWORD(wParam
) == BN_CLICKED
||
1534 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1535 cfg
.no_applic_k
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICK
);
1538 if (HIWORD(wParam
) == BN_CLICKED
||
1539 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1540 cfg
.alt_f4
= IsDlgButtonChecked (hwnd
, IDC_ALTF4
);
1543 if (HIWORD(wParam
) == BN_CLICKED
||
1544 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1545 cfg
.alt_space
= IsDlgButtonChecked (hwnd
, IDC_ALTSPACE
);
1548 if (HIWORD(wParam
) == BN_CLICKED
||
1549 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1550 cfg
.alt_only
= IsDlgButtonChecked (hwnd
, IDC_ALTONLY
);
1552 case IDC_ECHOBACKEND
:
1555 if (HIWORD(wParam
) == BN_CLICKED
||
1556 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1557 if (LOWORD(wParam
)==IDC_ECHOBACKEND
) cfg
.localecho
=LD_BACKEND
;
1558 if (LOWORD(wParam
)==IDC_ECHOYES
) cfg
.localecho
=LD_YES
;
1559 if (LOWORD(wParam
)==IDC_ECHONO
) cfg
.localecho
=LD_NO
;
1562 case IDC_EDITBACKEND
:
1565 if (HIWORD(wParam
) == BN_CLICKED
||
1566 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1567 if (LOWORD(wParam
)==IDC_EDITBACKEND
) cfg
.localedit
=LD_BACKEND
;
1568 if (LOWORD(wParam
)==IDC_EDITYES
) cfg
.localedit
=LD_YES
;
1569 if (LOWORD(wParam
)==IDC_EDITNO
) cfg
.localedit
=LD_NO
;
1572 case IDC_ANSWEREDIT
:
1573 if (HIWORD(wParam
) == EN_CHANGE
)
1574 GetDlgItemText (hwnd
, IDC_ANSWEREDIT
, cfg
.answerback
,
1575 sizeof(cfg
.answerback
)-1);
1577 case IDC_ALWAYSONTOP
:
1578 if (HIWORD(wParam
) == BN_CLICKED
||
1579 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1580 cfg
.alwaysontop
= IsDlgButtonChecked (hwnd
, IDC_ALWAYSONTOP
);
1583 if (HIWORD(wParam
) == BN_CLICKED
||
1584 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1585 cfg
.scroll_on_key
= IsDlgButtonChecked (hwnd
, IDC_SCROLLKEY
);
1587 case IDC_SCROLLDISP
:
1588 if (HIWORD(wParam
) == BN_CLICKED
||
1589 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1590 cfg
.scroll_on_disp
= IsDlgButtonChecked (hwnd
, IDC_SCROLLDISP
);
1592 case IDC_COMPOSEKEY
:
1593 if (HIWORD(wParam
) == BN_CLICKED
||
1594 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1595 cfg
.compose_key
= IsDlgButtonChecked (hwnd
, IDC_COMPOSEKEY
);
1597 case IDC_CTRLALTKEYS
:
1598 if (HIWORD(wParam
) == BN_CLICKED
||
1599 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1600 cfg
.ctrlaltkeys
= IsDlgButtonChecked (hwnd
, IDC_CTRLALTKEYS
);
1603 if (HIWORD(wParam
) == BN_CLICKED
||
1604 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1605 cfg
.wrap_mode
= IsDlgButtonChecked (hwnd
, IDC_WRAPMODE
);
1608 if (HIWORD(wParam
) == BN_CLICKED
||
1609 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1610 cfg
.dec_om
= IsDlgButtonChecked (hwnd
, IDC_DECOM
);
1613 if (HIWORD(wParam
) == BN_CLICKED
||
1614 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1615 cfg
.lfhascr
= IsDlgButtonChecked (hwnd
, IDC_LFHASCR
);
1618 if (HIWORD(wParam
) == EN_CHANGE
)
1619 MyGetDlgItemInt (hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1622 if (HIWORD(wParam
) == EN_CHANGE
)
1623 MyGetDlgItemInt (hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1626 if (HIWORD(wParam
) == EN_CHANGE
)
1627 MyGetDlgItemInt (hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1629 case IDC_CHOOSEFONT
:
1630 lf
.lfHeight
= cfg
.fontheight
;
1631 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1632 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1633 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1634 lf
.lfCharSet
= cfg
.fontcharset
;
1635 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1636 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1637 lf
.lfQuality
= DEFAULT_QUALITY
;
1638 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1639 strncpy (lf
.lfFaceName
, cfg
.font
, sizeof(lf
.lfFaceName
)-1);
1640 lf
.lfFaceName
[sizeof(lf
.lfFaceName
)-1] = '\0';
1642 cf
.lStructSize
= sizeof(cf
);
1643 cf
.hwndOwner
= hwnd
;
1645 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1646 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1648 if (ChooseFont (&cf
)) {
1649 strncpy (cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
)-1);
1650 cfg
.font
[sizeof(cfg
.font
)-1] = '\0';
1651 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1652 cfg
.fontcharset
= lf
.lfCharSet
;
1653 cfg
.fontheight
= cf
.iPointSize
/ 10;
1654 fmtfont (fontstatic
);
1655 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
1658 case IDC_BELL_DISABLED
:
1659 case IDC_BELL_DEFAULT
:
1660 case IDC_BELL_WAVEFILE
:
1661 case IDC_BELL_VISUAL
:
1662 if (HIWORD(wParam
) == BN_CLICKED
||
1663 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1664 if (LOWORD(wParam
)==IDC_BELL_DISABLED
) cfg
.beep
= BELL_DISABLED
;
1665 if (LOWORD(wParam
)==IDC_BELL_DEFAULT
) cfg
.beep
= BELL_DEFAULT
;
1666 if (LOWORD(wParam
)==IDC_BELL_WAVEFILE
) cfg
.beep
= BELL_WAVEFILE
;
1667 if (LOWORD(wParam
)==IDC_BELL_VISUAL
) cfg
.beep
= BELL_VISUAL
;
1670 case IDC_BELL_WAVEBROWSE
:
1671 memset(&of
, 0, sizeof(of
));
1672 #ifdef OPENFILENAME_SIZE_VERSION_400
1673 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1675 of
.lStructSize
= sizeof(of
);
1677 of
.hwndOwner
= hwnd
;
1678 of
.lpstrFilter
= "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
1679 of
.lpstrCustomFilter
= NULL
;
1680 of
.nFilterIndex
= 1;
1681 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.bell_wavefile
);
1682 of
.nMaxFile
= sizeof(filename
);
1683 of
.lpstrFileTitle
= NULL
;
1684 of
.lpstrInitialDir
= NULL
;
1685 of
.lpstrTitle
= "Select Bell Sound File";
1687 if (GetOpenFileName(&of
)) {
1688 strcpy(cfg
.bell_wavefile
, filename
);
1689 SetDlgItemText (hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
);
1692 case IDC_BELL_WAVEEDIT
:
1693 if (HIWORD(wParam
) == EN_CHANGE
)
1694 GetDlgItemText (hwnd
, IDC_BELL_WAVEEDIT
, cfg
.bell_wavefile
,
1695 sizeof(cfg
.bell_wavefile
)-1);
1698 if (HIWORD(wParam
) == BN_CLICKED
||
1699 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1700 cfg
.bellovl
= IsDlgButtonChecked (hwnd
, IDC_BELLOVL
);
1703 if (HIWORD(wParam
) == EN_CHANGE
)
1704 MyGetDlgItemInt (hwnd
, IDC_BELLOVLN
, &cfg
.bellovl_n
);
1707 if (HIWORD(wParam
) == EN_CHANGE
)
1708 MyGetDlgItemInt (hwnd
, IDC_BELLOVLT
, &cfg
.bellovl_t
);
1711 if (HIWORD(wParam
) == EN_CHANGE
)
1712 MyGetDlgItemInt (hwnd
, IDC_BELLOVLS
, &cfg
.bellovl_s
);
1715 if (HIWORD(wParam
) == BN_CLICKED
||
1716 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1717 cfg
.blinktext
= IsDlgButtonChecked (hwnd
, IDC_BLINKTEXT
);
1720 if (HIWORD(wParam
) == BN_CLICKED
||
1721 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1722 cfg
.bce
= IsDlgButtonChecked (hwnd
, IDC_BCE
);
1725 if (HIWORD(wParam
) == BN_CLICKED
||
1726 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1727 cfg
.win_name_always
= IsDlgButtonChecked (hwnd
, IDC_WINNAME
);
1730 if (HIWORD(wParam
) == BN_CLICKED
||
1731 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1732 cfg
.hide_mouseptr
= IsDlgButtonChecked (hwnd
, IDC_HIDEMOUSE
);
1735 if (HIWORD(wParam
) == BN_CLICKED
||
1736 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1737 cfg
.cursor_type
= 0;
1740 if (HIWORD(wParam
) == BN_CLICKED
||
1741 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1742 cfg
.cursor_type
= 1;
1745 if (HIWORD(wParam
) == BN_CLICKED
||
1746 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1747 cfg
.cursor_type
= 2;
1750 if (HIWORD(wParam
) == BN_CLICKED
||
1751 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1752 cfg
.blink_cur
= IsDlgButtonChecked (hwnd
, IDC_BLINKCUR
);
1755 if (HIWORD(wParam
) == BN_CLICKED
||
1756 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1757 cfg
.scrollbar
= IsDlgButtonChecked (hwnd
, IDC_SCROLLBAR
);
1760 if (HIWORD(wParam
) == BN_CLICKED
||
1761 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1762 cfg
.locksize
= IsDlgButtonChecked (hwnd
, IDC_LOCKSIZE
);
1765 if (HIWORD(wParam
) == EN_CHANGE
)
1766 GetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
1767 sizeof(cfg
.wintitle
)-1);
1772 if (HIWORD(wParam
) == BN_CLICKED
||
1773 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1774 cfg
.close_on_exit
= IsDlgButtonChecked (hwnd
, IDC_COEALWAYS
) ? COE_ALWAYS
:
1775 IsDlgButtonChecked (hwnd
, IDC_COENEVER
) ? COE_NEVER
:
1780 if (HIWORD(wParam
) == BN_CLICKED
||
1781 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1782 cfg
.warn_on_close
= IsDlgButtonChecked (hwnd
, IDC_CLOSEWARN
);
1785 if (HIWORD(wParam
) == EN_CHANGE
)
1786 GetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
,
1787 sizeof(cfg
.termtype
)-1);
1790 if (HIWORD(wParam
) == EN_CHANGE
)
1791 GetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
1792 sizeof(cfg
.logfilename
)-1);
1795 memset(&of
, 0, sizeof(of
));
1796 #ifdef OPENFILENAME_SIZE_VERSION_400
1797 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1799 of
.lStructSize
= sizeof(of
);
1801 of
.hwndOwner
= hwnd
;
1802 of
.lpstrFilter
= "All Files\0*\0\0\0";
1803 of
.lpstrCustomFilter
= NULL
;
1804 of
.nFilterIndex
= 1;
1805 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.logfilename
);
1806 of
.nMaxFile
= sizeof(filename
);
1807 of
.lpstrFileTitle
= NULL
;
1808 of
.lpstrInitialDir
= NULL
;
1809 of
.lpstrTitle
= "Select session log file";
1811 if (GetSaveFileName(&of
)) {
1812 strcpy(cfg
.logfilename
, filename
);
1813 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
1817 case IDC_LSTATASCII
:
1819 if (HIWORD(wParam
) == BN_CLICKED
||
1820 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1821 if (IsDlgButtonChecked (hwnd
, IDC_LSTATOFF
)) cfg
.logtype
= 0;
1822 if (IsDlgButtonChecked (hwnd
, IDC_LSTATASCII
)) cfg
.logtype
= 1;
1823 if (IsDlgButtonChecked (hwnd
, IDC_LSTATRAW
)) cfg
.logtype
= 2;
1828 if (HIWORD(wParam
) == EN_CHANGE
)
1829 GetDlgItemText (hwnd
, LOWORD(wParam
), cfg
.termspeed
,
1830 sizeof(cfg
.termspeed
)-1);
1833 if (HIWORD(wParam
) == EN_CHANGE
)
1834 GetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
,
1835 sizeof(cfg
.username
)-1);
1837 case IDC_RLLUSEREDIT
:
1838 if (HIWORD(wParam
) == EN_CHANGE
)
1839 GetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
,
1840 sizeof(cfg
.localusername
)-1);
1844 cfg
.rfc_environ
= IsDlgButtonChecked (hwnd
, IDC_EMRFC
);
1847 if (HIWORD(wParam
) == BN_CLICKED
||
1848 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1849 char str
[sizeof(cfg
.environmt
)];
1851 GetDlgItemText (hwnd
, IDC_VAREDIT
, str
, sizeof(str
)-1);
1856 p
= str
+ strlen(str
);
1858 GetDlgItemText (hwnd
, IDC_VALEDIT
, p
, sizeof(str
)-1-(p
-str
));
1868 if ((p
-cfg
.environmt
) + strlen(str
) + 2 < sizeof(cfg
.environmt
)) {
1870 p
[strlen(str
)+1] = '\0';
1871 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
1873 SetDlgItemText (hwnd
, IDC_VAREDIT
, "");
1874 SetDlgItemText (hwnd
, IDC_VALEDIT
, "");
1876 MessageBox(hwnd
, "Environment too big", "PuTTY Error",
1877 MB_OK
| MB_ICONERROR
);
1882 if (HIWORD(wParam
) != BN_CLICKED
&&
1883 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1885 i
= SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0, 0);
1891 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
1916 if (HIWORD(wParam
) == BN_CLICKED
||
1917 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1918 cfg
.nopty
= IsDlgButtonChecked (hwnd
, IDC_NOPTY
);
1921 if (HIWORD(wParam
) == BN_CLICKED
||
1922 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1923 cfg
.compression
= IsDlgButtonChecked (hwnd
, IDC_COMPRESS
);
1926 if (HIWORD(wParam
) == BN_CLICKED
||
1927 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1928 cfg
.buggymac
= IsDlgButtonChecked (hwnd
, IDC_BUGGYMAC
);
1931 if (HIWORD(wParam
) == BN_CLICKED
||
1932 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1933 cfg
.agentfwd
= IsDlgButtonChecked (hwnd
, IDC_AGENTFWD
);
1935 case IDC_CIPHER3DES
:
1936 case IDC_CIPHERBLOWF
:
1939 if (HIWORD(wParam
) == BN_CLICKED
||
1940 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1941 if (IsDlgButtonChecked (hwnd
, IDC_CIPHER3DES
))
1942 cfg
.cipher
= CIPHER_3DES
;
1943 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERBLOWF
))
1944 cfg
.cipher
= CIPHER_BLOWFISH
;
1945 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERDES
))
1946 cfg
.cipher
= CIPHER_DES
;
1947 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERAES
))
1948 cfg
.cipher
= CIPHER_AES
;
1953 if (HIWORD(wParam
) == BN_CLICKED
||
1954 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1955 if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT1
))
1957 else if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT2
))
1962 if (HIWORD(wParam
) == BN_CLICKED
||
1963 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1964 cfg
.try_tis_auth
= IsDlgButtonChecked (hwnd
, IDC_AUTHTIS
);
1967 if (HIWORD(wParam
) == EN_CHANGE
)
1968 GetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
1969 sizeof(cfg
.keyfile
)-1);
1972 if (HIWORD(wParam
) == EN_CHANGE
)
1973 GetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
1974 sizeof(cfg
.remote_cmd
)-1);
1977 memset(&of
, 0, sizeof(of
));
1978 #ifdef OPENFILENAME_SIZE_VERSION_400
1979 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1981 of
.lStructSize
= sizeof(of
);
1983 of
.hwndOwner
= hwnd
;
1984 of
.lpstrFilter
= "All Files\0*\0\0\0";
1985 of
.lpstrCustomFilter
= NULL
;
1986 of
.nFilterIndex
= 1;
1987 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1988 of
.nMaxFile
= sizeof(filename
);
1989 of
.lpstrFileTitle
= NULL
;
1990 of
.lpstrInitialDir
= NULL
;
1991 of
.lpstrTitle
= "Select Public Key File";
1993 if (GetOpenFileName(&of
)) {
1994 strcpy(cfg
.keyfile
, filename
);
1995 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1999 cfg
.rawcnp
= IsDlgButtonChecked (hwnd
, IDC_RAWCNP
);
2002 cfg
.mouse_is_xterm
= IsDlgButtonChecked (hwnd
, IDC_MBXTERM
);
2008 int n
= GetDlgItemInt (hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
2013 for (i
=0; i
<256; i
++)
2014 if (SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_GETSEL
,
2017 cfg
.wordness
[i
] = n
;
2018 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
2019 LB_DELETESTRING
, i
, 0);
2020 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
2021 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
2023 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
2030 case IDC_BOLDCOLOUR
:
2031 if (HIWORD(wParam
) == BN_CLICKED
||
2032 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2034 cfg
.bold_colour
= IsDlgButtonChecked (hwnd
, IDC_BOLDCOLOUR
);
2035 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
2036 if (n
!= 12+10*cfg
.bold_colour
) {
2038 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
2039 LB_DELETESTRING
, i
, 0);
2040 for (i
=0; i
<22; i
++)
2041 if (cfg
.bold_colour
|| permcolour
[i
])
2042 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
2044 (LPARAM
) colours
[i
]);
2049 if (HIWORD(wParam
) == BN_CLICKED
||
2050 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2051 cfg
.try_palette
= IsDlgButtonChecked (hwnd
, IDC_PALETTE
);
2053 case IDC_COLOURLIST
:
2054 if (HIWORD(wParam
) == LBN_DBLCLK
||
2055 HIWORD(wParam
) == LBN_SELCHANGE
) {
2056 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
2058 if (!cfg
.bold_colour
)
2059 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
2060 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0], FALSE
);
2061 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1], FALSE
);
2062 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2], FALSE
);
2066 if (HIWORD(wParam
) == BN_CLICKED
||
2067 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2068 static CHOOSECOLOR cc
;
2069 static DWORD custom
[16] = {0}; /* zero initialisers */
2070 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
2072 if (!cfg
.bold_colour
)
2073 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
2074 cc
.lStructSize
= sizeof(cc
);
2075 cc
.hwndOwner
= hwnd
;
2076 cc
.hInstance
= (HWND
)hinst
;
2077 cc
.lpCustColors
= custom
;
2078 cc
.rgbResult
= RGB (cfg
.colours
[i
][0], cfg
.colours
[i
][1],
2080 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
2081 if (ChooseColor(&cc
)) {
2083 (unsigned char) (cc
.rgbResult
& 0xFF);
2085 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
2087 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
2088 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
2090 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
2092 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
2098 case IDC_KOI8WIN1251
:
2099 case IDC_88592WIN1250
:
2100 case IDC_88592CP852
:
2101 cfg
.xlat_enablekoiwin
=
2102 IsDlgButtonChecked (hwnd
, IDC_KOI8WIN1251
);
2103 cfg
.xlat_88592w1250
=
2104 IsDlgButtonChecked (hwnd
, IDC_88592WIN1250
);
2105 cfg
.xlat_88592cp852
=
2106 IsDlgButtonChecked (hwnd
, IDC_88592CP852
);
2108 case IDC_CAPSLOCKCYR
:
2109 if (HIWORD(wParam
) == BN_CLICKED
||
2110 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
2111 cfg
.xlat_capslockcyr
=
2112 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
2115 case IDC_VTXWINDOWS
:
2120 (IsDlgButtonChecked (hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
:
2121 IsDlgButtonChecked (hwnd
, IDC_VTOEMANSI
) ? VT_OEMANSI
:
2122 IsDlgButtonChecked (hwnd
, IDC_VTOEMONLY
) ? VT_OEMONLY
:
2125 case IDC_X11_FORWARD
:
2126 if (HIWORD(wParam
) == BN_CLICKED
||
2127 HIWORD(wParam
) == BN_DOUBLECLICKED
)
2128 cfg
.x11_forward
= IsDlgButtonChecked (hwnd
, IDC_X11_FORWARD
);
2130 case IDC_X11_DISPLAY
:
2131 if (HIWORD(wParam
) == EN_CHANGE
)
2132 GetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
2133 sizeof(cfg
.x11_display
)-1);
2138 EndDialog (hwnd
, 0);
2141 /* Grrr Explorer will maximize Dialogs! */
2143 if (wParam
== SIZE_MAXIMIZED
)
2150 static int CALLBACK
MainDlgProc (HWND hwnd
, UINT msg
,
2151 WPARAM wParam
, LPARAM lParam
) {
2152 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
2154 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
2155 EnableWindow(hwnd
, 0);
2156 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2157 GetParent(hwnd
), AboutProc
);
2158 EnableWindow(hwnd
, 1);
2159 SetActiveWindow(hwnd
);
2161 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 0);
2164 static int CALLBACK
ReconfDlgProc (HWND hwnd
, UINT msg
,
2165 WPARAM wParam
, LPARAM lParam
) {
2166 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 1);
2169 void defuse_showwindow(void) {
2171 * Work around the fact that the app's first call to ShowWindow
2172 * will ignore the default in favour of the shell-provided
2177 hwnd
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2179 ShowWindow(hwnd
, SW_HIDE
);
2180 DestroyWindow(hwnd
);
2184 int do_config (void) {
2188 savedsession
[0] = '\0';
2189 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2190 get_sesslist(FALSE
);
2195 int do_reconfig (HWND hwnd
) {
2199 backup_cfg
= cfg
; /* structure copy */
2200 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2202 cfg
= backup_cfg
; /* structure copy */
2207 void logevent (char *string
) {
2211 if (nevents
>= negsize
) {
2213 events
= srealloc (events
, negsize
* sizeof(*events
));
2217 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t", localtime(&t
));
2219 events
[nevents
] = smalloc(strlen(timebuf
)+strlen(string
)+1);
2220 strcpy(events
[nevents
], timebuf
);
2221 strcat(events
[nevents
], string
);
2224 SendDlgItemMessage (logbox
, IDN_LIST
, LB_ADDSTRING
,
2225 0, (LPARAM
)events
[nevents
]);
2226 count
= SendDlgItemMessage (logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2227 SendDlgItemMessage (logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
-1, 0);
2232 void showeventlog (HWND hwnd
) {
2234 logbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2236 ShowWindow (logbox
, SW_SHOWNORMAL
);
2238 SetActiveWindow(logbox
);
2241 void showabout (HWND hwnd
) {
2242 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),hwnd
, AboutProc
);
2245 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2246 char *keystr
, char *fingerprint
) {
2249 static const char absentmsg
[] =
2250 "The server's host key is not cached in the registry. You\n"
2251 "have no guarantee that the server is the computer you\n"
2253 "The server's key fingerprint is:\n"
2255 "If you trust this host, hit Yes to add the key to\n"
2256 "PuTTY's cache and carry on connecting.\n"
2257 "If you do not trust this host, hit No to abandon the\n"
2260 static const char wrongmsg
[] =
2261 "WARNING - POTENTIAL SECURITY BREACH!\n"
2263 "The server's host key does not match the one PuTTY has\n"
2264 "cached in the registry. This means that either the\n"
2265 "server administrator has changed the host key, or you\n"
2266 "have actually connected to another computer pretending\n"
2267 "to be the server.\n"
2268 "The new key fingerprint is:\n"
2270 "If you were expecting this change and trust the new key,\n"
2271 "hit Yes to update PuTTY's cache and continue connecting.\n"
2272 "If you want to carry on connecting but without updating\n"
2273 "the cache, hit No.\n"
2274 "If you want to abandon the connection completely, hit\n"
2275 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2278 static const char mbtitle
[] = "PuTTY Security Alert";
2281 char message
[160+ /* sensible fingerprint max size */
2282 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2283 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2286 * Verify the key against the registry.
2288 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2290 if (ret
== 0) /* success - key matched OK */
2292 if (ret
== 2) { /* key was different */
2294 sprintf(message
, wrongmsg
, fingerprint
);
2295 mbret
= MessageBox(NULL
, message
, mbtitle
,
2296 MB_ICONWARNING
| MB_YESNOCANCEL
);
2298 store_host_key(host
, port
, keytype
, keystr
);
2299 if (mbret
== IDCANCEL
)
2302 if (ret
== 1) { /* key was absent */
2304 sprintf(message
, absentmsg
, fingerprint
);
2305 mbret
= MessageBox(NULL
, message
, mbtitle
,
2306 MB_ICONWARNING
| MB_YESNO
);
2309 store_host_key(host
, port
, keytype
, keystr
);
2314 * Ask whether to wipe a session log file before writing to it.
2315 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2317 int askappend(char *filename
) {
2318 static const char mbtitle
[] = "PuTTY Log to File";
2319 static const char msgtemplate
[] =
2320 "The session log file \"%.*s\" already exists.\n"
2321 "You can overwrite it with a new session log,\n"
2322 "append your session log to the end of it,\n"
2323 "or disable session logging for this session.\n"
2324 "Hit Yes to wipe the file, No to append to it,\n"
2325 "or Cancel to disable logging.";
2326 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2328 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2330 mbret
= MessageBox(NULL
, message
, mbtitle
,
2331 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2334 else if (mbret
== IDNO
)