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
,
306 appearancepanelstart
,
307 IDC_TITLE_APPEARANCE
,
325 connectionpanelstart
,
326 IDC_TITLE_CONNECTION
,
424 translationpanelstart
,
425 IDC_TITLE_TRANSLATION
,
426 IDC_BOX_TRANSLATION1
,
427 IDC_BOX_TRANSLATION2
,
428 IDC_BOX_TRANSLATION3
,
453 static const char *const colours
[] = {
454 "Default Foreground", "Default Bold Foreground",
455 "Default Background", "Default Bold Background",
456 "Cursor Text", "Cursor Colour",
457 "ANSI Black", "ANSI Black Bold",
458 "ANSI Red", "ANSI Red Bold",
459 "ANSI Green", "ANSI Green Bold",
460 "ANSI Yellow", "ANSI Yellow Bold",
461 "ANSI Blue", "ANSI Blue Bold",
462 "ANSI Magenta", "ANSI Magenta Bold",
463 "ANSI Cyan", "ANSI Cyan Bold",
464 "ANSI White", "ANSI White Bold"
466 static const int permcolour
[] = {
467 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
468 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
469 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
472 static void fmtfont (char *buf
) {
473 sprintf (buf
, "Font: %s, ", cfg
.font
);
475 strcat(buf
, "bold, ");
476 if (cfg
.fontheight
== 0)
477 strcat (buf
, "default height");
479 sprintf (buf
+strlen(buf
), "%d-point",
480 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
));
483 static void init_dlg_ctrls(HWND hwnd
) {
485 char fontstatic
[256];
487 SetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
);
488 SetDlgItemText (hwnd
, IDC_SESSEDIT
, savedsession
);
491 n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
493 SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
494 LB_DELETESTRING
, i
, 0);
495 for (i
= 0; i
< nsessions
; i
++)
496 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
497 0, (LPARAM
) (sessions
[i
]));
499 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
500 CheckRadioButton (hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
501 cfg
.protocol
==PROT_SSH ? IDC_PROTSSH
:
502 cfg
.protocol
==PROT_TELNET ? IDC_PROTTELNET
:
503 cfg
.protocol
==PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
504 SetDlgItemInt (hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
506 CheckRadioButton (hwnd
, IDC_DEL008
, IDC_DEL127
,
507 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
508 CheckRadioButton (hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
509 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
510 CheckRadioButton (hwnd
, IDC_FUNCTILDE
, IDC_FUNCVT400
,
511 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
512 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
513 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
514 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
516 CheckDlgButton (hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
517 CheckDlgButton (hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
518 CheckRadioButton (hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
519 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
520 CheckRadioButton (hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
521 cfg
.nethack_keypad ? IDC_KPNH
:
522 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
523 CheckDlgButton (hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
524 CheckDlgButton (hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
525 CheckDlgButton (hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
526 CheckDlgButton (hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
527 CheckRadioButton (hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
528 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
529 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
530 CheckRadioButton (hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
531 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
532 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
533 CheckDlgButton (hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
534 CheckDlgButton (hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
535 CheckDlgButton (hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
537 CheckDlgButton (hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
538 CheckDlgButton (hwnd
, IDC_DECOM
, cfg
.dec_om
);
539 CheckDlgButton (hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
540 SetDlgItemInt (hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
541 SetDlgItemInt (hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
542 SetDlgItemInt (hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
543 fmtfont (fontstatic
);
544 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
545 CheckDlgButton (hwnd
, IDC_BEEP
, cfg
.beep
);
546 CheckDlgButton (hwnd
, IDC_BCE
, cfg
.bce
);
547 CheckDlgButton (hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
549 SetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
550 CheckDlgButton (hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
551 CheckDlgButton (hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
552 CheckRadioButton (hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
553 cfg
.cursor_type
==0 ? IDC_CURBLOCK
:
554 cfg
.cursor_type
==1 ? IDC_CURUNDER
: IDC_CURVERT
);
555 CheckDlgButton (hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
556 CheckDlgButton (hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
557 CheckDlgButton (hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
558 CheckRadioButton (hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
559 cfg
.close_on_exit
==COE_NORMAL ? IDC_COENORMAL
:
560 cfg
.close_on_exit
==COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
561 CheckDlgButton (hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
563 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
564 SetDlgItemText (hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
565 SetDlgItemText (hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
566 SetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
567 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
568 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
569 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
570 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
571 cfg
.logtype
== 1 ? IDC_LSTATASCII
:
574 char *p
= cfg
.environmt
;
576 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
581 CheckRadioButton (hwnd
, IDC_EMBSD
, IDC_EMRFC
,
582 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
584 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
585 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
586 CheckDlgButton (hwnd
, IDC_NOPTY
, cfg
.nopty
);
587 CheckDlgButton (hwnd
, IDC_COMPRESS
, cfg
.compression
);
588 CheckDlgButton (hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
589 CheckDlgButton (hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
590 CheckRadioButton (hwnd
, IDC_CIPHER3DES
, IDC_CIPHERAES
,
591 cfg
.cipher
== CIPHER_BLOWFISH ? IDC_CIPHERBLOWF
:
592 cfg
.cipher
== CIPHER_DES ? IDC_CIPHERDES
:
593 cfg
.cipher
== CIPHER_AES ? IDC_CIPHERAES
:
595 CheckRadioButton (hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
596 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
597 CheckDlgButton (hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
598 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
599 SetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
601 CheckRadioButton (hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
602 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
603 CheckDlgButton (hwnd
, IDC_RAWCNP
, cfg
.rawcnp
);
605 static int tabs
[4] = {25, 61, 96, 128};
606 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
609 for (i
=0; i
<256; i
++) {
611 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
612 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
614 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
618 CheckDlgButton (hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
619 CheckDlgButton (hwnd
, IDC_PALETTE
, cfg
.try_palette
);
622 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
624 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
625 LB_DELETESTRING
, i
, 0);
627 if (cfg
.bold_colour
|| permcolour
[i
])
628 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
629 (LPARAM
) colours
[i
]);
631 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
632 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
633 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
634 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
636 CheckRadioButton (hwnd
, IDC_NOXLAT
, IDC_88592CP852
,
637 cfg
.xlat_88592w1250 ? IDC_88592WIN1250
:
638 cfg
.xlat_88592cp852 ? IDC_88592CP852
:
639 cfg
.xlat_enablekoiwin ? IDC_KOI8WIN1251
:
641 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
642 CheckRadioButton (hwnd
, IDC_VTXWINDOWS
, IDC_VTPOORMAN
,
643 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
644 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
645 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
648 CheckDlgButton (hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
649 SetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
652 struct treeview_faff
{
657 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
658 int level
, char *text
) {
662 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
-1] : TVI_ROOT
);
663 ins
.hInsertAfter
= faff
->lastat
[level
];
664 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
665 #define INSITEM DUMMYUNIONNAME.item
669 ins
.INSITEM
.mask
= TVIF_TEXT
;
670 ins
.INSITEM
.pszText
= text
;
671 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
673 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
-1], TVE_EXPAND
);
674 faff
->lastat
[level
] = newitem
;
675 for (i
= level
+1; i
< 4; i
++) faff
->lastat
[i
] = NULL
;
680 * Create the panelfuls of controls in the configuration box.
682 static void create_controls(HWND hwnd
, int dlgtype
, int panel
) {
683 if (panel
== sessionpanelstart
) {
684 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
686 ctlposinit(&cp
, hwnd
, 80, 3, 13);
687 bartitle(&cp
, "Basic options for your PuTTY session",
690 beginbox(&cp
, "Specify your connection by host name",
693 "Host &Name", IDC_HOSTSTATIC
, IDC_HOST
, 75,
694 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
695 if (backends
[3].backend
== NULL
) {
696 /* this is PuTTYtel, so only three protocols available */
697 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
699 "&Telnet", IDC_PROTTELNET
,
700 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
702 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
704 "&Telnet", IDC_PROTTELNET
,
705 "Rlog&in", IDC_PROTRLOGIN
,
714 beginbox(&cp
, "Load, save or delete a stored session",
716 sesssaver(&cp
, "Sav&ed Sessions",
717 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
718 "&Load", IDC_SESSLOAD
,
719 "&Save", IDC_SESSSAVE
,
720 "&Delete", IDC_SESSDEL
, NULL
);
723 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
724 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
725 "Always", IDC_COEALWAYS
,
726 "Never", IDC_COENEVER
,
727 "Only on clean exit", IDC_COENORMAL
, NULL
);
731 if (panel
== loggingpanelstart
) {
732 /* The Logging panel. Accelerators used: [acgo] tplfw */
734 ctlposinit(&cp
, hwnd
, 80, 3, 13);
735 bartitle(&cp
, "Options controlling session logging",
737 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
739 "Session logging:", IDC_LSTATSTATIC
,
740 "Logging &turned off completely", IDC_LSTATOFF
,
741 "Log &printable output only", IDC_LSTATASCII
,
742 "&Log all session output", IDC_LSTATRAW
, NULL
);
743 editbutton(&cp
, "Log &file name:",
744 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
749 if (panel
== terminalpanelstart
) {
750 /* The Terminal panel. Accelerators used: [acgo] wdlben ht */
752 ctlposinit(&cp
, hwnd
, 80, 3, 13);
753 bartitle(&cp
, "Options controlling the terminal emulation",
755 beginbox(&cp
, "Set various terminal options",
757 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
758 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
759 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
760 checkbox(&cp
, "&Beep enabled", IDC_BEEP
);
761 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
762 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
765 beginbox(&cp
, "Line discipline options",
767 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
768 "Auto", IDC_ECHOBACKEND
,
769 "Force on", IDC_ECHOYES
,
770 "Force off", IDC_ECHONO
, NULL
);
771 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
772 "Auto", IDC_EDITBACKEND
,
773 "Force on", IDC_EDITYES
,
774 "Force off", IDC_EDITNO
, NULL
);
778 if (panel
== keyboardpanelstart
) {
779 /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxv unpymie t */
781 ctlposinit(&cp
, hwnd
, 80, 3, 13);
782 bartitle(&cp
, "Options controlling the effects of keys",
784 beginbox(&cp
, "Change the sequences sent by:",
786 radioline(&cp
, "The Backspace key", IDC_DELSTATIC
, 2,
787 "Control-&H", IDC_DEL008
,
788 "Control-&? (127)", IDC_DEL127
, NULL
);
789 radioline(&cp
, "The Home and End keys", IDC_HOMESTATIC
, 2,
790 "&Standard", IDC_HOMETILDE
,
791 "&rxvt", IDC_HOMERXVT
, NULL
);
792 radioline(&cp
, "The Function keys and keypad", IDC_FUNCSTATIC
, 4,
793 "ESC[n&~", IDC_FUNCTILDE
,
794 "&Linux", IDC_FUNCLINUX
,
795 "&Xterm R6", IDC_FUNCXTERM
,
796 "&VT400", IDC_FUNCVT400
, NULL
);
798 beginbox(&cp
, "Application keypad settings:",
801 "Application c&ursor keys totally disabled",
803 radioline(&cp
, "Initial state of cursor keys:", IDC_CURSTATIC
, 2,
804 "&Normal", IDC_CURNORMAL
,
805 "A&pplication", IDC_CURAPPLIC
, NULL
);
807 "Application ke&ypad keys totally disabled",
809 radioline(&cp
, "Initial state of numeric keypad:", IDC_KPSTATIC
, 3,
810 "Nor&mal", IDC_KPNORMAL
,
811 "Appl&ication", IDC_KPAPPLIC
,
812 "N&etHack", IDC_KPNH
, NULL
);
814 beginbox(&cp
, "Enable extra keyboard features:",
816 checkbox(&cp
, "Application and AltGr ac&t as Compose key",
821 if (panel
== windowpanelstart
) {
822 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
824 ctlposinit(&cp
, hwnd
, 80, 3, 13);
825 bartitle(&cp
, "Options controlling PuTTY's window",
827 beginbox(&cp
, "Set the size of the window",
830 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
831 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50,
833 checkbox(&cp
, "Lock window size against resi&zing", IDC_LOCKSIZE
);
835 beginbox(&cp
, "Control the scrollback in the window",
837 staticedit(&cp
, "Lines of &scrollback",
838 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
839 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
840 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
841 checkbox(&cp
, "Reset scrollback on dis&play activity",
844 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
845 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
846 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
847 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
848 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
849 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
853 if (panel
== appearancepanelstart
) {
854 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p */
856 ctlposinit(&cp
, hwnd
, 80, 3, 13);
857 bartitle(&cp
, "Options controlling PuTTY's appearance",
858 IDC_TITLE_APPEARANCE
);
859 beginbox(&cp
, "Adjust the use of the cursor",
860 IDC_BOX_APPEARANCE1
);
861 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
862 "B&lock", IDC_CURBLOCK
,
863 "&Underline", IDC_CURUNDER
,
864 "&Vertical line", IDC_CURVERT
,
866 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
868 beginbox(&cp
, "Set the font used in the terminal window",
869 IDC_BOX_APPEARANCE2
);
870 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
872 beginbox(&cp
, "Adjust the use of the window title",
873 IDC_BOX_APPEARANCE3
);
875 "Window &title:", IDC_WINTITLE
,
876 IDC_WINEDIT
, 100, NULL
);
877 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
879 beginbox(&cp
, "Adjust the use of the mouse pointer",
880 IDC_BOX_APPEARANCE4
);
881 checkbox(&cp
, "Hide mouse &pointer when typing in window",
886 if (panel
== translationpanelstart
) {
887 /* The Translation panel. Accelerators used: [acgo] xbep t s */
889 ctlposinit(&cp
, hwnd
, 80, 3, 13);
890 bartitle(&cp
, "Options controlling character set translation",
891 IDC_TITLE_TRANSLATION
);
892 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
893 IDC_BOX_TRANSLATION1
);
895 "Handling of line drawing characters:", IDC_VTSTATIC
,
896 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
897 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
898 "Use font in O&EM mode only", IDC_VTOEMONLY
,
899 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
900 IDC_VTPOORMAN
, NULL
);
902 beginbox(&cp
, "Enable character set translation on received data",
903 IDC_BOX_TRANSLATION2
);
905 "Character set &translation:", IDC_XLATSTATIC
,
907 "KOI8 / Win-1251", IDC_KOI8WIN1251
,
908 "ISO-8859-2 / Win-1250", IDC_88592WIN1250
,
909 "ISO-8859-2 / CP852", IDC_88592CP852
, NULL
);
911 beginbox(&cp
, "Enable character set translation on input data",
912 IDC_BOX_TRANSLATION3
);
913 checkbox(&cp
, "CAP&S LOCK acts as cyrillic switch",
918 if (panel
== selectionpanelstart
) {
919 /* The Selection panel. Accelerators used: [acgo] d wx hst */
921 ctlposinit(&cp
, hwnd
, 80, 3, 13);
922 bartitle(&cp
, "Options controlling copy and paste",
923 IDC_TITLE_SELECTION
);
924 beginbox(&cp
, "Translation of pasted characters",
926 checkbox(&cp
, "&Don't translate line drawing chars into +, - and |",
929 beginbox(&cp
, "Control which mouse button does which thing",
931 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
932 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
933 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
936 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
938 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
939 "&Set", IDC_CCSET
, IDC_CCEDIT
,
940 "&to class", IDC_CCSTATIC2
);
944 if (panel
== colourspanelstart
) {
945 /* The Colours panel. Accelerators used: [acgo] blum */
947 ctlposinit(&cp
, hwnd
, 80, 3, 13);
948 bartitle(&cp
, "Options controlling use of colours",
950 beginbox(&cp
, "General options for colour usage",
952 checkbox(&cp
, "&Bolded text is a different colour", IDC_BOLDCOLOUR
);
953 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
955 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
957 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
958 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
959 "&Modify...", IDC_CHANGE
,
960 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
961 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
962 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
966 if (panel
== connectionpanelstart
) {
967 /* The Connection panel. Accelerators used: [acgo] tuk */
969 ctlposinit(&cp
, hwnd
, 80, 3, 13);
970 bartitle(&cp
, "Options controlling the connection", IDC_TITLE_CONNECTION
);
972 beginbox(&cp
, "Data to send to the server",
973 IDC_BOX_CONNECTION1
);
974 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
, IDC_TTEDIT
, 50);
975 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
, IDC_LOGEDIT
, 50);
978 beginbox(&cp
, "Sending of null packets to keep session active",
979 IDC_BOX_CONNECTION2
);
980 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
981 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
985 if (panel
== telnetpanelstart
) {
986 /* The Telnet panel. Accelerators used: [acgo] svldr bf */
988 ctlposinit(&cp
, hwnd
, 80, 3, 13);
990 bartitle(&cp
, "Options controlling Telnet connections", IDC_TITLE_TELNET
);
991 beginbox(&cp
, "Data to send to the server",
993 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
, IDC_TSEDIT
, 50);
994 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
995 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
,
996 "Va&lue", IDC_VALSTATIC
, IDC_VALEDIT
,
998 "A&dd", IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1000 beginbox(&cp
, "Telnet protocol adjustments",
1002 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC
, 2,
1003 "&BSD (commonplace)", IDC_EMBSD
,
1004 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1009 if (panel
== rloginpanelstart
) {
1010 /* The Rlogin panel. Accelerators used: [acgo] sl */
1012 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1014 bartitle(&cp
, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN
);
1015 beginbox(&cp
, "Data to send to the server",
1017 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
, IDC_R_TSEDIT
, 50);
1018 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
, IDC_RLLUSEREDIT
, 50);
1023 if (panel
== sshpanelstart
) {
1024 /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bds i */
1026 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1028 bartitle(&cp
, "Options controlling SSH connections", IDC_TITLE_SSH
);
1029 beginbox(&cp
, "Data to send to the server",
1032 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1035 beginbox(&cp
, "Authentication options",
1037 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1039 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1040 editbutton(&cp
, "Private &key file for authentication:",
1041 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...", IDC_PKBUTTON
);
1043 beginbox(&cp
, "Protocol options",
1045 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1046 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1047 radioline(&cp
, "Preferred SSH protocol version:",
1048 IDC_SSHPROTSTATIC
, 2,
1049 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1050 radioline(&cp
, "Preferred encryption algorithm:", IDC_CIPHERSTATIC
, 4,
1051 "&3DES", IDC_CIPHER3DES
,
1052 "&Blowfish", IDC_CIPHERBLOWF
,
1053 "&DES", IDC_CIPHERDES
,
1054 "AE&S", IDC_CIPHERAES
,
1056 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1062 if (panel
== tunnelspanelstart
) {
1063 /* The Tunnels panel. Accelerators used: [acgo] ex */
1065 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1067 bartitle(&cp
, "Options controlling SSH tunnelling",
1069 beginbox(&cp
, "X11 forwarding options",
1071 checkbox(&cp
, "&Enable X11 forwarding",
1073 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1074 IDC_X11_DISPLAY
, 50, NULL
);
1081 * This function is the configuration box.
1083 static int GenericMainDlgProc (HWND hwnd
, UINT msg
,
1084 WPARAM wParam
, LPARAM lParam
,
1087 struct treeview_faff tvfaff
;
1090 char filename
[sizeof(cfg
.keyfile
)];
1093 char fontstatic
[256];
1095 struct servent
* service
;
1101 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1103 * Centre the window.
1105 { /* centre the window */
1108 hw
= GetDesktopWindow();
1109 if (GetWindowRect (hw
, &rs
) && GetWindowRect (hwnd
, &rd
))
1110 MoveWindow (hwnd
, (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
)/2,
1111 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
)/2,
1112 rd
.right
-rd
.left
, rd
.bottom
-rd
.top
, TRUE
);
1116 * Create the tree view.
1123 r
.left
= 3; r
.right
= r
.left
+ 75;
1124 r
.top
= 3; r
.bottom
= r
.top
+ 10;
1125 MapDialogRect(hwnd
, &r
);
1126 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1127 WS_CHILD
| WS_VISIBLE
,
1129 r
.right
-r
.left
, r
.bottom
-r
.top
,
1130 hwnd
, (HMENU
)IDCX_TVSTATIC
, hinst
, NULL
);
1131 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1132 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1134 r
.left
= 3; r
.right
= r
.left
+ 75;
1135 r
.top
= 13; r
.bottom
= r
.top
+ 206;
1136 MapDialogRect(hwnd
, &r
);
1137 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1138 WS_CHILD
| WS_VISIBLE
|
1139 WS_TABSTOP
| TVS_HASLINES
|
1140 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
|
1141 TVS_LINESATROOT
| TVS_SHOWSELALWAYS
,
1143 r
.right
-r
.left
, r
.bottom
-r
.top
,
1144 hwnd
, (HMENU
)IDCX_TREEVIEW
, hinst
, NULL
);
1145 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1146 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1147 tvfaff
.treeview
= treeview
;
1148 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1152 * Set up the tree view contents.
1154 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1155 treeview_insert(&tvfaff
, 1, "Logging");
1156 treeview_insert(&tvfaff
, 0, "Terminal");
1157 treeview_insert(&tvfaff
, 1, "Keyboard");
1158 treeview_insert(&tvfaff
, 0, "Window");
1159 treeview_insert(&tvfaff
, 1, "Appearance");
1160 treeview_insert(&tvfaff
, 1, "Translation");
1161 treeview_insert(&tvfaff
, 1, "Selection");
1162 treeview_insert(&tvfaff
, 1, "Colours");
1163 treeview_insert(&tvfaff
, 0, "Connection");
1165 treeview_insert(&tvfaff
, 1, "Telnet");
1166 treeview_insert(&tvfaff
, 1, "Rlogin");
1167 if (backends
[3].backend
!= NULL
) {
1168 treeview_insert(&tvfaff
, 1, "SSH");
1169 treeview_insert(&tvfaff
, 2, "Tunnels");
1174 * Put the treeview selection on to the Session panel. This
1175 * should also cause creation of the relevant controls.
1177 TreeView_SelectItem(treeview
, hsession
);
1180 * Set focus into the first available control.
1184 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1185 if (!ctl
) ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1189 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1193 * Button release should trigger WM_OK if there was a
1194 * previous double click on the session list.
1198 SendMessage (hwnd
, WM_COMMAND
, IDOK
, 0);
1201 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1202 ((LPNMHDR
)lParam
)->code
== TVN_SELCHANGED
) {
1203 HTREEITEM i
= TreeView_GetSelection(((LPNMHDR
)lParam
)->hwndFrom
);
1208 item
.pszText
= buffer
;
1209 item
.cchTextMax
= sizeof(buffer
);
1210 item
.mask
= TVIF_TEXT
;
1211 TreeView_GetItem(((LPNMHDR
)lParam
)->hwndFrom
, &item
);
1212 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1213 HWND item
= GetDlgItem(hwnd
, j
);
1215 DestroyWindow(item
);
1217 if (!strcmp(buffer
, "Session"))
1218 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1219 if (!strcmp(buffer
, "Logging"))
1220 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1221 if (!strcmp(buffer
, "Keyboard"))
1222 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1223 if (!strcmp(buffer
, "Terminal"))
1224 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1225 if (!strcmp(buffer
, "Window"))
1226 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1227 if (!strcmp(buffer
, "Appearance"))
1228 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1229 if (!strcmp(buffer
, "Tunnels"))
1230 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1231 if (!strcmp(buffer
, "Connection"))
1232 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1233 if (!strcmp(buffer
, "Telnet"))
1234 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1235 if (!strcmp(buffer
, "Rlogin"))
1236 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1237 if (!strcmp(buffer
, "SSH"))
1238 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1239 if (!strcmp(buffer
, "Selection"))
1240 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1241 if (!strcmp(buffer
, "Colours"))
1242 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1243 if (!strcmp(buffer
, "Translation"))
1244 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1246 init_dlg_ctrls(hwnd
);
1248 SetFocus (((LPNMHDR
)lParam
)->hwndFrom
); /* ensure focus stays */
1254 * Only process WM_COMMAND once the dialog is fully formed.
1256 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
1259 EndDialog (hwnd
, 1);
1264 EndDialog (hwnd
, 0);
1266 case IDC_PROTTELNET
:
1267 case IDC_PROTRLOGIN
:
1270 if (HIWORD(wParam
) == BN_CLICKED
||
1271 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1272 int i
= IsDlgButtonChecked (hwnd
, IDC_PROTSSH
);
1273 int j
= IsDlgButtonChecked (hwnd
, IDC_PROTTELNET
);
1274 int k
= IsDlgButtonChecked (hwnd
, IDC_PROTRLOGIN
);
1275 cfg
.protocol
= i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
: PROT_RAW
;
1276 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22) ||
1277 (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23) ||
1278 (cfg
.protocol
== PROT_RLOGIN
&& cfg
.port
!= 513)) {
1279 cfg
.port
= i ?
22 : j ?
23 : 513;
1280 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1285 if (HIWORD(wParam
) == EN_CHANGE
)
1286 GetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
,
1287 sizeof(cfg
.host
)-1);
1290 if (HIWORD(wParam
) == EN_CHANGE
) {
1291 GetDlgItemText (hwnd
, IDC_PORT
, portname
, 31);
1292 if (isdigit(portname
[0]))
1293 MyGetDlgItemInt (hwnd
, IDC_PORT
, &cfg
.port
);
1295 service
= getservbyname(portname
, NULL
);
1296 if (service
) cfg
.port
= ntohs(service
->s_port
);
1302 if (HIWORD(wParam
) == EN_CHANGE
) {
1303 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1305 GetDlgItemText (hwnd
, IDC_SESSEDIT
,
1306 savedsession
, sizeof(savedsession
)-1);
1307 savedsession
[sizeof(savedsession
)-1] = '\0';
1311 if (HIWORD(wParam
) == BN_CLICKED
||
1312 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1317 GetDlgItemText (hwnd
, IDC_SESSEDIT
, str
, sizeof(str
)-1);
1319 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1320 LB_GETCURSEL
, 0, 0);
1325 strcpy (str
, sessions
[n
]);
1327 save_settings (str
, !!strcmp(str
, "Default Settings"), &cfg
);
1328 get_sesslist (FALSE
);
1329 get_sesslist (TRUE
);
1330 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1332 for (i
= 0; i
< nsessions
; i
++)
1333 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1334 0, (LPARAM
) (sessions
[i
]));
1335 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1341 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1342 HIWORD(wParam
) != BN_CLICKED
&&
1343 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1345 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1346 HIWORD(wParam
) != LBN_DBLCLK
)
1349 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1350 LB_GETCURSEL
, 0, 0);
1356 isdef
= !strcmp(sessions
[n
], "Default Settings");
1357 load_settings (sessions
[n
], !isdef
, &cfg
);
1358 init_dlg_ctrls(hwnd
);
1360 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1362 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1364 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1366 * A double-click on a saved session should
1367 * actually start the session, not just load it.
1368 * Unless it's Default Settings or some other
1369 * host-less set of saved settings.
1378 if (HIWORD(wParam
) == BN_CLICKED
||
1379 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1380 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1381 LB_GETCURSEL
, 0, 0);
1382 if (n
== LB_ERR
|| n
== 0) {
1386 del_settings(sessions
[n
]);
1387 get_sesslist (FALSE
);
1388 get_sesslist (TRUE
);
1389 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1391 for (i
= 0; i
< nsessions
; i
++)
1392 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1393 0, (LPARAM
) (sessions
[i
]));
1394 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1398 if (HIWORD(wParam
) == EN_CHANGE
)
1399 MyGetDlgItemInt (hwnd
, IDC_PINGEDIT
, &cfg
.ping_interval
);
1403 if (HIWORD(wParam
) == BN_CLICKED
||
1404 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1405 cfg
.bksp_is_delete
= IsDlgButtonChecked (hwnd
, IDC_DEL127
);
1409 if (HIWORD(wParam
) == BN_CLICKED
||
1410 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1411 cfg
.rxvt_homeend
= IsDlgButtonChecked (hwnd
, IDC_HOMERXVT
);
1414 if (HIWORD(wParam
) == BN_CLICKED
||
1415 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1419 if (HIWORD(wParam
) == BN_CLICKED
||
1420 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1425 if (HIWORD(wParam
) == BN_CLICKED
||
1426 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1427 cfg
.funky_type
= IsDlgButtonChecked (hwnd
, IDC_FUNCLINUX
);
1431 if (HIWORD(wParam
) == BN_CLICKED
||
1432 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1433 cfg
.app_keypad
= IsDlgButtonChecked (hwnd
, IDC_KPAPPLIC
);
1434 cfg
.nethack_keypad
= FALSE
;
1438 if (HIWORD(wParam
) == BN_CLICKED
||
1439 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1440 cfg
.app_keypad
= FALSE
;
1441 cfg
.nethack_keypad
= TRUE
;
1446 if (HIWORD(wParam
) == BN_CLICKED
||
1447 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1448 cfg
.app_cursor
= IsDlgButtonChecked (hwnd
, IDC_CURAPPLIC
);
1451 if (HIWORD(wParam
) == BN_CLICKED
||
1452 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1453 cfg
.no_applic_c
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICC
);
1456 if (HIWORD(wParam
) == BN_CLICKED
||
1457 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1458 cfg
.no_applic_k
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICK
);
1461 if (HIWORD(wParam
) == BN_CLICKED
||
1462 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1463 cfg
.alt_f4
= IsDlgButtonChecked (hwnd
, IDC_ALTF4
);
1466 if (HIWORD(wParam
) == BN_CLICKED
||
1467 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1468 cfg
.alt_space
= IsDlgButtonChecked (hwnd
, IDC_ALTSPACE
);
1471 if (HIWORD(wParam
) == BN_CLICKED
||
1472 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1473 cfg
.alt_only
= IsDlgButtonChecked (hwnd
, IDC_ALTONLY
);
1475 case IDC_ECHOBACKEND
:
1478 if (HIWORD(wParam
) == BN_CLICKED
||
1479 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1480 if (LOWORD(wParam
)==IDC_ECHOBACKEND
) cfg
.localecho
=LD_BACKEND
;
1481 if (LOWORD(wParam
)==IDC_ECHOYES
) cfg
.localecho
=LD_YES
;
1482 if (LOWORD(wParam
)==IDC_ECHONO
) cfg
.localecho
=LD_NO
;
1485 case IDC_EDITBACKEND
:
1488 if (HIWORD(wParam
) == BN_CLICKED
||
1489 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1490 if (LOWORD(wParam
)==IDC_EDITBACKEND
) cfg
.localedit
=LD_BACKEND
;
1491 if (LOWORD(wParam
)==IDC_EDITYES
) cfg
.localedit
=LD_YES
;
1492 if (LOWORD(wParam
)==IDC_EDITNO
) cfg
.localedit
=LD_NO
;
1495 case IDC_ALWAYSONTOP
:
1496 if (HIWORD(wParam
) == BN_CLICKED
||
1497 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1498 cfg
.alwaysontop
= IsDlgButtonChecked (hwnd
, IDC_ALWAYSONTOP
);
1501 if (HIWORD(wParam
) == BN_CLICKED
||
1502 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1503 cfg
.scroll_on_key
= IsDlgButtonChecked (hwnd
, IDC_SCROLLKEY
);
1505 case IDC_SCROLLDISP
:
1506 if (HIWORD(wParam
) == BN_CLICKED
||
1507 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1508 cfg
.scroll_on_disp
= IsDlgButtonChecked (hwnd
, IDC_SCROLLDISP
);
1510 case IDC_COMPOSEKEY
:
1511 if (HIWORD(wParam
) == BN_CLICKED
||
1512 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1513 cfg
.compose_key
= IsDlgButtonChecked (hwnd
, IDC_COMPOSEKEY
);
1516 if (HIWORD(wParam
) == BN_CLICKED
||
1517 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1518 cfg
.wrap_mode
= IsDlgButtonChecked (hwnd
, IDC_WRAPMODE
);
1521 if (HIWORD(wParam
) == BN_CLICKED
||
1522 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1523 cfg
.dec_om
= IsDlgButtonChecked (hwnd
, IDC_DECOM
);
1526 if (HIWORD(wParam
) == BN_CLICKED
||
1527 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1528 cfg
.lfhascr
= IsDlgButtonChecked (hwnd
, IDC_LFHASCR
);
1531 if (HIWORD(wParam
) == EN_CHANGE
)
1532 MyGetDlgItemInt (hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1535 if (HIWORD(wParam
) == EN_CHANGE
)
1536 MyGetDlgItemInt (hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1539 if (HIWORD(wParam
) == EN_CHANGE
)
1540 MyGetDlgItemInt (hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1542 case IDC_CHOOSEFONT
:
1543 lf
.lfHeight
= cfg
.fontheight
;
1544 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1545 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1546 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1547 lf
.lfCharSet
= cfg
.fontcharset
;
1548 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1549 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1550 lf
.lfQuality
= DEFAULT_QUALITY
;
1551 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1552 strncpy (lf
.lfFaceName
, cfg
.font
, sizeof(lf
.lfFaceName
)-1);
1553 lf
.lfFaceName
[sizeof(lf
.lfFaceName
)-1] = '\0';
1555 cf
.lStructSize
= sizeof(cf
);
1556 cf
.hwndOwner
= hwnd
;
1558 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1559 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1561 if (ChooseFont (&cf
)) {
1562 strncpy (cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
)-1);
1563 cfg
.font
[sizeof(cfg
.font
)-1] = '\0';
1564 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1565 cfg
.fontcharset
= lf
.lfCharSet
;
1566 cfg
.fontheight
= cf
.iPointSize
/ 10;
1567 fmtfont (fontstatic
);
1568 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
1572 if (HIWORD(wParam
) == BN_CLICKED
||
1573 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1574 cfg
.beep
= IsDlgButtonChecked (hwnd
, IDC_BEEP
);
1577 if (HIWORD(wParam
) == BN_CLICKED
||
1578 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1579 cfg
.blinktext
= IsDlgButtonChecked (hwnd
, IDC_BLINKTEXT
);
1582 if (HIWORD(wParam
) == BN_CLICKED
||
1583 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1584 cfg
.bce
= IsDlgButtonChecked (hwnd
, IDC_BCE
);
1587 if (HIWORD(wParam
) == BN_CLICKED
||
1588 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1589 cfg
.win_name_always
= IsDlgButtonChecked (hwnd
, IDC_WINNAME
);
1592 if (HIWORD(wParam
) == BN_CLICKED
||
1593 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1594 cfg
.hide_mouseptr
= IsDlgButtonChecked (hwnd
, IDC_HIDEMOUSE
);
1597 if (HIWORD(wParam
) == BN_CLICKED
||
1598 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1599 cfg
.cursor_type
= 0;
1602 if (HIWORD(wParam
) == BN_CLICKED
||
1603 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1604 cfg
.cursor_type
= 1;
1607 if (HIWORD(wParam
) == BN_CLICKED
||
1608 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1609 cfg
.cursor_type
= 2;
1612 if (HIWORD(wParam
) == BN_CLICKED
||
1613 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1614 cfg
.blink_cur
= IsDlgButtonChecked (hwnd
, IDC_BLINKCUR
);
1617 if (HIWORD(wParam
) == BN_CLICKED
||
1618 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1619 cfg
.scrollbar
= IsDlgButtonChecked (hwnd
, IDC_SCROLLBAR
);
1622 if (HIWORD(wParam
) == BN_CLICKED
||
1623 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1624 cfg
.locksize
= IsDlgButtonChecked (hwnd
, IDC_LOCKSIZE
);
1627 if (HIWORD(wParam
) == EN_CHANGE
)
1628 GetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
1629 sizeof(cfg
.wintitle
)-1);
1634 if (HIWORD(wParam
) == BN_CLICKED
||
1635 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1636 cfg
.close_on_exit
= IsDlgButtonChecked (hwnd
, IDC_COEALWAYS
) ? COE_ALWAYS
:
1637 IsDlgButtonChecked (hwnd
, IDC_COENEVER
) ? COE_NEVER
:
1642 if (HIWORD(wParam
) == BN_CLICKED
||
1643 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1644 cfg
.warn_on_close
= IsDlgButtonChecked (hwnd
, IDC_CLOSEWARN
);
1647 if (HIWORD(wParam
) == EN_CHANGE
)
1648 GetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
,
1649 sizeof(cfg
.termtype
)-1);
1652 if (HIWORD(wParam
) == EN_CHANGE
)
1653 GetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
1654 sizeof(cfg
.logfilename
)-1);
1657 memset(&of
, 0, sizeof(of
));
1658 #ifdef OPENFILENAME_SIZE_VERSION_400
1659 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1661 of
.lStructSize
= sizeof(of
);
1663 of
.hwndOwner
= hwnd
;
1664 of
.lpstrFilter
= "All Files\0*\0\0\0";
1665 of
.lpstrCustomFilter
= NULL
;
1666 of
.nFilterIndex
= 1;
1667 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.logfilename
);
1668 of
.nMaxFile
= sizeof(filename
);
1669 of
.lpstrFileTitle
= NULL
;
1670 of
.lpstrInitialDir
= NULL
;
1671 of
.lpstrTitle
= "Select session log file";
1673 if (GetSaveFileName(&of
)) {
1674 strcpy(cfg
.logfilename
, filename
);
1675 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
1679 case IDC_LSTATASCII
:
1681 if (HIWORD(wParam
) == BN_CLICKED
||
1682 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1683 if (IsDlgButtonChecked (hwnd
, IDC_LSTATOFF
)) cfg
.logtype
= 0;
1684 if (IsDlgButtonChecked (hwnd
, IDC_LSTATASCII
)) cfg
.logtype
= 1;
1685 if (IsDlgButtonChecked (hwnd
, IDC_LSTATRAW
)) cfg
.logtype
= 2;
1690 if (HIWORD(wParam
) == EN_CHANGE
)
1691 GetDlgItemText (hwnd
, LOWORD(wParam
), cfg
.termspeed
,
1692 sizeof(cfg
.termspeed
)-1);
1695 if (HIWORD(wParam
) == EN_CHANGE
)
1696 GetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
,
1697 sizeof(cfg
.username
)-1);
1699 case IDC_RLLUSEREDIT
:
1700 if (HIWORD(wParam
) == EN_CHANGE
)
1701 GetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
,
1702 sizeof(cfg
.localusername
)-1);
1706 cfg
.rfc_environ
= IsDlgButtonChecked (hwnd
, IDC_EMRFC
);
1709 if (HIWORD(wParam
) == BN_CLICKED
||
1710 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1711 char str
[sizeof(cfg
.environmt
)];
1713 GetDlgItemText (hwnd
, IDC_VAREDIT
, str
, sizeof(str
)-1);
1718 p
= str
+ strlen(str
);
1720 GetDlgItemText (hwnd
, IDC_VALEDIT
, p
, sizeof(str
)-1-(p
-str
));
1730 if ((p
-cfg
.environmt
) + strlen(str
) + 2 < sizeof(cfg
.environmt
)) {
1732 p
[strlen(str
)+1] = '\0';
1733 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
1735 SetDlgItemText (hwnd
, IDC_VAREDIT
, "");
1736 SetDlgItemText (hwnd
, IDC_VALEDIT
, "");
1738 MessageBox(hwnd
, "Environment too big", "PuTTY Error",
1739 MB_OK
| MB_ICONERROR
);
1744 if (HIWORD(wParam
) != BN_CLICKED
&&
1745 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1747 i
= SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0, 0);
1753 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
1778 if (HIWORD(wParam
) == BN_CLICKED
||
1779 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1780 cfg
.nopty
= IsDlgButtonChecked (hwnd
, IDC_NOPTY
);
1783 if (HIWORD(wParam
) == BN_CLICKED
||
1784 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1785 cfg
.compression
= IsDlgButtonChecked (hwnd
, IDC_COMPRESS
);
1788 if (HIWORD(wParam
) == BN_CLICKED
||
1789 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1790 cfg
.buggymac
= IsDlgButtonChecked (hwnd
, IDC_BUGGYMAC
);
1793 if (HIWORD(wParam
) == BN_CLICKED
||
1794 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1795 cfg
.agentfwd
= IsDlgButtonChecked (hwnd
, IDC_AGENTFWD
);
1797 case IDC_CIPHER3DES
:
1798 case IDC_CIPHERBLOWF
:
1801 if (HIWORD(wParam
) == BN_CLICKED
||
1802 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1803 if (IsDlgButtonChecked (hwnd
, IDC_CIPHER3DES
))
1804 cfg
.cipher
= CIPHER_3DES
;
1805 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERBLOWF
))
1806 cfg
.cipher
= CIPHER_BLOWFISH
;
1807 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERDES
))
1808 cfg
.cipher
= CIPHER_DES
;
1809 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERAES
))
1810 cfg
.cipher
= CIPHER_AES
;
1815 if (HIWORD(wParam
) == BN_CLICKED
||
1816 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1817 if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT1
))
1819 else if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT2
))
1824 if (HIWORD(wParam
) == BN_CLICKED
||
1825 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1826 cfg
.try_tis_auth
= IsDlgButtonChecked (hwnd
, IDC_AUTHTIS
);
1829 if (HIWORD(wParam
) == EN_CHANGE
)
1830 GetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
1831 sizeof(cfg
.keyfile
)-1);
1834 if (HIWORD(wParam
) == EN_CHANGE
)
1835 GetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
1836 sizeof(cfg
.remote_cmd
)-1);
1839 memset(&of
, 0, sizeof(of
));
1840 #ifdef OPENFILENAME_SIZE_VERSION_400
1841 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1843 of
.lStructSize
= sizeof(of
);
1845 of
.hwndOwner
= hwnd
;
1846 of
.lpstrFilter
= "All Files\0*\0\0\0";
1847 of
.lpstrCustomFilter
= NULL
;
1848 of
.nFilterIndex
= 1;
1849 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1850 of
.nMaxFile
= sizeof(filename
);
1851 of
.lpstrFileTitle
= NULL
;
1852 of
.lpstrInitialDir
= NULL
;
1853 of
.lpstrTitle
= "Select Public Key File";
1855 if (GetOpenFileName(&of
)) {
1856 strcpy(cfg
.keyfile
, filename
);
1857 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1861 cfg
.rawcnp
= IsDlgButtonChecked (hwnd
, IDC_RAWCNP
);
1864 cfg
.mouse_is_xterm
= IsDlgButtonChecked (hwnd
, IDC_MBXTERM
);
1870 int n
= GetDlgItemInt (hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
1875 for (i
=0; i
<256; i
++)
1876 if (SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_GETSEL
,
1879 cfg
.wordness
[i
] = n
;
1880 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1881 LB_DELETESTRING
, i
, 0);
1882 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
1883 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
1885 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1892 case IDC_BOLDCOLOUR
:
1893 if (HIWORD(wParam
) == BN_CLICKED
||
1894 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1896 cfg
.bold_colour
= IsDlgButtonChecked (hwnd
, IDC_BOLDCOLOUR
);
1897 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
1898 if (n
!= 12+10*cfg
.bold_colour
) {
1900 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1901 LB_DELETESTRING
, i
, 0);
1902 for (i
=0; i
<22; i
++)
1903 if (cfg
.bold_colour
|| permcolour
[i
])
1904 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1906 (LPARAM
) colours
[i
]);
1911 if (HIWORD(wParam
) == BN_CLICKED
||
1912 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1913 cfg
.try_palette
= IsDlgButtonChecked (hwnd
, IDC_PALETTE
);
1915 case IDC_COLOURLIST
:
1916 if (HIWORD(wParam
) == LBN_DBLCLK
||
1917 HIWORD(wParam
) == LBN_SELCHANGE
) {
1918 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1920 if (!cfg
.bold_colour
)
1921 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1922 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0], FALSE
);
1923 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1], FALSE
);
1924 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2], FALSE
);
1928 if (HIWORD(wParam
) == BN_CLICKED
||
1929 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1930 static CHOOSECOLOR cc
;
1931 static DWORD custom
[16] = {0}; /* zero initialisers */
1932 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1934 if (!cfg
.bold_colour
)
1935 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1936 cc
.lStructSize
= sizeof(cc
);
1937 cc
.hwndOwner
= hwnd
;
1938 cc
.hInstance
= (HWND
)hinst
;
1939 cc
.lpCustColors
= custom
;
1940 cc
.rgbResult
= RGB (cfg
.colours
[i
][0], cfg
.colours
[i
][1],
1942 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
1943 if (ChooseColor(&cc
)) {
1945 (unsigned char) (cc
.rgbResult
& 0xFF);
1947 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
1949 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
1950 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
1952 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
1954 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
1960 case IDC_KOI8WIN1251
:
1961 case IDC_88592WIN1250
:
1962 case IDC_88592CP852
:
1963 cfg
.xlat_enablekoiwin
=
1964 IsDlgButtonChecked (hwnd
, IDC_KOI8WIN1251
);
1965 cfg
.xlat_88592w1250
=
1966 IsDlgButtonChecked (hwnd
, IDC_88592WIN1250
);
1967 cfg
.xlat_88592cp852
=
1968 IsDlgButtonChecked (hwnd
, IDC_88592CP852
);
1970 case IDC_CAPSLOCKCYR
:
1971 if (HIWORD(wParam
) == BN_CLICKED
||
1972 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1973 cfg
.xlat_capslockcyr
=
1974 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
1977 case IDC_VTXWINDOWS
:
1982 (IsDlgButtonChecked (hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
:
1983 IsDlgButtonChecked (hwnd
, IDC_VTOEMANSI
) ? VT_OEMANSI
:
1984 IsDlgButtonChecked (hwnd
, IDC_VTOEMONLY
) ? VT_OEMONLY
:
1987 case IDC_X11_FORWARD
:
1988 if (HIWORD(wParam
) == BN_CLICKED
||
1989 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1990 cfg
.x11_forward
= IsDlgButtonChecked (hwnd
, IDC_X11_FORWARD
);
1992 case IDC_X11_DISPLAY
:
1993 if (HIWORD(wParam
) == EN_CHANGE
)
1994 GetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
1995 sizeof(cfg
.x11_display
)-1);
2000 EndDialog (hwnd
, 0);
2003 /* Grrr Explorer will maximize Dialogs! */
2005 if (wParam
== SIZE_MAXIMIZED
)
2012 static int CALLBACK
MainDlgProc (HWND hwnd
, UINT msg
,
2013 WPARAM wParam
, LPARAM lParam
) {
2014 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
2016 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
2017 EnableWindow(hwnd
, 0);
2018 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2019 GetParent(hwnd
), AboutProc
);
2020 EnableWindow(hwnd
, 1);
2021 SetActiveWindow(hwnd
);
2023 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 0);
2026 static int CALLBACK
ReconfDlgProc (HWND hwnd
, UINT msg
,
2027 WPARAM wParam
, LPARAM lParam
) {
2028 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 1);
2031 void defuse_showwindow(void) {
2033 * Work around the fact that the app's first call to ShowWindow
2034 * will ignore the default in favour of the shell-provided
2039 hwnd
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2041 ShowWindow(hwnd
, SW_HIDE
);
2042 DestroyWindow(hwnd
);
2046 int do_config (void) {
2050 savedsession
[0] = '\0';
2051 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2052 get_sesslist(FALSE
);
2057 int do_reconfig (HWND hwnd
) {
2061 backup_cfg
= cfg
; /* structure copy */
2062 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2064 cfg
= backup_cfg
; /* structure copy */
2069 void logevent (char *string
) {
2073 if (nevents
>= negsize
) {
2075 events
= srealloc (events
, negsize
* sizeof(*events
));
2079 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t", localtime(&t
));
2081 events
[nevents
] = smalloc(strlen(timebuf
)+strlen(string
)+1);
2082 strcpy(events
[nevents
], timebuf
);
2083 strcat(events
[nevents
], string
);
2086 SendDlgItemMessage (logbox
, IDN_LIST
, LB_ADDSTRING
,
2087 0, (LPARAM
)events
[nevents
]);
2088 count
= SendDlgItemMessage (logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2089 SendDlgItemMessage (logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
-1, 0);
2094 void showeventlog (HWND hwnd
) {
2096 logbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2098 ShowWindow (logbox
, SW_SHOWNORMAL
);
2100 SetActiveWindow(logbox
);
2103 void showabout (HWND hwnd
) {
2104 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),hwnd
, AboutProc
);
2107 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2108 char *keystr
, char *fingerprint
) {
2111 static const char absentmsg
[] =
2112 "The server's host key is not cached in the registry. You\n"
2113 "have no guarantee that the server is the computer you\n"
2115 "The server's key fingerprint is:\n"
2117 "If you trust this host, hit Yes to add the key to\n"
2118 "PuTTY's cache and carry on connecting.\n"
2119 "If you do not trust this host, hit No to abandon the\n"
2122 static const char wrongmsg
[] =
2123 "WARNING - POTENTIAL SECURITY BREACH!\n"
2125 "The server's host key does not match the one PuTTY has\n"
2126 "cached in the registry. This means that either the\n"
2127 "server administrator has changed the host key, or you\n"
2128 "have actually connected to another computer pretending\n"
2129 "to be the server.\n"
2130 "The new key fingerprint is:\n"
2132 "If you were expecting this change and trust the new key,\n"
2133 "hit Yes to update PuTTY's cache and continue connecting.\n"
2134 "If you want to carry on connecting but without updating\n"
2135 "the cache, hit No.\n"
2136 "If you want to abandon the connection completely, hit\n"
2137 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2140 static const char mbtitle
[] = "PuTTY Security Alert";
2143 char message
[160+ /* sensible fingerprint max size */
2144 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2145 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2148 * Verify the key against the registry.
2150 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2152 if (ret
== 0) /* success - key matched OK */
2154 if (ret
== 2) { /* key was different */
2156 sprintf(message
, wrongmsg
, fingerprint
);
2157 mbret
= MessageBox(NULL
, message
, mbtitle
,
2158 MB_ICONWARNING
| MB_YESNOCANCEL
);
2160 store_host_key(host
, port
, keytype
, keystr
);
2161 if (mbret
== IDCANCEL
)
2164 if (ret
== 1) { /* key was absent */
2166 sprintf(message
, absentmsg
, fingerprint
);
2167 mbret
= MessageBox(NULL
, message
, mbtitle
,
2168 MB_ICONWARNING
| MB_YESNO
);
2171 store_host_key(host
, port
, keytype
, keystr
);
2176 * Ask whether to wipe a session log file before writing to it.
2177 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2179 int askappend(char *filename
) {
2180 static const char mbtitle
[] = "PuTTY Log to File";
2181 static const char msgtemplate
[] =
2182 "The session log file \"%.*s\" already exists.\n"
2183 "You can overwrite it with a new session log,\n"
2184 "append your session log to the end of it,\n"
2185 "or disable session logging for this session.\n"
2186 "Hit Yes to wipe the file, No to append to it,\n"
2187 "or Cancel to disable logging.";
2188 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2190 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2192 mbret
= MessageBox(NULL
, message
, mbtitle
,
2193 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2196 else if (mbret
== IDNO
)