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
,
293 appearancepanelstart
,
294 IDC_TITLE_APPEARANCE
,
312 connectionpanelstart
,
313 IDC_TITLE_CONNECTION
,
408 translationpanelstart
,
409 IDC_TITLE_TRANSLATION
,
410 IDC_BOX_TRANSLATION1
,
411 IDC_BOX_TRANSLATION2
,
412 IDC_BOX_TRANSLATION3
,
437 static const char *const colours
[] = {
438 "Default Foreground", "Default Bold Foreground",
439 "Default Background", "Default Bold Background",
440 "Cursor Text", "Cursor Colour",
441 "ANSI Black", "ANSI Black Bold",
442 "ANSI Red", "ANSI Red Bold",
443 "ANSI Green", "ANSI Green Bold",
444 "ANSI Yellow", "ANSI Yellow Bold",
445 "ANSI Blue", "ANSI Blue Bold",
446 "ANSI Magenta", "ANSI Magenta Bold",
447 "ANSI Cyan", "ANSI Cyan Bold",
448 "ANSI White", "ANSI White Bold"
450 static const int permcolour
[] = {
451 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
452 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
453 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
456 static void fmtfont (char *buf
) {
457 sprintf (buf
, "Font: %s, ", cfg
.font
);
459 strcat(buf
, "bold, ");
460 if (cfg
.fontheight
== 0)
461 strcat (buf
, "default height");
463 sprintf (buf
+strlen(buf
), "%d-%s",
464 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
),
465 (cfg
.fontheight
< 0 ?
"pixel" : "point"));
468 static void init_dlg_ctrls(HWND hwnd
) {
470 char fontstatic
[256];
472 SetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
);
473 SetDlgItemText (hwnd
, IDC_SESSEDIT
, savedsession
);
476 n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
478 SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
479 LB_DELETESTRING
, i
, 0);
480 for (i
= 0; i
< nsessions
; i
++)
481 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
482 0, (LPARAM
) (sessions
[i
]));
484 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
485 CheckRadioButton (hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
486 cfg
.protocol
==PROT_SSH ? IDC_PROTSSH
:
487 cfg
.protocol
==PROT_TELNET ? IDC_PROTTELNET
:
488 cfg
.protocol
==PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
489 SetDlgItemInt (hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
491 CheckRadioButton (hwnd
, IDC_DEL008
, IDC_DEL127
,
492 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
493 CheckRadioButton (hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
494 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
495 CheckRadioButton (hwnd
, IDC_FUNCTILDE
, IDC_FUNCVT400
,
496 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
497 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
498 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
499 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
501 CheckDlgButton (hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
502 CheckDlgButton (hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
503 CheckRadioButton (hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
504 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
505 CheckRadioButton (hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
506 cfg
.nethack_keypad ? IDC_KPNH
:
507 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
508 CheckDlgButton (hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
509 CheckDlgButton (hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
510 CheckDlgButton (hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
511 CheckDlgButton (hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
512 CheckRadioButton (hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
513 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
514 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
515 CheckRadioButton (hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
516 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
517 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
518 CheckDlgButton (hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
519 CheckDlgButton (hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
520 CheckDlgButton (hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
522 CheckDlgButton (hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
523 CheckDlgButton (hwnd
, IDC_DECOM
, cfg
.dec_om
);
524 CheckDlgButton (hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
525 SetDlgItemInt (hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
526 SetDlgItemInt (hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
527 SetDlgItemInt (hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
528 fmtfont (fontstatic
);
529 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
530 CheckDlgButton (hwnd
, IDC_BEEP
, cfg
.beep
);
531 CheckDlgButton (hwnd
, IDC_BCE
, cfg
.bce
);
532 CheckDlgButton (hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
534 SetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
535 CheckDlgButton (hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
536 CheckDlgButton (hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
537 CheckRadioButton (hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
538 cfg
.cursor_type
==0 ? IDC_CURBLOCK
:
539 cfg
.cursor_type
==1 ? IDC_CURUNDER
: IDC_CURVERT
);
540 CheckDlgButton (hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
541 CheckDlgButton (hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
542 CheckDlgButton (hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
543 CheckRadioButton (hwnd
, IDC_COEALWAYS
, IDC_COENEVER
,
544 cfg
.close_on_exit
==COE_NEVER ? IDC_COENEVER
:
545 cfg
.close_on_exit
==COE_NORMAL ? IDC_COENORMAL
: IDC_COEALWAYS
);
546 CheckDlgButton (hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
548 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
549 SetDlgItemText (hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
550 SetDlgItemText (hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
551 SetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
552 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
553 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
554 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
555 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
556 cfg
.logtype
== 1 ? IDC_LSTATASCII
:
559 char *p
= cfg
.environmt
;
561 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
566 CheckRadioButton (hwnd
, IDC_EMBSD
, IDC_EMRFC
,
567 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
569 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
570 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
571 CheckDlgButton (hwnd
, IDC_NOPTY
, cfg
.nopty
);
572 CheckDlgButton (hwnd
, IDC_COMPRESS
, cfg
.compression
);
573 CheckDlgButton (hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
574 CheckDlgButton (hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
575 CheckRadioButton (hwnd
, IDC_CIPHER3DES
, IDC_CIPHERDES
,
576 cfg
.cipher
== CIPHER_BLOWFISH ? IDC_CIPHERBLOWF
:
577 cfg
.cipher
== CIPHER_DES ? IDC_CIPHERDES
:
579 CheckRadioButton (hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
580 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
581 CheckDlgButton (hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
582 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
583 SetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
585 CheckRadioButton (hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
586 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
588 static int tabs
[4] = {25, 61, 96, 128};
589 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
592 for (i
=0; i
<256; i
++) {
594 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
595 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
597 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
601 CheckDlgButton (hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
602 CheckDlgButton (hwnd
, IDC_PALETTE
, cfg
.try_palette
);
605 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
607 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
608 LB_DELETESTRING
, i
, 0);
610 if (cfg
.bold_colour
|| permcolour
[i
])
611 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
612 (LPARAM
) colours
[i
]);
614 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
615 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
616 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
617 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
619 CheckRadioButton (hwnd
, IDC_NOXLAT
, IDC_88592CP852
,
620 cfg
.xlat_88592w1250 ? IDC_88592WIN1250
:
621 cfg
.xlat_88592cp852 ? IDC_88592CP852
:
622 cfg
.xlat_enablekoiwin ? IDC_KOI8WIN1251
:
624 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
625 CheckRadioButton (hwnd
, IDC_VTXWINDOWS
, IDC_VTPOORMAN
,
626 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
627 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
628 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
631 CheckDlgButton (hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
632 SetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
635 struct treeview_faff
{
640 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
641 int level
, char *text
) {
645 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
-1] : TVI_ROOT
);
646 ins
.hInsertAfter
= faff
->lastat
[level
];
647 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
648 #define INSITEM DUMMYUNIONNAME.item
652 ins
.INSITEM
.mask
= TVIF_TEXT
;
653 ins
.INSITEM
.pszText
= text
;
654 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
656 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
-1], TVE_EXPAND
);
657 faff
->lastat
[level
] = newitem
;
658 for (i
= level
+1; i
< 4; i
++) faff
->lastat
[i
] = NULL
;
663 * Create the panelfuls of controls in the configuration box.
665 static void create_controls(HWND hwnd
, int dlgtype
, int panel
) {
666 if (panel
== sessionpanelstart
) {
667 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
669 ctlposinit(&cp
, hwnd
, 80, 3, 13);
670 bartitle(&cp
, "Basic options for your PuTTY session",
673 beginbox(&cp
, "Specify your connection by host name",
676 "Host &Name", IDC_HOSTSTATIC
, IDC_HOST
, 75,
677 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
678 if (backends
[3].backend
== NULL
) {
679 /* this is PuTTYtel, so only three protocols available */
680 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
682 "&Telnet", IDC_PROTTELNET
,
683 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
685 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
687 "&Telnet", IDC_PROTTELNET
,
688 "Rlog&in", IDC_PROTRLOGIN
,
697 beginbox(&cp
, "Load, save or delete a stored session",
699 sesssaver(&cp
, "Sav&ed Sessions",
700 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
701 "&Load", IDC_SESSLOAD
,
702 "&Save", IDC_SESSSAVE
,
703 "&Delete", IDC_SESSDEL
, NULL
);
706 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
707 radioline(&cp
, "At session end, close &window:", IDC_CLOSEEXIT
, 3,
708 "Always", IDC_COEALWAYS
,
709 "On clean exit", IDC_COENORMAL
,
710 "Never", IDC_COENEVER
, NULL
);
714 if (panel
== loggingpanelstart
) {
715 /* The Logging panel. Accelerators used: [acgo] tplfw */
717 ctlposinit(&cp
, hwnd
, 80, 3, 13);
718 bartitle(&cp
, "Options controlling session logging",
720 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
722 "Session logging:", IDC_LSTATSTATIC
,
723 "Logging &turned off completely", IDC_LSTATOFF
,
724 "Log &printable output only", IDC_LSTATASCII
,
725 "&Log all session output", IDC_LSTATRAW
, NULL
);
726 editbutton(&cp
, "Log &file name:",
727 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
732 if (panel
== terminalpanelstart
) {
733 /* The Terminal panel. Accelerators used: [acgo] wdlben ht */
735 ctlposinit(&cp
, hwnd
, 80, 3, 13);
736 bartitle(&cp
, "Options controlling the terminal emulation",
738 beginbox(&cp
, "Set various terminal options",
740 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
741 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
742 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
743 checkbox(&cp
, "&Beep enabled", IDC_BEEP
);
744 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
745 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
748 beginbox(&cp
, "Line discipline options",
750 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
751 "Auto", IDC_ECHOBACKEND
,
752 "Force on", IDC_ECHOYES
,
753 "Force off", IDC_ECHONO
, NULL
);
754 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
755 "Auto", IDC_EDITBACKEND
,
756 "Force on", IDC_EDITYES
,
757 "Force off", IDC_EDITNO
, NULL
);
761 if (panel
== keyboardpanelstart
) {
762 /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxv unpymie t */
764 ctlposinit(&cp
, hwnd
, 80, 3, 13);
765 bartitle(&cp
, "Options controlling the effects of keys",
767 beginbox(&cp
, "Change the sequences sent by:",
769 radioline(&cp
, "The Backspace key", IDC_DELSTATIC
, 2,
770 "Control-&H", IDC_DEL008
,
771 "Control-&? (127)", IDC_DEL127
, NULL
);
772 radioline(&cp
, "The Home and End keys", IDC_HOMESTATIC
, 2,
773 "&Standard", IDC_HOMETILDE
,
774 "&rxvt", IDC_HOMERXVT
, NULL
);
775 radioline(&cp
, "The Function keys and keypad", IDC_FUNCSTATIC
, 4,
776 "ESC[n&~", IDC_FUNCTILDE
,
777 "&Linux", IDC_FUNCLINUX
,
778 "&Xterm R6", IDC_FUNCXTERM
,
779 "&VT400", IDC_FUNCVT400
, NULL
);
781 beginbox(&cp
, "Application keypad settings:",
784 "Application c&ursor keys totally disabled",
786 radioline(&cp
, "Initial state of cursor keys:", IDC_CURSTATIC
, 2,
787 "&Normal", IDC_CURNORMAL
,
788 "A&pplication", IDC_CURAPPLIC
, NULL
);
790 "Application ke&ypad keys totally disabled",
792 radioline(&cp
, "Initial state of numeric keypad:", IDC_KPSTATIC
, 3,
793 "Nor&mal", IDC_KPNORMAL
,
794 "Appl&ication", IDC_KPAPPLIC
,
795 "N&etHack", IDC_KPNH
, NULL
);
797 beginbox(&cp
, "Enable extra keyboard features:",
799 checkbox(&cp
, "Application and AltGr ac&t as Compose key",
804 if (panel
== windowpanelstart
) {
805 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
807 ctlposinit(&cp
, hwnd
, 80, 3, 13);
808 bartitle(&cp
, "Options controlling PuTTY's window",
810 beginbox(&cp
, "Set the size of the window",
813 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
814 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50,
816 checkbox(&cp
, "Lock window size against resi&zing", IDC_LOCKSIZE
);
818 beginbox(&cp
, "Control the scrollback in the window",
820 staticedit(&cp
, "Lines of &scrollback",
821 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
822 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
823 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
824 checkbox(&cp
, "Reset scrollback on dis&play activity",
827 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
828 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
829 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
830 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
831 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
832 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
836 if (panel
== appearancepanelstart
) {
837 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p */
839 ctlposinit(&cp
, hwnd
, 80, 3, 13);
840 bartitle(&cp
, "Options controlling PuTTY's appearance",
841 IDC_TITLE_APPEARANCE
);
842 beginbox(&cp
, "Adjust the use of the cursor",
843 IDC_BOX_APPEARANCE1
);
844 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
845 "B&lock", IDC_CURBLOCK
,
846 "&Underline", IDC_CURUNDER
,
847 "&Vertical line", IDC_CURVERT
,
849 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
851 beginbox(&cp
, "Set the font used in the terminal window",
852 IDC_BOX_APPEARANCE2
);
853 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
855 beginbox(&cp
, "Adjust the use of the window title",
856 IDC_BOX_APPEARANCE3
);
858 "Window &title:", IDC_WINTITLE
,
859 IDC_WINEDIT
, 100, NULL
);
860 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
862 beginbox(&cp
, "Adjust the use of the mouse pointer",
863 IDC_BOX_APPEARANCE4
);
864 checkbox(&cp
, "Hide mouse &pointer when typing in window",
869 if (panel
== translationpanelstart
) {
870 /* The Translation panel. Accelerators used: [acgo] xbep t s */
872 ctlposinit(&cp
, hwnd
, 80, 3, 13);
873 bartitle(&cp
, "Options controlling character set translation",
874 IDC_TITLE_TRANSLATION
);
875 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
876 IDC_BOX_TRANSLATION1
);
878 "Handling of line drawing characters:", IDC_VTSTATIC
,
879 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
880 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
881 "Use font in O&EM mode only", IDC_VTOEMONLY
,
882 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
883 IDC_VTPOORMAN
, NULL
);
885 beginbox(&cp
, "Enable character set translation on received data",
886 IDC_BOX_TRANSLATION2
);
888 "Character set &translation:", IDC_XLATSTATIC
,
890 "KOI8 / Win-1251", IDC_KOI8WIN1251
,
891 "ISO-8859-2 / Win-1250", IDC_88592WIN1250
,
892 "ISO-8859-2 / CP852", IDC_88592CP852
, NULL
);
894 beginbox(&cp
, "Enable character set translation on input data",
895 IDC_BOX_TRANSLATION3
);
896 checkbox(&cp
, "CAP&S LOCK acts as cyrillic switch",
901 if (panel
== selectionpanelstart
) {
902 /* The Selection panel. Accelerators used: [acgo] wx hst */
904 ctlposinit(&cp
, hwnd
, 80, 3, 13);
905 bartitle(&cp
, "Options controlling copy and paste",
906 IDC_TITLE_SELECTION
);
907 beginbox(&cp
, "Control which mouse button does which thing",
909 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
910 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
911 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
914 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
916 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
917 "&Set", IDC_CCSET
, IDC_CCEDIT
,
918 "&to class", IDC_CCSTATIC2
);
922 if (panel
== colourspanelstart
) {
923 /* The Colours panel. Accelerators used: [acgo] blum */
925 ctlposinit(&cp
, hwnd
, 80, 3, 13);
926 bartitle(&cp
, "Options controlling use of colours",
928 beginbox(&cp
, "General options for colour usage",
930 checkbox(&cp
, "&Bolded text is a different colour", IDC_BOLDCOLOUR
);
931 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
933 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
935 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
936 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
937 "&Modify...", IDC_CHANGE
,
938 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
939 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
940 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
944 if (panel
== connectionpanelstart
) {
945 /* The Connection panel. Accelerators used: [acgo] tuk */
947 ctlposinit(&cp
, hwnd
, 80, 3, 13);
948 bartitle(&cp
, "Options controlling the connection", IDC_TITLE_CONNECTION
);
950 beginbox(&cp
, "Data to send to the server",
951 IDC_BOX_CONNECTION1
);
952 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
, IDC_TTEDIT
, 50);
953 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
, IDC_LOGEDIT
, 50);
956 beginbox(&cp
, "Sending of null packets to keep session active",
957 IDC_BOX_CONNECTION2
);
958 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
959 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
963 if (panel
== telnetpanelstart
) {
964 /* The Telnet panel. Accelerators used: [acgo] svldr bf */
966 ctlposinit(&cp
, hwnd
, 80, 3, 13);
968 bartitle(&cp
, "Options controlling Telnet connections", IDC_TITLE_TELNET
);
969 beginbox(&cp
, "Data to send to the server",
971 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
, IDC_TSEDIT
, 50);
972 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
973 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
,
974 "Va&lue", IDC_VALSTATIC
, IDC_VALEDIT
,
976 "A&dd", IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
978 beginbox(&cp
, "Telnet protocol adjustments",
980 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC
, 2,
981 "&BSD (commonplace)", IDC_EMBSD
,
982 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
987 if (panel
== rloginpanelstart
) {
988 /* The Rlogin panel. Accelerators used: [acgo] sl */
990 ctlposinit(&cp
, hwnd
, 80, 3, 13);
992 bartitle(&cp
, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN
);
993 beginbox(&cp
, "Data to send to the server",
995 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
, IDC_R_TSEDIT
, 50);
996 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
, IDC_RLLUSEREDIT
, 50);
1001 if (panel
== sshpanelstart
) {
1002 /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bd i */
1004 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1006 bartitle(&cp
, "Options controlling SSH connections", IDC_TITLE_SSH
);
1007 beginbox(&cp
, "Data to send to the server",
1010 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1013 beginbox(&cp
, "Authentication options",
1015 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1017 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1018 editbutton(&cp
, "Private &key file for authentication:",
1019 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...", IDC_PKBUTTON
);
1021 beginbox(&cp
, "Protocol options",
1023 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1024 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1025 radioline(&cp
, "Preferred SSH protocol version:",
1026 IDC_SSHPROTSTATIC
, 2,
1027 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1028 radioline(&cp
, "Preferred encryption algorithm:", IDC_CIPHERSTATIC
, 3,
1029 "&3DES", IDC_CIPHER3DES
,
1030 "&Blowfish", IDC_CIPHERBLOWF
,
1031 "&DES", IDC_CIPHERDES
, NULL
);
1032 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1038 if (panel
== tunnelspanelstart
) {
1039 /* The Tunnels panel. Accelerators used: [acgo] ex */
1041 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1043 bartitle(&cp
, "Options controlling SSH tunnelling",
1045 beginbox(&cp
, "X11 forwarding options",
1047 checkbox(&cp
, "&Enable X11 forwarding",
1049 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1050 IDC_X11_DISPLAY
, 50, NULL
);
1057 * This function is the configuration box.
1059 static int GenericMainDlgProc (HWND hwnd
, UINT msg
,
1060 WPARAM wParam
, LPARAM lParam
,
1063 struct treeview_faff tvfaff
;
1066 char filename
[sizeof(cfg
.keyfile
)];
1069 char fontstatic
[256];
1071 struct servent
* service
;
1077 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1079 * Centre the window.
1081 { /* centre the window */
1084 hw
= GetDesktopWindow();
1085 if (GetWindowRect (hw
, &rs
) && GetWindowRect (hwnd
, &rd
))
1086 MoveWindow (hwnd
, (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
)/2,
1087 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
)/2,
1088 rd
.right
-rd
.left
, rd
.bottom
-rd
.top
, TRUE
);
1092 * Create the tree view.
1099 r
.left
= 3; r
.right
= r
.left
+ 75;
1100 r
.top
= 3; r
.bottom
= r
.top
+ 10;
1101 MapDialogRect(hwnd
, &r
);
1102 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1103 WS_CHILD
| WS_VISIBLE
,
1105 r
.right
-r
.left
, r
.bottom
-r
.top
,
1106 hwnd
, (HMENU
)IDCX_TVSTATIC
, hinst
, NULL
);
1107 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1108 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1110 r
.left
= 3; r
.right
= r
.left
+ 75;
1111 r
.top
= 13; r
.bottom
= r
.top
+ 206;
1112 MapDialogRect(hwnd
, &r
);
1113 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1114 WS_CHILD
| WS_VISIBLE
|
1115 WS_TABSTOP
| TVS_HASLINES
|
1116 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
|
1117 TVS_LINESATROOT
| TVS_SHOWSELALWAYS
,
1119 r
.right
-r
.left
, r
.bottom
-r
.top
,
1120 hwnd
, (HMENU
)IDCX_TREEVIEW
, hinst
, NULL
);
1121 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1122 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1123 tvfaff
.treeview
= treeview
;
1124 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1128 * Set up the tree view contents.
1130 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1131 treeview_insert(&tvfaff
, 1, "Logging");
1132 treeview_insert(&tvfaff
, 0, "Terminal");
1133 treeview_insert(&tvfaff
, 1, "Keyboard");
1134 treeview_insert(&tvfaff
, 0, "Window");
1135 treeview_insert(&tvfaff
, 1, "Appearance");
1136 treeview_insert(&tvfaff
, 1, "Translation");
1137 treeview_insert(&tvfaff
, 1, "Selection");
1138 treeview_insert(&tvfaff
, 1, "Colours");
1139 treeview_insert(&tvfaff
, 0, "Connection");
1141 treeview_insert(&tvfaff
, 1, "Telnet");
1142 treeview_insert(&tvfaff
, 1, "Rlogin");
1143 if (backends
[3].backend
!= NULL
) {
1144 treeview_insert(&tvfaff
, 1, "SSH");
1145 treeview_insert(&tvfaff
, 2, "Tunnels");
1150 * Put the treeview selection on to the Session panel. This
1151 * should also cause creation of the relevant controls.
1153 TreeView_SelectItem(treeview
, hsession
);
1156 * Set focus into the first available control.
1160 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1161 if (!ctl
) ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1165 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1169 * Button release should trigger WM_OK if there was a
1170 * previous double click on the session list.
1174 SendMessage (hwnd
, WM_COMMAND
, IDOK
, 0);
1177 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1178 ((LPNMHDR
)lParam
)->code
== TVN_SELCHANGED
) {
1179 HTREEITEM i
= TreeView_GetSelection(((LPNMHDR
)lParam
)->hwndFrom
);
1184 item
.pszText
= buffer
;
1185 item
.cchTextMax
= sizeof(buffer
);
1186 item
.mask
= TVIF_TEXT
;
1187 TreeView_GetItem(((LPNMHDR
)lParam
)->hwndFrom
, &item
);
1188 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1189 HWND item
= GetDlgItem(hwnd
, j
);
1191 DestroyWindow(item
);
1193 if (!strcmp(buffer
, "Session"))
1194 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1195 if (!strcmp(buffer
, "Logging"))
1196 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1197 if (!strcmp(buffer
, "Keyboard"))
1198 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1199 if (!strcmp(buffer
, "Terminal"))
1200 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1201 if (!strcmp(buffer
, "Window"))
1202 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1203 if (!strcmp(buffer
, "Appearance"))
1204 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1205 if (!strcmp(buffer
, "Tunnels"))
1206 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1207 if (!strcmp(buffer
, "Connection"))
1208 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1209 if (!strcmp(buffer
, "Telnet"))
1210 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1211 if (!strcmp(buffer
, "Rlogin"))
1212 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1213 if (!strcmp(buffer
, "SSH"))
1214 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1215 if (!strcmp(buffer
, "Selection"))
1216 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1217 if (!strcmp(buffer
, "Colours"))
1218 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1219 if (!strcmp(buffer
, "Translation"))
1220 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1222 init_dlg_ctrls(hwnd
);
1224 SetFocus (((LPNMHDR
)lParam
)->hwndFrom
); /* ensure focus stays */
1230 * Only process WM_COMMAND once the dialog is fully formed.
1232 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
1235 EndDialog (hwnd
, 1);
1240 EndDialog (hwnd
, 0);
1242 case IDC_PROTTELNET
:
1243 case IDC_PROTRLOGIN
:
1246 if (HIWORD(wParam
) == BN_CLICKED
||
1247 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1248 int i
= IsDlgButtonChecked (hwnd
, IDC_PROTSSH
);
1249 int j
= IsDlgButtonChecked (hwnd
, IDC_PROTTELNET
);
1250 int k
= IsDlgButtonChecked (hwnd
, IDC_PROTRLOGIN
);
1251 cfg
.protocol
= i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
: PROT_RAW
;
1252 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22) ||
1253 (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23) ||
1254 (cfg
.protocol
== PROT_RLOGIN
&& cfg
.port
!= 513)) {
1255 cfg
.port
= i ?
22 : j ?
23 : 513;
1256 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1261 if (HIWORD(wParam
) == EN_CHANGE
)
1262 GetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
,
1263 sizeof(cfg
.host
)-1);
1266 if (HIWORD(wParam
) == EN_CHANGE
) {
1267 GetDlgItemText (hwnd
, IDC_PORT
, portname
, 31);
1268 if (isdigit(portname
[0]))
1269 MyGetDlgItemInt (hwnd
, IDC_PORT
, &cfg
.port
);
1271 service
= getservbyname(portname
, NULL
);
1272 if (service
) cfg
.port
= ntohs(service
->s_port
);
1278 if (HIWORD(wParam
) == EN_CHANGE
) {
1279 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1281 GetDlgItemText (hwnd
, IDC_SESSEDIT
,
1282 savedsession
, sizeof(savedsession
)-1);
1283 savedsession
[sizeof(savedsession
)-1] = '\0';
1287 if (HIWORD(wParam
) == BN_CLICKED
||
1288 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1293 GetDlgItemText (hwnd
, IDC_SESSEDIT
, str
, sizeof(str
)-1);
1295 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1296 LB_GETCURSEL
, 0, 0);
1301 strcpy (str
, sessions
[n
]);
1303 save_settings (str
, !!strcmp(str
, "Default Settings"), &cfg
);
1304 get_sesslist (FALSE
);
1305 get_sesslist (TRUE
);
1306 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1308 for (i
= 0; i
< nsessions
; i
++)
1309 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1310 0, (LPARAM
) (sessions
[i
]));
1311 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1317 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1318 HIWORD(wParam
) != BN_CLICKED
&&
1319 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1321 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1322 HIWORD(wParam
) != LBN_DBLCLK
)
1325 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1326 LB_GETCURSEL
, 0, 0);
1332 isdef
= !strcmp(sessions
[n
], "Default Settings");
1333 load_settings (sessions
[n
], !isdef
, &cfg
);
1334 init_dlg_ctrls(hwnd
);
1336 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1338 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1340 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1342 * A double-click on a saved session should
1343 * actually start the session, not just load it.
1344 * Unless it's Default Settings or some other
1345 * host-less set of saved settings.
1354 if (HIWORD(wParam
) == BN_CLICKED
||
1355 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1356 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1357 LB_GETCURSEL
, 0, 0);
1358 if (n
== LB_ERR
|| n
== 0) {
1362 del_settings(sessions
[n
]);
1363 get_sesslist (FALSE
);
1364 get_sesslist (TRUE
);
1365 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1367 for (i
= 0; i
< nsessions
; i
++)
1368 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1369 0, (LPARAM
) (sessions
[i
]));
1370 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1374 if (HIWORD(wParam
) == EN_CHANGE
)
1375 MyGetDlgItemInt (hwnd
, IDC_PINGEDIT
, &cfg
.ping_interval
);
1379 if (HIWORD(wParam
) == BN_CLICKED
||
1380 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1381 cfg
.bksp_is_delete
= IsDlgButtonChecked (hwnd
, IDC_DEL127
);
1385 if (HIWORD(wParam
) == BN_CLICKED
||
1386 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1387 cfg
.rxvt_homeend
= IsDlgButtonChecked (hwnd
, IDC_HOMERXVT
);
1390 if (HIWORD(wParam
) == BN_CLICKED
||
1391 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1395 if (HIWORD(wParam
) == BN_CLICKED
||
1396 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1401 if (HIWORD(wParam
) == BN_CLICKED
||
1402 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1403 cfg
.funky_type
= IsDlgButtonChecked (hwnd
, IDC_FUNCLINUX
);
1407 if (HIWORD(wParam
) == BN_CLICKED
||
1408 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1409 cfg
.app_keypad
= IsDlgButtonChecked (hwnd
, IDC_KPAPPLIC
);
1410 cfg
.nethack_keypad
= FALSE
;
1414 if (HIWORD(wParam
) == BN_CLICKED
||
1415 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1416 cfg
.app_keypad
= FALSE
;
1417 cfg
.nethack_keypad
= TRUE
;
1422 if (HIWORD(wParam
) == BN_CLICKED
||
1423 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1424 cfg
.app_cursor
= IsDlgButtonChecked (hwnd
, IDC_CURAPPLIC
);
1427 if (HIWORD(wParam
) == BN_CLICKED
||
1428 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1429 cfg
.no_applic_c
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICC
);
1432 if (HIWORD(wParam
) == BN_CLICKED
||
1433 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1434 cfg
.no_applic_k
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICK
);
1437 if (HIWORD(wParam
) == BN_CLICKED
||
1438 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1439 cfg
.alt_f4
= IsDlgButtonChecked (hwnd
, IDC_ALTF4
);
1442 if (HIWORD(wParam
) == BN_CLICKED
||
1443 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1444 cfg
.alt_space
= IsDlgButtonChecked (hwnd
, IDC_ALTSPACE
);
1447 if (HIWORD(wParam
) == BN_CLICKED
||
1448 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1449 cfg
.alt_only
= IsDlgButtonChecked (hwnd
, IDC_ALTONLY
);
1451 case IDC_ECHOBACKEND
:
1454 if (HIWORD(wParam
) == BN_CLICKED
||
1455 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1456 if (LOWORD(wParam
)==IDC_ECHOBACKEND
) cfg
.localecho
=LD_BACKEND
;
1457 if (LOWORD(wParam
)==IDC_ECHOYES
) cfg
.localecho
=LD_YES
;
1458 if (LOWORD(wParam
)==IDC_ECHONO
) cfg
.localecho
=LD_NO
;
1461 case IDC_EDITBACKEND
:
1464 if (HIWORD(wParam
) == BN_CLICKED
||
1465 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1466 if (LOWORD(wParam
)==IDC_EDITBACKEND
) cfg
.localedit
=LD_BACKEND
;
1467 if (LOWORD(wParam
)==IDC_EDITYES
) cfg
.localedit
=LD_YES
;
1468 if (LOWORD(wParam
)==IDC_EDITNO
) cfg
.localedit
=LD_NO
;
1471 case IDC_ALWAYSONTOP
:
1472 if (HIWORD(wParam
) == BN_CLICKED
||
1473 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1474 cfg
.alwaysontop
= IsDlgButtonChecked (hwnd
, IDC_ALWAYSONTOP
);
1477 if (HIWORD(wParam
) == BN_CLICKED
||
1478 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1479 cfg
.scroll_on_key
= IsDlgButtonChecked (hwnd
, IDC_SCROLLKEY
);
1481 case IDC_SCROLLDISP
:
1482 if (HIWORD(wParam
) == BN_CLICKED
||
1483 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1484 cfg
.scroll_on_disp
= IsDlgButtonChecked (hwnd
, IDC_SCROLLDISP
);
1486 case IDC_COMPOSEKEY
:
1487 if (HIWORD(wParam
) == BN_CLICKED
||
1488 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1489 cfg
.compose_key
= IsDlgButtonChecked (hwnd
, IDC_COMPOSEKEY
);
1492 if (HIWORD(wParam
) == BN_CLICKED
||
1493 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1494 cfg
.wrap_mode
= IsDlgButtonChecked (hwnd
, IDC_WRAPMODE
);
1497 if (HIWORD(wParam
) == BN_CLICKED
||
1498 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1499 cfg
.dec_om
= IsDlgButtonChecked (hwnd
, IDC_DECOM
);
1502 if (HIWORD(wParam
) == BN_CLICKED
||
1503 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1504 cfg
.lfhascr
= IsDlgButtonChecked (hwnd
, IDC_LFHASCR
);
1507 if (HIWORD(wParam
) == EN_CHANGE
)
1508 MyGetDlgItemInt (hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1511 if (HIWORD(wParam
) == EN_CHANGE
)
1512 MyGetDlgItemInt (hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1515 if (HIWORD(wParam
) == EN_CHANGE
)
1516 MyGetDlgItemInt (hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1518 case IDC_CHOOSEFONT
:
1519 lf
.lfHeight
= cfg
.fontheight
;
1520 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1521 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1522 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1523 lf
.lfCharSet
= cfg
.fontcharset
;
1524 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1525 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1526 lf
.lfQuality
= DEFAULT_QUALITY
;
1527 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1528 strncpy (lf
.lfFaceName
, cfg
.font
, sizeof(lf
.lfFaceName
)-1);
1529 lf
.lfFaceName
[sizeof(lf
.lfFaceName
)-1] = '\0';
1531 cf
.lStructSize
= sizeof(cf
);
1532 cf
.hwndOwner
= hwnd
;
1534 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1535 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1537 if (ChooseFont (&cf
)) {
1538 strncpy (cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
)-1);
1539 cfg
.font
[sizeof(cfg
.font
)-1] = '\0';
1540 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1541 cfg
.fontcharset
= lf
.lfCharSet
;
1542 cfg
.fontheight
= lf
.lfHeight
;
1543 fmtfont (fontstatic
);
1544 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
1548 if (HIWORD(wParam
) == BN_CLICKED
||
1549 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1550 cfg
.beep
= IsDlgButtonChecked (hwnd
, IDC_BEEP
);
1553 if (HIWORD(wParam
) == BN_CLICKED
||
1554 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1555 cfg
.blinktext
= IsDlgButtonChecked (hwnd
, IDC_BLINKTEXT
);
1558 if (HIWORD(wParam
) == BN_CLICKED
||
1559 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1560 cfg
.bce
= IsDlgButtonChecked (hwnd
, IDC_BCE
);
1563 if (HIWORD(wParam
) == BN_CLICKED
||
1564 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1565 cfg
.win_name_always
= IsDlgButtonChecked (hwnd
, IDC_WINNAME
);
1568 if (HIWORD(wParam
) == BN_CLICKED
||
1569 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1570 cfg
.hide_mouseptr
= IsDlgButtonChecked (hwnd
, IDC_HIDEMOUSE
);
1573 if (HIWORD(wParam
) == BN_CLICKED
||
1574 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1575 cfg
.cursor_type
= 0;
1578 if (HIWORD(wParam
) == BN_CLICKED
||
1579 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1580 cfg
.cursor_type
= 1;
1583 if (HIWORD(wParam
) == BN_CLICKED
||
1584 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1585 cfg
.cursor_type
= 2;
1588 if (HIWORD(wParam
) == BN_CLICKED
||
1589 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1590 cfg
.blink_cur
= IsDlgButtonChecked (hwnd
, IDC_BLINKCUR
);
1593 if (HIWORD(wParam
) == BN_CLICKED
||
1594 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1595 cfg
.scrollbar
= IsDlgButtonChecked (hwnd
, IDC_SCROLLBAR
);
1598 if (HIWORD(wParam
) == BN_CLICKED
||
1599 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1600 cfg
.locksize
= IsDlgButtonChecked (hwnd
, IDC_LOCKSIZE
);
1603 if (HIWORD(wParam
) == EN_CHANGE
)
1604 GetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
1605 sizeof(cfg
.wintitle
)-1);
1610 if (HIWORD(wParam
) == BN_CLICKED
||
1611 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1612 cfg
.close_on_exit
= IsDlgButtonChecked (hwnd
, IDC_COEALWAYS
) ? COE_ALWAYS
:
1613 IsDlgButtonChecked (hwnd
, IDC_COENORMAL
) ? COE_NORMAL
:
1618 if (HIWORD(wParam
) == BN_CLICKED
||
1619 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1620 cfg
.warn_on_close
= IsDlgButtonChecked (hwnd
, IDC_CLOSEWARN
);
1623 if (HIWORD(wParam
) == EN_CHANGE
)
1624 GetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
,
1625 sizeof(cfg
.termtype
)-1);
1628 if (HIWORD(wParam
) == EN_CHANGE
)
1629 GetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
1630 sizeof(cfg
.logfilename
)-1);
1633 memset(&of
, 0, sizeof(of
));
1634 #ifdef OPENFILENAME_SIZE_VERSION_400
1635 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1637 of
.lStructSize
= sizeof(of
);
1639 of
.hwndOwner
= hwnd
;
1640 of
.lpstrFilter
= "All Files\0*\0\0\0";
1641 of
.lpstrCustomFilter
= NULL
;
1642 of
.nFilterIndex
= 1;
1643 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.logfilename
);
1644 of
.nMaxFile
= sizeof(filename
);
1645 of
.lpstrFileTitle
= NULL
;
1646 of
.lpstrInitialDir
= NULL
;
1647 of
.lpstrTitle
= "Select session log file";
1649 if (GetSaveFileName(&of
)) {
1650 strcpy(cfg
.logfilename
, filename
);
1651 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
1655 case IDC_LSTATASCII
:
1657 if (HIWORD(wParam
) == BN_CLICKED
||
1658 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1659 if (IsDlgButtonChecked (hwnd
, IDC_LSTATOFF
)) cfg
.logtype
= 0;
1660 if (IsDlgButtonChecked (hwnd
, IDC_LSTATASCII
)) cfg
.logtype
= 1;
1661 if (IsDlgButtonChecked (hwnd
, IDC_LSTATRAW
)) cfg
.logtype
= 2;
1666 if (HIWORD(wParam
) == EN_CHANGE
)
1667 GetDlgItemText (hwnd
, LOWORD(wParam
), cfg
.termspeed
,
1668 sizeof(cfg
.termspeed
)-1);
1671 if (HIWORD(wParam
) == EN_CHANGE
)
1672 GetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
,
1673 sizeof(cfg
.username
)-1);
1675 case IDC_RLLUSEREDIT
:
1676 if (HIWORD(wParam
) == EN_CHANGE
)
1677 GetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
,
1678 sizeof(cfg
.localusername
)-1);
1682 cfg
.rfc_environ
= IsDlgButtonChecked (hwnd
, IDC_EMRFC
);
1685 if (HIWORD(wParam
) == BN_CLICKED
||
1686 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1687 char str
[sizeof(cfg
.environmt
)];
1689 GetDlgItemText (hwnd
, IDC_VAREDIT
, str
, sizeof(str
)-1);
1694 p
= str
+ strlen(str
);
1696 GetDlgItemText (hwnd
, IDC_VALEDIT
, p
, sizeof(str
)-1-(p
-str
));
1706 if ((p
-cfg
.environmt
) + strlen(str
) + 2 < sizeof(cfg
.environmt
)) {
1708 p
[strlen(str
)+1] = '\0';
1709 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
1711 SetDlgItemText (hwnd
, IDC_VAREDIT
, "");
1712 SetDlgItemText (hwnd
, IDC_VALEDIT
, "");
1714 MessageBox(hwnd
, "Environment too big", "PuTTY Error",
1715 MB_OK
| MB_ICONERROR
);
1720 if (HIWORD(wParam
) != BN_CLICKED
&&
1721 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1723 i
= SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0, 0);
1729 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
1754 if (HIWORD(wParam
) == BN_CLICKED
||
1755 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1756 cfg
.nopty
= IsDlgButtonChecked (hwnd
, IDC_NOPTY
);
1759 if (HIWORD(wParam
) == BN_CLICKED
||
1760 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1761 cfg
.compression
= IsDlgButtonChecked (hwnd
, IDC_COMPRESS
);
1764 if (HIWORD(wParam
) == BN_CLICKED
||
1765 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1766 cfg
.buggymac
= IsDlgButtonChecked (hwnd
, IDC_BUGGYMAC
);
1769 if (HIWORD(wParam
) == BN_CLICKED
||
1770 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1771 cfg
.agentfwd
= IsDlgButtonChecked (hwnd
, IDC_AGENTFWD
);
1773 case IDC_CIPHER3DES
:
1774 case IDC_CIPHERBLOWF
:
1776 if (HIWORD(wParam
) == BN_CLICKED
||
1777 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1778 if (IsDlgButtonChecked (hwnd
, IDC_CIPHER3DES
))
1779 cfg
.cipher
= CIPHER_3DES
;
1780 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERBLOWF
))
1781 cfg
.cipher
= CIPHER_BLOWFISH
;
1782 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERDES
))
1783 cfg
.cipher
= CIPHER_DES
;
1788 if (HIWORD(wParam
) == BN_CLICKED
||
1789 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1790 if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT1
))
1792 else if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT2
))
1797 if (HIWORD(wParam
) == BN_CLICKED
||
1798 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1799 cfg
.try_tis_auth
= IsDlgButtonChecked (hwnd
, IDC_AUTHTIS
);
1802 if (HIWORD(wParam
) == EN_CHANGE
)
1803 GetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
1804 sizeof(cfg
.keyfile
)-1);
1807 if (HIWORD(wParam
) == EN_CHANGE
)
1808 GetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
1809 sizeof(cfg
.remote_cmd
)-1);
1812 memset(&of
, 0, sizeof(of
));
1813 #ifdef OPENFILENAME_SIZE_VERSION_400
1814 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1816 of
.lStructSize
= sizeof(of
);
1818 of
.hwndOwner
= hwnd
;
1819 of
.lpstrFilter
= "All Files\0*\0\0\0";
1820 of
.lpstrCustomFilter
= NULL
;
1821 of
.nFilterIndex
= 1;
1822 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1823 of
.nMaxFile
= sizeof(filename
);
1824 of
.lpstrFileTitle
= NULL
;
1825 of
.lpstrInitialDir
= NULL
;
1826 of
.lpstrTitle
= "Select Public Key File";
1828 if (GetOpenFileName(&of
)) {
1829 strcpy(cfg
.keyfile
, filename
);
1830 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1835 cfg
.mouse_is_xterm
= IsDlgButtonChecked (hwnd
, IDC_MBXTERM
);
1841 int n
= GetDlgItemInt (hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
1846 for (i
=0; i
<256; i
++)
1847 if (SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_GETSEL
,
1850 cfg
.wordness
[i
] = n
;
1851 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1852 LB_DELETESTRING
, i
, 0);
1853 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
1854 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
1856 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1863 case IDC_BOLDCOLOUR
:
1864 if (HIWORD(wParam
) == BN_CLICKED
||
1865 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1867 cfg
.bold_colour
= IsDlgButtonChecked (hwnd
, IDC_BOLDCOLOUR
);
1868 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
1869 if (n
!= 12+10*cfg
.bold_colour
) {
1871 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1872 LB_DELETESTRING
, i
, 0);
1873 for (i
=0; i
<22; i
++)
1874 if (cfg
.bold_colour
|| permcolour
[i
])
1875 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1877 (LPARAM
) colours
[i
]);
1882 if (HIWORD(wParam
) == BN_CLICKED
||
1883 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1884 cfg
.try_palette
= IsDlgButtonChecked (hwnd
, IDC_PALETTE
);
1886 case IDC_COLOURLIST
:
1887 if (HIWORD(wParam
) == LBN_DBLCLK
||
1888 HIWORD(wParam
) == LBN_SELCHANGE
) {
1889 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1891 if (!cfg
.bold_colour
)
1892 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1893 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0], FALSE
);
1894 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1], FALSE
);
1895 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2], FALSE
);
1899 if (HIWORD(wParam
) == BN_CLICKED
||
1900 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1901 static CHOOSECOLOR cc
;
1902 static DWORD custom
[16] = {0}; /* zero initialisers */
1903 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1905 if (!cfg
.bold_colour
)
1906 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1907 cc
.lStructSize
= sizeof(cc
);
1908 cc
.hwndOwner
= hwnd
;
1909 cc
.hInstance
= (HWND
)hinst
;
1910 cc
.lpCustColors
= custom
;
1911 cc
.rgbResult
= RGB (cfg
.colours
[i
][0], cfg
.colours
[i
][1],
1913 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
1914 if (ChooseColor(&cc
)) {
1916 (unsigned char) (cc
.rgbResult
& 0xFF);
1918 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
1920 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
1921 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
1923 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
1925 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
1931 case IDC_KOI8WIN1251
:
1932 case IDC_88592WIN1250
:
1933 case IDC_88592CP852
:
1934 cfg
.xlat_enablekoiwin
=
1935 IsDlgButtonChecked (hwnd
, IDC_KOI8WIN1251
);
1936 cfg
.xlat_88592w1250
=
1937 IsDlgButtonChecked (hwnd
, IDC_88592WIN1250
);
1938 cfg
.xlat_88592cp852
=
1939 IsDlgButtonChecked (hwnd
, IDC_88592CP852
);
1941 case IDC_CAPSLOCKCYR
:
1942 if (HIWORD(wParam
) == BN_CLICKED
||
1943 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1944 cfg
.xlat_capslockcyr
=
1945 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
1948 case IDC_VTXWINDOWS
:
1953 (IsDlgButtonChecked (hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
:
1954 IsDlgButtonChecked (hwnd
, IDC_VTOEMANSI
) ? VT_OEMANSI
:
1955 IsDlgButtonChecked (hwnd
, IDC_VTOEMONLY
) ? VT_OEMONLY
:
1958 case IDC_X11_FORWARD
:
1959 if (HIWORD(wParam
) == BN_CLICKED
||
1960 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1961 cfg
.x11_forward
= IsDlgButtonChecked (hwnd
, IDC_X11_FORWARD
);
1963 case IDC_X11_DISPLAY
:
1964 if (HIWORD(wParam
) == EN_CHANGE
)
1965 GetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
1966 sizeof(cfg
.x11_display
)-1);
1971 EndDialog (hwnd
, 0);
1974 /* Grrr Explorer will maximize Dialogs! */
1976 if (wParam
== SIZE_MAXIMIZED
)
1983 static int CALLBACK
MainDlgProc (HWND hwnd
, UINT msg
,
1984 WPARAM wParam
, LPARAM lParam
) {
1985 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
1987 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
1988 EnableWindow(hwnd
, 0);
1989 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1990 GetParent(hwnd
), AboutProc
);
1991 EnableWindow(hwnd
, 1);
1992 SetActiveWindow(hwnd
);
1994 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 0);
1997 static int CALLBACK
ReconfDlgProc (HWND hwnd
, UINT msg
,
1998 WPARAM wParam
, LPARAM lParam
) {
1999 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 1);
2002 void defuse_showwindow(void) {
2004 * Work around the fact that the app's first call to ShowWindow
2005 * will ignore the default in favour of the shell-provided
2010 hwnd
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2012 ShowWindow(hwnd
, SW_HIDE
);
2013 DestroyWindow(hwnd
);
2017 int do_config (void) {
2021 savedsession
[0] = '\0';
2022 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2023 get_sesslist(FALSE
);
2028 int do_reconfig (HWND hwnd
) {
2032 backup_cfg
= cfg
; /* structure copy */
2033 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2035 cfg
= backup_cfg
; /* structure copy */
2040 void logevent (char *string
) {
2041 if (nevents
>= negsize
) {
2043 events
= srealloc (events
, negsize
* sizeof(*events
));
2045 events
[nevents
] = smalloc(1+strlen(string
));
2046 strcpy (events
[nevents
], string
);
2050 SendDlgItemMessage (logbox
, IDN_LIST
, LB_ADDSTRING
,
2052 count
= SendDlgItemMessage (logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2053 SendDlgItemMessage (logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
-1, 0);
2057 void showeventlog (HWND hwnd
) {
2059 logbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2061 ShowWindow (logbox
, SW_SHOWNORMAL
);
2063 SetActiveWindow(logbox
);
2066 void showabout (HWND hwnd
) {
2067 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),hwnd
, AboutProc
);
2070 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2071 char *keystr
, char *fingerprint
) {
2074 static const char absentmsg
[] =
2075 "The server's host key is not cached in the registry. You\n"
2076 "have no guarantee that the server is the computer you\n"
2078 "The server's key fingerprint is:\n"
2080 "If you trust this host, hit Yes to add the key to\n"
2081 "PuTTY's cache and carry on connecting.\n"
2082 "If you do not trust this host, hit No to abandon the\n"
2085 static const char wrongmsg
[] =
2086 "WARNING - POTENTIAL SECURITY BREACH!\n"
2088 "The server's host key does not match the one PuTTY has\n"
2089 "cached in the registry. This means that either the\n"
2090 "server administrator has changed the host key, or you\n"
2091 "have actually connected to another computer pretending\n"
2092 "to be the server.\n"
2093 "The new key fingerprint is:\n"
2095 "If you were expecting this change and trust the new key,\n"
2096 "hit Yes to update PuTTY's cache and continue connecting.\n"
2097 "If you want to carry on connecting but without updating\n"
2098 "the cache, hit No.\n"
2099 "If you want to abandon the connection completely, hit\n"
2100 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2103 static const char mbtitle
[] = "PuTTY Security Alert";
2106 char message
[160+ /* sensible fingerprint max size */
2107 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2108 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2111 * Verify the key against the registry.
2113 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2115 if (ret
== 0) /* success - key matched OK */
2117 if (ret
== 2) { /* key was different */
2119 sprintf(message
, wrongmsg
, fingerprint
);
2120 mbret
= MessageBox(NULL
, message
, mbtitle
,
2121 MB_ICONWARNING
| MB_YESNOCANCEL
);
2123 store_host_key(host
, port
, keytype
, keystr
);
2124 if (mbret
== IDCANCEL
)
2127 if (ret
== 1) { /* key was absent */
2129 sprintf(message
, absentmsg
, fingerprint
);
2130 mbret
= MessageBox(NULL
, message
, mbtitle
,
2131 MB_ICONWARNING
| MB_YESNO
);
2134 store_host_key(host
, port
, keytype
, keystr
);
2139 * Ask whether to wipe a session log file before writing to it.
2140 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2142 int askappend(char *filename
) {
2143 static const char mbtitle
[] = "PuTTY Log to File";
2144 static const char msgtemplate
[] =
2145 "The session log file \"%.*s\" already exists.\n"
2146 "You can overwrite it with a new session log,\n"
2147 "append your session log to the end of it,\n"
2148 "or disable session logging for this session.\n"
2149 "Hit Yes to wipe the file, No to append to it,\n"
2150 "or Cancel to disable logging.";
2151 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2153 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2155 mbret
= MessageBox(NULL
, message
, mbtitle
,
2156 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2159 else if (mbret
== IDNO
)