15 static char **events
= NULL
;
16 static int nevents
= 0, negsize
= 0;
20 void force_normal(HWND hwnd
)
22 static int recurse
= 0;
29 wp
.length
= sizeof(wp
);
30 if (GetWindowPlacement(hwnd
, &wp
) && wp
.showCmd
== SW_SHOWMAXIMIZED
)
32 wp
.showCmd
= SW_SHOWNORMAL
;
33 SetWindowPlacement(hwnd
, &wp
);
38 static void MyGetDlgItemInt (HWND hwnd
, int id
, int *result
) {
41 n
= GetDlgItemInt (hwnd
, id
, &ok
, FALSE
);
46 static int CALLBACK
LogProc (HWND hwnd
, UINT msg
,
47 WPARAM wParam
, LPARAM lParam
) {
53 static int tabs
[4] = {78, 108};
54 SendDlgItemMessage (hwnd
, IDN_LIST
, LB_SETTABSTOPS
, 2,
57 for (i
=0; i
<nevents
; i
++)
58 SendDlgItemMessage (hwnd
, IDN_LIST
, LB_ADDSTRING
,
59 0, (LPARAM
)events
[i
]);
62 switch (LOWORD(wParam
)) {
66 SetActiveWindow(GetParent(hwnd
));
70 if (HIWORD(wParam
) == BN_CLICKED
||
71 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
74 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
75 LB_GETSELCOUNT
, 0, 0);
76 if (selcount
== 0) { /* don't even try to copy zero items */
81 selitems
= smalloc(selcount
* sizeof(int));
83 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
85 selcount
, (LPARAM
)selitems
);
89 static unsigned char sel_nl
[] = SEL_NL
;
91 if (count
== 0) { /* can't copy zero stuff */
97 for (i
= 0; i
< count
; i
++)
98 size
+= strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
100 clipdata
= smalloc(size
);
103 for (i
= 0; i
< count
; i
++) {
104 char *q
= events
[selitems
[i
]];
105 int qlen
= strlen(q
);
108 memcpy(p
, sel_nl
, sizeof(sel_nl
));
111 write_clip(clipdata
, size
, TRUE
);
116 for (i
= 0; i
< nevents
; i
++)
117 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
126 SetActiveWindow(GetParent(hwnd
));
127 DestroyWindow (hwnd
);
133 static int CALLBACK
LicenceProc (HWND hwnd
, UINT msg
,
134 WPARAM wParam
, LPARAM lParam
) {
139 switch (LOWORD(wParam
)) {
152 static int CALLBACK
AboutProc (HWND hwnd
, UINT msg
,
153 WPARAM wParam
, LPARAM lParam
) {
156 SetDlgItemText (hwnd
, IDA_VERSION
, ver
);
159 switch (LOWORD(wParam
)) {
162 EndDialog(hwnd
, TRUE
);
165 EnableWindow(hwnd
, 0);
166 DialogBox (hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
168 EnableWindow(hwnd
, 1);
169 SetActiveWindow(hwnd
);
174 EndDialog(hwnd
, TRUE
);
181 * Null dialog procedure.
183 static int CALLBACK
NullDlgProc (HWND hwnd
, UINT msg
,
184 WPARAM wParam
, LPARAM lParam
) {
188 static char savedsession
[2048];
190 enum { IDCX_ABOUT
= IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
299 appearancepanelstart
,
300 IDC_TITLE_APPEARANCE
,
318 connectionpanelstart
,
319 IDC_TITLE_CONNECTION
,
414 translationpanelstart
,
415 IDC_TITLE_TRANSLATION
,
416 IDC_BOX_TRANSLATION1
,
417 IDC_BOX_TRANSLATION2
,
418 IDC_BOX_TRANSLATION3
,
443 static const char *const colours
[] = {
444 "Default Foreground", "Default Bold Foreground",
445 "Default Background", "Default Bold Background",
446 "Cursor Text", "Cursor Colour",
447 "ANSI Black", "ANSI Black Bold",
448 "ANSI Red", "ANSI Red Bold",
449 "ANSI Green", "ANSI Green Bold",
450 "ANSI Yellow", "ANSI Yellow Bold",
451 "ANSI Blue", "ANSI Blue Bold",
452 "ANSI Magenta", "ANSI Magenta Bold",
453 "ANSI Cyan", "ANSI Cyan Bold",
454 "ANSI White", "ANSI White Bold"
456 static const int permcolour
[] = {
457 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
458 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
459 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
462 static void fmtfont (char *buf
) {
463 sprintf (buf
, "Font: %s, ", cfg
.font
);
465 strcat(buf
, "bold, ");
466 if (cfg
.fontheight
== 0)
467 strcat (buf
, "default height");
469 sprintf (buf
+strlen(buf
), "%d-%s",
470 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
),
471 (cfg
.fontheight
< 0 ?
"pixel" : "point"));
474 static void init_dlg_ctrls(HWND hwnd
) {
476 char fontstatic
[256];
478 SetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
);
479 SetDlgItemText (hwnd
, IDC_SESSEDIT
, savedsession
);
482 n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_GETCOUNT
, 0, 0);
484 SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
485 LB_DELETESTRING
, i
, 0);
486 for (i
= 0; i
< nsessions
; i
++)
487 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
488 0, (LPARAM
) (sessions
[i
]));
490 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
491 CheckRadioButton (hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
492 cfg
.protocol
==PROT_SSH ? IDC_PROTSSH
:
493 cfg
.protocol
==PROT_TELNET ? IDC_PROTTELNET
:
494 cfg
.protocol
==PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
495 SetDlgItemInt (hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
497 CheckRadioButton (hwnd
, IDC_DEL008
, IDC_DEL127
,
498 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
499 CheckRadioButton (hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
500 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
501 CheckRadioButton (hwnd
, IDC_FUNCTILDE
, IDC_FUNCVT400
,
502 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
503 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
504 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
505 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
507 CheckDlgButton (hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
508 CheckDlgButton (hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
509 CheckRadioButton (hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
510 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
511 CheckRadioButton (hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
512 cfg
.nethack_keypad ? IDC_KPNH
:
513 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
514 CheckDlgButton (hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
515 CheckDlgButton (hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
516 CheckDlgButton (hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
517 CheckDlgButton (hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
518 CheckRadioButton (hwnd
, IDC_ECHOBACKEND
, IDC_ECHONO
,
519 cfg
.localecho
== LD_BACKEND ? IDC_ECHOBACKEND
:
520 cfg
.localecho
== LD_YES ? IDC_ECHOYES
: IDC_ECHONO
);
521 CheckRadioButton (hwnd
, IDC_EDITBACKEND
, IDC_EDITNO
,
522 cfg
.localedit
== LD_BACKEND ? IDC_EDITBACKEND
:
523 cfg
.localedit
== LD_YES ? IDC_EDITYES
: IDC_EDITNO
);
524 CheckDlgButton (hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
525 CheckDlgButton (hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
526 CheckDlgButton (hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
528 CheckDlgButton (hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
529 CheckDlgButton (hwnd
, IDC_DECOM
, cfg
.dec_om
);
530 CheckDlgButton (hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
531 SetDlgItemInt (hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
532 SetDlgItemInt (hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
533 SetDlgItemInt (hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
534 fmtfont (fontstatic
);
535 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
536 CheckDlgButton (hwnd
, IDC_BEEP
, cfg
.beep
);
537 CheckDlgButton (hwnd
, IDC_BCE
, cfg
.bce
);
538 CheckDlgButton (hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
540 SetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
541 CheckDlgButton (hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
542 CheckDlgButton (hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
543 CheckRadioButton (hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
544 cfg
.cursor_type
==0 ? IDC_CURBLOCK
:
545 cfg
.cursor_type
==1 ? IDC_CURUNDER
: IDC_CURVERT
);
546 CheckDlgButton (hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
547 CheckDlgButton (hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
548 CheckDlgButton (hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
549 CheckRadioButton (hwnd
, IDC_COEALWAYS
, IDC_COENORMAL
,
550 cfg
.close_on_exit
==COE_NORMAL ? IDC_COENORMAL
:
551 cfg
.close_on_exit
==COE_NEVER ? IDC_COENEVER
: IDC_COEALWAYS
);
552 CheckDlgButton (hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
554 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
555 SetDlgItemText (hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
556 SetDlgItemText (hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
557 SetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
558 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
559 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
560 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
561 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
562 cfg
.logtype
== 1 ? IDC_LSTATASCII
:
565 char *p
= cfg
.environmt
;
567 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
572 CheckRadioButton (hwnd
, IDC_EMBSD
, IDC_EMRFC
,
573 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
575 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
576 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
577 CheckDlgButton (hwnd
, IDC_NOPTY
, cfg
.nopty
);
578 CheckDlgButton (hwnd
, IDC_COMPRESS
, cfg
.compression
);
579 CheckDlgButton (hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
580 CheckDlgButton (hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
581 CheckRadioButton (hwnd
, IDC_CIPHER3DES
, IDC_CIPHERDES
,
582 cfg
.cipher
== CIPHER_BLOWFISH ? IDC_CIPHERBLOWF
:
583 cfg
.cipher
== CIPHER_DES ? IDC_CIPHERDES
:
585 CheckRadioButton (hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
586 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
587 CheckDlgButton (hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
588 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
589 SetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
591 CheckRadioButton (hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
592 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
594 static int tabs
[4] = {25, 61, 96, 128};
595 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
598 for (i
=0; i
<256; i
++) {
600 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
601 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
603 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
607 CheckDlgButton (hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
608 CheckDlgButton (hwnd
, IDC_PALETTE
, cfg
.try_palette
);
611 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
613 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
614 LB_DELETESTRING
, i
, 0);
616 if (cfg
.bold_colour
|| permcolour
[i
])
617 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
618 (LPARAM
) colours
[i
]);
620 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
621 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
622 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
623 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
625 CheckRadioButton (hwnd
, IDC_NOXLAT
, IDC_88592CP852
,
626 cfg
.xlat_88592w1250 ? IDC_88592WIN1250
:
627 cfg
.xlat_88592cp852 ? IDC_88592CP852
:
628 cfg
.xlat_enablekoiwin ? IDC_KOI8WIN1251
:
630 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
631 CheckRadioButton (hwnd
, IDC_VTXWINDOWS
, IDC_VTPOORMAN
,
632 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
633 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
634 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
637 CheckDlgButton (hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
638 SetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
641 struct treeview_faff
{
646 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
647 int level
, char *text
) {
651 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
-1] : TVI_ROOT
);
652 ins
.hInsertAfter
= faff
->lastat
[level
];
653 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
654 #define INSITEM DUMMYUNIONNAME.item
658 ins
.INSITEM
.mask
= TVIF_TEXT
;
659 ins
.INSITEM
.pszText
= text
;
660 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
662 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
-1], TVE_EXPAND
);
663 faff
->lastat
[level
] = newitem
;
664 for (i
= level
+1; i
< 4; i
++) faff
->lastat
[i
] = NULL
;
669 * Create the panelfuls of controls in the configuration box.
671 static void create_controls(HWND hwnd
, int dlgtype
, int panel
) {
672 if (panel
== sessionpanelstart
) {
673 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
675 ctlposinit(&cp
, hwnd
, 80, 3, 13);
676 bartitle(&cp
, "Basic options for your PuTTY session",
679 beginbox(&cp
, "Specify your connection by host name",
682 "Host &Name", IDC_HOSTSTATIC
, IDC_HOST
, 75,
683 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
684 if (backends
[3].backend
== NULL
) {
685 /* this is PuTTYtel, so only three protocols available */
686 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
688 "&Telnet", IDC_PROTTELNET
,
689 "Rlog&in", IDC_PROTRLOGIN
, NULL
);
691 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
693 "&Telnet", IDC_PROTTELNET
,
694 "Rlog&in", IDC_PROTRLOGIN
,
703 beginbox(&cp
, "Load, save or delete a stored session",
705 sesssaver(&cp
, "Sav&ed Sessions",
706 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
707 "&Load", IDC_SESSLOAD
,
708 "&Save", IDC_SESSSAVE
,
709 "&Delete", IDC_SESSDEL
, NULL
);
712 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
);
713 radioline(&cp
, "Close &window on exit:", IDC_CLOSEEXIT
, 4,
714 "Always", IDC_COEALWAYS
,
715 "Never", IDC_COENEVER
,
716 "Only on clean exit", IDC_COENORMAL
, NULL
);
720 if (panel
== loggingpanelstart
) {
721 /* The Logging panel. Accelerators used: [acgo] tplfw */
723 ctlposinit(&cp
, hwnd
, 80, 3, 13);
724 bartitle(&cp
, "Options controlling session logging",
726 beginbox(&cp
, NULL
, IDC_BOX_LOGGING1
);
728 "Session logging:", IDC_LSTATSTATIC
,
729 "Logging &turned off completely", IDC_LSTATOFF
,
730 "Log &printable output only", IDC_LSTATASCII
,
731 "&Log all session output", IDC_LSTATRAW
, NULL
);
732 editbutton(&cp
, "Log &file name:",
733 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
738 if (panel
== terminalpanelstart
) {
739 /* The Terminal panel. Accelerators used: [acgo] wdlben ht */
741 ctlposinit(&cp
, hwnd
, 80, 3, 13);
742 bartitle(&cp
, "Options controlling the terminal emulation",
744 beginbox(&cp
, "Set various terminal options",
746 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
747 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
748 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
749 checkbox(&cp
, "&Beep enabled", IDC_BEEP
);
750 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
751 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
754 beginbox(&cp
, "Line discipline options",
756 radioline(&cp
, "Local ec&ho:", IDC_ECHOSTATIC
, 3,
757 "Auto", IDC_ECHOBACKEND
,
758 "Force on", IDC_ECHOYES
,
759 "Force off", IDC_ECHONO
, NULL
);
760 radioline(&cp
, "Local line edi&ting:", IDC_EDITSTATIC
, 3,
761 "Auto", IDC_EDITBACKEND
,
762 "Force on", IDC_EDITYES
,
763 "Force off", IDC_EDITNO
, NULL
);
767 if (panel
== keyboardpanelstart
) {
768 /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxv unpymie t */
770 ctlposinit(&cp
, hwnd
, 80, 3, 13);
771 bartitle(&cp
, "Options controlling the effects of keys",
773 beginbox(&cp
, "Change the sequences sent by:",
775 radioline(&cp
, "The Backspace key", IDC_DELSTATIC
, 2,
776 "Control-&H", IDC_DEL008
,
777 "Control-&? (127)", IDC_DEL127
, NULL
);
778 radioline(&cp
, "The Home and End keys", IDC_HOMESTATIC
, 2,
779 "&Standard", IDC_HOMETILDE
,
780 "&rxvt", IDC_HOMERXVT
, NULL
);
781 radioline(&cp
, "The Function keys and keypad", IDC_FUNCSTATIC
, 4,
782 "ESC[n&~", IDC_FUNCTILDE
,
783 "&Linux", IDC_FUNCLINUX
,
784 "&Xterm R6", IDC_FUNCXTERM
,
785 "&VT400", IDC_FUNCVT400
, NULL
);
787 beginbox(&cp
, "Application keypad settings:",
790 "Application c&ursor keys totally disabled",
792 radioline(&cp
, "Initial state of cursor keys:", IDC_CURSTATIC
, 2,
793 "&Normal", IDC_CURNORMAL
,
794 "A&pplication", IDC_CURAPPLIC
, NULL
);
796 "Application ke&ypad keys totally disabled",
798 radioline(&cp
, "Initial state of numeric keypad:", IDC_KPSTATIC
, 3,
799 "Nor&mal", IDC_KPNORMAL
,
800 "Appl&ication", IDC_KPAPPLIC
,
801 "N&etHack", IDC_KPNH
, NULL
);
803 beginbox(&cp
, "Enable extra keyboard features:",
805 checkbox(&cp
, "Application and AltGr ac&t as Compose key",
810 if (panel
== windowpanelstart
) {
811 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
813 ctlposinit(&cp
, hwnd
, 80, 3, 13);
814 bartitle(&cp
, "Options controlling PuTTY's window",
816 beginbox(&cp
, "Set the size of the window",
819 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
820 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50,
822 checkbox(&cp
, "Lock window size against resi&zing", IDC_LOCKSIZE
);
824 beginbox(&cp
, "Control the scrollback in the window",
826 staticedit(&cp
, "Lines of &scrollback",
827 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
828 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
829 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
830 checkbox(&cp
, "Reset scrollback on dis&play activity",
833 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
);
834 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
835 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
836 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
837 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
838 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
842 if (panel
== appearancepanelstart
) {
843 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p */
845 ctlposinit(&cp
, hwnd
, 80, 3, 13);
846 bartitle(&cp
, "Options controlling PuTTY's appearance",
847 IDC_TITLE_APPEARANCE
);
848 beginbox(&cp
, "Adjust the use of the cursor",
849 IDC_BOX_APPEARANCE1
);
850 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
851 "B&lock", IDC_CURBLOCK
,
852 "&Underline", IDC_CURUNDER
,
853 "&Vertical line", IDC_CURVERT
,
855 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
857 beginbox(&cp
, "Set the font used in the terminal window",
858 IDC_BOX_APPEARANCE2
);
859 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
861 beginbox(&cp
, "Adjust the use of the window title",
862 IDC_BOX_APPEARANCE3
);
864 "Window &title:", IDC_WINTITLE
,
865 IDC_WINEDIT
, 100, NULL
);
866 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
868 beginbox(&cp
, "Adjust the use of the mouse pointer",
869 IDC_BOX_APPEARANCE4
);
870 checkbox(&cp
, "Hide mouse &pointer when typing in window",
875 if (panel
== translationpanelstart
) {
876 /* The Translation panel. Accelerators used: [acgo] xbep t s */
878 ctlposinit(&cp
, hwnd
, 80, 3, 13);
879 bartitle(&cp
, "Options controlling character set translation",
880 IDC_TITLE_TRANSLATION
);
881 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
882 IDC_BOX_TRANSLATION1
);
884 "Handling of line drawing characters:", IDC_VTSTATIC
,
885 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
886 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
887 "Use font in O&EM mode only", IDC_VTOEMONLY
,
888 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
889 IDC_VTPOORMAN
, NULL
);
891 beginbox(&cp
, "Enable character set translation on received data",
892 IDC_BOX_TRANSLATION2
);
894 "Character set &translation:", IDC_XLATSTATIC
,
896 "KOI8 / Win-1251", IDC_KOI8WIN1251
,
897 "ISO-8859-2 / Win-1250", IDC_88592WIN1250
,
898 "ISO-8859-2 / CP852", IDC_88592CP852
, NULL
);
900 beginbox(&cp
, "Enable character set translation on input data",
901 IDC_BOX_TRANSLATION3
);
902 checkbox(&cp
, "CAP&S LOCK acts as cyrillic switch",
907 if (panel
== selectionpanelstart
) {
908 /* The Selection panel. Accelerators used: [acgo] wx hst */
910 ctlposinit(&cp
, hwnd
, 80, 3, 13);
911 bartitle(&cp
, "Options controlling copy and paste",
912 IDC_TITLE_SELECTION
);
913 beginbox(&cp
, "Control which mouse button does which thing",
915 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
916 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
917 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
920 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
922 charclass(&cp
, "C&haracter classes:", IDC_CCSTATIC
, IDC_CCLIST
,
923 "&Set", IDC_CCSET
, IDC_CCEDIT
,
924 "&to class", IDC_CCSTATIC2
);
928 if (panel
== colourspanelstart
) {
929 /* The Colours panel. Accelerators used: [acgo] blum */
931 ctlposinit(&cp
, hwnd
, 80, 3, 13);
932 bartitle(&cp
, "Options controlling use of colours",
934 beginbox(&cp
, "General options for colour usage",
936 checkbox(&cp
, "&Bolded text is a different colour", IDC_BOLDCOLOUR
);
937 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
939 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
941 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
942 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
943 "&Modify...", IDC_CHANGE
,
944 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
945 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
946 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
950 if (panel
== connectionpanelstart
) {
951 /* The Connection panel. Accelerators used: [acgo] tuk */
953 ctlposinit(&cp
, hwnd
, 80, 3, 13);
954 bartitle(&cp
, "Options controlling the connection", IDC_TITLE_CONNECTION
);
956 beginbox(&cp
, "Data to send to the server",
957 IDC_BOX_CONNECTION1
);
958 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
, IDC_TTEDIT
, 50);
959 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
, IDC_LOGEDIT
, 50);
962 beginbox(&cp
, "Sending of null packets to keep session active",
963 IDC_BOX_CONNECTION2
);
964 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
965 IDC_PINGSTATIC
, IDC_PINGEDIT
, 20);
969 if (panel
== telnetpanelstart
) {
970 /* The Telnet panel. Accelerators used: [acgo] svldr bf */
972 ctlposinit(&cp
, hwnd
, 80, 3, 13);
974 bartitle(&cp
, "Options controlling Telnet connections", IDC_TITLE_TELNET
);
975 beginbox(&cp
, "Data to send to the server",
977 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
, IDC_TSEDIT
, 50);
978 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
979 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
,
980 "Va&lue", IDC_VALSTATIC
, IDC_VALEDIT
,
982 "A&dd", IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
984 beginbox(&cp
, "Telnet protocol adjustments",
986 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC
, 2,
987 "&BSD (commonplace)", IDC_EMBSD
,
988 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
993 if (panel
== rloginpanelstart
) {
994 /* The Rlogin panel. Accelerators used: [acgo] sl */
996 ctlposinit(&cp
, hwnd
, 80, 3, 13);
998 bartitle(&cp
, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN
);
999 beginbox(&cp
, "Data to send to the server",
1001 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
, IDC_R_TSEDIT
, 50);
1002 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
, IDC_RLLUSEREDIT
, 50);
1007 if (panel
== sshpanelstart
) {
1008 /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bd i */
1010 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1012 bartitle(&cp
, "Options controlling SSH connections", IDC_TITLE_SSH
);
1013 beginbox(&cp
, "Data to send to the server",
1016 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1019 beginbox(&cp
, "Authentication options",
1021 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1023 checkbox(&cp
, "Allow agent &forwarding", IDC_AGENTFWD
);
1024 editbutton(&cp
, "Private &key file for authentication:",
1025 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...", IDC_PKBUTTON
);
1027 beginbox(&cp
, "Protocol options",
1029 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1030 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1031 radioline(&cp
, "Preferred SSH protocol version:",
1032 IDC_SSHPROTSTATIC
, 2,
1033 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1034 radioline(&cp
, "Preferred encryption algorithm:", IDC_CIPHERSTATIC
, 3,
1035 "&3DES", IDC_CIPHER3DES
,
1036 "&Blowfish", IDC_CIPHERBLOWF
,
1037 "&DES", IDC_CIPHERDES
, NULL
);
1038 checkbox(&cp
, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1044 if (panel
== tunnelspanelstart
) {
1045 /* The Tunnels panel. Accelerators used: [acgo] ex */
1047 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1049 bartitle(&cp
, "Options controlling SSH tunnelling",
1051 beginbox(&cp
, "X11 forwarding options",
1053 checkbox(&cp
, "&Enable X11 forwarding",
1055 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1056 IDC_X11_DISPLAY
, 50, NULL
);
1063 * This function is the configuration box.
1065 static int GenericMainDlgProc (HWND hwnd
, UINT msg
,
1066 WPARAM wParam
, LPARAM lParam
,
1069 struct treeview_faff tvfaff
;
1072 char filename
[sizeof(cfg
.keyfile
)];
1075 char fontstatic
[256];
1077 struct servent
* service
;
1083 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
1085 * Centre the window.
1087 { /* centre the window */
1090 hw
= GetDesktopWindow();
1091 if (GetWindowRect (hw
, &rs
) && GetWindowRect (hwnd
, &rd
))
1092 MoveWindow (hwnd
, (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
)/2,
1093 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
)/2,
1094 rd
.right
-rd
.left
, rd
.bottom
-rd
.top
, TRUE
);
1098 * Create the tree view.
1105 r
.left
= 3; r
.right
= r
.left
+ 75;
1106 r
.top
= 3; r
.bottom
= r
.top
+ 10;
1107 MapDialogRect(hwnd
, &r
);
1108 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
1109 WS_CHILD
| WS_VISIBLE
,
1111 r
.right
-r
.left
, r
.bottom
-r
.top
,
1112 hwnd
, (HMENU
)IDCX_TVSTATIC
, hinst
, NULL
);
1113 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1114 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1116 r
.left
= 3; r
.right
= r
.left
+ 75;
1117 r
.top
= 13; r
.bottom
= r
.top
+ 206;
1118 MapDialogRect(hwnd
, &r
);
1119 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
1120 WS_CHILD
| WS_VISIBLE
|
1121 WS_TABSTOP
| TVS_HASLINES
|
1122 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
|
1123 TVS_LINESATROOT
| TVS_SHOWSELALWAYS
,
1125 r
.right
-r
.left
, r
.bottom
-r
.top
,
1126 hwnd
, (HMENU
)IDCX_TREEVIEW
, hinst
, NULL
);
1127 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
1128 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
1129 tvfaff
.treeview
= treeview
;
1130 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
1134 * Set up the tree view contents.
1136 hsession
= treeview_insert(&tvfaff
, 0, "Session");
1137 treeview_insert(&tvfaff
, 1, "Logging");
1138 treeview_insert(&tvfaff
, 0, "Terminal");
1139 treeview_insert(&tvfaff
, 1, "Keyboard");
1140 treeview_insert(&tvfaff
, 0, "Window");
1141 treeview_insert(&tvfaff
, 1, "Appearance");
1142 treeview_insert(&tvfaff
, 1, "Translation");
1143 treeview_insert(&tvfaff
, 1, "Selection");
1144 treeview_insert(&tvfaff
, 1, "Colours");
1145 treeview_insert(&tvfaff
, 0, "Connection");
1147 treeview_insert(&tvfaff
, 1, "Telnet");
1148 treeview_insert(&tvfaff
, 1, "Rlogin");
1149 if (backends
[3].backend
!= NULL
) {
1150 treeview_insert(&tvfaff
, 1, "SSH");
1151 treeview_insert(&tvfaff
, 2, "Tunnels");
1156 * Put the treeview selection on to the Session panel. This
1157 * should also cause creation of the relevant controls.
1159 TreeView_SelectItem(treeview
, hsession
);
1162 * Set focus into the first available control.
1166 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1167 if (!ctl
) ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1171 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1175 * Button release should trigger WM_OK if there was a
1176 * previous double click on the session list.
1180 SendMessage (hwnd
, WM_COMMAND
, IDOK
, 0);
1183 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1184 ((LPNMHDR
)lParam
)->code
== TVN_SELCHANGED
) {
1185 HTREEITEM i
= TreeView_GetSelection(((LPNMHDR
)lParam
)->hwndFrom
);
1190 item
.pszText
= buffer
;
1191 item
.cchTextMax
= sizeof(buffer
);
1192 item
.mask
= TVIF_TEXT
;
1193 TreeView_GetItem(((LPNMHDR
)lParam
)->hwndFrom
, &item
);
1194 for (j
= controlstartvalue
; j
< controlendvalue
; j
++) {
1195 HWND item
= GetDlgItem(hwnd
, j
);
1197 DestroyWindow(item
);
1199 if (!strcmp(buffer
, "Session"))
1200 create_controls(hwnd
, dlgtype
, sessionpanelstart
);
1201 if (!strcmp(buffer
, "Logging"))
1202 create_controls(hwnd
, dlgtype
, loggingpanelstart
);
1203 if (!strcmp(buffer
, "Keyboard"))
1204 create_controls(hwnd
, dlgtype
, keyboardpanelstart
);
1205 if (!strcmp(buffer
, "Terminal"))
1206 create_controls(hwnd
, dlgtype
, terminalpanelstart
);
1207 if (!strcmp(buffer
, "Window"))
1208 create_controls(hwnd
, dlgtype
, windowpanelstart
);
1209 if (!strcmp(buffer
, "Appearance"))
1210 create_controls(hwnd
, dlgtype
, appearancepanelstart
);
1211 if (!strcmp(buffer
, "Tunnels"))
1212 create_controls(hwnd
, dlgtype
, tunnelspanelstart
);
1213 if (!strcmp(buffer
, "Connection"))
1214 create_controls(hwnd
, dlgtype
, connectionpanelstart
);
1215 if (!strcmp(buffer
, "Telnet"))
1216 create_controls(hwnd
, dlgtype
, telnetpanelstart
);
1217 if (!strcmp(buffer
, "Rlogin"))
1218 create_controls(hwnd
, dlgtype
, rloginpanelstart
);
1219 if (!strcmp(buffer
, "SSH"))
1220 create_controls(hwnd
, dlgtype
, sshpanelstart
);
1221 if (!strcmp(buffer
, "Selection"))
1222 create_controls(hwnd
, dlgtype
, selectionpanelstart
);
1223 if (!strcmp(buffer
, "Colours"))
1224 create_controls(hwnd
, dlgtype
, colourspanelstart
);
1225 if (!strcmp(buffer
, "Translation"))
1226 create_controls(hwnd
, dlgtype
, translationpanelstart
);
1228 init_dlg_ctrls(hwnd
);
1230 SetFocus (((LPNMHDR
)lParam
)->hwndFrom
); /* ensure focus stays */
1236 * Only process WM_COMMAND once the dialog is fully formed.
1238 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
1241 EndDialog (hwnd
, 1);
1246 EndDialog (hwnd
, 0);
1248 case IDC_PROTTELNET
:
1249 case IDC_PROTRLOGIN
:
1252 if (HIWORD(wParam
) == BN_CLICKED
||
1253 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1254 int i
= IsDlgButtonChecked (hwnd
, IDC_PROTSSH
);
1255 int j
= IsDlgButtonChecked (hwnd
, IDC_PROTTELNET
);
1256 int k
= IsDlgButtonChecked (hwnd
, IDC_PROTRLOGIN
);
1257 cfg
.protocol
= i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
: PROT_RAW
;
1258 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22) ||
1259 (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23) ||
1260 (cfg
.protocol
== PROT_RLOGIN
&& cfg
.port
!= 513)) {
1261 cfg
.port
= i ?
22 : j ?
23 : 513;
1262 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1267 if (HIWORD(wParam
) == EN_CHANGE
)
1268 GetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
,
1269 sizeof(cfg
.host
)-1);
1272 if (HIWORD(wParam
) == EN_CHANGE
) {
1273 GetDlgItemText (hwnd
, IDC_PORT
, portname
, 31);
1274 if (isdigit(portname
[0]))
1275 MyGetDlgItemInt (hwnd
, IDC_PORT
, &cfg
.port
);
1277 service
= getservbyname(portname
, NULL
);
1278 if (service
) cfg
.port
= ntohs(service
->s_port
);
1284 if (HIWORD(wParam
) == EN_CHANGE
) {
1285 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1287 GetDlgItemText (hwnd
, IDC_SESSEDIT
,
1288 savedsession
, sizeof(savedsession
)-1);
1289 savedsession
[sizeof(savedsession
)-1] = '\0';
1293 if (HIWORD(wParam
) == BN_CLICKED
||
1294 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1299 GetDlgItemText (hwnd
, IDC_SESSEDIT
, str
, sizeof(str
)-1);
1301 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1302 LB_GETCURSEL
, 0, 0);
1307 strcpy (str
, sessions
[n
]);
1309 save_settings (str
, !!strcmp(str
, "Default Settings"), &cfg
);
1310 get_sesslist (FALSE
);
1311 get_sesslist (TRUE
);
1312 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1314 for (i
= 0; i
< nsessions
; i
++)
1315 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1316 0, (LPARAM
) (sessions
[i
]));
1317 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1323 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1324 HIWORD(wParam
) != BN_CLICKED
&&
1325 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1327 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1328 HIWORD(wParam
) != LBN_DBLCLK
)
1331 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1332 LB_GETCURSEL
, 0, 0);
1338 isdef
= !strcmp(sessions
[n
], "Default Settings");
1339 load_settings (sessions
[n
], !isdef
, &cfg
);
1340 init_dlg_ctrls(hwnd
);
1342 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1344 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1346 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1348 * A double-click on a saved session should
1349 * actually start the session, not just load it.
1350 * Unless it's Default Settings or some other
1351 * host-less set of saved settings.
1360 if (HIWORD(wParam
) == BN_CLICKED
||
1361 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1362 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1363 LB_GETCURSEL
, 0, 0);
1364 if (n
== LB_ERR
|| n
== 0) {
1368 del_settings(sessions
[n
]);
1369 get_sesslist (FALSE
);
1370 get_sesslist (TRUE
);
1371 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1373 for (i
= 0; i
< nsessions
; i
++)
1374 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1375 0, (LPARAM
) (sessions
[i
]));
1376 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1380 if (HIWORD(wParam
) == EN_CHANGE
)
1381 MyGetDlgItemInt (hwnd
, IDC_PINGEDIT
, &cfg
.ping_interval
);
1385 if (HIWORD(wParam
) == BN_CLICKED
||
1386 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1387 cfg
.bksp_is_delete
= IsDlgButtonChecked (hwnd
, IDC_DEL127
);
1391 if (HIWORD(wParam
) == BN_CLICKED
||
1392 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1393 cfg
.rxvt_homeend
= IsDlgButtonChecked (hwnd
, IDC_HOMERXVT
);
1396 if (HIWORD(wParam
) == BN_CLICKED
||
1397 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1401 if (HIWORD(wParam
) == BN_CLICKED
||
1402 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1407 if (HIWORD(wParam
) == BN_CLICKED
||
1408 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1409 cfg
.funky_type
= IsDlgButtonChecked (hwnd
, IDC_FUNCLINUX
);
1413 if (HIWORD(wParam
) == BN_CLICKED
||
1414 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1415 cfg
.app_keypad
= IsDlgButtonChecked (hwnd
, IDC_KPAPPLIC
);
1416 cfg
.nethack_keypad
= FALSE
;
1420 if (HIWORD(wParam
) == BN_CLICKED
||
1421 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1422 cfg
.app_keypad
= FALSE
;
1423 cfg
.nethack_keypad
= TRUE
;
1428 if (HIWORD(wParam
) == BN_CLICKED
||
1429 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1430 cfg
.app_cursor
= IsDlgButtonChecked (hwnd
, IDC_CURAPPLIC
);
1433 if (HIWORD(wParam
) == BN_CLICKED
||
1434 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1435 cfg
.no_applic_c
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICC
);
1438 if (HIWORD(wParam
) == BN_CLICKED
||
1439 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1440 cfg
.no_applic_k
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICK
);
1443 if (HIWORD(wParam
) == BN_CLICKED
||
1444 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1445 cfg
.alt_f4
= IsDlgButtonChecked (hwnd
, IDC_ALTF4
);
1448 if (HIWORD(wParam
) == BN_CLICKED
||
1449 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1450 cfg
.alt_space
= IsDlgButtonChecked (hwnd
, IDC_ALTSPACE
);
1453 if (HIWORD(wParam
) == BN_CLICKED
||
1454 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1455 cfg
.alt_only
= IsDlgButtonChecked (hwnd
, IDC_ALTONLY
);
1457 case IDC_ECHOBACKEND
:
1460 if (HIWORD(wParam
) == BN_CLICKED
||
1461 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1462 if (LOWORD(wParam
)==IDC_ECHOBACKEND
) cfg
.localecho
=LD_BACKEND
;
1463 if (LOWORD(wParam
)==IDC_ECHOYES
) cfg
.localecho
=LD_YES
;
1464 if (LOWORD(wParam
)==IDC_ECHONO
) cfg
.localecho
=LD_NO
;
1467 case IDC_EDITBACKEND
:
1470 if (HIWORD(wParam
) == BN_CLICKED
||
1471 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1472 if (LOWORD(wParam
)==IDC_EDITBACKEND
) cfg
.localedit
=LD_BACKEND
;
1473 if (LOWORD(wParam
)==IDC_EDITYES
) cfg
.localedit
=LD_YES
;
1474 if (LOWORD(wParam
)==IDC_EDITNO
) cfg
.localedit
=LD_NO
;
1477 case IDC_ALWAYSONTOP
:
1478 if (HIWORD(wParam
) == BN_CLICKED
||
1479 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1480 cfg
.alwaysontop
= IsDlgButtonChecked (hwnd
, IDC_ALWAYSONTOP
);
1483 if (HIWORD(wParam
) == BN_CLICKED
||
1484 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1485 cfg
.scroll_on_key
= IsDlgButtonChecked (hwnd
, IDC_SCROLLKEY
);
1487 case IDC_SCROLLDISP
:
1488 if (HIWORD(wParam
) == BN_CLICKED
||
1489 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1490 cfg
.scroll_on_disp
= IsDlgButtonChecked (hwnd
, IDC_SCROLLDISP
);
1492 case IDC_COMPOSEKEY
:
1493 if (HIWORD(wParam
) == BN_CLICKED
||
1494 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1495 cfg
.compose_key
= IsDlgButtonChecked (hwnd
, IDC_COMPOSEKEY
);
1498 if (HIWORD(wParam
) == BN_CLICKED
||
1499 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1500 cfg
.wrap_mode
= IsDlgButtonChecked (hwnd
, IDC_WRAPMODE
);
1503 if (HIWORD(wParam
) == BN_CLICKED
||
1504 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1505 cfg
.dec_om
= IsDlgButtonChecked (hwnd
, IDC_DECOM
);
1508 if (HIWORD(wParam
) == BN_CLICKED
||
1509 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1510 cfg
.lfhascr
= IsDlgButtonChecked (hwnd
, IDC_LFHASCR
);
1513 if (HIWORD(wParam
) == EN_CHANGE
)
1514 MyGetDlgItemInt (hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1517 if (HIWORD(wParam
) == EN_CHANGE
)
1518 MyGetDlgItemInt (hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1521 if (HIWORD(wParam
) == EN_CHANGE
)
1522 MyGetDlgItemInt (hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1524 case IDC_CHOOSEFONT
:
1525 lf
.lfHeight
= cfg
.fontheight
;
1526 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1527 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1528 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1529 lf
.lfCharSet
= cfg
.fontcharset
;
1530 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1531 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1532 lf
.lfQuality
= DEFAULT_QUALITY
;
1533 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1534 strncpy (lf
.lfFaceName
, cfg
.font
, sizeof(lf
.lfFaceName
)-1);
1535 lf
.lfFaceName
[sizeof(lf
.lfFaceName
)-1] = '\0';
1537 cf
.lStructSize
= sizeof(cf
);
1538 cf
.hwndOwner
= hwnd
;
1540 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1541 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1543 if (ChooseFont (&cf
)) {
1544 strncpy (cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
)-1);
1545 cfg
.font
[sizeof(cfg
.font
)-1] = '\0';
1546 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1547 cfg
.fontcharset
= lf
.lfCharSet
;
1548 cfg
.fontheight
= lf
.lfHeight
;
1549 fmtfont (fontstatic
);
1550 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
1554 if (HIWORD(wParam
) == BN_CLICKED
||
1555 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1556 cfg
.beep
= IsDlgButtonChecked (hwnd
, IDC_BEEP
);
1559 if (HIWORD(wParam
) == BN_CLICKED
||
1560 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1561 cfg
.blinktext
= IsDlgButtonChecked (hwnd
, IDC_BLINKTEXT
);
1564 if (HIWORD(wParam
) == BN_CLICKED
||
1565 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1566 cfg
.bce
= IsDlgButtonChecked (hwnd
, IDC_BCE
);
1569 if (HIWORD(wParam
) == BN_CLICKED
||
1570 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1571 cfg
.win_name_always
= IsDlgButtonChecked (hwnd
, IDC_WINNAME
);
1574 if (HIWORD(wParam
) == BN_CLICKED
||
1575 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1576 cfg
.hide_mouseptr
= IsDlgButtonChecked (hwnd
, IDC_HIDEMOUSE
);
1579 if (HIWORD(wParam
) == BN_CLICKED
||
1580 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1581 cfg
.cursor_type
= 0;
1584 if (HIWORD(wParam
) == BN_CLICKED
||
1585 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1586 cfg
.cursor_type
= 1;
1589 if (HIWORD(wParam
) == BN_CLICKED
||
1590 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1591 cfg
.cursor_type
= 2;
1594 if (HIWORD(wParam
) == BN_CLICKED
||
1595 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1596 cfg
.blink_cur
= IsDlgButtonChecked (hwnd
, IDC_BLINKCUR
);
1599 if (HIWORD(wParam
) == BN_CLICKED
||
1600 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1601 cfg
.scrollbar
= IsDlgButtonChecked (hwnd
, IDC_SCROLLBAR
);
1604 if (HIWORD(wParam
) == BN_CLICKED
||
1605 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1606 cfg
.locksize
= IsDlgButtonChecked (hwnd
, IDC_LOCKSIZE
);
1609 if (HIWORD(wParam
) == EN_CHANGE
)
1610 GetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
1611 sizeof(cfg
.wintitle
)-1);
1616 if (HIWORD(wParam
) == BN_CLICKED
||
1617 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1618 cfg
.close_on_exit
= IsDlgButtonChecked (hwnd
, IDC_COEALWAYS
) ? COE_ALWAYS
:
1619 IsDlgButtonChecked (hwnd
, IDC_COENEVER
) ? COE_NEVER
:
1624 if (HIWORD(wParam
) == BN_CLICKED
||
1625 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1626 cfg
.warn_on_close
= IsDlgButtonChecked (hwnd
, IDC_CLOSEWARN
);
1629 if (HIWORD(wParam
) == EN_CHANGE
)
1630 GetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
,
1631 sizeof(cfg
.termtype
)-1);
1634 if (HIWORD(wParam
) == EN_CHANGE
)
1635 GetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
1636 sizeof(cfg
.logfilename
)-1);
1639 memset(&of
, 0, sizeof(of
));
1640 #ifdef OPENFILENAME_SIZE_VERSION_400
1641 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1643 of
.lStructSize
= sizeof(of
);
1645 of
.hwndOwner
= hwnd
;
1646 of
.lpstrFilter
= "All Files\0*\0\0\0";
1647 of
.lpstrCustomFilter
= NULL
;
1648 of
.nFilterIndex
= 1;
1649 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.logfilename
);
1650 of
.nMaxFile
= sizeof(filename
);
1651 of
.lpstrFileTitle
= NULL
;
1652 of
.lpstrInitialDir
= NULL
;
1653 of
.lpstrTitle
= "Select session log file";
1655 if (GetSaveFileName(&of
)) {
1656 strcpy(cfg
.logfilename
, filename
);
1657 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
1661 case IDC_LSTATASCII
:
1663 if (HIWORD(wParam
) == BN_CLICKED
||
1664 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1665 if (IsDlgButtonChecked (hwnd
, IDC_LSTATOFF
)) cfg
.logtype
= 0;
1666 if (IsDlgButtonChecked (hwnd
, IDC_LSTATASCII
)) cfg
.logtype
= 1;
1667 if (IsDlgButtonChecked (hwnd
, IDC_LSTATRAW
)) cfg
.logtype
= 2;
1672 if (HIWORD(wParam
) == EN_CHANGE
)
1673 GetDlgItemText (hwnd
, LOWORD(wParam
), cfg
.termspeed
,
1674 sizeof(cfg
.termspeed
)-1);
1677 if (HIWORD(wParam
) == EN_CHANGE
)
1678 GetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
,
1679 sizeof(cfg
.username
)-1);
1681 case IDC_RLLUSEREDIT
:
1682 if (HIWORD(wParam
) == EN_CHANGE
)
1683 GetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
,
1684 sizeof(cfg
.localusername
)-1);
1688 cfg
.rfc_environ
= IsDlgButtonChecked (hwnd
, IDC_EMRFC
);
1691 if (HIWORD(wParam
) == BN_CLICKED
||
1692 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1693 char str
[sizeof(cfg
.environmt
)];
1695 GetDlgItemText (hwnd
, IDC_VAREDIT
, str
, sizeof(str
)-1);
1700 p
= str
+ strlen(str
);
1702 GetDlgItemText (hwnd
, IDC_VALEDIT
, p
, sizeof(str
)-1-(p
-str
));
1712 if ((p
-cfg
.environmt
) + strlen(str
) + 2 < sizeof(cfg
.environmt
)) {
1714 p
[strlen(str
)+1] = '\0';
1715 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
1717 SetDlgItemText (hwnd
, IDC_VAREDIT
, "");
1718 SetDlgItemText (hwnd
, IDC_VALEDIT
, "");
1720 MessageBox(hwnd
, "Environment too big", "PuTTY Error",
1721 MB_OK
| MB_ICONERROR
);
1726 if (HIWORD(wParam
) != BN_CLICKED
&&
1727 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1729 i
= SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0, 0);
1735 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
1760 if (HIWORD(wParam
) == BN_CLICKED
||
1761 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1762 cfg
.nopty
= IsDlgButtonChecked (hwnd
, IDC_NOPTY
);
1765 if (HIWORD(wParam
) == BN_CLICKED
||
1766 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1767 cfg
.compression
= IsDlgButtonChecked (hwnd
, IDC_COMPRESS
);
1770 if (HIWORD(wParam
) == BN_CLICKED
||
1771 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1772 cfg
.buggymac
= IsDlgButtonChecked (hwnd
, IDC_BUGGYMAC
);
1775 if (HIWORD(wParam
) == BN_CLICKED
||
1776 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1777 cfg
.agentfwd
= IsDlgButtonChecked (hwnd
, IDC_AGENTFWD
);
1779 case IDC_CIPHER3DES
:
1780 case IDC_CIPHERBLOWF
:
1782 if (HIWORD(wParam
) == BN_CLICKED
||
1783 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1784 if (IsDlgButtonChecked (hwnd
, IDC_CIPHER3DES
))
1785 cfg
.cipher
= CIPHER_3DES
;
1786 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERBLOWF
))
1787 cfg
.cipher
= CIPHER_BLOWFISH
;
1788 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERDES
))
1789 cfg
.cipher
= CIPHER_DES
;
1794 if (HIWORD(wParam
) == BN_CLICKED
||
1795 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1796 if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT1
))
1798 else if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT2
))
1803 if (HIWORD(wParam
) == BN_CLICKED
||
1804 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1805 cfg
.try_tis_auth
= IsDlgButtonChecked (hwnd
, IDC_AUTHTIS
);
1808 if (HIWORD(wParam
) == EN_CHANGE
)
1809 GetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
1810 sizeof(cfg
.keyfile
)-1);
1813 if (HIWORD(wParam
) == EN_CHANGE
)
1814 GetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
1815 sizeof(cfg
.remote_cmd
)-1);
1818 memset(&of
, 0, sizeof(of
));
1819 #ifdef OPENFILENAME_SIZE_VERSION_400
1820 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1822 of
.lStructSize
= sizeof(of
);
1824 of
.hwndOwner
= hwnd
;
1825 of
.lpstrFilter
= "All Files\0*\0\0\0";
1826 of
.lpstrCustomFilter
= NULL
;
1827 of
.nFilterIndex
= 1;
1828 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1829 of
.nMaxFile
= sizeof(filename
);
1830 of
.lpstrFileTitle
= NULL
;
1831 of
.lpstrInitialDir
= NULL
;
1832 of
.lpstrTitle
= "Select Public Key File";
1834 if (GetOpenFileName(&of
)) {
1835 strcpy(cfg
.keyfile
, filename
);
1836 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1841 cfg
.mouse_is_xterm
= IsDlgButtonChecked (hwnd
, IDC_MBXTERM
);
1847 int n
= GetDlgItemInt (hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
1852 for (i
=0; i
<256; i
++)
1853 if (SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_GETSEL
,
1856 cfg
.wordness
[i
] = n
;
1857 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1858 LB_DELETESTRING
, i
, 0);
1859 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
1860 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
1862 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1869 case IDC_BOLDCOLOUR
:
1870 if (HIWORD(wParam
) == BN_CLICKED
||
1871 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1873 cfg
.bold_colour
= IsDlgButtonChecked (hwnd
, IDC_BOLDCOLOUR
);
1874 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
1875 if (n
!= 12+10*cfg
.bold_colour
) {
1877 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1878 LB_DELETESTRING
, i
, 0);
1879 for (i
=0; i
<22; i
++)
1880 if (cfg
.bold_colour
|| permcolour
[i
])
1881 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1883 (LPARAM
) colours
[i
]);
1888 if (HIWORD(wParam
) == BN_CLICKED
||
1889 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1890 cfg
.try_palette
= IsDlgButtonChecked (hwnd
, IDC_PALETTE
);
1892 case IDC_COLOURLIST
:
1893 if (HIWORD(wParam
) == LBN_DBLCLK
||
1894 HIWORD(wParam
) == LBN_SELCHANGE
) {
1895 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1897 if (!cfg
.bold_colour
)
1898 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1899 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0], FALSE
);
1900 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1], FALSE
);
1901 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2], FALSE
);
1905 if (HIWORD(wParam
) == BN_CLICKED
||
1906 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1907 static CHOOSECOLOR cc
;
1908 static DWORD custom
[16] = {0}; /* zero initialisers */
1909 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1911 if (!cfg
.bold_colour
)
1912 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1913 cc
.lStructSize
= sizeof(cc
);
1914 cc
.hwndOwner
= hwnd
;
1915 cc
.hInstance
= (HWND
)hinst
;
1916 cc
.lpCustColors
= custom
;
1917 cc
.rgbResult
= RGB (cfg
.colours
[i
][0], cfg
.colours
[i
][1],
1919 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
1920 if (ChooseColor(&cc
)) {
1922 (unsigned char) (cc
.rgbResult
& 0xFF);
1924 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
1926 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
1927 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
1929 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
1931 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
1937 case IDC_KOI8WIN1251
:
1938 case IDC_88592WIN1250
:
1939 case IDC_88592CP852
:
1940 cfg
.xlat_enablekoiwin
=
1941 IsDlgButtonChecked (hwnd
, IDC_KOI8WIN1251
);
1942 cfg
.xlat_88592w1250
=
1943 IsDlgButtonChecked (hwnd
, IDC_88592WIN1250
);
1944 cfg
.xlat_88592cp852
=
1945 IsDlgButtonChecked (hwnd
, IDC_88592CP852
);
1947 case IDC_CAPSLOCKCYR
:
1948 if (HIWORD(wParam
) == BN_CLICKED
||
1949 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1950 cfg
.xlat_capslockcyr
=
1951 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
1954 case IDC_VTXWINDOWS
:
1959 (IsDlgButtonChecked (hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
:
1960 IsDlgButtonChecked (hwnd
, IDC_VTOEMANSI
) ? VT_OEMANSI
:
1961 IsDlgButtonChecked (hwnd
, IDC_VTOEMONLY
) ? VT_OEMONLY
:
1964 case IDC_X11_FORWARD
:
1965 if (HIWORD(wParam
) == BN_CLICKED
||
1966 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1967 cfg
.x11_forward
= IsDlgButtonChecked (hwnd
, IDC_X11_FORWARD
);
1969 case IDC_X11_DISPLAY
:
1970 if (HIWORD(wParam
) == EN_CHANGE
)
1971 GetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
1972 sizeof(cfg
.x11_display
)-1);
1977 EndDialog (hwnd
, 0);
1980 /* Grrr Explorer will maximize Dialogs! */
1982 if (wParam
== SIZE_MAXIMIZED
)
1989 static int CALLBACK
MainDlgProc (HWND hwnd
, UINT msg
,
1990 WPARAM wParam
, LPARAM lParam
) {
1991 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
1993 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
1994 EnableWindow(hwnd
, 0);
1995 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1996 GetParent(hwnd
), AboutProc
);
1997 EnableWindow(hwnd
, 1);
1998 SetActiveWindow(hwnd
);
2000 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 0);
2003 static int CALLBACK
ReconfDlgProc (HWND hwnd
, UINT msg
,
2004 WPARAM wParam
, LPARAM lParam
) {
2005 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 1);
2008 void defuse_showwindow(void) {
2010 * Work around the fact that the app's first call to ShowWindow
2011 * will ignore the default in favour of the shell-provided
2016 hwnd
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2018 ShowWindow(hwnd
, SW_HIDE
);
2019 DestroyWindow(hwnd
);
2023 int do_config (void) {
2027 savedsession
[0] = '\0';
2028 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
2029 get_sesslist(FALSE
);
2034 int do_reconfig (HWND hwnd
) {
2038 backup_cfg
= cfg
; /* structure copy */
2039 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
2041 cfg
= backup_cfg
; /* structure copy */
2046 void logevent (char *string
) {
2050 if (nevents
>= negsize
) {
2052 events
= srealloc (events
, negsize
* sizeof(*events
));
2056 strftime(timebuf
, sizeof(timebuf
), "%Y-%m-%d %H:%M:%S\t", localtime(&t
));
2058 events
[nevents
] = smalloc(strlen(timebuf
)+strlen(string
)+1);
2059 strcpy(events
[nevents
], timebuf
);
2060 strcat(events
[nevents
], string
);
2063 SendDlgItemMessage (logbox
, IDN_LIST
, LB_ADDSTRING
,
2064 0, (LPARAM
)events
[nevents
]);
2065 count
= SendDlgItemMessage (logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
2066 SendDlgItemMessage (logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
-1, 0);
2071 void showeventlog (HWND hwnd
) {
2073 logbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2075 ShowWindow (logbox
, SW_SHOWNORMAL
);
2077 SetActiveWindow(logbox
);
2080 void showabout (HWND hwnd
) {
2081 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),hwnd
, AboutProc
);
2084 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2085 char *keystr
, char *fingerprint
) {
2088 static const char absentmsg
[] =
2089 "The server's host key is not cached in the registry. You\n"
2090 "have no guarantee that the server is the computer you\n"
2092 "The server's key fingerprint is:\n"
2094 "If you trust this host, hit Yes to add the key to\n"
2095 "PuTTY's cache and carry on connecting.\n"
2096 "If you do not trust this host, hit No to abandon the\n"
2099 static const char wrongmsg
[] =
2100 "WARNING - POTENTIAL SECURITY BREACH!\n"
2102 "The server's host key does not match the one PuTTY has\n"
2103 "cached in the registry. This means that either the\n"
2104 "server administrator has changed the host key, or you\n"
2105 "have actually connected to another computer pretending\n"
2106 "to be the server.\n"
2107 "The new key fingerprint is:\n"
2109 "If you were expecting this change and trust the new key,\n"
2110 "hit Yes to update PuTTY's cache and continue connecting.\n"
2111 "If you want to carry on connecting but without updating\n"
2112 "the cache, hit No.\n"
2113 "If you want to abandon the connection completely, hit\n"
2114 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2117 static const char mbtitle
[] = "PuTTY Security Alert";
2120 char message
[160+ /* sensible fingerprint max size */
2121 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2122 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2125 * Verify the key against the registry.
2127 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2129 if (ret
== 0) /* success - key matched OK */
2131 if (ret
== 2) { /* key was different */
2133 sprintf(message
, wrongmsg
, fingerprint
);
2134 mbret
= MessageBox(NULL
, message
, mbtitle
,
2135 MB_ICONWARNING
| MB_YESNOCANCEL
);
2137 store_host_key(host
, port
, keytype
, keystr
);
2138 if (mbret
== IDCANCEL
)
2141 if (ret
== 1) { /* key was absent */
2143 sprintf(message
, absentmsg
, fingerprint
);
2144 mbret
= MessageBox(NULL
, message
, mbtitle
,
2145 MB_ICONWARNING
| MB_YESNO
);
2148 store_host_key(host
, port
, keytype
, keystr
);
2153 * Ask whether to wipe a session log file before writing to it.
2154 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2156 int askappend(char *filename
) {
2157 static const char mbtitle
[] = "PuTTY Log to File";
2158 static const char msgtemplate
[] =
2159 "The session log file \"%.*s\" already exists.\n"
2160 "You can overwrite it with a new session log,\n"
2161 "append your session log to the end of it,\n"
2162 "or disable session logging for this session.\n"
2163 "Hit Yes to wipe the file, No to append to it,\n"
2164 "or Cancel to disable logging.";
2165 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2167 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2169 mbret
= MessageBox(NULL
, message
, mbtitle
,
2170 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2173 else if (mbret
== IDNO
)