13 static char **events
= NULL
;
14 static int nevents
= 0, negsize
= 0;
16 static HWND logbox
= NULL
, abtbox
= NULL
;
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
) {
52 for (i
=0; i
<nevents
; i
++)
53 SendDlgItemMessage (hwnd
, IDN_LIST
, LB_ADDSTRING
,
54 0, (LPARAM
)events
[i
]);
57 switch (LOWORD(wParam
)) {
63 if (HIWORD(wParam
) == BN_CLICKED
||
64 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
67 selcount
= SendDlgItemMessage(hwnd
, IDN_LIST
,
68 LB_GETSELCOUNT
, 0, 0);
69 selitems
= smalloc(selcount
* sizeof(int));
71 int count
= SendDlgItemMessage(hwnd
, IDN_LIST
,
73 selcount
, (LPARAM
)selitems
);
77 static unsigned char sel_nl
[] = SEL_NL
;
79 if (count
== 0) { /* can't copy zero stuff */
85 for (i
= 0; i
< count
; i
++)
86 size
+= strlen(events
[selitems
[i
]]) + sizeof(sel_nl
);
88 clipdata
= smalloc(size
);
91 for (i
= 0; i
< count
; i
++) {
92 char *q
= events
[selitems
[i
]];
96 memcpy(p
, sel_nl
, sizeof(sel_nl
));
99 write_clip(clipdata
, size
, TRUE
);
104 for (i
= 0; i
< nevents
; i
++)
105 SendDlgItemMessage(hwnd
, IDN_LIST
, LB_SETSEL
,
114 DestroyWindow (hwnd
);
120 static int CALLBACK
LicenceProc (HWND hwnd
, UINT msg
,
121 WPARAM wParam
, LPARAM lParam
) {
126 switch (LOWORD(wParam
)) {
139 static int CALLBACK
AboutProc (HWND hwnd
, UINT msg
,
140 WPARAM wParam
, LPARAM lParam
) {
143 SetDlgItemText (hwnd
, IDA_VERSION
, ver
);
146 switch (LOWORD(wParam
)) {
149 DestroyWindow (hwnd
);
152 EnableWindow(hwnd
, 0);
153 DialogBox (hinst
, MAKEINTRESOURCE(IDD_LICENCEBOX
),
155 EnableWindow(hwnd
, 1);
156 SetActiveWindow(hwnd
);
162 DestroyWindow (hwnd
);
169 * Null dialog procedure.
171 static int CALLBACK
NullDlgProc (HWND hwnd
, UINT msg
,
172 WPARAM wParam
, LPARAM lParam
) {
176 static char savedsession
[2048];
178 enum { IDCX_ABOUT
= IDC_ABOUT
, IDCX_TVSTATIC
, IDCX_TREEVIEW
, controlstartvalue
,
182 IDC_BOX_SESSION1
, IDC_BOXT_SESSION1
,
183 IDC_BOX_SESSION2
, IDC_BOXT_SESSION2
,
205 IDC_BOX_KEYBOARD1
, IDC_BOXT_KEYBOARD1
,
206 IDC_BOX_KEYBOARD2
, IDC_BOXT_KEYBOARD2
,
207 IDC_BOX_KEYBOARD3
, IDC_BOXT_KEYBOARD3
,
233 IDC_BOX_TERMINAL1
, IDC_BOXT_TERMINAL1
,
234 IDC_BOX_TERMINAL2
, IDC_BOXT_TERMINAL2
,
253 IDC_BOX_WINDOW1
, IDC_BOXT_WINDOW1
,
254 IDC_BOX_WINDOW2
, IDC_BOXT_WINDOW2
,
273 appearancepanelstart
,
274 IDC_TITLE_APPEARANCE
,
275 IDC_BOX_APPEARANCE1
, IDC_BOXT_APPEARANCE1
,
276 IDC_BOX_APPEARANCE2
, IDC_BOXT_APPEARANCE2
,
277 IDC_BOX_APPEARANCE3
, IDC_BOXT_APPEARANCE3
,
290 connectionpanelstart
,
291 IDC_TITLE_CONNECTION
,
292 IDC_BOX_CONNECTION1
, IDC_BOXT_CONNECTION1
,
293 IDC_BOX_CONNECTION2
, IDC_BOXT_CONNECTION2
,
304 IDC_BOX_TELNET1
, IDC_BOXT_TELNET1
,
305 IDC_BOX_TELNET2
, IDC_BOXT_TELNET2
,
323 IDC_BOX_RLOGIN1
, IDC_BOXT_RLOGIN1
,
324 IDC_BOX_RLOGIN2
, IDC_BOXT_RLOGIN2
,
333 IDC_BOX_SSH1
, IDC_BOXT_SSH1
,
334 IDC_BOX_SSH2
, IDC_BOXT_SSH2
,
335 IDC_BOX_SSH3
, IDC_BOXT_SSH3
,
357 IDC_BOX_SELECTION1
, IDC_BOXT_SELECTION1
,
358 IDC_BOX_SELECTION2
, IDC_BOXT_SELECTION2
,
371 IDC_BOX_COLOURS1
, IDC_BOXT_COLOURS1
,
372 IDC_BOX_COLOURS2
, IDC_BOXT_COLOURS2
,
386 translationpanelstart
,
387 IDC_TITLE_TRANSLATION
,
388 IDC_BOX_TRANSLATION1
, IDC_BOXT_TRANSLATION1
,
389 IDC_BOX_TRANSLATION2
, IDC_BOXT_TRANSLATION2
,
390 IDC_BOX_TRANSLATION3
, IDC_BOXT_TRANSLATION3
,
406 IDC_BOX_TUNNELS
, IDC_BOXT_TUNNELS
,
415 static const char *const colours
[] = {
416 "Default Foreground", "Default Bold Foreground",
417 "Default Background", "Default Bold Background",
418 "Cursor Text", "Cursor Colour",
419 "ANSI Black", "ANSI Black Bold",
420 "ANSI Red", "ANSI Red Bold",
421 "ANSI Green", "ANSI Green Bold",
422 "ANSI Yellow", "ANSI Yellow Bold",
423 "ANSI Blue", "ANSI Blue Bold",
424 "ANSI Magenta", "ANSI Magenta Bold",
425 "ANSI Cyan", "ANSI Cyan Bold",
426 "ANSI White", "ANSI White Bold"
428 static const int permcolour
[] = {
429 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
430 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
431 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
434 static void fmtfont (char *buf
) {
435 sprintf (buf
, "Font: %s, ", cfg
.font
);
437 strcat(buf
, "bold, ");
438 if (cfg
.fontheight
== 0)
439 strcat (buf
, "default height");
441 sprintf (buf
+strlen(buf
), "%d-%s",
442 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
),
443 (cfg
.fontheight
< 0 ?
"pixel" : "point"));
446 static void init_dlg_ctrls(HWND hwnd
) {
448 char fontstatic
[256];
450 SetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
);
451 SetDlgItemText (hwnd
, IDC_SESSEDIT
, savedsession
);
452 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
453 CheckRadioButton (hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
454 cfg
.protocol
==PROT_SSH ? IDC_PROTSSH
:
455 cfg
.protocol
==PROT_TELNET ? IDC_PROTTELNET
:
456 cfg
.protocol
==PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
457 SetDlgItemInt (hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
459 CheckRadioButton (hwnd
, IDC_DEL008
, IDC_DEL127
,
460 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
461 CheckRadioButton (hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
462 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
463 CheckRadioButton (hwnd
, IDC_FUNCTILDE
, IDC_FUNCVT400
,
464 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
465 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
466 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
467 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
469 CheckDlgButton (hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
470 CheckDlgButton (hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
471 CheckRadioButton (hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
472 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
473 CheckRadioButton (hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
474 cfg
.nethack_keypad ? IDC_KPNH
:
475 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
476 CheckDlgButton (hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
477 CheckDlgButton (hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
478 CheckDlgButton (hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
479 CheckDlgButton (hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
480 CheckDlgButton (hwnd
, IDC_LDISCTERM
, cfg
.ldisc_term
);
481 CheckDlgButton (hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
482 CheckDlgButton (hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
483 CheckDlgButton (hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
485 CheckDlgButton (hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
486 CheckDlgButton (hwnd
, IDC_DECOM
, cfg
.dec_om
);
487 CheckDlgButton (hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
488 SetDlgItemInt (hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
489 SetDlgItemInt (hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
490 SetDlgItemInt (hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
491 fmtfont (fontstatic
);
492 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
493 CheckDlgButton (hwnd
, IDC_BEEP
, cfg
.beep
);
494 CheckDlgButton (hwnd
, IDC_BCE
, cfg
.bce
);
495 CheckDlgButton (hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
497 SetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
498 CheckDlgButton (hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
499 CheckRadioButton (hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
500 cfg
.cursor_type
==0 ? IDC_CURBLOCK
:
501 cfg
.cursor_type
==1 ? IDC_CURUNDER
: IDC_CURVERT
);
502 CheckDlgButton (hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
503 CheckDlgButton (hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
504 CheckDlgButton (hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
505 CheckDlgButton (hwnd
, IDC_CLOSEEXIT
, cfg
.close_on_exit
);
506 CheckDlgButton (hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
508 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
509 SetDlgItemText (hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
510 SetDlgItemText (hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
511 SetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
512 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
513 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
514 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
515 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
516 cfg
.logtype
== 1 ? IDC_LSTATASCII
:
519 char *p
= cfg
.environmt
;
521 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
526 CheckRadioButton (hwnd
, IDC_EMBSD
, IDC_EMRFC
,
527 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
529 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
530 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
531 CheckDlgButton (hwnd
, IDC_NOPTY
, cfg
.nopty
);
532 CheckDlgButton (hwnd
, IDC_COMPRESS
, cfg
.compression
);
533 CheckDlgButton (hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
534 CheckDlgButton (hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
535 CheckRadioButton (hwnd
, IDC_CIPHER3DES
, IDC_CIPHERDES
,
536 cfg
.cipher
== CIPHER_BLOWFISH ? IDC_CIPHERBLOWF
:
537 cfg
.cipher
== CIPHER_DES ? IDC_CIPHERDES
:
539 CheckRadioButton (hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
540 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
541 CheckDlgButton (hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
542 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
543 SetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
545 CheckRadioButton (hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
546 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
548 static int tabs
[4] = {25, 61, 96, 128};
549 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
552 for (i
=0; i
<256; i
++) {
554 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
555 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
557 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
561 CheckDlgButton (hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
562 CheckDlgButton (hwnd
, IDC_PALETTE
, cfg
.try_palette
);
565 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
567 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
568 LB_DELETESTRING
, i
, 0);
570 if (cfg
.bold_colour
|| permcolour
[i
])
571 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
572 (LPARAM
) colours
[i
]);
574 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
575 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
576 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
577 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
579 CheckRadioButton (hwnd
, IDC_NOXLAT
, IDC_88592CP852
,
580 cfg
.xlat_88592w1250 ? IDC_88592WIN1250
:
581 cfg
.xlat_88592cp852 ? IDC_88592CP852
:
582 cfg
.xlat_enablekoiwin ? IDC_KOI8WIN1251
:
584 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
585 CheckRadioButton (hwnd
, IDC_VTXWINDOWS
, IDC_VTPOORMAN
,
586 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
587 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
588 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
591 CheckDlgButton (hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
592 SetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
595 static void hide(HWND hwnd
, int hide
, int minid
, int maxid
) {
597 for (i
= minid
; i
< maxid
; i
++) {
598 HWND ctl
= GetDlgItem(hwnd
, i
);
601 EnableWindow(ctl
, 1);
602 ShowWindow(ctl
, hide ? SW_HIDE
: SW_SHOW
);
604 EnableWindow(ctl
, 0);
609 struct treeview_faff
{
614 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
615 int level
, char *text
) {
619 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
-1] : TVI_ROOT
);
620 ins
.hInsertAfter
= faff
->lastat
[level
];
621 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
622 #define INSITEM DUMMYUNIONNAME.item
626 ins
.INSITEM
.mask
= TVIF_TEXT
;
627 ins
.INSITEM
.pszText
= text
;
628 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
630 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
-1], TVE_EXPAND
);
631 faff
->lastat
[level
] = newitem
;
632 for (i
= level
+1; i
< 4; i
++) faff
->lastat
[i
] = NULL
;
637 * This _huge_ function is the configuration box.
639 static int GenericMainDlgProc (HWND hwnd
, UINT msg
,
640 WPARAM wParam
, LPARAM lParam
,
643 struct treeview_faff tvfaff
;
646 char filename
[sizeof(cfg
.keyfile
)];
649 char fontstatic
[256];
651 struct servent
* service
;
657 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
661 { /* centre the window */
664 hw
= GetDesktopWindow();
665 if (GetWindowRect (hw
, &rs
) && GetWindowRect (hwnd
, &rd
))
666 MoveWindow (hwnd
, (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
)/2,
667 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
)/2,
668 rd
.right
-rd
.left
, rd
.bottom
-rd
.top
, TRUE
);
672 * Create the tree view.
679 r
.left
= 3; r
.right
= r
.left
+ 75;
680 r
.top
= 3; r
.bottom
= r
.top
+ 10;
681 MapDialogRect(hwnd
, &r
);
682 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
683 WS_CHILD
| WS_VISIBLE
,
685 r
.right
-r
.left
, r
.bottom
-r
.top
,
686 hwnd
, (HMENU
)IDCX_TVSTATIC
, hinst
, NULL
);
687 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
688 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
690 r
.left
= 3; r
.right
= r
.left
+ 75;
691 r
.top
= 13; r
.bottom
= r
.top
+ 206;
692 MapDialogRect(hwnd
, &r
);
693 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
694 WS_CHILD
| WS_VISIBLE
|
695 WS_TABSTOP
| TVS_HASLINES
|
696 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
|
697 TVS_LINESATROOT
| TVS_SHOWSELALWAYS
,
699 r
.right
-r
.left
, r
.bottom
-r
.top
,
700 hwnd
, (HMENU
)IDCX_TREEVIEW
, hinst
, NULL
);
701 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
702 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
703 tvfaff
.treeview
= treeview
;
704 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
708 * Create the various panelfuls of controls.
711 /* The Session panel. Accelerators used: [acgo] nprthelsdx */
714 ctlposinit(&cp
, hwnd
, 80, 3, 13);
715 bartitle(&cp
, "Basic options for your PuTTY session",
718 beginbox(&cp
, "Specify your connection by host name",
719 IDC_BOX_SESSION1
, IDC_BOXT_SESSION1
);
721 "Host &Name", IDC_HOSTSTATIC
, IDC_HOST
, 75,
722 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
723 if (backends
[3].backend
== NULL
) {
724 /* this is PuTTYtel, so only two protocols available */
725 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
727 "&Telnet", IDC_PROTTELNET
,
728 "R&login", IDC_PROTRLOGIN
, NULL
);
730 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
732 "&Telnet", IDC_PROTTELNET
,
733 "R&login", IDC_PROTRLOGIN
,
742 beginbox(&cp
, "Load, save or delete a stored session",
743 IDC_BOX_SESSION2
, IDC_BOXT_SESSION2
);
744 sesssaver(&cp
, "Sav&ed Sessions",
745 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
746 "&Load", IDC_SESSLOAD
,
747 "&Save", IDC_SESSSAVE
,
748 "&Delete", IDC_SESSDEL
, NULL
);
751 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
, 0);
752 checkbox(&cp
, "Close Window on E&xit", IDC_CLOSEEXIT
);
755 hsession
= treeview_insert(&tvfaff
, 0, "Session");
758 /* The Terminal panel. Accelerators used: [acgo] &dflbenuw */
761 ctlposinit(&cp
, hwnd
, 80, 3, 13);
762 bartitle(&cp
, "Options controlling the terminal emulation",
764 beginbox(&cp
, "Set various terminal options",
765 IDC_BOX_TERMINAL1
, IDC_BOXT_TERMINAL1
);
766 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
767 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
768 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
769 checkbox(&cp
, "&Beep enabled", IDC_BEEP
);
770 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
771 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
772 checkbox(&cp
, "&Use local terminal line discipline", IDC_LDISCTERM
);
775 beginbox(&cp
, "Control session logging",
776 IDC_BOX_TERMINAL2
, IDC_BOXT_TERMINAL2
);
778 "Session logging:", IDC_LSTATSTATIC
,
779 "Logging turned &off completely", IDC_LSTATOFF
,
780 "Log printable output only", IDC_LSTATASCII
,
781 "Log all session output", IDC_LSTATRAW
, NULL
);
782 editbutton(&cp
, "Log &file name:",
783 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
787 treeview_insert(&tvfaff
, 0, "Terminal");
790 /* The Keyboard panel. Accelerators used: [acgo] h?srvlxvnpmietu */
793 ctlposinit(&cp
, hwnd
, 80, 3, 13);
794 bartitle(&cp
, "Options controlling the effects of keys",
796 beginbox(&cp
, "Change the sequences sent by:",
797 IDC_BOX_KEYBOARD1
, IDC_BOXT_KEYBOARD1
);
798 radioline(&cp
, "The Backspace key", IDC_DELSTATIC
, 2,
799 "Control-&H", IDC_DEL008
,
800 "Control-&? (127)", IDC_DEL127
, NULL
);
801 radioline(&cp
, "The Home and End keys", IDC_HOMESTATIC
, 2,
802 "&Standard", IDC_HOMETILDE
,
803 "&rxvt", IDC_HOMERXVT
, NULL
);
804 radioline(&cp
, "The Function keys and keypad", IDC_FUNCSTATIC
, 4,
805 "ESC[n&~", IDC_FUNCTILDE
,
806 "&Linux", IDC_FUNCLINUX
,
807 "&Xterm R6", IDC_FUNCXTERM
,
808 "&VT400", IDC_FUNCVT400
, NULL
);
810 beginbox(&cp
, "Application keypad settings:",
811 IDC_BOX_KEYBOARD2
, IDC_BOXT_KEYBOARD2
);
813 "Application c&ursor keys totally disabled",
815 radioline(&cp
, "Initial state of cursor keys:", IDC_CURSTATIC
, 2,
816 "&Normal", IDC_CURNORMAL
,
817 "A&pplication", IDC_CURAPPLIC
, NULL
);
819 "Application ke&ypad keys totally disabled",
821 radioline(&cp
, "Initial state of numeric keypad:", IDC_KPSTATIC
, 3,
822 "Nor&mal", IDC_KPNORMAL
,
823 "Appl&ication", IDC_KPAPPLIC
,
824 "N&etHack", IDC_KPNH
, NULL
);
826 beginbox(&cp
, "Enable extra keyboard features:",
827 IDC_BOX_KEYBOARD3
, IDC_BOXT_KEYBOARD3
);
828 checkbox(&cp
, "Application and AltGr ac&t as Compose key",
832 treeview_insert(&tvfaff
, 1, "Keyboard");
835 /* The Window panel. Accelerators used: [acgo] bsdkw4ylpt */
838 ctlposinit(&cp
, hwnd
, 80, 3, 13);
839 bartitle(&cp
, "Options controlling PuTTY's window",
841 beginbox(&cp
, "Set the size of the window",
842 IDC_BOX_WINDOW1
, IDC_BOXT_WINDOW1
);
844 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
845 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50,
847 checkbox(&cp
, "Loc&k window size against resizing", IDC_LOCKSIZE
);
849 beginbox(&cp
, "Control the scrollback in the window",
850 IDC_BOX_WINDOW2
, IDC_BOXT_WINDOW2
);
851 staticedit(&cp
, "Lines of &scrollback",
852 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
853 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
854 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
855 checkbox(&cp
, "Reset scrollback on dis&play activity",
858 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
, 0);
859 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
860 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
861 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
862 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
863 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
866 treeview_insert(&tvfaff
, 0, "Window");
869 /* The Appearance panel. Accelerators used: [acgo] rmkhtibluv */
872 ctlposinit(&cp
, hwnd
, 80, 3, 13);
873 bartitle(&cp
, "Options controlling PuTTY's appearance",
874 IDC_TITLE_APPEARANCE
);
875 beginbox(&cp
, "Adjust the use of the cursor",
876 IDC_BOX_APPEARANCE1
, IDC_BOXT_APPEARANCE1
);
877 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
878 "B&lock", IDC_CURBLOCK
,
879 "&Underline", IDC_CURUNDER
,
880 "&Vertical line", IDC_CURVERT
,
882 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
884 beginbox(&cp
, "Set the font used in the terminal window",
885 IDC_BOX_APPEARANCE2
, IDC_BOXT_APPEARANCE2
);
886 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
888 beginbox(&cp
, "Adjust the use of the window title",
889 IDC_BOX_APPEARANCE3
, IDC_BOXT_APPEARANCE3
);
891 "Window &title:", IDC_WINTITLE
,
892 IDC_WINEDIT
, 100, NULL
);
893 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
896 treeview_insert(&tvfaff
, 1, "Appearance");
899 /* The Translation panel. Accelerators used: [acgo] xbepnkis */
902 ctlposinit(&cp
, hwnd
, 80, 3, 13);
903 bartitle(&cp
, "Options controlling character set translation",
904 IDC_TITLE_TRANSLATION
);
905 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
906 IDC_BOX_TRANSLATION1
, IDC_BOXT_TRANSLATION1
);
908 "Handling of line drawing characters:", IDC_VTSTATIC
,
909 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
910 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
911 "Use font in O&EM mode only", IDC_VTOEMONLY
,
912 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
913 IDC_VTPOORMAN
, NULL
);
915 beginbox(&cp
, "Enable character set translation on received data",
916 IDC_BOX_TRANSLATION2
, IDC_BOXT_TRANSLATION2
);
918 "Character set translation:", IDC_XLATSTATIC
,
920 "&KOI8 / Win-1251", IDC_KOI8WIN1251
,
921 "&ISO-8859-2 / Win-1250", IDC_88592WIN1250
,
922 "&ISO-8859-2 / CP852", IDC_88592CP852
, NULL
);
924 beginbox(&cp
, "Enable character set translation on input data",
925 IDC_BOX_TRANSLATION3
, IDC_BOXT_TRANSLATION3
);
926 checkbox(&cp
, "CAP&S LOCK acts as cyrillic switch",
930 treeview_insert(&tvfaff
, 1, "Translation");
933 /* The Selection panel. Accelerators used: [acgo] wxst */
936 ctlposinit(&cp
, hwnd
, 80, 3, 13);
937 bartitle(&cp
, "Options controlling copy and paste",
938 IDC_TITLE_SELECTION
);
939 beginbox(&cp
, "Control which mouse button does which thing",
940 IDC_BOX_SELECTION1
, IDC_BOXT_SELECTION1
);
941 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
942 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
943 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
946 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
947 IDC_BOX_SELECTION2
, IDC_BOXT_SELECTION2
);
948 charclass(&cp
, "Character classes:", IDC_CCSTATIC
, IDC_CCLIST
,
949 "&Set", IDC_CCSET
, IDC_CCEDIT
,
950 "&to class", IDC_CCSTATIC2
);
953 treeview_insert(&tvfaff
, 1, "Selection");
956 /* The Colours panel. Accelerators used: [acgo] blum */
959 ctlposinit(&cp
, hwnd
, 80, 3, 13);
960 bartitle(&cp
, "Options controlling use of colours",
962 beginbox(&cp
, "General options for colour usage",
963 IDC_BOX_COLOURS1
, IDC_BOXT_COLOURS1
);
964 checkbox(&cp
, "&Bolded text is a different colour", IDC_BOLDCOLOUR
);
965 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
967 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
968 IDC_BOX_COLOURS2
, IDC_BOXT_COLOURS2
);
969 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
970 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
971 "&Modify...", IDC_CHANGE
,
972 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
973 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
974 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
977 treeview_insert(&tvfaff
, 1, "Colours");
980 /* The Connection panel. Accelerators used: [acgo] tuk */
983 ctlposinit(&cp
, hwnd
, 80, 3, 13);
984 bartitle(&cp
, "Options controlling the connection", IDC_TITLE_CONNECTION
);
986 beginbox(&cp
, "Data to send to the server",
987 IDC_BOX_CONNECTION1
, IDC_BOXT_CONNECTION1
);
988 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
, IDC_TTEDIT
, 50);
989 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
, IDC_LOGEDIT
, 50);
992 beginbox(&cp
, "Sending of null packets to keep session active",
993 IDC_BOX_CONNECTION2
, IDC_BOXT_CONNECTION2
);
994 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
995 IDC_PINGSTATIC
, IDC_PINGEDIT
, 25);
998 treeview_insert(&tvfaff
, 0, "Connection");
1001 /* The Telnet panel. Accelerators used: [acgo] svldrbf */
1004 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1006 bartitle(&cp
, "Options controlling Telnet connections", IDC_TITLE_TELNET
);
1007 beginbox(&cp
, "Data to send to the server",
1008 IDC_BOX_TELNET1
, IDC_BOXT_TELNET1
);
1009 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
, IDC_TSEDIT
, 50);
1010 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1011 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
,
1012 "Va&lue", IDC_VALSTATIC
, IDC_VALEDIT
,
1014 "A&dd", IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1016 beginbox(&cp
, "Telnet protocol adjustments",
1017 IDC_BOX_TELNET2
, IDC_BOXT_TELNET2
);
1018 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC
, 2,
1019 "&BSD (commonplace)", IDC_EMBSD
,
1020 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1023 treeview_insert(&tvfaff
, 1, "Telnet");
1028 /* The Rlogin Panel */
1031 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1033 bartitle(&cp
, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN
);
1034 beginbox(&cp
, "Data to send to the server",
1035 IDC_BOX_RLOGIN1
, IDC_BOXT_RLOGIN1
);
1036 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
, IDC_R_TSEDIT
, 50);
1037 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
, IDC_RLLUSEREDIT
, 50);
1040 treeview_insert(&tvfaff
, 1, "Rlogin");
1044 /* The SSH panel. Accelerators used: [acgo] rmakwp123bd */
1045 if (backends
[3].backend
!= NULL
) {
1047 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1049 bartitle(&cp
, "Options controlling SSH connections", IDC_TITLE_SSH
);
1050 beginbox(&cp
, "Data to send to the server",
1051 IDC_BOX_SSH1
, IDC_BOXT_SSH1
);
1053 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1056 beginbox(&cp
, "Authentication options",
1057 IDC_BOX_SSH2
, IDC_BOXT_SSH2
);
1058 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1060 checkbox(&cp
, "Allow &agent forwarding", IDC_AGENTFWD
);
1061 editbutton(&cp
, "Private &key file for authentication:",
1062 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...", IDC_PKBUTTON
);
1064 beginbox(&cp
, "Protocol options",
1065 IDC_BOX_SSH3
, IDC_BOXT_SSH3
);
1066 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1067 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1068 radioline(&cp
, "Preferred SSH protocol version:",
1069 IDC_SSHPROTSTATIC
, 2,
1070 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1071 radioline(&cp
, "Preferred encryption algorithm:", IDC_CIPHERSTATIC
, 3,
1072 "&3DES", IDC_CIPHER3DES
,
1073 "&Blowfish", IDC_CIPHERBLOWF
,
1074 "&DES", IDC_CIPHERDES
, NULL
);
1075 checkbox(&cp
, "Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1079 treeview_insert(&tvfaff
, 1, "SSH");
1082 /* The Tunnels panel. Accelerators used: [acgo] ex */
1085 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1087 bartitle(&cp
, "Options controlling SSH tunnelling",
1089 beginbox(&cp
, "X11 forwarding options",
1090 IDC_BOX_TUNNELS
, IDC_BOXT_TUNNELS
);
1091 checkbox(&cp
, "&Enable X11 forwarding",
1093 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1094 IDC_X11_DISPLAY
, 50, NULL
);
1097 treeview_insert(&tvfaff
, 2, "Tunnels");
1101 init_dlg_ctrls(hwnd
);
1102 for (i
= 0; i
< nsessions
; i
++)
1103 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1104 0, (LPARAM
) (sessions
[i
]));
1107 * Hide all the controls to start with.
1109 hide(hwnd
, TRUE
, controlstartvalue
, controlendvalue
);
1112 * Put the treeview selection on to the Session panel. This
1113 * should also cause unhiding of the relevant controls.
1115 TreeView_SelectItem(treeview
, hsession
);
1118 * Set focus into the first available control.
1122 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1123 if (!ctl
) ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1127 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1131 * Button release should trigger WM_OK if there was a
1132 * previous double click on the session list.
1136 SendMessage (hwnd
, WM_COMMAND
, IDOK
, 0);
1139 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1140 ((LPNMHDR
)lParam
)->code
== TVN_SELCHANGED
) {
1141 HTREEITEM i
= TreeView_GetSelection(((LPNMHDR
)lParam
)->hwndFrom
);
1145 item
.pszText
= buffer
;
1146 item
.cchTextMax
= sizeof(buffer
);
1147 item
.mask
= TVIF_TEXT
;
1148 TreeView_GetItem(((LPNMHDR
)lParam
)->hwndFrom
, &item
);
1149 hide(hwnd
, TRUE
, controlstartvalue
, controlendvalue
);
1150 if (!strcmp(buffer
, "Session"))
1151 hide(hwnd
, FALSE
, sessionpanelstart
, sessionpanelend
);
1152 if (!strcmp(buffer
, "Keyboard"))
1153 hide(hwnd
, FALSE
, keyboardpanelstart
, keyboardpanelend
);
1154 if (!strcmp(buffer
, "Terminal"))
1155 hide(hwnd
, FALSE
, terminalpanelstart
, terminalpanelend
);
1156 if (!strcmp(buffer
, "Window"))
1157 hide(hwnd
, FALSE
, windowpanelstart
, windowpanelend
);
1158 if (!strcmp(buffer
, "Appearance"))
1159 hide(hwnd
, FALSE
, appearancepanelstart
, appearancepanelend
);
1160 if (!strcmp(buffer
, "Tunnels"))
1161 hide(hwnd
, FALSE
, tunnelspanelstart
, tunnelspanelend
);
1162 if (!strcmp(buffer
, "Connection"))
1163 hide(hwnd
, FALSE
, connectionpanelstart
, connectionpanelend
);
1164 if (!strcmp(buffer
, "Telnet"))
1165 hide(hwnd
, FALSE
, telnetpanelstart
, telnetpanelend
);
1166 if (!strcmp(buffer
, "Rlogin"))
1167 hide(hwnd
, FALSE
, rloginpanelstart
, rloginpanelend
);
1168 if (!strcmp(buffer
, "SSH"))
1169 hide(hwnd
, FALSE
, sshpanelstart
, sshpanelend
);
1170 if (!strcmp(buffer
, "Selection"))
1171 hide(hwnd
, FALSE
, selectionpanelstart
, selectionpanelend
);
1172 if (!strcmp(buffer
, "Colours"))
1173 hide(hwnd
, FALSE
, colourspanelstart
, colourspanelend
);
1174 if (!strcmp(buffer
, "Translation"))
1175 hide(hwnd
, FALSE
, translationpanelstart
, translationpanelend
);
1177 SetFocus (((LPNMHDR
)lParam
)->hwndFrom
); /* ensure focus stays */
1183 * Only process WM_COMMAND once the dialog is fully formed.
1185 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
1188 EndDialog (hwnd
, 1);
1193 EndDialog (hwnd
, 0);
1195 case IDC_PROTTELNET
:
1196 case IDC_PROTRLOGIN
:
1199 if (HIWORD(wParam
) == BN_CLICKED
||
1200 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1201 int i
= IsDlgButtonChecked (hwnd
, IDC_PROTSSH
);
1202 int j
= IsDlgButtonChecked (hwnd
, IDC_PROTTELNET
);
1203 int k
= IsDlgButtonChecked (hwnd
, IDC_PROTRLOGIN
);
1204 cfg
.protocol
= i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
: PROT_RAW
;
1205 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22) ||
1206 (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23) ||
1207 (cfg
.protocol
== PROT_RLOGIN
&& cfg
.port
!= 513)) {
1208 cfg
.port
= i ?
22 : j ?
23 : 513;
1209 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1214 if (HIWORD(wParam
) == EN_CHANGE
)
1215 GetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
,
1216 sizeof(cfg
.host
)-1);
1219 if (HIWORD(wParam
) == EN_CHANGE
) {
1220 GetDlgItemText (hwnd
, IDC_PORT
, portname
, 31);
1221 if (isdigit(portname
[0]))
1222 MyGetDlgItemInt (hwnd
, IDC_PORT
, &cfg
.port
);
1224 service
= getservbyname(portname
, NULL
);
1225 if (service
) cfg
.port
= ntohs(service
->s_port
);
1231 if (HIWORD(wParam
) == EN_CHANGE
) {
1232 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1234 GetDlgItemText (hwnd
, IDC_SESSEDIT
,
1235 savedsession
, sizeof(savedsession
)-1);
1236 savedsession
[sizeof(savedsession
)-1] = '\0';
1240 if (HIWORD(wParam
) == BN_CLICKED
||
1241 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1246 GetDlgItemText (hwnd
, IDC_SESSEDIT
, str
, sizeof(str
)-1);
1248 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1249 LB_GETCURSEL
, 0, 0);
1254 strcpy (str
, sessions
[n
]);
1256 save_settings (str
, !!strcmp(str
, "Default Settings"), &cfg
);
1257 get_sesslist (FALSE
);
1258 get_sesslist (TRUE
);
1259 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1261 for (i
= 0; i
< nsessions
; i
++)
1262 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1263 0, (LPARAM
) (sessions
[i
]));
1264 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1270 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1271 HIWORD(wParam
) != BN_CLICKED
&&
1272 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1274 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1275 HIWORD(wParam
) != LBN_DBLCLK
)
1278 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1279 LB_GETCURSEL
, 0, 0);
1285 isdef
= !strcmp(sessions
[n
], "Default Settings");
1286 load_settings (sessions
[n
], !isdef
, &cfg
);
1287 init_dlg_ctrls(hwnd
);
1289 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1291 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1293 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1295 * A double-click on a saved session should
1296 * actually start the session, not just load it.
1297 * Unless it's Default Settings or some other
1298 * host-less set of saved settings.
1307 if (HIWORD(wParam
) == BN_CLICKED
||
1308 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1309 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1310 LB_GETCURSEL
, 0, 0);
1311 if (n
== LB_ERR
|| n
== 0) {
1315 del_settings(sessions
[n
]);
1316 get_sesslist (FALSE
);
1317 get_sesslist (TRUE
);
1318 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1320 for (i
= 0; i
< nsessions
; i
++)
1321 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1322 0, (LPARAM
) (sessions
[i
]));
1323 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1327 if (HIWORD(wParam
) == EN_CHANGE
)
1328 MyGetDlgItemInt (hwnd
, IDC_PINGEDIT
, &cfg
.ping_interval
);
1332 if (HIWORD(wParam
) == BN_CLICKED
||
1333 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1334 cfg
.bksp_is_delete
= IsDlgButtonChecked (hwnd
, IDC_DEL127
);
1338 if (HIWORD(wParam
) == BN_CLICKED
||
1339 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1340 cfg
.rxvt_homeend
= IsDlgButtonChecked (hwnd
, IDC_HOMERXVT
);
1343 if (HIWORD(wParam
) == BN_CLICKED
||
1344 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1348 if (HIWORD(wParam
) == BN_CLICKED
||
1349 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1354 if (HIWORD(wParam
) == BN_CLICKED
||
1355 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1356 cfg
.funky_type
= IsDlgButtonChecked (hwnd
, IDC_FUNCLINUX
);
1360 if (HIWORD(wParam
) == BN_CLICKED
||
1361 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1362 cfg
.app_keypad
= IsDlgButtonChecked (hwnd
, IDC_KPAPPLIC
);
1363 cfg
.nethack_keypad
= FALSE
;
1367 if (HIWORD(wParam
) == BN_CLICKED
||
1368 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1369 cfg
.app_keypad
= FALSE
;
1370 cfg
.nethack_keypad
= TRUE
;
1375 if (HIWORD(wParam
) == BN_CLICKED
||
1376 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1377 cfg
.app_cursor
= IsDlgButtonChecked (hwnd
, IDC_CURAPPLIC
);
1380 if (HIWORD(wParam
) == BN_CLICKED
||
1381 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1382 cfg
.no_applic_c
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICC
);
1385 if (HIWORD(wParam
) == BN_CLICKED
||
1386 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1387 cfg
.no_applic_k
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICK
);
1390 if (HIWORD(wParam
) == BN_CLICKED
||
1391 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1392 cfg
.alt_f4
= IsDlgButtonChecked (hwnd
, IDC_ALTF4
);
1395 if (HIWORD(wParam
) == BN_CLICKED
||
1396 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1397 cfg
.alt_space
= IsDlgButtonChecked (hwnd
, IDC_ALTSPACE
);
1400 if (HIWORD(wParam
) == BN_CLICKED
||
1401 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1402 cfg
.alt_only
= IsDlgButtonChecked (hwnd
, IDC_ALTONLY
);
1405 if (HIWORD(wParam
) == BN_CLICKED
||
1406 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1407 cfg
.ldisc_term
= IsDlgButtonChecked (hwnd
, IDC_LDISCTERM
);
1409 case IDC_ALWAYSONTOP
:
1410 if (HIWORD(wParam
) == BN_CLICKED
||
1411 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1412 cfg
.alwaysontop
= IsDlgButtonChecked (hwnd
, IDC_ALWAYSONTOP
);
1415 if (HIWORD(wParam
) == BN_CLICKED
||
1416 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1417 cfg
.scroll_on_key
= IsDlgButtonChecked (hwnd
, IDC_SCROLLKEY
);
1419 case IDC_SCROLLDISP
:
1420 if (HIWORD(wParam
) == BN_CLICKED
||
1421 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1422 cfg
.scroll_on_disp
= IsDlgButtonChecked (hwnd
, IDC_SCROLLDISP
);
1424 case IDC_COMPOSEKEY
:
1425 if (HIWORD(wParam
) == BN_CLICKED
||
1426 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1427 cfg
.compose_key
= IsDlgButtonChecked (hwnd
, IDC_COMPOSEKEY
);
1430 if (HIWORD(wParam
) == BN_CLICKED
||
1431 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1432 cfg
.wrap_mode
= IsDlgButtonChecked (hwnd
, IDC_WRAPMODE
);
1435 if (HIWORD(wParam
) == BN_CLICKED
||
1436 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1437 cfg
.dec_om
= IsDlgButtonChecked (hwnd
, IDC_DECOM
);
1440 if (HIWORD(wParam
) == BN_CLICKED
||
1441 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1442 cfg
.lfhascr
= IsDlgButtonChecked (hwnd
, IDC_LFHASCR
);
1445 if (HIWORD(wParam
) == EN_CHANGE
)
1446 MyGetDlgItemInt (hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1449 if (HIWORD(wParam
) == EN_CHANGE
)
1450 MyGetDlgItemInt (hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1453 if (HIWORD(wParam
) == EN_CHANGE
)
1454 MyGetDlgItemInt (hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1456 case IDC_CHOOSEFONT
:
1457 lf
.lfHeight
= cfg
.fontheight
;
1458 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1459 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1460 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1461 lf
.lfCharSet
= cfg
.fontcharset
;
1462 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1463 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1464 lf
.lfQuality
= DEFAULT_QUALITY
;
1465 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1466 strncpy (lf
.lfFaceName
, cfg
.font
, sizeof(lf
.lfFaceName
)-1);
1467 lf
.lfFaceName
[sizeof(lf
.lfFaceName
)-1] = '\0';
1469 cf
.lStructSize
= sizeof(cf
);
1470 cf
.hwndOwner
= hwnd
;
1472 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1473 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1475 if (ChooseFont (&cf
)) {
1476 strncpy (cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
)-1);
1477 cfg
.font
[sizeof(cfg
.font
)-1] = '\0';
1478 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1479 cfg
.fontcharset
= lf
.lfCharSet
;
1480 cfg
.fontheight
= lf
.lfHeight
;
1481 fmtfont (fontstatic
);
1482 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
1486 if (HIWORD(wParam
) == BN_CLICKED
||
1487 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1488 cfg
.beep
= IsDlgButtonChecked (hwnd
, IDC_BEEP
);
1491 if (HIWORD(wParam
) == BN_CLICKED
||
1492 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1493 cfg
.blinktext
= IsDlgButtonChecked (hwnd
, IDC_BLINKTEXT
);
1496 if (HIWORD(wParam
) == BN_CLICKED
||
1497 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1498 cfg
.bce
= IsDlgButtonChecked (hwnd
, IDC_BCE
);
1501 if (HIWORD(wParam
) == BN_CLICKED
||
1502 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1503 cfg
.win_name_always
= IsDlgButtonChecked (hwnd
, IDC_WINNAME
);
1506 if (HIWORD(wParam
) == BN_CLICKED
||
1507 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1508 cfg
.cursor_type
= 0;
1511 if (HIWORD(wParam
) == BN_CLICKED
||
1512 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1513 cfg
.cursor_type
= 1;
1516 if (HIWORD(wParam
) == BN_CLICKED
||
1517 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1518 cfg
.cursor_type
= 2;
1521 if (HIWORD(wParam
) == BN_CLICKED
||
1522 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1523 cfg
.blink_cur
= IsDlgButtonChecked (hwnd
, IDC_BLINKCUR
);
1526 if (HIWORD(wParam
) == BN_CLICKED
||
1527 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1528 cfg
.scrollbar
= IsDlgButtonChecked (hwnd
, IDC_SCROLLBAR
);
1531 if (HIWORD(wParam
) == BN_CLICKED
||
1532 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1533 cfg
.locksize
= IsDlgButtonChecked (hwnd
, IDC_LOCKSIZE
);
1536 if (HIWORD(wParam
) == EN_CHANGE
)
1537 GetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
1538 sizeof(cfg
.wintitle
)-1);
1541 if (HIWORD(wParam
) == BN_CLICKED
||
1542 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1543 cfg
.close_on_exit
= IsDlgButtonChecked (hwnd
, IDC_CLOSEEXIT
);
1546 if (HIWORD(wParam
) == BN_CLICKED
||
1547 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1548 cfg
.warn_on_close
= IsDlgButtonChecked (hwnd
, IDC_CLOSEWARN
);
1551 if (HIWORD(wParam
) == EN_CHANGE
)
1552 GetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
,
1553 sizeof(cfg
.termtype
)-1);
1556 if (HIWORD(wParam
) == EN_CHANGE
)
1557 GetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
1558 sizeof(cfg
.logfilename
)-1);
1561 memset(&of
, 0, sizeof(of
));
1562 #ifdef OPENFILENAME_SIZE_VERSION_400
1563 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1565 of
.lStructSize
= sizeof(of
);
1567 of
.hwndOwner
= hwnd
;
1568 of
.lpstrFilter
= "All Files\0*\0\0\0";
1569 of
.lpstrCustomFilter
= NULL
;
1570 of
.nFilterIndex
= 1;
1571 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1572 of
.nMaxFile
= sizeof(filename
);
1573 of
.lpstrFileTitle
= NULL
;
1574 of
.lpstrInitialDir
= NULL
;
1575 of
.lpstrTitle
= "Select session log file";
1577 if (GetSaveFileName(&of
)) {
1578 strcpy(cfg
.keyfile
, filename
);
1579 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.keyfile
);
1583 case IDC_LSTATASCII
:
1585 if (HIWORD(wParam
) == BN_CLICKED
||
1586 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1587 if (IsDlgButtonChecked (hwnd
, IDC_LSTATOFF
)) cfg
.logtype
= 0;
1588 if (IsDlgButtonChecked (hwnd
, IDC_LSTATASCII
)) cfg
.logtype
= 1;
1589 if (IsDlgButtonChecked (hwnd
, IDC_LSTATRAW
)) cfg
.logtype
= 2;
1594 if (HIWORD(wParam
) == EN_CHANGE
)
1595 GetDlgItemText (hwnd
, LOWORD(wParam
), cfg
.termspeed
,
1596 sizeof(cfg
.termspeed
)-1);
1599 if (HIWORD(wParam
) == EN_CHANGE
)
1600 GetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
,
1601 sizeof(cfg
.username
)-1);
1603 case IDC_RLLUSEREDIT
:
1604 if (HIWORD(wParam
) == EN_CHANGE
)
1605 GetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
,
1606 sizeof(cfg
.localusername
)-1);
1610 cfg
.rfc_environ
= IsDlgButtonChecked (hwnd
, IDC_EMRFC
);
1613 if (HIWORD(wParam
) == BN_CLICKED
||
1614 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1615 char str
[sizeof(cfg
.environmt
)];
1617 GetDlgItemText (hwnd
, IDC_VAREDIT
, str
, sizeof(str
)-1);
1622 p
= str
+ strlen(str
);
1624 GetDlgItemText (hwnd
, IDC_VALEDIT
, p
, sizeof(str
)-1-(p
-str
));
1634 if ((p
-cfg
.environmt
) + strlen(str
) + 2 < sizeof(cfg
.environmt
)) {
1636 p
[strlen(str
)+1] = '\0';
1637 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
1639 SetDlgItemText (hwnd
, IDC_VAREDIT
, "");
1640 SetDlgItemText (hwnd
, IDC_VALEDIT
, "");
1642 MessageBox(hwnd
, "Environment too big", "PuTTY Error",
1643 MB_OK
| MB_ICONERROR
);
1648 if (HIWORD(wParam
) != BN_CLICKED
&&
1649 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1651 i
= SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0, 0);
1657 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
1682 if (HIWORD(wParam
) == BN_CLICKED
||
1683 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1684 cfg
.nopty
= IsDlgButtonChecked (hwnd
, IDC_NOPTY
);
1687 if (HIWORD(wParam
) == BN_CLICKED
||
1688 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1689 cfg
.compression
= IsDlgButtonChecked (hwnd
, IDC_COMPRESS
);
1692 if (HIWORD(wParam
) == BN_CLICKED
||
1693 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1694 cfg
.buggymac
= IsDlgButtonChecked (hwnd
, IDC_BUGGYMAC
);
1697 if (HIWORD(wParam
) == BN_CLICKED
||
1698 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1699 cfg
.agentfwd
= IsDlgButtonChecked (hwnd
, IDC_AGENTFWD
);
1701 case IDC_CIPHER3DES
:
1702 case IDC_CIPHERBLOWF
:
1704 if (HIWORD(wParam
) == BN_CLICKED
||
1705 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1706 if (IsDlgButtonChecked (hwnd
, IDC_CIPHER3DES
))
1707 cfg
.cipher
= CIPHER_3DES
;
1708 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERBLOWF
))
1709 cfg
.cipher
= CIPHER_BLOWFISH
;
1710 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERDES
))
1711 cfg
.cipher
= CIPHER_DES
;
1716 if (HIWORD(wParam
) == BN_CLICKED
||
1717 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1718 if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT1
))
1720 else if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT2
))
1725 if (HIWORD(wParam
) == BN_CLICKED
||
1726 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1727 cfg
.try_tis_auth
= IsDlgButtonChecked (hwnd
, IDC_AUTHTIS
);
1730 if (HIWORD(wParam
) == EN_CHANGE
)
1731 GetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
1732 sizeof(cfg
.keyfile
)-1);
1735 if (HIWORD(wParam
) == EN_CHANGE
)
1736 GetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
1737 sizeof(cfg
.remote_cmd
)-1);
1740 memset(&of
, 0, sizeof(of
));
1741 #ifdef OPENFILENAME_SIZE_VERSION_400
1742 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1744 of
.lStructSize
= sizeof(of
);
1746 of
.hwndOwner
= hwnd
;
1747 of
.lpstrFilter
= "All Files\0*\0\0\0";
1748 of
.lpstrCustomFilter
= NULL
;
1749 of
.nFilterIndex
= 1;
1750 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1751 of
.nMaxFile
= sizeof(filename
);
1752 of
.lpstrFileTitle
= NULL
;
1753 of
.lpstrInitialDir
= NULL
;
1754 of
.lpstrTitle
= "Select Public Key File";
1756 if (GetOpenFileName(&of
)) {
1757 strcpy(cfg
.keyfile
, filename
);
1758 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1763 cfg
.mouse_is_xterm
= IsDlgButtonChecked (hwnd
, IDC_MBXTERM
);
1769 int n
= GetDlgItemInt (hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
1774 for (i
=0; i
<256; i
++)
1775 if (SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_GETSEL
,
1778 cfg
.wordness
[i
] = n
;
1779 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1780 LB_DELETESTRING
, i
, 0);
1781 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
1782 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
1784 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1791 case IDC_BOLDCOLOUR
:
1792 if (HIWORD(wParam
) == BN_CLICKED
||
1793 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1795 cfg
.bold_colour
= IsDlgButtonChecked (hwnd
, IDC_BOLDCOLOUR
);
1796 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
1797 if (n
!= 12+10*cfg
.bold_colour
) {
1799 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1800 LB_DELETESTRING
, i
, 0);
1801 for (i
=0; i
<22; i
++)
1802 if (cfg
.bold_colour
|| permcolour
[i
])
1803 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1805 (LPARAM
) colours
[i
]);
1810 if (HIWORD(wParam
) == BN_CLICKED
||
1811 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1812 cfg
.try_palette
= IsDlgButtonChecked (hwnd
, IDC_PALETTE
);
1814 case IDC_COLOURLIST
:
1815 if (HIWORD(wParam
) == LBN_DBLCLK
||
1816 HIWORD(wParam
) == LBN_SELCHANGE
) {
1817 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1819 if (!cfg
.bold_colour
)
1820 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1821 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0], FALSE
);
1822 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1], FALSE
);
1823 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2], FALSE
);
1827 if (HIWORD(wParam
) == BN_CLICKED
||
1828 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1829 static CHOOSECOLOR cc
;
1830 static DWORD custom
[16] = {0}; /* zero initialisers */
1831 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1833 if (!cfg
.bold_colour
)
1834 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1835 cc
.lStructSize
= sizeof(cc
);
1836 cc
.hwndOwner
= hwnd
;
1837 cc
.hInstance
= (HWND
)hinst
;
1838 cc
.lpCustColors
= custom
;
1839 cc
.rgbResult
= RGB (cfg
.colours
[i
][0], cfg
.colours
[i
][1],
1841 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
1842 if (ChooseColor(&cc
)) {
1844 (unsigned char) (cc
.rgbResult
& 0xFF);
1846 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
1848 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
1849 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
1851 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
1853 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
1859 case IDC_KOI8WIN1251
:
1860 case IDC_88592WIN1250
:
1861 case IDC_88592CP852
:
1862 cfg
.xlat_enablekoiwin
=
1863 IsDlgButtonChecked (hwnd
, IDC_KOI8WIN1251
);
1864 cfg
.xlat_88592w1250
=
1865 IsDlgButtonChecked (hwnd
, IDC_88592WIN1250
);
1866 cfg
.xlat_88592cp852
=
1867 IsDlgButtonChecked (hwnd
, IDC_88592CP852
);
1869 case IDC_CAPSLOCKCYR
:
1870 if (HIWORD(wParam
) == BN_CLICKED
||
1871 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1872 cfg
.xlat_capslockcyr
=
1873 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
1876 case IDC_VTXWINDOWS
:
1881 (IsDlgButtonChecked (hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
:
1882 IsDlgButtonChecked (hwnd
, IDC_VTOEMANSI
) ? VT_OEMANSI
:
1883 IsDlgButtonChecked (hwnd
, IDC_VTOEMONLY
) ? VT_OEMONLY
:
1886 case IDC_X11_FORWARD
:
1887 if (HIWORD(wParam
) == BN_CLICKED
||
1888 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1889 cfg
.x11_forward
= IsDlgButtonChecked (hwnd
, IDC_X11_FORWARD
);
1891 case IDC_X11_DISPLAY
:
1892 if (HIWORD(wParam
) == EN_CHANGE
)
1893 GetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
1894 sizeof(cfg
.x11_display
)-1);
1899 EndDialog (hwnd
, 0);
1902 /* Grrr Explorer will maximize Dialogs! */
1904 if (wParam
== SIZE_MAXIMIZED
)
1911 static int CALLBACK
MainDlgProc (HWND hwnd
, UINT msg
,
1912 WPARAM wParam
, LPARAM lParam
) {
1913 static HWND page
= NULL
;
1915 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
1917 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
1918 EnableWindow(hwnd
, 0);
1919 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1920 GetParent(hwnd
), AboutProc
);
1921 EnableWindow(hwnd
, 1);
1922 SetActiveWindow(hwnd
);
1924 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 0);
1927 static int CALLBACK
ReconfDlgProc (HWND hwnd
, UINT msg
,
1928 WPARAM wParam
, LPARAM lParam
) {
1930 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 1);
1933 void defuse_showwindow(void) {
1935 * Work around the fact that the app's first call to ShowWindow
1936 * will ignore the default in favour of the shell-provided
1941 hwnd
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1943 ShowWindow(hwnd
, SW_HIDE
);
1944 DestroyWindow(hwnd
);
1948 int do_config (void) {
1952 savedsession
[0] = '\0';
1953 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
1954 get_sesslist(FALSE
);
1959 int do_reconfig (HWND hwnd
) {
1963 backup_cfg
= cfg
; /* structure copy */
1964 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
1966 cfg
= backup_cfg
; /* structure copy */
1971 void logevent (char *string
) {
1972 if (nevents
>= negsize
) {
1974 events
= srealloc (events
, negsize
* sizeof(*events
));
1976 events
[nevents
] = smalloc(1+strlen(string
));
1977 strcpy (events
[nevents
], string
);
1981 SendDlgItemMessage (logbox
, IDN_LIST
, LB_ADDSTRING
,
1983 count
= SendDlgItemMessage (logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
1984 SendDlgItemMessage (logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
-1, 0);
1988 void showeventlog (HWND hwnd
) {
1990 logbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
1992 ShowWindow (logbox
, SW_SHOWNORMAL
);
1996 void showabout (HWND hwnd
) {
1998 abtbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2000 ShowWindow (abtbox
, SW_SHOWNORMAL
);
2004 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2005 char *keystr
, char *fingerprint
) {
2008 static const char absentmsg
[] =
2009 "The server's host key is not cached in the registry. You\n"
2010 "have no guarantee that the server is the computer you\n"
2012 "The server's key fingerprint is:\n"
2014 "If you trust this host, hit Yes to add the key to\n"
2015 "PuTTY's cache and carry on connecting.\n"
2016 "If you do not trust this host, hit No to abandon the\n"
2019 static const char wrongmsg
[] =
2020 "WARNING - POTENTIAL SECURITY BREACH!\n"
2022 "The server's host key does not match the one PuTTY has\n"
2023 "cached in the registry. This means that either the\n"
2024 "server administrator has changed the host key, or you\n"
2025 "have actually connected to another computer pretending\n"
2026 "to be the server.\n"
2027 "The new key fingerprint is:\n"
2029 "If you were expecting this change and trust the new key,\n"
2030 "hit Yes to update PuTTY's cache and continue connecting.\n"
2031 "If you want to carry on connecting but without updating\n"
2032 "the cache, hit No.\n"
2033 "If you want to abandon the connection completely, hit\n"
2034 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2037 static const char mbtitle
[] = "PuTTY Security Alert";
2040 char message
[160+ /* sensible fingerprint max size */
2041 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2042 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2045 * Verify the key against the registry.
2047 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2049 if (ret
== 0) /* success - key matched OK */
2051 if (ret
== 2) { /* key was different */
2053 sprintf(message
, wrongmsg
, fingerprint
);
2054 mbret
= MessageBox(NULL
, message
, mbtitle
,
2055 MB_ICONWARNING
| MB_YESNOCANCEL
);
2057 store_host_key(host
, port
, keytype
, keystr
);
2058 if (mbret
== IDCANCEL
)
2061 if (ret
== 1) { /* key was absent */
2063 sprintf(message
, absentmsg
, fingerprint
);
2064 mbret
= MessageBox(NULL
, message
, mbtitle
,
2065 MB_ICONWARNING
| MB_YESNO
);
2068 store_host_key(host
, port
, keytype
, keystr
);
2073 * Ask whether to wipe a session log file before writing to it.
2074 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2076 int askappend(char *filename
) {
2077 static const char mbtitle
[] = "PuTTY Log to File";
2078 static const char msgtemplate
[] =
2079 "The session log file \"%.*s\" already exists.\n"
2080 "You can overwrite it with a new session log,\n"
2081 "append your session log to the end of it,\n"
2082 "or disable session logging for this session.\n"
2083 "Hit Yes to wipe the file, No to append to it,\n"
2084 "or Cancel to disable logging.";
2085 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2087 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2089 mbret
= MessageBox(NULL
, message
, mbtitle
,
2090 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2093 else if (mbret
== IDNO
)