14 static char **events
= NULL
;
15 static int nevents
= 0, negsize
= 0;
19 void force_normal(HWND hwnd
)
21 static int recurse
= 0;
28 wp
.length
= sizeof(wp
);
29 if (GetWindowPlacement(hwnd
, &wp
) && wp
.showCmd
== SW_SHOWMAXIMIZED
)
31 wp
.showCmd
= SW_SHOWNORMAL
;
32 SetWindowPlacement(hwnd
, &wp
);
37 static void MyGetDlgItemInt (HWND hwnd
, int id
, int *result
) {
40 n
= GetDlgItemInt (hwnd
, id
, &ok
, FALSE
);
45 static int CALLBACK
LogProc (HWND hwnd
, UINT msg
,
46 WPARAM wParam
, LPARAM lParam
) {
51 for (i
=0; i
<nevents
; i
++)
52 SendDlgItemMessage (hwnd
, IDN_LIST
, LB_ADDSTRING
,
53 0, (LPARAM
)events
[i
]);
56 switch (LOWORD(wParam
)) {
60 SetActiveWindow(GetParent(hwnd
));
64 if (HIWORD(wParam
) == BN_CLICKED
||
65 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
68 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
69 LB_GETSELCOUNT
, 0, 0);
70 if (selcount
== 0) { /* don't even try to copy zero items */
75 selitems
= smalloc(selcount
* sizeof(int));
77 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
79 selcount
, (LPARAM
)selitems
);
83 static unsigned char sel_nl
[] = SEL_NL
;
85 if (count
== 0) { /* can't copy zero stuff */
91 for (i
= 0; i
< count
; i
++)
92 size
+= strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
94 clipdata
= smalloc(size
);
97 for (i
= 0; i
< count
; i
++) {
98 char *q
= events
[selitems
[i
]];
102 memcpy(p
, sel_nl
, sizeof(sel_nl
));
105 write_clip(clipdata
, size
, TRUE
);
110 for (i
= 0; i
< nevents
; i
++)
111 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
120 SetActiveWindow(GetParent(hwnd
));
121 DestroyWindow (hwnd
);
127 static int CALLBACK
LicenceProc (HWND hwnd
, UINT msg
,
128 WPARAM wParam
, LPARAM lParam
) {
133 switch (LOWORD(wParam
)) {
146 static int CALLBACK
AboutProc (HWND hwnd
, UINT msg
,
147 WPARAM wParam
, LPARAM lParam
) {
150 SetDlgItemText (hwnd
, IDA_VERSION
, ver
);
153 switch (LOWORD(wParam
)) {
156 EndDialog(hwnd
, TRUE
);
159 EnableWindow(hwnd
, 0);
160 DialogBox (hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
162 EnableWindow(hwnd
, 1);
163 SetActiveWindow(hwnd
);
168 EndDialog(hwnd
, TRUE
);
175 * Null dialog procedure.
177 static int CALLBACK
NullDlgProc (HWND hwnd
, UINT msg
,
178 WPARAM wParam
, LPARAM lParam
) {
182 static char savedsession
[2048];
184 enum { IDCX_ABOUT
= IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
290 appearancepanelstart
,
291 IDC_TITLE_APPEARANCE
,
309 connectionpanelstart
,
310 IDC_TITLE_CONNECTION
,
405 translationpanelstart
,
406 IDC_TITLE_TRANSLATION
,
407 IDC_BOX_TRANSLATION1
,
408 IDC_BOX_TRANSLATION2
,
409 IDC_BOX_TRANSLATION3
,
434 static const char *const colours
[] = {
435 "Default Foreground", "Default Bold Foreground",
436 "Default Background", "Default Bold Background",
437 "Cursor Text", "Cursor Colour",
438 "ANSI Black", "ANSI Black Bold",
439 "ANSI Red", "ANSI Red Bold",
440 "ANSI Green", "ANSI Green Bold",
441 "ANSI Yellow", "ANSI Yellow Bold",
442 "ANSI Blue", "ANSI Blue Bold",
443 "ANSI Magenta", "ANSI Magenta Bold",
444 "ANSI Cyan", "ANSI Cyan Bold",
445 "ANSI White", "ANSI White Bold"
447 static const int permcolour
[] = {
448 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
449 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
450 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
453 static void fmtfont (char *buf
) {
454 sprintf (buf
, "Font: %s, ", cfg
.font
);
456 strcat(buf
, "bold, ");
457 if (cfg
.fontheight
== 0)
458 strcat (buf
, "default height");
460 sprintf (buf
+strlen(buf
), "%d-%s",
461 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
),
462 (cfg
.fontheight
< 0 ?
"pixel" : "point"));
465 static void init_dlg_ctrls(HWND hwnd
) {
467 char fontstatic
[256];
469 SetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
);
470 SetDlgItemText (hwnd
, IDC_SESSEDIT
, savedsession
);
473 n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
475 SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
476 LB_DELETESTRING
, i
, 0);
477 for (i
= 0; i
< nsessions
; i
++)
478 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
479 0, (LPARAM
) (sessions
[i
]));
481 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
482 CheckRadioButton (hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
483 cfg
.protocol
==PROT_SSH ? IDC_PROTSSH
:
484 cfg
.protocol
==PROT_TELNET ? IDC_PROTTELNET
:
485 cfg
.protocol
==PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
486 SetDlgItemInt (hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
488 CheckRadioButton (hwnd
, IDC_DEL008
, IDC_DEL127
,
489 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
490 CheckRadioButton (hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
491 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
492 CheckRadioButton (hwnd
, IDC_FUNCTILDE
, IDC_FUNCVT400
,
493 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
494 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
495 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
496 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
498 CheckDlgButton (hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
499 CheckDlgButton (hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
500 CheckRadioButton (hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
501 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
502 CheckRadioButton (hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
503 cfg
.nethack_keypad ? IDC_KPNH
:
504 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
505 CheckDlgButton (hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
506 CheckDlgButton (hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
507 CheckDlgButton (hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
508 CheckDlgButton (hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
509 CheckRadioButton (hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
510 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
511 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
512 CheckRadioButton (hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
513 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
514 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
515 CheckDlgButton (hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
516 CheckDlgButton (hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
517 CheckDlgButton (hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
519 CheckDlgButton (hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
520 CheckDlgButton (hwnd
, IDC_DECOM
, cfg
.dec_om
);
521 CheckDlgButton (hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
522 SetDlgItemInt (hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
523 SetDlgItemInt (hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
524 SetDlgItemInt (hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
525 fmtfont (fontstatic
);
526 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
527 CheckDlgButton (hwnd
, IDC_BEEP
, cfg
.beep
);
528 CheckDlgButton (hwnd
, IDC_BCE
, cfg
.bce
);
529 CheckDlgButton (hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
531 SetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
532 CheckDlgButton (hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
533 CheckDlgButton (hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
534 CheckRadioButton (hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
535 cfg
.cursor_type
==0 ? IDC_CURBLOCK
:
536 cfg
.cursor_type
==1 ? IDC_CURUNDER
: IDC_CURVERT
);
537 CheckDlgButton (hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
538 CheckDlgButton (hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
539 CheckDlgButton (hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
540 CheckDlgButton (hwnd
, IDC_CLOSEEXIT
, cfg
.close_on_exit
);
541 CheckDlgButton (hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
543 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
544 SetDlgItemText (hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
545 SetDlgItemText (hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
546 SetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
547 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
548 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
549 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
550 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
551 cfg
.logtype
== 1 ? IDC_LSTATASCII
:
554 char *p
= cfg
.environmt
;
556 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
561 CheckRadioButton (hwnd
, IDC_EMBSD
, IDC_EMRFC
,
562 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
564 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
565 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
566 CheckDlgButton (hwnd
, IDC_NOPTY
, cfg
.nopty
);
567 CheckDlgButton (hwnd
, IDC_COMPRESS
, cfg
.compression
);
568 CheckDlgButton (hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
569 CheckDlgButton (hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
570 CheckRadioButton (hwnd
, IDC_CIPHER3DES
, IDC_CIPHERDES
,
571 cfg
.cipher
== CIPHER_BLOWFISH ? IDC_CIPHERBLOWF
:
572 cfg
.cipher
== CIPHER_DES ? IDC_CIPHERDES
:
574 CheckRadioButton (hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
575 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
576 CheckDlgButton (hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
577 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
578 SetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
580 CheckRadioButton (hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
581 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
583 static int tabs
[4] = {25, 61, 96, 128};
584 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
587 for (i
=0; i
<256; i
++) {
589 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
590 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
592 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
596 CheckDlgButton (hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
597 CheckDlgButton (hwnd
, IDC_PALETTE
, cfg
.try_palette
);
600 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
602 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
603 LB_DELETESTRING
, i
, 0);
605 if (cfg
.bold_colour
|| permcolour
[i
])
606 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
607 (LPARAM
) colours
[i
]);
609 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
610 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
611 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
612 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
614 CheckRadioButton (hwnd
, IDC_NOXLAT
, IDC_88592CP852
,
615 cfg
.xlat_88592w1250 ? IDC_88592WIN1250
:
616 cfg
.xlat_88592cp852 ? IDC_88592CP852
:
617 cfg
.xlat_enablekoiwin ? IDC_KOI8WIN1251
:
619 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
620 CheckRadioButton (hwnd
, IDC_VTXWINDOWS
, IDC_VTPOORMAN
,
621 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
622 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
623 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
626 CheckDlgButton (hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
627 SetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
630 struct treeview_faff
{
635 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
636 int level
, char *text
) {
640 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
-1] : TVI_ROOT
);
641 ins
.hInsertAfter
= faff
->lastat
[level
];
642 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
643 #define INSITEM DUMMYUNIONNAME.item
647 ins
.INSITEM
.mask
= TVIF_TEXT
;
648 ins
.INSITEM
.pszText
= text
;
649 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
651 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
-1], TVE_EXPAND
);
652 faff
->lastat
[level
] = newitem
;
653 for (i
= level
+1; i
< 4; i
++) faff
->lastat
[i
] = NULL
;
658 * Create the panelfuls of controls in the configuration box.
660 static void create_controls(HWND hwnd
, int dlgtype
, int panel
) {
661 if (panel
== sessionpanelstart
) {
662 /* The Session panel. Accelerators used: [acgo] nprtih elsd x */
664 ctlposinit(&cp
, hwnd
, 80, 3, 13);
665 bartitle(&cp
, "Basic options for your PuTTY session",
668 beginbox(&cp
, "Specify your connection by host name",
671 "Host &Name", IDC_HOSTSTATIC
, IDC_HOST
, 75,
672 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
673 if (backends
[3].backend
== NULL
) {
674 /* this is PuTTYtel, so only three protocols available */
675 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
677 "&Telnet", IDC_PROTTELNET
,
678 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
680 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
682 "&Telnet", IDC_PROTTELNET
,
683 "Rlog&in", IDC_PROTRLOGIN
,
692 beginbox(&cp
, "Load, save or delete a stored session",
694 sesssaver(&cp
, "Sav&ed Sessions",
695 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
696 "&Load", IDC_SESSLOAD
,
697 "&Save", IDC_SESSSAVE
,
698 "&Delete", IDC_SESSDEL
, NULL
);
701 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
702 checkbox(&cp
, "Close Window on E&xit", IDC_CLOSEEXIT
);
706 if (panel
== loggingpanelstart
) {
707 /* The Logging panel. Accelerators used: [acgo] tplfw */
709 ctlposinit(&cp
, hwnd
, 80, 3, 13);
710 bartitle(&cp
, "Options controlling session logging",
712 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
714 "Session logging:", IDC_LSTATSTATIC
,
715 "Logging &turned off completely", IDC_LSTATOFF
,
716 "Log &printable output only", IDC_LSTATASCII
,
717 "&Log all session output", IDC_LSTATRAW
, NULL
);
718 editbutton(&cp
, "Log &file name:",
719 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
724 if (panel
== terminalpanelstart
) {
725 /* The Terminal panel. Accelerators used: [acgo] wdlben ht */
727 ctlposinit(&cp
, hwnd
, 80, 3, 13);
728 bartitle(&cp
, "Options controlling the terminal emulation",
730 beginbox(&cp
, "Set various terminal options",
732 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
733 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
734 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
735 checkbox(&cp
, "&Beep enabled", IDC_BEEP
);
736 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
737 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
740 beginbox(&cp
, "Line discipline options",
742 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
743 "Auto", IDC_ECHOBACKEND
,
744 "Force on", IDC_ECHOYES
,
745 "Force off", IDC_ECHONO
, NULL
);
746 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
747 "Auto", IDC_EDITBACKEND
,
748 "Force on", IDC_EDITYES
,
749 "Force off", IDC_EDITNO
, NULL
);
753 if (panel
== keyboardpanelstart
) {
754 /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxv unpymie t */
756 ctlposinit(&cp
, hwnd
, 80, 3, 13);
757 bartitle(&cp
, "Options controlling the effects of keys",
759 beginbox(&cp
, "Change the sequences sent by:",
761 radioline(&cp
, "The Backspace key", IDC_DELSTATIC
, 2,
762 "Control-&H", IDC_DEL008
,
763 "Control-&? (127)", IDC_DEL127
, NULL
);
764 radioline(&cp
, "The Home and End keys", IDC_HOMESTATIC
, 2,
765 "&Standard", IDC_HOMETILDE
,
766 "&rxvt", IDC_HOMERXVT
, NULL
);
767 radioline(&cp
, "The Function keys and keypad", IDC_FUNCSTATIC
, 4,
768 "ESC[n&~", IDC_FUNCTILDE
,
769 "&Linux", IDC_FUNCLINUX
,
770 "&Xterm R6", IDC_FUNCXTERM
,
771 "&VT400", IDC_FUNCVT400
, NULL
);
773 beginbox(&cp
, "Application keypad settings:",
776 "Application c&ursor keys totally disabled",
778 radioline(&cp
, "Initial state of cursor keys:", IDC_CURSTATIC
, 2,
779 "&Normal", IDC_CURNORMAL
,
780 "A&pplication", IDC_CURAPPLIC
, NULL
);
782 "Application ke&ypad keys totally disabled",
784 radioline(&cp
, "Initial state of numeric keypad:", IDC_KPSTATIC
, 3,
785 "Nor&mal", IDC_KPNORMAL
,
786 "Appl&ication", IDC_KPAPPLIC
,
787 "N&etHack", IDC_KPNH
, NULL
);
789 beginbox(&cp
, "Enable extra keyboard features:",
791 checkbox(&cp
, "Application and AltGr ac&t as Compose key",
796 if (panel
== windowpanelstart
) {
797 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
799 ctlposinit(&cp
, hwnd
, 80, 3, 13);
800 bartitle(&cp
, "Options controlling PuTTY's window",
802 beginbox(&cp
, "Set the size of the window",
805 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
806 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50,
808 checkbox(&cp
, "Lock window size against resi&zing", IDC_LOCKSIZE
);
810 beginbox(&cp
, "Control the scrollback in the window",
812 staticedit(&cp
, "Lines of &scrollback",
813 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
814 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
815 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
816 checkbox(&cp
, "Reset scrollback on dis&play activity",
819 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
820 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
821 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
822 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
823 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
824 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
828 if (panel
== appearancepanelstart
) {
829 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p */
831 ctlposinit(&cp
, hwnd
, 80, 3, 13);
832 bartitle(&cp
, "Options controlling PuTTY's appearance",
833 IDC_TITLE_APPEARANCE
);
834 beginbox(&cp
, "Adjust the use of the cursor",
835 IDC_BOX_APPEARANCE1
);
836 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
837 "B&lock", IDC_CURBLOCK
,
838 "&Underline", IDC_CURUNDER
,
839 "&Vertical line", IDC_CURVERT
,
841 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
843 beginbox(&cp
, "Set the font used in the terminal window",
844 IDC_BOX_APPEARANCE2
);
845 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
847 beginbox(&cp
, "Adjust the use of the window title",
848 IDC_BOX_APPEARANCE3
);
850 "Window &title:", IDC_WINTITLE
,
851 IDC_WINEDIT
, 100, NULL
);
852 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
854 beginbox(&cp
, "Adjust the use of the mouse pointer",
855 IDC_BOX_APPEARANCE4
);
856 checkbox(&cp
, "Hide mouse &pointer when typing in window",
861 if (panel
== translationpanelstart
) {
862 /* The Translation panel. Accelerators used: [acgo] xbep t s */
864 ctlposinit(&cp
, hwnd
, 80, 3, 13);
865 bartitle(&cp
, "Options controlling character set translation",
866 IDC_TITLE_TRANSLATION
);
867 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
868 IDC_BOX_TRANSLATION1
);
870 "Handling of line drawing characters:", IDC_VTSTATIC
,
871 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
872 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
873 "Use font in O&EM mode only", IDC_VTOEMONLY
,
874 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
875 IDC_VTPOORMAN
, NULL
);
877 beginbox(&cp
, "Enable character set translation on received data",
878 IDC_BOX_TRANSLATION2
);
880 "Character set &translation:", IDC_XLATSTATIC
,
882 "KOI8 / Win-1251", IDC_KOI8WIN1251
,
883 "ISO-8859-2 / Win-1250", IDC_88592WIN1250
,
884 "ISO-8859-2 / CP852", IDC_88592CP852
, NULL
);
886 beginbox(&cp
, "Enable character set translation on input data",
887 IDC_BOX_TRANSLATION3
);
888 checkbox(&cp
, "CAP&S LOCK acts as cyrillic switch",
893 if (panel
== selectionpanelstart
) {
894 /* The Selection panel. Accelerators used: [acgo] wx hst */
896 ctlposinit(&cp
, hwnd
, 80, 3, 13);
897 bartitle(&cp
, "Options controlling copy and paste",
898 IDC_TITLE_SELECTION
);
899 beginbox(&cp
, "Control which mouse button does which thing",
901 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
902 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
903 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
906 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
908 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
909 "&Set", IDC_CCSET
, IDC_CCEDIT
,
910 "&to class", IDC_CCSTATIC2
);
914 if (panel
== colourspanelstart
) {
915 /* The Colours panel. Accelerators used: [acgo] blum */
917 ctlposinit(&cp
, hwnd
, 80, 3, 13);
918 bartitle(&cp
, "Options controlling use of colours",
920 beginbox(&cp
, "General options for colour usage",
922 checkbox(&cp
, "&Bolded text is a different colour", IDC_BOLDCOLOUR
);
923 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
925 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
927 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
928 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
929 "&Modify...", IDC_CHANGE
,
930 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
931 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
932 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
936 if (panel
== connectionpanelstart
) {
937 /* The Connection panel. Accelerators used: [acgo] tuk */
939 ctlposinit(&cp
, hwnd
, 80, 3, 13);
940 bartitle(&cp
, "Options controlling the connection", IDC_TITLE_CONNECTION
);
942 beginbox(&cp
, "Data to send to the server",
943 IDC_BOX_CONNECTION1
);
944 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
, IDC_TTEDIT
, 50);
945 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
, IDC_LOGEDIT
, 50);
948 beginbox(&cp
, "Sending of null packets to keep session active",
949 IDC_BOX_CONNECTION2
);
950 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
951 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
955 if (panel
== telnetpanelstart
) {
956 /* The Telnet panel. Accelerators used: [acgo] svldr bf */
958 ctlposinit(&cp
, hwnd
, 80, 3, 13);
960 bartitle(&cp
, "Options controlling Telnet connections", IDC_TITLE_TELNET
);
961 beginbox(&cp
, "Data to send to the server",
963 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
, IDC_TSEDIT
, 50);
964 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
965 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
,
966 "Va&lue", IDC_VALSTATIC
, IDC_VALEDIT
,
968 "A&dd", IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
970 beginbox(&cp
, "Telnet protocol adjustments",
972 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC
, 2,
973 "&BSD (commonplace)", IDC_EMBSD
,
974 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
979 if (panel
== rloginpanelstart
) {
980 /* The Rlogin panel. Accelerators used: [acgo] sl */
982 ctlposinit(&cp
, hwnd
, 80, 3, 13);
984 bartitle(&cp
, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN
);
985 beginbox(&cp
, "Data to send to the server",
987 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
, IDC_R_TSEDIT
, 50);
988 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
, IDC_RLLUSEREDIT
, 50);
993 if (panel
== sshpanelstart
) {
994 /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bd i */
996 ctlposinit(&cp
, hwnd
, 80, 3, 13);
998 bartitle(&cp
, "Options controlling SSH connections", IDC_TITLE_SSH
);
999 beginbox(&cp
, "Data to send to the server",
1002 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1005 beginbox(&cp
, "Authentication options",
1007 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1009 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1010 editbutton(&cp
, "Private &key file for authentication:",
1011 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...", IDC_PKBUTTON
);
1013 beginbox(&cp
, "Protocol options",
1015 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1016 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1017 radioline(&cp
, "Preferred SSH protocol version:",
1018 IDC_SSHPROTSTATIC
, 2,
1019 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1020 radioline(&cp
, "Preferred encryption algorithm:", IDC_CIPHERSTATIC
, 3,
1021 "&3DES", IDC_CIPHER3DES
,
1022 "&Blowfish", IDC_CIPHERBLOWF
,
1023 "&DES", IDC_CIPHERDES
, NULL
);
1024 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1030 if (panel
== tunnelspanelstart
) {
1031 /* The Tunnels panel. Accelerators used: [acgo] ex */
1033 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1035 bartitle(&cp
, "Options controlling SSH tunnelling",
1037 beginbox(&cp
, "X11 forwarding options",
1039 checkbox(&cp
, "&Enable X11 forwarding",
1041 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1042 IDC_X11_DISPLAY
, 50, NULL
);
1049 * This function is the configuration box.
1051 static int GenericMainDlgProc (HWND hwnd
, UINT msg
,
1052 WPARAM wParam
, LPARAM lParam
,
1055 struct treeview_faff tvfaff
;
1058 char filename
[sizeof(cfg
.keyfile
)];
1061 char fontstatic
[256];
1063 struct servent
* service
;
1069 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1071 * Centre the window.
1073 { /* centre the window */
1076 hw
= GetDesktopWindow();
1077 if (GetWindowRect (hw
, &rs
) && GetWindowRect (hwnd
, &rd
))
1078 MoveWindow (hwnd
, (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
)/2,
1079 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
)/2,
1080 rd
.right
-rd
.left
, rd
.bottom
-rd
.top
, TRUE
);
1084 * Create the tree view.
1091 r
.left
= 3; r
.right
= r
.left
+ 75;
1092 r
.top
= 3; r
.bottom
= r
.top
+ 10;
1093 MapDialogRect(hwnd
, &r
);
1094 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1095 WS_CHILD
| WS_VISIBLE
,
1097 r
.right
-r
.left
, r
.bottom
-r
.top
,
1098 hwnd
, (HMENU
)IDCX_TVSTATIC
, hinst
, NULL
);
1099 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1100 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1102 r
.left
= 3; r
.right
= r
.left
+ 75;
1103 r
.top
= 13; r
.bottom
= r
.top
+ 206;
1104 MapDialogRect(hwnd
, &r
);
1105 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1106 WS_CHILD
| WS_VISIBLE
|
1107 WS_TABSTOP
| TVS_HASLINES
|
1108 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
|
1109 TVS_LINESATROOT
| TVS_SHOWSELALWAYS
,
1111 r
.right
-r
.left
, r
.bottom
-r
.top
,
1112 hwnd
, (HMENU
)IDCX_TREEVIEW
, hinst
, NULL
);
1113 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1114 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1115 tvfaff
.treeview
= treeview
;
1116 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1120 * Set up the tree view contents.
1122 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1123 treeview_insert(&tvfaff
, 1, "Logging");
1124 treeview_insert(&tvfaff
, 0, "Terminal");
1125 treeview_insert(&tvfaff
, 1, "Keyboard");
1126 treeview_insert(&tvfaff
, 0, "Window");
1127 treeview_insert(&tvfaff
, 1, "Appearance");
1128 treeview_insert(&tvfaff
, 1, "Translation");
1129 treeview_insert(&tvfaff
, 1, "Selection");
1130 treeview_insert(&tvfaff
, 1, "Colours");
1131 treeview_insert(&tvfaff
, 0, "Connection");
1133 treeview_insert(&tvfaff
, 1, "Telnet");
1134 treeview_insert(&tvfaff
, 1, "Rlogin");
1135 if (backends
[3].backend
!= NULL
) {
1136 treeview_insert(&tvfaff
, 1, "SSH");
1137 treeview_insert(&tvfaff
, 2, "Tunnels");
1142 * Put the treeview selection on to the Session panel. This
1143 * should also cause creation of the relevant controls.
1145 TreeView_SelectItem(treeview
, hsession
);
1148 * Set focus into the first available control.
1152 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1153 if (!ctl
) ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1157 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1161 * Button release should trigger WM_OK if there was a
1162 * previous double click on the session list.
1166 SendMessage (hwnd
, WM_COMMAND
, IDOK
, 0);
1169 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1170 ((LPNMHDR
)lParam
)->code
== TVN_SELCHANGED
) {
1171 HTREEITEM i
= TreeView_GetSelection(((LPNMHDR
)lParam
)->hwndFrom
);
1176 item
.pszText
= buffer
;
1177 item
.cchTextMax
= sizeof(buffer
);
1178 item
.mask
= TVIF_TEXT
;
1179 TreeView_GetItem(((LPNMHDR
)lParam
)->hwndFrom
, &item
);
1180 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1181 HWND item
= GetDlgItem(hwnd
, j
);
1183 DestroyWindow(item
);
1185 if (!strcmp(buffer
, "Session"))
1186 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1187 if (!strcmp(buffer
, "Logging"))
1188 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1189 if (!strcmp(buffer
, "Keyboard"))
1190 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1191 if (!strcmp(buffer
, "Terminal"))
1192 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1193 if (!strcmp(buffer
, "Window"))
1194 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1195 if (!strcmp(buffer
, "Appearance"))
1196 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1197 if (!strcmp(buffer
, "Tunnels"))
1198 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1199 if (!strcmp(buffer
, "Connection"))
1200 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1201 if (!strcmp(buffer
, "Telnet"))
1202 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1203 if (!strcmp(buffer
, "Rlogin"))
1204 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1205 if (!strcmp(buffer
, "SSH"))
1206 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1207 if (!strcmp(buffer
, "Selection"))
1208 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1209 if (!strcmp(buffer
, "Colours"))
1210 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1211 if (!strcmp(buffer
, "Translation"))
1212 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1214 init_dlg_ctrls(hwnd
);
1216 SetFocus (((LPNMHDR
)lParam
)->hwndFrom
); /* ensure focus stays */
1222 * Only process WM_COMMAND once the dialog is fully formed.
1224 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
1227 EndDialog (hwnd
, 1);
1232 EndDialog (hwnd
, 0);
1234 case IDC_PROTTELNET
:
1235 case IDC_PROTRLOGIN
:
1238 if (HIWORD(wParam
) == BN_CLICKED
||
1239 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1240 int i
= IsDlgButtonChecked (hwnd
, IDC_PROTSSH
);
1241 int j
= IsDlgButtonChecked (hwnd
, IDC_PROTTELNET
);
1242 int k
= IsDlgButtonChecked (hwnd
, IDC_PROTRLOGIN
);
1243 cfg
.protocol
= i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
: PROT_RAW
;
1244 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22) ||
1245 (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23) ||
1246 (cfg
.protocol
== PROT_RLOGIN
&& cfg
.port
!= 513)) {
1247 cfg
.port
= i ?
22 : j ?
23 : 513;
1248 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1253 if (HIWORD(wParam
) == EN_CHANGE
)
1254 GetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
,
1255 sizeof(cfg
.host
)-1);
1258 if (HIWORD(wParam
) == EN_CHANGE
) {
1259 GetDlgItemText (hwnd
, IDC_PORT
, portname
, 31);
1260 if (isdigit(portname
[0]))
1261 MyGetDlgItemInt (hwnd
, IDC_PORT
, &cfg
.port
);
1263 service
= getservbyname(portname
, NULL
);
1264 if (service
) cfg
.port
= ntohs(service
->s_port
);
1270 if (HIWORD(wParam
) == EN_CHANGE
) {
1271 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1273 GetDlgItemText (hwnd
, IDC_SESSEDIT
,
1274 savedsession
, sizeof(savedsession
)-1);
1275 savedsession
[sizeof(savedsession
)-1] = '\0';
1279 if (HIWORD(wParam
) == BN_CLICKED
||
1280 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1285 GetDlgItemText (hwnd
, IDC_SESSEDIT
, str
, sizeof(str
)-1);
1287 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1288 LB_GETCURSEL
, 0, 0);
1293 strcpy (str
, sessions
[n
]);
1295 save_settings (str
, !!strcmp(str
, "Default Settings"), &cfg
);
1296 get_sesslist (FALSE
);
1297 get_sesslist (TRUE
);
1298 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1300 for (i
= 0; i
< nsessions
; i
++)
1301 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1302 0, (LPARAM
) (sessions
[i
]));
1303 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1309 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1310 HIWORD(wParam
) != BN_CLICKED
&&
1311 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1313 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1314 HIWORD(wParam
) != LBN_DBLCLK
)
1317 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1318 LB_GETCURSEL
, 0, 0);
1324 isdef
= !strcmp(sessions
[n
], "Default Settings");
1325 load_settings (sessions
[n
], !isdef
, &cfg
);
1326 init_dlg_ctrls(hwnd
);
1328 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1330 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1332 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1334 * A double-click on a saved session should
1335 * actually start the session, not just load it.
1336 * Unless it's Default Settings or some other
1337 * host-less set of saved settings.
1346 if (HIWORD(wParam
) == BN_CLICKED
||
1347 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1348 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1349 LB_GETCURSEL
, 0, 0);
1350 if (n
== LB_ERR
|| n
== 0) {
1354 del_settings(sessions
[n
]);
1355 get_sesslist (FALSE
);
1356 get_sesslist (TRUE
);
1357 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1359 for (i
= 0; i
< nsessions
; i
++)
1360 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1361 0, (LPARAM
) (sessions
[i
]));
1362 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1366 if (HIWORD(wParam
) == EN_CHANGE
)
1367 MyGetDlgItemInt (hwnd
, IDC_PINGEDIT
, &cfg
.ping_interval
);
1371 if (HIWORD(wParam
) == BN_CLICKED
||
1372 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1373 cfg
.bksp_is_delete
= IsDlgButtonChecked (hwnd
, IDC_DEL127
);
1377 if (HIWORD(wParam
) == BN_CLICKED
||
1378 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1379 cfg
.rxvt_homeend
= IsDlgButtonChecked (hwnd
, IDC_HOMERXVT
);
1382 if (HIWORD(wParam
) == BN_CLICKED
||
1383 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1387 if (HIWORD(wParam
) == BN_CLICKED
||
1388 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1393 if (HIWORD(wParam
) == BN_CLICKED
||
1394 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1395 cfg
.funky_type
= IsDlgButtonChecked (hwnd
, IDC_FUNCLINUX
);
1399 if (HIWORD(wParam
) == BN_CLICKED
||
1400 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1401 cfg
.app_keypad
= IsDlgButtonChecked (hwnd
, IDC_KPAPPLIC
);
1402 cfg
.nethack_keypad
= FALSE
;
1406 if (HIWORD(wParam
) == BN_CLICKED
||
1407 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1408 cfg
.app_keypad
= FALSE
;
1409 cfg
.nethack_keypad
= TRUE
;
1414 if (HIWORD(wParam
) == BN_CLICKED
||
1415 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1416 cfg
.app_cursor
= IsDlgButtonChecked (hwnd
, IDC_CURAPPLIC
);
1419 if (HIWORD(wParam
) == BN_CLICKED
||
1420 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1421 cfg
.no_applic_c
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICC
);
1424 if (HIWORD(wParam
) == BN_CLICKED
||
1425 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1426 cfg
.no_applic_k
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICK
);
1429 if (HIWORD(wParam
) == BN_CLICKED
||
1430 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1431 cfg
.alt_f4
= IsDlgButtonChecked (hwnd
, IDC_ALTF4
);
1434 if (HIWORD(wParam
) == BN_CLICKED
||
1435 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1436 cfg
.alt_space
= IsDlgButtonChecked (hwnd
, IDC_ALTSPACE
);
1439 if (HIWORD(wParam
) == BN_CLICKED
||
1440 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1441 cfg
.alt_only
= IsDlgButtonChecked (hwnd
, IDC_ALTONLY
);
1443 case IDC_ECHOBACKEND
:
1446 if (HIWORD(wParam
) == BN_CLICKED
||
1447 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1448 if (LOWORD(wParam
)==IDC_ECHOBACKEND
) cfg
.localecho
=LD_BACKEND
;
1449 if (LOWORD(wParam
)==IDC_ECHOYES
) cfg
.localecho
=LD_YES
;
1450 if (LOWORD(wParam
)==IDC_ECHONO
) cfg
.localecho
=LD_NO
;
1453 case IDC_EDITBACKEND
:
1456 if (HIWORD(wParam
) == BN_CLICKED
||
1457 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1458 if (LOWORD(wParam
)==IDC_EDITBACKEND
) cfg
.localedit
=LD_BACKEND
;
1459 if (LOWORD(wParam
)==IDC_EDITYES
) cfg
.localedit
=LD_YES
;
1460 if (LOWORD(wParam
)==IDC_EDITNO
) cfg
.localedit
=LD_NO
;
1463 case IDC_ALWAYSONTOP
:
1464 if (HIWORD(wParam
) == BN_CLICKED
||
1465 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1466 cfg
.alwaysontop
= IsDlgButtonChecked (hwnd
, IDC_ALWAYSONTOP
);
1469 if (HIWORD(wParam
) == BN_CLICKED
||
1470 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1471 cfg
.scroll_on_key
= IsDlgButtonChecked (hwnd
, IDC_SCROLLKEY
);
1473 case IDC_SCROLLDISP
:
1474 if (HIWORD(wParam
) == BN_CLICKED
||
1475 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1476 cfg
.scroll_on_disp
= IsDlgButtonChecked (hwnd
, IDC_SCROLLDISP
);
1478 case IDC_COMPOSEKEY
:
1479 if (HIWORD(wParam
) == BN_CLICKED
||
1480 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1481 cfg
.compose_key
= IsDlgButtonChecked (hwnd
, IDC_COMPOSEKEY
);
1484 if (HIWORD(wParam
) == BN_CLICKED
||
1485 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1486 cfg
.wrap_mode
= IsDlgButtonChecked (hwnd
, IDC_WRAPMODE
);
1489 if (HIWORD(wParam
) == BN_CLICKED
||
1490 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1491 cfg
.dec_om
= IsDlgButtonChecked (hwnd
, IDC_DECOM
);
1494 if (HIWORD(wParam
) == BN_CLICKED
||
1495 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1496 cfg
.lfhascr
= IsDlgButtonChecked (hwnd
, IDC_LFHASCR
);
1499 if (HIWORD(wParam
) == EN_CHANGE
)
1500 MyGetDlgItemInt (hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1503 if (HIWORD(wParam
) == EN_CHANGE
)
1504 MyGetDlgItemInt (hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1507 if (HIWORD(wParam
) == EN_CHANGE
)
1508 MyGetDlgItemInt (hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1510 case IDC_CHOOSEFONT
:
1511 lf
.lfHeight
= cfg
.fontheight
;
1512 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1513 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1514 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1515 lf
.lfCharSet
= cfg
.fontcharset
;
1516 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1517 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1518 lf
.lfQuality
= DEFAULT_QUALITY
;
1519 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1520 strncpy (lf
.lfFaceName
, cfg
.font
, sizeof(lf
.lfFaceName
)-1);
1521 lf
.lfFaceName
[sizeof(lf
.lfFaceName
)-1] = '\0';
1523 cf
.lStructSize
= sizeof(cf
);
1524 cf
.hwndOwner
= hwnd
;
1526 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1527 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1529 if (ChooseFont (&cf
)) {
1530 strncpy (cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
)-1);
1531 cfg
.font
[sizeof(cfg
.font
)-1] = '\0';
1532 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1533 cfg
.fontcharset
= lf
.lfCharSet
;
1534 cfg
.fontheight
= lf
.lfHeight
;
1535 fmtfont (fontstatic
);
1536 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
1540 if (HIWORD(wParam
) == BN_CLICKED
||
1541 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1542 cfg
.beep
= IsDlgButtonChecked (hwnd
, IDC_BEEP
);
1545 if (HIWORD(wParam
) == BN_CLICKED
||
1546 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1547 cfg
.blinktext
= IsDlgButtonChecked (hwnd
, IDC_BLINKTEXT
);
1550 if (HIWORD(wParam
) == BN_CLICKED
||
1551 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1552 cfg
.bce
= IsDlgButtonChecked (hwnd
, IDC_BCE
);
1555 if (HIWORD(wParam
) == BN_CLICKED
||
1556 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1557 cfg
.win_name_always
= IsDlgButtonChecked (hwnd
, IDC_WINNAME
);
1560 if (HIWORD(wParam
) == BN_CLICKED
||
1561 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1562 cfg
.hide_mouseptr
= IsDlgButtonChecked (hwnd
, IDC_HIDEMOUSE
);
1565 if (HIWORD(wParam
) == BN_CLICKED
||
1566 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1567 cfg
.cursor_type
= 0;
1570 if (HIWORD(wParam
) == BN_CLICKED
||
1571 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1572 cfg
.cursor_type
= 1;
1575 if (HIWORD(wParam
) == BN_CLICKED
||
1576 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1577 cfg
.cursor_type
= 2;
1580 if (HIWORD(wParam
) == BN_CLICKED
||
1581 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1582 cfg
.blink_cur
= IsDlgButtonChecked (hwnd
, IDC_BLINKCUR
);
1585 if (HIWORD(wParam
) == BN_CLICKED
||
1586 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1587 cfg
.scrollbar
= IsDlgButtonChecked (hwnd
, IDC_SCROLLBAR
);
1590 if (HIWORD(wParam
) == BN_CLICKED
||
1591 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1592 cfg
.locksize
= IsDlgButtonChecked (hwnd
, IDC_LOCKSIZE
);
1595 if (HIWORD(wParam
) == EN_CHANGE
)
1596 GetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
1597 sizeof(cfg
.wintitle
)-1);
1600 if (HIWORD(wParam
) == BN_CLICKED
||
1601 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1602 cfg
.close_on_exit
= IsDlgButtonChecked (hwnd
, IDC_CLOSEEXIT
);
1605 if (HIWORD(wParam
) == BN_CLICKED
||
1606 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1607 cfg
.warn_on_close
= IsDlgButtonChecked (hwnd
, IDC_CLOSEWARN
);
1610 if (HIWORD(wParam
) == EN_CHANGE
)
1611 GetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
,
1612 sizeof(cfg
.termtype
)-1);
1615 if (HIWORD(wParam
) == EN_CHANGE
)
1616 GetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
1617 sizeof(cfg
.logfilename
)-1);
1620 memset(&of
, 0, sizeof(of
));
1621 #ifdef OPENFILENAME_SIZE_VERSION_400
1622 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1624 of
.lStructSize
= sizeof(of
);
1626 of
.hwndOwner
= hwnd
;
1627 of
.lpstrFilter
= "All Files\0*\0\0\0";
1628 of
.lpstrCustomFilter
= NULL
;
1629 of
.nFilterIndex
= 1;
1630 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.logfilename
);
1631 of
.nMaxFile
= sizeof(filename
);
1632 of
.lpstrFileTitle
= NULL
;
1633 of
.lpstrInitialDir
= NULL
;
1634 of
.lpstrTitle
= "Select session log file";
1636 if (GetSaveFileName(&of
)) {
1637 strcpy(cfg
.logfilename
, filename
);
1638 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
1642 case IDC_LSTATASCII
:
1644 if (HIWORD(wParam
) == BN_CLICKED
||
1645 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1646 if (IsDlgButtonChecked (hwnd
, IDC_LSTATOFF
)) cfg
.logtype
= 0;
1647 if (IsDlgButtonChecked (hwnd
, IDC_LSTATASCII
)) cfg
.logtype
= 1;
1648 if (IsDlgButtonChecked (hwnd
, IDC_LSTATRAW
)) cfg
.logtype
= 2;
1653 if (HIWORD(wParam
) == EN_CHANGE
)
1654 GetDlgItemText (hwnd
, LOWORD(wParam
), cfg
.termspeed
,
1655 sizeof(cfg
.termspeed
)-1);
1658 if (HIWORD(wParam
) == EN_CHANGE
)
1659 GetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
,
1660 sizeof(cfg
.username
)-1);
1662 case IDC_RLLUSEREDIT
:
1663 if (HIWORD(wParam
) == EN_CHANGE
)
1664 GetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
,
1665 sizeof(cfg
.localusername
)-1);
1669 cfg
.rfc_environ
= IsDlgButtonChecked (hwnd
, IDC_EMRFC
);
1672 if (HIWORD(wParam
) == BN_CLICKED
||
1673 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1674 char str
[sizeof(cfg
.environmt
)];
1676 GetDlgItemText (hwnd
, IDC_VAREDIT
, str
, sizeof(str
)-1);
1681 p
= str
+ strlen(str
);
1683 GetDlgItemText (hwnd
, IDC_VALEDIT
, p
, sizeof(str
)-1-(p
-str
));
1693 if ((p
-cfg
.environmt
) + strlen(str
) + 2 < sizeof(cfg
.environmt
)) {
1695 p
[strlen(str
)+1] = '\0';
1696 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
1698 SetDlgItemText (hwnd
, IDC_VAREDIT
, "");
1699 SetDlgItemText (hwnd
, IDC_VALEDIT
, "");
1701 MessageBox(hwnd
, "Environment too big", "PuTTY Error",
1702 MB_OK
| MB_ICONERROR
);
1707 if (HIWORD(wParam
) != BN_CLICKED
&&
1708 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1710 i
= SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0, 0);
1716 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
1741 if (HIWORD(wParam
) == BN_CLICKED
||
1742 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1743 cfg
.nopty
= IsDlgButtonChecked (hwnd
, IDC_NOPTY
);
1746 if (HIWORD(wParam
) == BN_CLICKED
||
1747 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1748 cfg
.compression
= IsDlgButtonChecked (hwnd
, IDC_COMPRESS
);
1751 if (HIWORD(wParam
) == BN_CLICKED
||
1752 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1753 cfg
.buggymac
= IsDlgButtonChecked (hwnd
, IDC_BUGGYMAC
);
1756 if (HIWORD(wParam
) == BN_CLICKED
||
1757 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1758 cfg
.agentfwd
= IsDlgButtonChecked (hwnd
, IDC_AGENTFWD
);
1760 case IDC_CIPHER3DES
:
1761 case IDC_CIPHERBLOWF
:
1763 if (HIWORD(wParam
) == BN_CLICKED
||
1764 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1765 if (IsDlgButtonChecked (hwnd
, IDC_CIPHER3DES
))
1766 cfg
.cipher
= CIPHER_3DES
;
1767 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERBLOWF
))
1768 cfg
.cipher
= CIPHER_BLOWFISH
;
1769 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERDES
))
1770 cfg
.cipher
= CIPHER_DES
;
1775 if (HIWORD(wParam
) == BN_CLICKED
||
1776 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1777 if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT1
))
1779 else if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT2
))
1784 if (HIWORD(wParam
) == BN_CLICKED
||
1785 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1786 cfg
.try_tis_auth
= IsDlgButtonChecked (hwnd
, IDC_AUTHTIS
);
1789 if (HIWORD(wParam
) == EN_CHANGE
)
1790 GetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
1791 sizeof(cfg
.keyfile
)-1);
1794 if (HIWORD(wParam
) == EN_CHANGE
)
1795 GetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
1796 sizeof(cfg
.remote_cmd
)-1);
1799 memset(&of
, 0, sizeof(of
));
1800 #ifdef OPENFILENAME_SIZE_VERSION_400
1801 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1803 of
.lStructSize
= sizeof(of
);
1805 of
.hwndOwner
= hwnd
;
1806 of
.lpstrFilter
= "All Files\0*\0\0\0";
1807 of
.lpstrCustomFilter
= NULL
;
1808 of
.nFilterIndex
= 1;
1809 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1810 of
.nMaxFile
= sizeof(filename
);
1811 of
.lpstrFileTitle
= NULL
;
1812 of
.lpstrInitialDir
= NULL
;
1813 of
.lpstrTitle
= "Select Public Key File";
1815 if (GetOpenFileName(&of
)) {
1816 strcpy(cfg
.keyfile
, filename
);
1817 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1822 cfg
.mouse_is_xterm
= IsDlgButtonChecked (hwnd
, IDC_MBXTERM
);
1828 int n
= GetDlgItemInt (hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
1833 for (i
=0; i
<256; i
++)
1834 if (SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_GETSEL
,
1837 cfg
.wordness
[i
] = n
;
1838 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1839 LB_DELETESTRING
, i
, 0);
1840 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
1841 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
1843 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1850 case IDC_BOLDCOLOUR
:
1851 if (HIWORD(wParam
) == BN_CLICKED
||
1852 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1854 cfg
.bold_colour
= IsDlgButtonChecked (hwnd
, IDC_BOLDCOLOUR
);
1855 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
1856 if (n
!= 12+10*cfg
.bold_colour
) {
1858 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1859 LB_DELETESTRING
, i
, 0);
1860 for (i
=0; i
<22; i
++)
1861 if (cfg
.bold_colour
|| permcolour
[i
])
1862 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1864 (LPARAM
) colours
[i
]);
1869 if (HIWORD(wParam
) == BN_CLICKED
||
1870 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1871 cfg
.try_palette
= IsDlgButtonChecked (hwnd
, IDC_PALETTE
);
1873 case IDC_COLOURLIST
:
1874 if (HIWORD(wParam
) == LBN_DBLCLK
||
1875 HIWORD(wParam
) == LBN_SELCHANGE
) {
1876 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1878 if (!cfg
.bold_colour
)
1879 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1880 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0], FALSE
);
1881 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1], FALSE
);
1882 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2], FALSE
);
1886 if (HIWORD(wParam
) == BN_CLICKED
||
1887 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1888 static CHOOSECOLOR cc
;
1889 static DWORD custom
[16] = {0}; /* zero initialisers */
1890 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1892 if (!cfg
.bold_colour
)
1893 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1894 cc
.lStructSize
= sizeof(cc
);
1895 cc
.hwndOwner
= hwnd
;
1896 cc
.hInstance
= (HWND
)hinst
;
1897 cc
.lpCustColors
= custom
;
1898 cc
.rgbResult
= RGB (cfg
.colours
[i
][0], cfg
.colours
[i
][1],
1900 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
1901 if (ChooseColor(&cc
)) {
1903 (unsigned char) (cc
.rgbResult
& 0xFF);
1905 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
1907 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
1908 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
1910 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
1912 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
1918 case IDC_KOI8WIN1251
:
1919 case IDC_88592WIN1250
:
1920 case IDC_88592CP852
:
1921 cfg
.xlat_enablekoiwin
=
1922 IsDlgButtonChecked (hwnd
, IDC_KOI8WIN1251
);
1923 cfg
.xlat_88592w1250
=
1924 IsDlgButtonChecked (hwnd
, IDC_88592WIN1250
);
1925 cfg
.xlat_88592cp852
=
1926 IsDlgButtonChecked (hwnd
, IDC_88592CP852
);
1928 case IDC_CAPSLOCKCYR
:
1929 if (HIWORD(wParam
) == BN_CLICKED
||
1930 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1931 cfg
.xlat_capslockcyr
=
1932 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
1935 case IDC_VTXWINDOWS
:
1940 (IsDlgButtonChecked (hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
:
1941 IsDlgButtonChecked (hwnd
, IDC_VTOEMANSI
) ? VT_OEMANSI
:
1942 IsDlgButtonChecked (hwnd
, IDC_VTOEMONLY
) ? VT_OEMONLY
:
1945 case IDC_X11_FORWARD
:
1946 if (HIWORD(wParam
) == BN_CLICKED
||
1947 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1948 cfg
.x11_forward
= IsDlgButtonChecked (hwnd
, IDC_X11_FORWARD
);
1950 case IDC_X11_DISPLAY
:
1951 if (HIWORD(wParam
) == EN_CHANGE
)
1952 GetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
1953 sizeof(cfg
.x11_display
)-1);
1958 EndDialog (hwnd
, 0);
1961 /* Grrr Explorer will maximize Dialogs! */
1963 if (wParam
== SIZE_MAXIMIZED
)
1970 static int CALLBACK
MainDlgProc (HWND hwnd
, UINT msg
,
1971 WPARAM wParam
, LPARAM lParam
) {
1972 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
1974 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
1975 EnableWindow(hwnd
, 0);
1976 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1977 GetParent(hwnd
), AboutProc
);
1978 EnableWindow(hwnd
, 1);
1979 SetActiveWindow(hwnd
);
1981 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 0);
1984 static int CALLBACK
ReconfDlgProc (HWND hwnd
, UINT msg
,
1985 WPARAM wParam
, LPARAM lParam
) {
1986 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 1);
1989 void defuse_showwindow(void) {
1991 * Work around the fact that the app's first call to ShowWindow
1992 * will ignore the default in favour of the shell-provided
1997 hwnd
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1999 ShowWindow(hwnd
, SW_HIDE
);
2000 DestroyWindow(hwnd
);
2004 int do_config (void) {
2008 savedsession
[0] = '\0';
2009 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2010 get_sesslist(FALSE
);
2015 int do_reconfig (HWND hwnd
) {
2019 backup_cfg
= cfg
; /* structure copy */
2020 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2022 cfg
= backup_cfg
; /* structure copy */
2027 void logevent (char *string
) {
2028 if (nevents
>= negsize
) {
2030 events
= srealloc (events
, negsize
* sizeof(*events
));
2032 events
[nevents
] = smalloc(1+strlen(string
));
2033 strcpy (events
[nevents
], string
);
2037 SendDlgItemMessage (logbox
, IDN_LIST
, LB_ADDSTRING
,
2039 count
= SendDlgItemMessage (logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2040 SendDlgItemMessage (logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
-1, 0);
2044 void showeventlog (HWND hwnd
) {
2046 logbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2048 ShowWindow (logbox
, SW_SHOWNORMAL
);
2050 SetActiveWindow(logbox
);
2053 void showabout (HWND hwnd
) {
2054 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),hwnd
, AboutProc
);
2057 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2058 char *keystr
, char *fingerprint
) {
2061 static const char absentmsg
[] =
2062 "The server's host key is not cached in the registry. You\n"
2063 "have no guarantee that the server is the computer you\n"
2065 "The server's key fingerprint is:\n"
2067 "If you trust this host, hit Yes to add the key to\n"
2068 "PuTTY's cache and carry on connecting.\n"
2069 "If you do not trust this host, hit No to abandon the\n"
2072 static const char wrongmsg
[] =
2073 "WARNING - POTENTIAL SECURITY BREACH!\n"
2075 "The server's host key does not match the one PuTTY has\n"
2076 "cached in the registry. This means that either the\n"
2077 "server administrator has changed the host key, or you\n"
2078 "have actually connected to another computer pretending\n"
2079 "to be the server.\n"
2080 "The new key fingerprint is:\n"
2082 "If you were expecting this change and trust the new key,\n"
2083 "hit Yes to update PuTTY's cache and continue connecting.\n"
2084 "If you want to carry on connecting but without updating\n"
2085 "the cache, hit No.\n"
2086 "If you want to abandon the connection completely, hit\n"
2087 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2090 static const char mbtitle
[] = "PuTTY Security Alert";
2093 char message
[160+ /* sensible fingerprint max size */
2094 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2095 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2098 * Verify the key against the registry.
2100 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2102 if (ret
== 0) /* success - key matched OK */
2104 if (ret
== 2) { /* key was different */
2106 sprintf(message
, wrongmsg
, fingerprint
);
2107 mbret
= MessageBox(NULL
, message
, mbtitle
,
2108 MB_ICONWARNING
| MB_YESNOCANCEL
);
2110 store_host_key(host
, port
, keytype
, keystr
);
2111 if (mbret
== IDCANCEL
)
2114 if (ret
== 1) { /* key was absent */
2116 sprintf(message
, absentmsg
, fingerprint
);
2117 mbret
= MessageBox(NULL
, message
, mbtitle
,
2118 MB_ICONWARNING
| MB_YESNO
);
2121 store_host_key(host
, port
, keytype
, keystr
);
2126 * Ask whether to wipe a session log file before writing to it.
2127 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2129 int askappend(char *filename
) {
2130 static const char mbtitle
[] = "PuTTY Log to File";
2131 static const char msgtemplate
[] =
2132 "The session log file \"%.*s\" already exists.\n"
2133 "You can overwrite it with a new session log,\n"
2134 "append your session log to the end of it,\n"
2135 "or disable session logging for this session.\n"
2136 "Hit Yes to wipe the file, No to append to it,\n"
2137 "or Cancel to disable logging.";
2138 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2140 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2142 mbret
= MessageBox(NULL
, message
, mbtitle
,
2143 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2146 else if (mbret
== IDNO
)