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
,
405 IDC_BOX_TUNNELS
, IDC_BOXT_TUNNELS
,
414 static const char *const colours
[] = {
415 "Default Foreground", "Default Bold Foreground",
416 "Default Background", "Default Bold Background",
417 "Cursor Text", "Cursor Colour",
418 "ANSI Black", "ANSI Black Bold",
419 "ANSI Red", "ANSI Red Bold",
420 "ANSI Green", "ANSI Green Bold",
421 "ANSI Yellow", "ANSI Yellow Bold",
422 "ANSI Blue", "ANSI Blue Bold",
423 "ANSI Magenta", "ANSI Magenta Bold",
424 "ANSI Cyan", "ANSI Cyan Bold",
425 "ANSI White", "ANSI White Bold"
427 static const int permcolour
[] = {
428 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
429 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
430 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
433 static void fmtfont (char *buf
) {
434 sprintf (buf
, "Font: %s, ", cfg
.font
);
436 strcat(buf
, "bold, ");
437 if (cfg
.fontheight
== 0)
438 strcat (buf
, "default height");
440 sprintf (buf
+strlen(buf
), "%d-%s",
441 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
),
442 (cfg
.fontheight
< 0 ?
"pixel" : "point"));
445 static void init_dlg_ctrls(HWND hwnd
) {
447 char fontstatic
[256];
449 SetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
);
450 SetDlgItemText (hwnd
, IDC_SESSEDIT
, savedsession
);
451 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
452 CheckRadioButton (hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
453 cfg
.protocol
==PROT_SSH ? IDC_PROTSSH
:
454 cfg
.protocol
==PROT_TELNET ? IDC_PROTTELNET
:
455 cfg
.protocol
==PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
456 SetDlgItemInt (hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
458 CheckRadioButton (hwnd
, IDC_DEL008
, IDC_DEL127
,
459 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
460 CheckRadioButton (hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
461 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
462 CheckRadioButton (hwnd
, IDC_FUNCTILDE
, IDC_FUNCVT400
,
463 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
464 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
465 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
466 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
468 CheckDlgButton (hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
469 CheckDlgButton (hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
470 CheckRadioButton (hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
471 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
472 CheckRadioButton (hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
473 cfg
.nethack_keypad ? IDC_KPNH
:
474 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
475 CheckDlgButton (hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
476 CheckDlgButton (hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
477 CheckDlgButton (hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
478 CheckDlgButton (hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
479 CheckDlgButton (hwnd
, IDC_LDISCTERM
, cfg
.ldisc_term
);
480 CheckDlgButton (hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
481 CheckDlgButton (hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
482 CheckDlgButton (hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
484 CheckDlgButton (hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
485 CheckDlgButton (hwnd
, IDC_DECOM
, cfg
.dec_om
);
486 CheckDlgButton (hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
487 SetDlgItemInt (hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
488 SetDlgItemInt (hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
489 SetDlgItemInt (hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
490 fmtfont (fontstatic
);
491 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
492 CheckDlgButton (hwnd
, IDC_BEEP
, cfg
.beep
);
493 CheckDlgButton (hwnd
, IDC_BCE
, cfg
.bce
);
494 CheckDlgButton (hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
496 SetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
497 CheckDlgButton (hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
498 CheckRadioButton (hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
499 cfg
.cursor_type
==0 ? IDC_CURBLOCK
:
500 cfg
.cursor_type
==1 ? IDC_CURUNDER
: IDC_CURVERT
);
501 CheckDlgButton (hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
502 CheckDlgButton (hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
503 CheckDlgButton (hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
504 CheckDlgButton (hwnd
, IDC_CLOSEEXIT
, cfg
.close_on_exit
);
505 CheckDlgButton (hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
507 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
508 SetDlgItemText (hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
509 SetDlgItemText (hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
510 SetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
511 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
512 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
513 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
514 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
515 cfg
.logtype
== 1 ? IDC_LSTATASCII
:
518 char *p
= cfg
.environmt
;
520 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
525 CheckRadioButton (hwnd
, IDC_EMBSD
, IDC_EMRFC
,
526 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
528 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
529 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
530 CheckDlgButton (hwnd
, IDC_NOPTY
, cfg
.nopty
);
531 CheckDlgButton (hwnd
, IDC_COMPRESS
, cfg
.compression
);
532 CheckDlgButton (hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
533 CheckDlgButton (hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
534 CheckRadioButton (hwnd
, IDC_CIPHER3DES
, IDC_CIPHERDES
,
535 cfg
.cipher
== CIPHER_BLOWFISH ? IDC_CIPHERBLOWF
:
536 cfg
.cipher
== CIPHER_DES ? IDC_CIPHERDES
:
538 CheckRadioButton (hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
539 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
540 CheckDlgButton (hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
541 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
542 SetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
544 CheckRadioButton (hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
545 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
547 static int tabs
[4] = {25, 61, 96, 128};
548 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
551 for (i
=0; i
<256; i
++) {
553 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
554 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
556 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
560 CheckDlgButton (hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
561 CheckDlgButton (hwnd
, IDC_PALETTE
, cfg
.try_palette
);
564 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
566 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
567 LB_DELETESTRING
, i
, 0);
569 if (cfg
.bold_colour
|| permcolour
[i
])
570 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
571 (LPARAM
) colours
[i
]);
573 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
574 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
575 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
576 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
578 CheckRadioButton (hwnd
, IDC_NOXLAT
, IDC_88592CP852
,
579 cfg
.xlat_88592w1250 ? IDC_88592WIN1250
:
580 cfg
.xlat_88592cp852 ? IDC_88592CP852
:
581 cfg
.xlat_enablekoiwin ? IDC_KOI8WIN1251
:
583 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
584 CheckRadioButton (hwnd
, IDC_VTXWINDOWS
, IDC_VTPOORMAN
,
585 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
586 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
587 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
590 CheckDlgButton (hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
591 SetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
594 static void hide(HWND hwnd
, int hide
, int minid
, int maxid
) {
596 for (i
= minid
; i
< maxid
; i
++) {
597 HWND ctl
= GetDlgItem(hwnd
, i
);
600 EnableWindow(ctl
, 1);
601 ShowWindow(ctl
, hide ? SW_HIDE
: SW_SHOW
);
603 EnableWindow(ctl
, 0);
608 struct treeview_faff
{
613 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
614 int level
, char *text
) {
618 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
-1] : TVI_ROOT
);
619 ins
.hInsertAfter
= faff
->lastat
[level
];
620 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
621 #define INSITEM DUMMYUNIONNAME.item
625 ins
.INSITEM
.mask
= TVIF_TEXT
;
626 ins
.INSITEM
.pszText
= text
;
627 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
629 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
-1], TVE_EXPAND
);
630 faff
->lastat
[level
] = newitem
;
631 for (i
= level
+1; i
< 4; i
++) faff
->lastat
[i
] = NULL
;
636 * This _huge_ function is the configuration box.
638 static int GenericMainDlgProc (HWND hwnd
, UINT msg
,
639 WPARAM wParam
, LPARAM lParam
,
642 struct treeview_faff tvfaff
;
645 char filename
[sizeof(cfg
.keyfile
)];
648 char fontstatic
[256];
650 struct servent
* service
;
656 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
660 { /* centre the window */
663 hw
= GetDesktopWindow();
664 if (GetWindowRect (hw
, &rs
) && GetWindowRect (hwnd
, &rd
))
665 MoveWindow (hwnd
, (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
)/2,
666 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
)/2,
667 rd
.right
-rd
.left
, rd
.bottom
-rd
.top
, TRUE
);
671 * Create the tree view.
678 r
.left
= 3; r
.right
= r
.left
+ 75;
679 r
.top
= 3; r
.bottom
= r
.top
+ 10;
680 MapDialogRect(hwnd
, &r
);
681 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
682 WS_CHILD
| WS_VISIBLE
,
684 r
.right
-r
.left
, r
.bottom
-r
.top
,
685 hwnd
, (HMENU
)IDCX_TVSTATIC
, hinst
, NULL
);
686 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
687 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
689 r
.left
= 3; r
.right
= r
.left
+ 75;
690 r
.top
= 13; r
.bottom
= r
.top
+ 206;
691 MapDialogRect(hwnd
, &r
);
692 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
693 WS_CHILD
| WS_VISIBLE
|
694 WS_TABSTOP
| TVS_HASLINES
|
695 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
|
696 TVS_LINESATROOT
| TVS_SHOWSELALWAYS
,
698 r
.right
-r
.left
, r
.bottom
-r
.top
,
699 hwnd
, (HMENU
)IDCX_TREEVIEW
, hinst
, NULL
);
700 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
701 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
702 tvfaff
.treeview
= treeview
;
703 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
707 * Create the various panelfuls of controls.
710 /* The Session panel. Accelerators used: [acgo] nprthelsdx */
713 ctlposinit(&cp
, hwnd
, 80, 3, 13);
714 bartitle(&cp
, "Basic options for your PuTTY session",
717 beginbox(&cp
, "Specify your connection by host name",
718 IDC_BOX_SESSION1
, IDC_BOXT_SESSION1
);
720 "Host &Name", IDC_HOSTSTATIC
, IDC_HOST
, 75,
721 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
722 if (backends
[3].backend
== NULL
) {
723 /* this is PuTTYtel, so only two protocols available */
724 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
726 "&Telnet", IDC_PROTTELNET
,
727 "R&login", IDC_PROTRLOGIN
, NULL
);
729 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
731 "&Telnet", IDC_PROTTELNET
,
732 "R&login", IDC_PROTRLOGIN
,
741 beginbox(&cp
, "Load, save or delete a stored session",
742 IDC_BOX_SESSION2
, IDC_BOXT_SESSION2
);
743 sesssaver(&cp
, "Sav&ed Sessions",
744 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
745 "&Load", IDC_SESSLOAD
,
746 "&Save", IDC_SESSSAVE
,
747 "&Delete", IDC_SESSDEL
, NULL
);
750 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
, 0);
751 checkbox(&cp
, "Close Window on E&xit", IDC_CLOSEEXIT
);
754 hsession
= treeview_insert(&tvfaff
, 0, "Session");
757 /* The Terminal panel. Accelerators used: [acgo] &dflbenuw */
760 ctlposinit(&cp
, hwnd
, 80, 3, 13);
761 bartitle(&cp
, "Options controlling the terminal emulation",
763 beginbox(&cp
, "Set various terminal options",
764 IDC_BOX_TERMINAL1
, IDC_BOXT_TERMINAL1
);
765 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
766 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
767 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
768 checkbox(&cp
, "&Beep enabled", IDC_BEEP
);
769 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
770 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
771 checkbox(&cp
, "&Use local terminal line discipline", IDC_LDISCTERM
);
774 beginbox(&cp
, "Control session logging",
775 IDC_BOX_TERMINAL2
, IDC_BOXT_TERMINAL2
);
777 "Session logging:", IDC_LSTATSTATIC
,
778 "Logging turned &off completely", IDC_LSTATOFF
,
779 "Log printable output only", IDC_LSTATASCII
,
780 "Log all session output", IDC_LSTATRAW
, NULL
);
781 editbutton(&cp
, "Log &file name:",
782 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
786 treeview_insert(&tvfaff
, 0, "Terminal");
789 /* The Keyboard panel. Accelerators used: [acgo] h?srvlxvnpmietu */
792 ctlposinit(&cp
, hwnd
, 80, 3, 13);
793 bartitle(&cp
, "Options controlling the effects of keys",
795 beginbox(&cp
, "Change the sequences sent by:",
796 IDC_BOX_KEYBOARD1
, IDC_BOXT_KEYBOARD1
);
797 radioline(&cp
, "The Backspace key", IDC_DELSTATIC
, 2,
798 "Control-&H", IDC_DEL008
,
799 "Control-&? (127)", IDC_DEL127
, NULL
);
800 radioline(&cp
, "The Home and End keys", IDC_HOMESTATIC
, 2,
801 "&Standard", IDC_HOMETILDE
,
802 "&rxvt", IDC_HOMERXVT
, NULL
);
803 radioline(&cp
, "The Function keys and keypad", IDC_FUNCSTATIC
, 4,
804 "ESC[n&~", IDC_FUNCTILDE
,
805 "&Linux", IDC_FUNCLINUX
,
806 "&Xterm R6", IDC_FUNCXTERM
,
807 "&VT400", IDC_FUNCVT400
, NULL
);
809 beginbox(&cp
, "Application keypad settings:",
810 IDC_BOX_KEYBOARD2
, IDC_BOXT_KEYBOARD2
);
812 "Application c&ursor keys totally disabled",
814 radioline(&cp
, "Initial state of cursor keys:", IDC_CURSTATIC
, 2,
815 "&Normal", IDC_CURNORMAL
,
816 "A&pplication", IDC_CURAPPLIC
, NULL
);
818 "Application ke&ypad keys totally disabled",
820 radioline(&cp
, "Initial state of numeric keypad:", IDC_KPSTATIC
, 3,
821 "Nor&mal", IDC_KPNORMAL
,
822 "Appl&ication", IDC_KPAPPLIC
,
823 "N&etHack", IDC_KPNH
, NULL
);
825 beginbox(&cp
, "Enable extra keyboard features:",
826 IDC_BOX_KEYBOARD3
, IDC_BOXT_KEYBOARD3
);
827 checkbox(&cp
, "Application and AltGr ac&t as Compose key",
831 treeview_insert(&tvfaff
, 1, "Keyboard");
834 /* The Window panel. Accelerators used: [acgo] bsdkw4ylpt */
837 ctlposinit(&cp
, hwnd
, 80, 3, 13);
838 bartitle(&cp
, "Options controlling PuTTY's window",
840 beginbox(&cp
, "Set the size of the window",
841 IDC_BOX_WINDOW1
, IDC_BOXT_WINDOW1
);
843 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
844 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50,
846 checkbox(&cp
, "Loc&k window size against resizing", IDC_LOCKSIZE
);
848 beginbox(&cp
, "Control the scrollback in the window",
849 IDC_BOX_WINDOW2
, IDC_BOXT_WINDOW2
);
850 staticedit(&cp
, "Lines of &scrollback",
851 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
852 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
853 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
854 checkbox(&cp
, "Reset scrollback on dis&play activity",
857 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
, 0);
858 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
859 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
860 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
861 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
862 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
865 treeview_insert(&tvfaff
, 0, "Window");
868 /* The Appearance panel. Accelerators used: [acgo] rmkhtibluv */
871 ctlposinit(&cp
, hwnd
, 80, 3, 13);
872 bartitle(&cp
, "Options controlling PuTTY's appearance",
873 IDC_TITLE_APPEARANCE
);
874 beginbox(&cp
, "Adjust the use of the cursor",
875 IDC_BOX_APPEARANCE1
, IDC_BOXT_APPEARANCE1
);
876 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
877 "B&lock", IDC_CURBLOCK
,
878 "&Underline", IDC_CURUNDER
,
879 "&Vertical line", IDC_CURVERT
,
881 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
883 beginbox(&cp
, "Set the font used in the terminal window",
884 IDC_BOX_APPEARANCE2
, IDC_BOXT_APPEARANCE2
);
885 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
887 beginbox(&cp
, "Adjust the use of the window title",
888 IDC_BOX_APPEARANCE3
, IDC_BOXT_APPEARANCE3
);
890 "Window &title:", IDC_WINTITLE
,
891 IDC_WINEDIT
, 100, NULL
);
892 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
895 treeview_insert(&tvfaff
, 1, "Appearance");
898 /* The Translation panel. Accelerators used: [acgo] xbepnkis */
901 ctlposinit(&cp
, hwnd
, 80, 3, 13);
902 bartitle(&cp
, "Options controlling character set translation",
903 IDC_TITLE_TRANSLATION
);
904 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
905 IDC_BOX_TRANSLATION1
, IDC_BOXT_TRANSLATION1
);
907 "Handling of line drawing characters:", IDC_VTSTATIC
,
908 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
909 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
910 "Use font in O&EM mode only", IDC_VTOEMONLY
,
911 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
912 IDC_VTPOORMAN
, NULL
);
914 beginbox(&cp
, "Enable character set translation on received data",
915 IDC_BOX_TRANSLATION2
, IDC_BOXT_TRANSLATION2
);
917 "Character set translation:", IDC_XLATSTATIC
,
919 "&KOI8 / Win-1251", IDC_KOI8WIN1251
,
920 "&ISO-8859-2 / Win-1250", IDC_88592WIN1250
,
921 "&ISO-8859-2 / CP852", IDC_88592CP852
, NULL
);
923 beginbox(&cp
, "Enable character set translation on input data",
924 IDC_BOX_TRANSLATION3
, IDC_BOXT_TRANSLATION3
);
925 checkbox(&cp
, "CAP&S LOCK acts as cyrillic switch",
929 treeview_insert(&tvfaff
, 1, "Translation");
932 /* The Selection panel. Accelerators used: [acgo] wxst */
935 ctlposinit(&cp
, hwnd
, 80, 3, 13);
936 bartitle(&cp
, "Options controlling copy and paste",
937 IDC_TITLE_SELECTION
);
938 beginbox(&cp
, "Control which mouse button does which thing",
939 IDC_BOX_SELECTION1
, IDC_BOXT_SELECTION1
);
940 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
941 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
942 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
945 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
946 IDC_BOX_SELECTION2
, IDC_BOXT_SELECTION2
);
947 charclass(&cp
, "Character classes:", IDC_CCSTATIC
, IDC_CCLIST
,
948 "&Set", IDC_CCSET
, IDC_CCEDIT
,
949 "&to class", IDC_CCSTATIC2
);
952 treeview_insert(&tvfaff
, 1, "Selection");
955 /* The Colours panel. Accelerators used: [acgo] blum */
958 ctlposinit(&cp
, hwnd
, 80, 3, 13);
959 bartitle(&cp
, "Options controlling use of colours",
961 beginbox(&cp
, "General options for colour usage",
962 IDC_BOX_COLOURS1
, IDC_BOXT_COLOURS1
);
963 checkbox(&cp
, "&Bolded text is a different colour", IDC_BOLDCOLOUR
);
964 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
966 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
967 IDC_BOX_COLOURS2
, IDC_BOXT_COLOURS2
);
968 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
969 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
970 "&Modify...", IDC_CHANGE
,
971 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
972 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
973 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
976 treeview_insert(&tvfaff
, 1, "Colours");
979 /* The Connection panel. Accelerators used: [acgo] tuk */
982 ctlposinit(&cp
, hwnd
, 80, 3, 13);
983 bartitle(&cp
, "Options controlling the connection", IDC_TITLE_CONNECTION
);
985 beginbox(&cp
, "Data to send to the server",
986 IDC_BOX_CONNECTION1
, IDC_BOXT_CONNECTION1
);
987 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
, IDC_TTEDIT
, 50);
988 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
, IDC_LOGEDIT
, 50);
991 beginbox(&cp
, "Sending of null packets to keep session active",
992 IDC_BOX_CONNECTION2
, IDC_BOXT_CONNECTION2
);
993 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
994 IDC_PINGSTATIC
, IDC_PINGEDIT
, 25);
997 treeview_insert(&tvfaff
, 0, "Connection");
1000 /* The Telnet panel. Accelerators used: [acgo] svldrbf */
1003 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1005 bartitle(&cp
, "Options controlling Telnet connections", IDC_TITLE_TELNET
);
1006 beginbox(&cp
, "Data to send to the server",
1007 IDC_BOX_TELNET1
, IDC_BOXT_TELNET1
);
1008 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
, IDC_TSEDIT
, 50);
1009 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1010 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
,
1011 "Va&lue", IDC_VALSTATIC
, IDC_VALEDIT
,
1013 "A&dd", IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1015 beginbox(&cp
, "Telnet protocol adjustments",
1016 IDC_BOX_TELNET2
, IDC_BOXT_TELNET2
);
1017 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC
, 2,
1018 "&BSD (commonplace)", IDC_EMBSD
,
1019 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1022 treeview_insert(&tvfaff
, 1, "Telnet");
1027 /* The Rlogin Panel */
1030 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1032 bartitle(&cp
, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN
);
1033 beginbox(&cp
, "Data to send to the server",
1034 IDC_BOX_RLOGIN1
, IDC_BOXT_RLOGIN1
);
1035 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
, IDC_R_TSEDIT
, 50);
1036 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
, IDC_RLLUSEREDIT
, 50);
1039 treeview_insert(&tvfaff
, 1, "Rlogin");
1043 /* The SSH panel. Accelerators used: [acgo] rmakwp123bd */
1044 if (backends
[3].backend
!= NULL
) {
1046 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1048 bartitle(&cp
, "Options controlling SSH connections", IDC_TITLE_SSH
);
1049 beginbox(&cp
, "Data to send to the server",
1050 IDC_BOX_SSH1
, IDC_BOXT_SSH1
);
1052 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1055 beginbox(&cp
, "Authentication options",
1056 IDC_BOX_SSH2
, IDC_BOXT_SSH2
);
1057 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1059 checkbox(&cp
, "Allow &agent forwarding", IDC_AGENTFWD
);
1060 editbutton(&cp
, "Private &key file for authentication:",
1061 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...", IDC_PKBUTTON
);
1063 beginbox(&cp
, "Protocol options",
1064 IDC_BOX_SSH3
, IDC_BOXT_SSH3
);
1065 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1066 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1067 radioline(&cp
, "Preferred SSH protocol version:",
1068 IDC_SSHPROTSTATIC
, 2,
1069 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1070 radioline(&cp
, "Preferred encryption algorithm:", IDC_CIPHERSTATIC
, 3,
1071 "&3DES", IDC_CIPHER3DES
,
1072 "&Blowfish", IDC_CIPHERBLOWF
,
1073 "&DES", IDC_CIPHERDES
, NULL
);
1074 checkbox(&cp
, "Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1078 treeview_insert(&tvfaff
, 1, "SSH");
1081 /* The Tunnels panel. Accelerators used: [acgo] ex */
1084 ctlposinit(&tp
, hwnd
, 80, 3, 13);
1086 beginbox(&tp
, "X11 forwarding options",
1087 IDC_BOX_TUNNELS
, IDC_BOXT_TUNNELS
);
1088 checkbox(&tp
, "&Enable X11 forwarding",
1090 multiedit(&tp
, "&X display location", IDC_X11_DISPSTATIC
,
1091 IDC_X11_DISPLAY
, 50, NULL
);
1094 treeview_insert(&tvfaff
, 2, "Tunnels");
1098 init_dlg_ctrls(hwnd
);
1099 for (i
= 0; i
< nsessions
; i
++)
1100 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1101 0, (LPARAM
) (sessions
[i
]));
1104 * Hide all the controls to start with.
1106 hide(hwnd
, TRUE
, controlstartvalue
, controlendvalue
);
1109 * Put the treeview selection on to the Session panel. This
1110 * should also cause unhiding of the relevant controls.
1112 TreeView_SelectItem(treeview
, hsession
);
1115 * Set focus into the first available control.
1119 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1120 if (!ctl
) ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1124 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1128 * Button release should trigger WM_OK if there was a
1129 * previous double click on the session list.
1133 SendMessage (hwnd
, WM_COMMAND
, IDOK
, 0);
1136 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1137 ((LPNMHDR
)lParam
)->code
== TVN_SELCHANGED
) {
1138 HTREEITEM i
= TreeView_GetSelection(((LPNMHDR
)lParam
)->hwndFrom
);
1142 item
.pszText
= buffer
;
1143 item
.cchTextMax
= sizeof(buffer
);
1144 item
.mask
= TVIF_TEXT
;
1145 TreeView_GetItem(((LPNMHDR
)lParam
)->hwndFrom
, &item
);
1146 hide(hwnd
, TRUE
, controlstartvalue
, controlendvalue
);
1147 if (!strcmp(buffer
, "Session"))
1148 hide(hwnd
, FALSE
, sessionpanelstart
, sessionpanelend
);
1149 if (!strcmp(buffer
, "Keyboard"))
1150 hide(hwnd
, FALSE
, keyboardpanelstart
, keyboardpanelend
);
1151 if (!strcmp(buffer
, "Terminal"))
1152 hide(hwnd
, FALSE
, terminalpanelstart
, terminalpanelend
);
1153 if (!strcmp(buffer
, "Window"))
1154 hide(hwnd
, FALSE
, windowpanelstart
, windowpanelend
);
1155 if (!strcmp(buffer
, "Appearance"))
1156 hide(hwnd
, FALSE
, appearancepanelstart
, appearancepanelend
);
1157 if (!strcmp(buffer
, "Tunnels"))
1158 hide(hwnd
, FALSE
, tunnelspanelstart
, tunnelspanelend
);
1159 if (!strcmp(buffer
, "Connection"))
1160 hide(hwnd
, FALSE
, connectionpanelstart
, connectionpanelend
);
1161 if (!strcmp(buffer
, "Telnet"))
1162 hide(hwnd
, FALSE
, telnetpanelstart
, telnetpanelend
);
1163 if (!strcmp(buffer
, "Rlogin"))
1164 hide(hwnd
, FALSE
, rloginpanelstart
, rloginpanelend
);
1165 if (!strcmp(buffer
, "SSH"))
1166 hide(hwnd
, FALSE
, sshpanelstart
, sshpanelend
);
1167 if (!strcmp(buffer
, "Selection"))
1168 hide(hwnd
, FALSE
, selectionpanelstart
, selectionpanelend
);
1169 if (!strcmp(buffer
, "Colours"))
1170 hide(hwnd
, FALSE
, colourspanelstart
, colourspanelend
);
1171 if (!strcmp(buffer
, "Translation"))
1172 hide(hwnd
, FALSE
, translationpanelstart
, translationpanelend
);
1174 SetFocus (((LPNMHDR
)lParam
)->hwndFrom
); /* ensure focus stays */
1180 * Only process WM_COMMAND once the dialog is fully formed.
1182 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
1185 EndDialog (hwnd
, 1);
1190 EndDialog (hwnd
, 0);
1192 case IDC_PROTTELNET
:
1193 case IDC_PROTRLOGIN
:
1196 if (HIWORD(wParam
) == BN_CLICKED
||
1197 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1198 int i
= IsDlgButtonChecked (hwnd
, IDC_PROTSSH
);
1199 int j
= IsDlgButtonChecked (hwnd
, IDC_PROTTELNET
);
1200 int k
= IsDlgButtonChecked (hwnd
, IDC_PROTRLOGIN
);
1201 cfg
.protocol
= i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
: PROT_RAW
;
1202 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22) ||
1203 (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23) ||
1204 (cfg
.protocol
== PROT_RLOGIN
&& cfg
.port
!= 513)) {
1205 cfg
.port
= i ?
22 : j ?
23 : 513;
1206 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1211 if (HIWORD(wParam
) == EN_CHANGE
)
1212 GetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
,
1213 sizeof(cfg
.host
)-1);
1216 if (HIWORD(wParam
) == EN_CHANGE
) {
1217 GetDlgItemText (hwnd
, IDC_PORT
, portname
, 31);
1218 if (isdigit(portname
[0]))
1219 MyGetDlgItemInt (hwnd
, IDC_PORT
, &cfg
.port
);
1221 service
= getservbyname(portname
, NULL
);
1222 if (service
) cfg
.port
= ntohs(service
->s_port
);
1228 if (HIWORD(wParam
) == EN_CHANGE
) {
1229 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1231 GetDlgItemText (hwnd
, IDC_SESSEDIT
,
1232 savedsession
, sizeof(savedsession
)-1);
1233 savedsession
[sizeof(savedsession
)-1] = '\0';
1237 if (HIWORD(wParam
) == BN_CLICKED
||
1238 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1243 GetDlgItemText (hwnd
, IDC_SESSEDIT
, str
, sizeof(str
)-1);
1245 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1246 LB_GETCURSEL
, 0, 0);
1251 strcpy (str
, sessions
[n
]);
1253 save_settings (str
, !!strcmp(str
, "Default Settings"), &cfg
);
1254 get_sesslist (FALSE
);
1255 get_sesslist (TRUE
);
1256 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1258 for (i
= 0; i
< nsessions
; i
++)
1259 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1260 0, (LPARAM
) (sessions
[i
]));
1261 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1267 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1268 HIWORD(wParam
) != BN_CLICKED
&&
1269 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1271 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1272 HIWORD(wParam
) != LBN_DBLCLK
)
1275 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1276 LB_GETCURSEL
, 0, 0);
1282 isdef
= !strcmp(sessions
[n
], "Default Settings");
1283 load_settings (sessions
[n
], !isdef
, &cfg
);
1284 init_dlg_ctrls(hwnd
);
1286 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1288 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1290 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1292 * A double-click on a saved session should
1293 * actually start the session, not just load it.
1294 * Unless it's Default Settings or some other
1295 * host-less set of saved settings.
1304 if (HIWORD(wParam
) == BN_CLICKED
||
1305 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1306 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1307 LB_GETCURSEL
, 0, 0);
1308 if (n
== LB_ERR
|| n
== 0) {
1312 del_settings(sessions
[n
]);
1313 get_sesslist (FALSE
);
1314 get_sesslist (TRUE
);
1315 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1317 for (i
= 0; i
< nsessions
; i
++)
1318 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1319 0, (LPARAM
) (sessions
[i
]));
1320 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1324 if (HIWORD(wParam
) == EN_CHANGE
)
1325 MyGetDlgItemInt (hwnd
, IDC_PINGEDIT
, &cfg
.ping_interval
);
1329 if (HIWORD(wParam
) == BN_CLICKED
||
1330 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1331 cfg
.bksp_is_delete
= IsDlgButtonChecked (hwnd
, IDC_DEL127
);
1335 if (HIWORD(wParam
) == BN_CLICKED
||
1336 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1337 cfg
.rxvt_homeend
= IsDlgButtonChecked (hwnd
, IDC_HOMERXVT
);
1340 if (HIWORD(wParam
) == BN_CLICKED
||
1341 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1345 if (HIWORD(wParam
) == BN_CLICKED
||
1346 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1351 if (HIWORD(wParam
) == BN_CLICKED
||
1352 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1353 cfg
.funky_type
= IsDlgButtonChecked (hwnd
, IDC_FUNCLINUX
);
1357 if (HIWORD(wParam
) == BN_CLICKED
||
1358 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1359 cfg
.app_keypad
= IsDlgButtonChecked (hwnd
, IDC_KPAPPLIC
);
1360 cfg
.nethack_keypad
= FALSE
;
1364 if (HIWORD(wParam
) == BN_CLICKED
||
1365 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1366 cfg
.app_keypad
= FALSE
;
1367 cfg
.nethack_keypad
= TRUE
;
1372 if (HIWORD(wParam
) == BN_CLICKED
||
1373 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1374 cfg
.app_cursor
= IsDlgButtonChecked (hwnd
, IDC_CURAPPLIC
);
1377 if (HIWORD(wParam
) == BN_CLICKED
||
1378 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1379 cfg
.no_applic_c
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICC
);
1382 if (HIWORD(wParam
) == BN_CLICKED
||
1383 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1384 cfg
.no_applic_k
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICK
);
1387 if (HIWORD(wParam
) == BN_CLICKED
||
1388 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1389 cfg
.alt_f4
= IsDlgButtonChecked (hwnd
, IDC_ALTF4
);
1392 if (HIWORD(wParam
) == BN_CLICKED
||
1393 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1394 cfg
.alt_space
= IsDlgButtonChecked (hwnd
, IDC_ALTSPACE
);
1397 if (HIWORD(wParam
) == BN_CLICKED
||
1398 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1399 cfg
.alt_only
= IsDlgButtonChecked (hwnd
, IDC_ALTONLY
);
1402 if (HIWORD(wParam
) == BN_CLICKED
||
1403 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1404 cfg
.ldisc_term
= IsDlgButtonChecked (hwnd
, IDC_LDISCTERM
);
1406 case IDC_ALWAYSONTOP
:
1407 if (HIWORD(wParam
) == BN_CLICKED
||
1408 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1409 cfg
.alwaysontop
= IsDlgButtonChecked (hwnd
, IDC_ALWAYSONTOP
);
1412 if (HIWORD(wParam
) == BN_CLICKED
||
1413 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1414 cfg
.scroll_on_key
= IsDlgButtonChecked (hwnd
, IDC_SCROLLKEY
);
1416 case IDC_SCROLLDISP
:
1417 if (HIWORD(wParam
) == BN_CLICKED
||
1418 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1419 cfg
.scroll_on_disp
= IsDlgButtonChecked (hwnd
, IDC_SCROLLDISP
);
1421 case IDC_COMPOSEKEY
:
1422 if (HIWORD(wParam
) == BN_CLICKED
||
1423 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1424 cfg
.compose_key
= IsDlgButtonChecked (hwnd
, IDC_COMPOSEKEY
);
1427 if (HIWORD(wParam
) == BN_CLICKED
||
1428 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1429 cfg
.wrap_mode
= IsDlgButtonChecked (hwnd
, IDC_WRAPMODE
);
1432 if (HIWORD(wParam
) == BN_CLICKED
||
1433 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1434 cfg
.dec_om
= IsDlgButtonChecked (hwnd
, IDC_DECOM
);
1437 if (HIWORD(wParam
) == BN_CLICKED
||
1438 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1439 cfg
.lfhascr
= IsDlgButtonChecked (hwnd
, IDC_LFHASCR
);
1442 if (HIWORD(wParam
) == EN_CHANGE
)
1443 MyGetDlgItemInt (hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1446 if (HIWORD(wParam
) == EN_CHANGE
)
1447 MyGetDlgItemInt (hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1450 if (HIWORD(wParam
) == EN_CHANGE
)
1451 MyGetDlgItemInt (hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1453 case IDC_CHOOSEFONT
:
1454 lf
.lfHeight
= cfg
.fontheight
;
1455 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1456 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1457 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1458 lf
.lfCharSet
= cfg
.fontcharset
;
1459 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1460 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1461 lf
.lfQuality
= DEFAULT_QUALITY
;
1462 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1463 strncpy (lf
.lfFaceName
, cfg
.font
, sizeof(lf
.lfFaceName
)-1);
1464 lf
.lfFaceName
[sizeof(lf
.lfFaceName
)-1] = '\0';
1466 cf
.lStructSize
= sizeof(cf
);
1467 cf
.hwndOwner
= hwnd
;
1469 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1470 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1472 if (ChooseFont (&cf
)) {
1473 strncpy (cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
)-1);
1474 cfg
.font
[sizeof(cfg
.font
)-1] = '\0';
1475 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1476 cfg
.fontcharset
= lf
.lfCharSet
;
1477 cfg
.fontheight
= lf
.lfHeight
;
1478 fmtfont (fontstatic
);
1479 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
1483 if (HIWORD(wParam
) == BN_CLICKED
||
1484 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1485 cfg
.beep
= IsDlgButtonChecked (hwnd
, IDC_BEEP
);
1488 if (HIWORD(wParam
) == BN_CLICKED
||
1489 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1490 cfg
.blinktext
= IsDlgButtonChecked (hwnd
, IDC_BLINKTEXT
);
1493 if (HIWORD(wParam
) == BN_CLICKED
||
1494 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1495 cfg
.bce
= IsDlgButtonChecked (hwnd
, IDC_BCE
);
1498 if (HIWORD(wParam
) == BN_CLICKED
||
1499 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1500 cfg
.win_name_always
= IsDlgButtonChecked (hwnd
, IDC_WINNAME
);
1503 if (HIWORD(wParam
) == BN_CLICKED
||
1504 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1505 cfg
.cursor_type
= 0;
1508 if (HIWORD(wParam
) == BN_CLICKED
||
1509 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1510 cfg
.cursor_type
= 1;
1513 if (HIWORD(wParam
) == BN_CLICKED
||
1514 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1515 cfg
.cursor_type
= 2;
1518 if (HIWORD(wParam
) == BN_CLICKED
||
1519 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1520 cfg
.blink_cur
= IsDlgButtonChecked (hwnd
, IDC_BLINKCUR
);
1523 if (HIWORD(wParam
) == BN_CLICKED
||
1524 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1525 cfg
.scrollbar
= IsDlgButtonChecked (hwnd
, IDC_SCROLLBAR
);
1528 if (HIWORD(wParam
) == BN_CLICKED
||
1529 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1530 cfg
.locksize
= IsDlgButtonChecked (hwnd
, IDC_LOCKSIZE
);
1533 if (HIWORD(wParam
) == EN_CHANGE
)
1534 GetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
1535 sizeof(cfg
.wintitle
)-1);
1538 if (HIWORD(wParam
) == BN_CLICKED
||
1539 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1540 cfg
.close_on_exit
= IsDlgButtonChecked (hwnd
, IDC_CLOSEEXIT
);
1543 if (HIWORD(wParam
) == BN_CLICKED
||
1544 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1545 cfg
.warn_on_close
= IsDlgButtonChecked (hwnd
, IDC_CLOSEWARN
);
1548 if (HIWORD(wParam
) == EN_CHANGE
)
1549 GetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
,
1550 sizeof(cfg
.termtype
)-1);
1553 if (HIWORD(wParam
) == EN_CHANGE
)
1554 GetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
1555 sizeof(cfg
.logfilename
)-1);
1558 memset(&of
, 0, sizeof(of
));
1559 #ifdef OPENFILENAME_SIZE_VERSION_400
1560 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1562 of
.lStructSize
= sizeof(of
);
1564 of
.hwndOwner
= hwnd
;
1565 of
.lpstrFilter
= "All Files\0*\0\0\0";
1566 of
.lpstrCustomFilter
= NULL
;
1567 of
.nFilterIndex
= 1;
1568 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1569 of
.nMaxFile
= sizeof(filename
);
1570 of
.lpstrFileTitle
= NULL
;
1571 of
.lpstrInitialDir
= NULL
;
1572 of
.lpstrTitle
= "Select session log file";
1574 if (GetSaveFileName(&of
)) {
1575 strcpy(cfg
.keyfile
, filename
);
1576 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.keyfile
);
1580 case IDC_LSTATASCII
:
1582 if (HIWORD(wParam
) == BN_CLICKED
||
1583 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1584 if (IsDlgButtonChecked (hwnd
, IDC_LSTATOFF
)) cfg
.logtype
= 0;
1585 if (IsDlgButtonChecked (hwnd
, IDC_LSTATASCII
)) cfg
.logtype
= 1;
1586 if (IsDlgButtonChecked (hwnd
, IDC_LSTATRAW
)) cfg
.logtype
= 2;
1591 if (HIWORD(wParam
) == EN_CHANGE
)
1592 GetDlgItemText (hwnd
, LOWORD(wParam
), cfg
.termspeed
,
1593 sizeof(cfg
.termspeed
)-1);
1596 if (HIWORD(wParam
) == EN_CHANGE
)
1597 GetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
,
1598 sizeof(cfg
.username
)-1);
1600 case IDC_RLLUSEREDIT
:
1601 if (HIWORD(wParam
) == EN_CHANGE
)
1602 GetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
,
1603 sizeof(cfg
.localusername
)-1);
1607 cfg
.rfc_environ
= IsDlgButtonChecked (hwnd
, IDC_EMRFC
);
1610 if (HIWORD(wParam
) == BN_CLICKED
||
1611 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1612 char str
[sizeof(cfg
.environmt
)];
1614 GetDlgItemText (hwnd
, IDC_VAREDIT
, str
, sizeof(str
)-1);
1619 p
= str
+ strlen(str
);
1621 GetDlgItemText (hwnd
, IDC_VALEDIT
, p
, sizeof(str
)-1-(p
-str
));
1631 if ((p
-cfg
.environmt
) + strlen(str
) + 2 < sizeof(cfg
.environmt
)) {
1633 p
[strlen(str
)+1] = '\0';
1634 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
1636 SetDlgItemText (hwnd
, IDC_VAREDIT
, "");
1637 SetDlgItemText (hwnd
, IDC_VALEDIT
, "");
1639 MessageBox(hwnd
, "Environment too big", "PuTTY Error",
1640 MB_OK
| MB_ICONERROR
);
1645 if (HIWORD(wParam
) != BN_CLICKED
&&
1646 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1648 i
= SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0, 0);
1654 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
1679 if (HIWORD(wParam
) == BN_CLICKED
||
1680 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1681 cfg
.nopty
= IsDlgButtonChecked (hwnd
, IDC_NOPTY
);
1684 if (HIWORD(wParam
) == BN_CLICKED
||
1685 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1686 cfg
.compression
= IsDlgButtonChecked (hwnd
, IDC_COMPRESS
);
1689 if (HIWORD(wParam
) == BN_CLICKED
||
1690 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1691 cfg
.buggymac
= IsDlgButtonChecked (hwnd
, IDC_BUGGYMAC
);
1694 if (HIWORD(wParam
) == BN_CLICKED
||
1695 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1696 cfg
.agentfwd
= IsDlgButtonChecked (hwnd
, IDC_AGENTFWD
);
1698 case IDC_CIPHER3DES
:
1699 case IDC_CIPHERBLOWF
:
1701 if (HIWORD(wParam
) == BN_CLICKED
||
1702 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1703 if (IsDlgButtonChecked (hwnd
, IDC_CIPHER3DES
))
1704 cfg
.cipher
= CIPHER_3DES
;
1705 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERBLOWF
))
1706 cfg
.cipher
= CIPHER_BLOWFISH
;
1707 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERDES
))
1708 cfg
.cipher
= CIPHER_DES
;
1713 if (HIWORD(wParam
) == BN_CLICKED
||
1714 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1715 if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT1
))
1717 else if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT2
))
1722 if (HIWORD(wParam
) == BN_CLICKED
||
1723 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1724 cfg
.try_tis_auth
= IsDlgButtonChecked (hwnd
, IDC_AUTHTIS
);
1727 if (HIWORD(wParam
) == EN_CHANGE
)
1728 GetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
1729 sizeof(cfg
.keyfile
)-1);
1732 if (HIWORD(wParam
) == EN_CHANGE
)
1733 GetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
1734 sizeof(cfg
.remote_cmd
)-1);
1737 memset(&of
, 0, sizeof(of
));
1738 #ifdef OPENFILENAME_SIZE_VERSION_400
1739 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1741 of
.lStructSize
= sizeof(of
);
1743 of
.hwndOwner
= hwnd
;
1744 of
.lpstrFilter
= "All Files\0*\0\0\0";
1745 of
.lpstrCustomFilter
= NULL
;
1746 of
.nFilterIndex
= 1;
1747 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1748 of
.nMaxFile
= sizeof(filename
);
1749 of
.lpstrFileTitle
= NULL
;
1750 of
.lpstrInitialDir
= NULL
;
1751 of
.lpstrTitle
= "Select Public Key File";
1753 if (GetOpenFileName(&of
)) {
1754 strcpy(cfg
.keyfile
, filename
);
1755 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1760 cfg
.mouse_is_xterm
= IsDlgButtonChecked (hwnd
, IDC_MBXTERM
);
1766 int n
= GetDlgItemInt (hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
1771 for (i
=0; i
<256; i
++)
1772 if (SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_GETSEL
,
1775 cfg
.wordness
[i
] = n
;
1776 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1777 LB_DELETESTRING
, i
, 0);
1778 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
1779 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
1781 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1788 case IDC_BOLDCOLOUR
:
1789 if (HIWORD(wParam
) == BN_CLICKED
||
1790 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1792 cfg
.bold_colour
= IsDlgButtonChecked (hwnd
, IDC_BOLDCOLOUR
);
1793 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
1794 if (n
!= 12+10*cfg
.bold_colour
) {
1796 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1797 LB_DELETESTRING
, i
, 0);
1798 for (i
=0; i
<22; i
++)
1799 if (cfg
.bold_colour
|| permcolour
[i
])
1800 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1802 (LPARAM
) colours
[i
]);
1807 if (HIWORD(wParam
) == BN_CLICKED
||
1808 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1809 cfg
.try_palette
= IsDlgButtonChecked (hwnd
, IDC_PALETTE
);
1811 case IDC_COLOURLIST
:
1812 if (HIWORD(wParam
) == LBN_DBLCLK
||
1813 HIWORD(wParam
) == LBN_SELCHANGE
) {
1814 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1816 if (!cfg
.bold_colour
)
1817 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1818 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0], FALSE
);
1819 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1], FALSE
);
1820 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2], FALSE
);
1824 if (HIWORD(wParam
) == BN_CLICKED
||
1825 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1826 static CHOOSECOLOR cc
;
1827 static DWORD custom
[16] = {0}; /* zero initialisers */
1828 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1830 if (!cfg
.bold_colour
)
1831 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1832 cc
.lStructSize
= sizeof(cc
);
1833 cc
.hwndOwner
= hwnd
;
1834 cc
.hInstance
= (HWND
)hinst
;
1835 cc
.lpCustColors
= custom
;
1836 cc
.rgbResult
= RGB (cfg
.colours
[i
][0], cfg
.colours
[i
][1],
1838 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
1839 if (ChooseColor(&cc
)) {
1841 (unsigned char) (cc
.rgbResult
& 0xFF);
1843 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
1845 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
1846 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
1848 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
1850 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
1856 case IDC_KOI8WIN1251
:
1857 case IDC_88592WIN1250
:
1858 case IDC_88592CP852
:
1859 cfg
.xlat_enablekoiwin
=
1860 IsDlgButtonChecked (hwnd
, IDC_KOI8WIN1251
);
1861 cfg
.xlat_88592w1250
=
1862 IsDlgButtonChecked (hwnd
, IDC_88592WIN1250
);
1863 cfg
.xlat_88592cp852
=
1864 IsDlgButtonChecked (hwnd
, IDC_88592CP852
);
1866 case IDC_CAPSLOCKCYR
:
1867 if (HIWORD(wParam
) == BN_CLICKED
||
1868 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1869 cfg
.xlat_capslockcyr
=
1870 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
1873 case IDC_VTXWINDOWS
:
1878 (IsDlgButtonChecked (hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
:
1879 IsDlgButtonChecked (hwnd
, IDC_VTOEMANSI
) ? VT_OEMANSI
:
1880 IsDlgButtonChecked (hwnd
, IDC_VTOEMONLY
) ? VT_OEMONLY
:
1883 case IDC_X11_FORWARD
:
1884 if (HIWORD(wParam
) == BN_CLICKED
||
1885 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1886 cfg
.x11_forward
= IsDlgButtonChecked (hwnd
, IDC_X11_FORWARD
);
1888 case IDC_X11_DISPLAY
:
1889 if (HIWORD(wParam
) == EN_CHANGE
)
1890 GetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
1891 sizeof(cfg
.x11_display
)-1);
1896 EndDialog (hwnd
, 0);
1899 /* Grrr Explorer will maximize Dialogs! */
1901 if (wParam
== SIZE_MAXIMIZED
)
1908 static int CALLBACK
MainDlgProc (HWND hwnd
, UINT msg
,
1909 WPARAM wParam
, LPARAM lParam
) {
1910 static HWND page
= NULL
;
1912 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
1914 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
1915 EnableWindow(hwnd
, 0);
1916 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1917 GetParent(hwnd
), AboutProc
);
1918 EnableWindow(hwnd
, 1);
1919 SetActiveWindow(hwnd
);
1921 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 0);
1924 static int CALLBACK
ReconfDlgProc (HWND hwnd
, UINT msg
,
1925 WPARAM wParam
, LPARAM lParam
) {
1927 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 1);
1930 void defuse_showwindow(void) {
1932 * Work around the fact that the app's first call to ShowWindow
1933 * will ignore the default in favour of the shell-provided
1938 hwnd
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1940 ShowWindow(hwnd
, SW_HIDE
);
1941 DestroyWindow(hwnd
);
1945 int do_config (void) {
1949 savedsession
[0] = '\0';
1950 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
1951 get_sesslist(FALSE
);
1956 int do_reconfig (HWND hwnd
) {
1960 backup_cfg
= cfg
; /* structure copy */
1961 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
1963 cfg
= backup_cfg
; /* structure copy */
1968 void logevent (char *string
) {
1969 if (nevents
>= negsize
) {
1971 events
= srealloc (events
, negsize
* sizeof(*events
));
1973 events
[nevents
] = smalloc(1+strlen(string
));
1974 strcpy (events
[nevents
], string
);
1978 SendDlgItemMessage (logbox
, IDN_LIST
, LB_ADDSTRING
,
1980 count
= SendDlgItemMessage (logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
1981 SendDlgItemMessage (logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
-1, 0);
1985 void showeventlog (HWND hwnd
) {
1987 logbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
1989 ShowWindow (logbox
, SW_SHOWNORMAL
);
1993 void showabout (HWND hwnd
) {
1995 abtbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1997 ShowWindow (abtbox
, SW_SHOWNORMAL
);
2001 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2002 char *keystr
, char *fingerprint
) {
2005 static const char absentmsg
[] =
2006 "The server's host key is not cached in the registry. You\n"
2007 "have no guarantee that the server is the computer you\n"
2009 "The server's key fingerprint is:\n"
2011 "If you trust this host, hit Yes to add the key to\n"
2012 "PuTTY's cache and carry on connecting.\n"
2013 "If you do not trust this host, hit No to abandon the\n"
2016 static const char wrongmsg
[] =
2017 "WARNING - POTENTIAL SECURITY BREACH!\n"
2019 "The server's host key does not match the one PuTTY has\n"
2020 "cached in the registry. This means that either the\n"
2021 "server administrator has changed the host key, or you\n"
2022 "have actually connected to another computer pretending\n"
2023 "to be the server.\n"
2024 "The new key fingerprint is:\n"
2026 "If you were expecting this change and trust the new key,\n"
2027 "hit Yes to update PuTTY's cache and continue connecting.\n"
2028 "If you want to carry on connecting but without updating\n"
2029 "the cache, hit No.\n"
2030 "If you want to abandon the connection completely, hit\n"
2031 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2034 static const char mbtitle
[] = "PuTTY Security Alert";
2037 char message
[160+ /* sensible fingerprint max size */
2038 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2039 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2042 * Verify the key against the registry.
2044 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2046 if (ret
== 0) /* success - key matched OK */
2048 if (ret
== 2) { /* key was different */
2050 sprintf(message
, wrongmsg
, fingerprint
);
2051 mbret
= MessageBox(NULL
, message
, mbtitle
,
2052 MB_ICONWARNING
| MB_YESNOCANCEL
);
2054 store_host_key(host
, port
, keytype
, keystr
);
2055 if (mbret
== IDCANCEL
)
2058 if (ret
== 1) { /* key was absent */
2060 sprintf(message
, absentmsg
, fingerprint
);
2061 mbret
= MessageBox(NULL
, message
, mbtitle
,
2062 MB_ICONWARNING
| MB_YESNO
);
2065 store_host_key(host
, port
, keytype
, keystr
);
2070 * Ask whether to wipe a session log file before writing to it.
2071 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2073 int askappend(char *filename
) {
2074 static const char mbtitle
[] = "PuTTY Log to File";
2075 static const char msgtemplate
[] =
2076 "The session log file \"%.*s\" already exists.\n"
2077 "You can overwrite it with a new session log,\n"
2078 "append your session log to the end of it,\n"
2079 "or disable session logging for this session.\n"
2080 "Hit Yes to wipe the file, No to append to it,\n"
2081 "or Cancel to disable logging.";
2082 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2084 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2086 mbret
= MessageBox(NULL
, message
, mbtitle
,
2087 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2090 else if (mbret
== IDNO
)