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
,
278 IDC_BOX_APPEARANCE4
, IDC_BOXT_APPEARANCE4
,
292 connectionpanelstart
,
293 IDC_TITLE_CONNECTION
,
294 IDC_BOX_CONNECTION1
, IDC_BOXT_CONNECTION1
,
295 IDC_BOX_CONNECTION2
, IDC_BOXT_CONNECTION2
,
306 IDC_BOX_TELNET1
, IDC_BOXT_TELNET1
,
307 IDC_BOX_TELNET2
, IDC_BOXT_TELNET2
,
325 IDC_BOX_RLOGIN1
, IDC_BOXT_RLOGIN1
,
326 IDC_BOX_RLOGIN2
, IDC_BOXT_RLOGIN2
,
335 IDC_BOX_SSH1
, IDC_BOXT_SSH1
,
336 IDC_BOX_SSH2
, IDC_BOXT_SSH2
,
337 IDC_BOX_SSH3
, IDC_BOXT_SSH3
,
359 IDC_BOX_SELECTION1
, IDC_BOXT_SELECTION1
,
360 IDC_BOX_SELECTION2
, IDC_BOXT_SELECTION2
,
373 IDC_BOX_COLOURS1
, IDC_BOXT_COLOURS1
,
374 IDC_BOX_COLOURS2
, IDC_BOXT_COLOURS2
,
388 translationpanelstart
,
389 IDC_TITLE_TRANSLATION
,
390 IDC_BOX_TRANSLATION1
, IDC_BOXT_TRANSLATION1
,
391 IDC_BOX_TRANSLATION2
, IDC_BOXT_TRANSLATION2
,
392 IDC_BOX_TRANSLATION3
, IDC_BOXT_TRANSLATION3
,
408 IDC_BOX_TUNNELS
, IDC_BOXT_TUNNELS
,
417 static const char *const colours
[] = {
418 "Default Foreground", "Default Bold Foreground",
419 "Default Background", "Default Bold Background",
420 "Cursor Text", "Cursor Colour",
421 "ANSI Black", "ANSI Black Bold",
422 "ANSI Red", "ANSI Red Bold",
423 "ANSI Green", "ANSI Green Bold",
424 "ANSI Yellow", "ANSI Yellow Bold",
425 "ANSI Blue", "ANSI Blue Bold",
426 "ANSI Magenta", "ANSI Magenta Bold",
427 "ANSI Cyan", "ANSI Cyan Bold",
428 "ANSI White", "ANSI White Bold"
430 static const int permcolour
[] = {
431 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, TRUE
,
432 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
,
433 TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
, TRUE
, FALSE
436 static void fmtfont (char *buf
) {
437 sprintf (buf
, "Font: %s, ", cfg
.font
);
439 strcat(buf
, "bold, ");
440 if (cfg
.fontheight
== 0)
441 strcat (buf
, "default height");
443 sprintf (buf
+strlen(buf
), "%d-%s",
444 (cfg
.fontheight
< 0 ?
-cfg
.fontheight
: cfg
.fontheight
),
445 (cfg
.fontheight
< 0 ?
"pixel" : "point"));
448 static void init_dlg_ctrls(HWND hwnd
) {
450 char fontstatic
[256];
452 SetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
);
453 SetDlgItemText (hwnd
, IDC_SESSEDIT
, savedsession
);
454 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
455 CheckRadioButton (hwnd
, IDC_PROTRAW
, IDC_PROTSSH
,
456 cfg
.protocol
==PROT_SSH ? IDC_PROTSSH
:
457 cfg
.protocol
==PROT_TELNET ? IDC_PROTTELNET
:
458 cfg
.protocol
==PROT_RLOGIN ? IDC_PROTRLOGIN
: IDC_PROTRAW
);
459 SetDlgItemInt (hwnd
, IDC_PINGEDIT
, cfg
.ping_interval
, FALSE
);
461 CheckRadioButton (hwnd
, IDC_DEL008
, IDC_DEL127
,
462 cfg
.bksp_is_delete ? IDC_DEL127
: IDC_DEL008
);
463 CheckRadioButton (hwnd
, IDC_HOMETILDE
, IDC_HOMERXVT
,
464 cfg
.rxvt_homeend ? IDC_HOMERXVT
: IDC_HOMETILDE
);
465 CheckRadioButton (hwnd
, IDC_FUNCTILDE
, IDC_FUNCVT400
,
466 cfg
.funky_type
== 0 ? IDC_FUNCTILDE
:
467 cfg
.funky_type
== 1 ? IDC_FUNCLINUX
:
468 cfg
.funky_type
== 2 ? IDC_FUNCXTERM
:
469 cfg
.funky_type
== 3 ? IDC_FUNCVT400
:
471 CheckDlgButton (hwnd
, IDC_NOAPPLICC
, cfg
.no_applic_c
);
472 CheckDlgButton (hwnd
, IDC_NOAPPLICK
, cfg
.no_applic_k
);
473 CheckRadioButton (hwnd
, IDC_CURNORMAL
, IDC_CURAPPLIC
,
474 cfg
.app_cursor ? IDC_CURAPPLIC
: IDC_CURNORMAL
);
475 CheckRadioButton (hwnd
, IDC_KPNORMAL
, IDC_KPNH
,
476 cfg
.nethack_keypad ? IDC_KPNH
:
477 cfg
.app_keypad ? IDC_KPAPPLIC
: IDC_KPNORMAL
);
478 CheckDlgButton (hwnd
, IDC_ALTF4
, cfg
.alt_f4
);
479 CheckDlgButton (hwnd
, IDC_ALTSPACE
, cfg
.alt_space
);
480 CheckDlgButton (hwnd
, IDC_ALTONLY
, cfg
.alt_only
);
481 CheckDlgButton (hwnd
, IDC_COMPOSEKEY
, cfg
.compose_key
);
482 CheckDlgButton (hwnd
, IDC_LDISCTERM
, cfg
.ldisc_term
);
483 CheckDlgButton (hwnd
, IDC_ALWAYSONTOP
, cfg
.alwaysontop
);
484 CheckDlgButton (hwnd
, IDC_SCROLLKEY
, cfg
.scroll_on_key
);
485 CheckDlgButton (hwnd
, IDC_SCROLLDISP
, cfg
.scroll_on_disp
);
487 CheckDlgButton (hwnd
, IDC_WRAPMODE
, cfg
.wrap_mode
);
488 CheckDlgButton (hwnd
, IDC_DECOM
, cfg
.dec_om
);
489 CheckDlgButton (hwnd
, IDC_LFHASCR
, cfg
.lfhascr
);
490 SetDlgItemInt (hwnd
, IDC_ROWSEDIT
, cfg
.height
, FALSE
);
491 SetDlgItemInt (hwnd
, IDC_COLSEDIT
, cfg
.width
, FALSE
);
492 SetDlgItemInt (hwnd
, IDC_SAVEEDIT
, cfg
.savelines
, FALSE
);
493 fmtfont (fontstatic
);
494 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
495 CheckDlgButton (hwnd
, IDC_BEEP
, cfg
.beep
);
496 CheckDlgButton (hwnd
, IDC_BCE
, cfg
.bce
);
497 CheckDlgButton (hwnd
, IDC_BLINKTEXT
, cfg
.blinktext
);
499 SetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
);
500 CheckDlgButton (hwnd
, IDC_WINNAME
, cfg
.win_name_always
);
501 CheckDlgButton (hwnd
, IDC_HIDEMOUSE
, cfg
.hide_mouseptr
);
502 CheckRadioButton (hwnd
, IDC_CURBLOCK
, IDC_CURVERT
,
503 cfg
.cursor_type
==0 ? IDC_CURBLOCK
:
504 cfg
.cursor_type
==1 ? IDC_CURUNDER
: IDC_CURVERT
);
505 CheckDlgButton (hwnd
, IDC_BLINKCUR
, cfg
.blink_cur
);
506 CheckDlgButton (hwnd
, IDC_SCROLLBAR
, cfg
.scrollbar
);
507 CheckDlgButton (hwnd
, IDC_LOCKSIZE
, cfg
.locksize
);
508 CheckDlgButton (hwnd
, IDC_CLOSEEXIT
, cfg
.close_on_exit
);
509 CheckDlgButton (hwnd
, IDC_CLOSEWARN
, cfg
.warn_on_close
);
511 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
512 SetDlgItemText (hwnd
, IDC_TSEDIT
, cfg
.termspeed
);
513 SetDlgItemText (hwnd
, IDC_R_TSEDIT
, cfg
.termspeed
);
514 SetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
);
515 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
516 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
);
517 CheckRadioButton(hwnd
, IDC_LSTATOFF
, IDC_LSTATRAW
,
518 cfg
.logtype
== 0 ? IDC_LSTATOFF
:
519 cfg
.logtype
== 1 ? IDC_LSTATASCII
:
522 char *p
= cfg
.environmt
;
524 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
, 0,
529 CheckRadioButton (hwnd
, IDC_EMBSD
, IDC_EMRFC
,
530 cfg
.rfc_environ ? IDC_EMRFC
: IDC_EMBSD
);
532 SetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
);
533 SetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
);
534 CheckDlgButton (hwnd
, IDC_NOPTY
, cfg
.nopty
);
535 CheckDlgButton (hwnd
, IDC_COMPRESS
, cfg
.compression
);
536 CheckDlgButton (hwnd
, IDC_BUGGYMAC
, cfg
.buggymac
);
537 CheckDlgButton (hwnd
, IDC_AGENTFWD
, cfg
.agentfwd
);
538 CheckRadioButton (hwnd
, IDC_CIPHER3DES
, IDC_CIPHERDES
,
539 cfg
.cipher
== CIPHER_BLOWFISH ? IDC_CIPHERBLOWF
:
540 cfg
.cipher
== CIPHER_DES ? IDC_CIPHERDES
:
542 CheckRadioButton (hwnd
, IDC_SSHPROT1
, IDC_SSHPROT2
,
543 cfg
.sshprot
== 1 ? IDC_SSHPROT1
: IDC_SSHPROT2
);
544 CheckDlgButton (hwnd
, IDC_AUTHTIS
, cfg
.try_tis_auth
);
545 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
546 SetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
);
548 CheckRadioButton (hwnd
, IDC_MBWINDOWS
, IDC_MBXTERM
,
549 cfg
.mouse_is_xterm ? IDC_MBXTERM
: IDC_MBWINDOWS
);
551 static int tabs
[4] = {25, 61, 96, 128};
552 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_SETTABSTOPS
, 4,
555 for (i
=0; i
<256; i
++) {
557 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
558 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
560 SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_ADDSTRING
, 0,
564 CheckDlgButton (hwnd
, IDC_BOLDCOLOUR
, cfg
.bold_colour
);
565 CheckDlgButton (hwnd
, IDC_PALETTE
, cfg
.try_palette
);
568 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
570 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
571 LB_DELETESTRING
, i
, 0);
573 if (cfg
.bold_colour
|| permcolour
[i
])
574 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_ADDSTRING
, 0,
575 (LPARAM
) colours
[i
]);
577 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_SETCURSEL
, 0, 0);
578 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[0][0], FALSE
);
579 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[0][1], FALSE
);
580 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[0][2], FALSE
);
582 CheckRadioButton (hwnd
, IDC_NOXLAT
, IDC_88592CP852
,
583 cfg
.xlat_88592w1250 ? IDC_88592WIN1250
:
584 cfg
.xlat_88592cp852 ? IDC_88592CP852
:
585 cfg
.xlat_enablekoiwin ? IDC_KOI8WIN1251
:
587 CheckDlgButton (hwnd
, IDC_CAPSLOCKCYR
, cfg
.xlat_capslockcyr
);
588 CheckRadioButton (hwnd
, IDC_VTXWINDOWS
, IDC_VTPOORMAN
,
589 cfg
.vtmode
== VT_XWINDOWS ? IDC_VTXWINDOWS
:
590 cfg
.vtmode
== VT_OEMANSI ? IDC_VTOEMANSI
:
591 cfg
.vtmode
== VT_OEMONLY ? IDC_VTOEMONLY
:
594 CheckDlgButton (hwnd
, IDC_X11_FORWARD
, cfg
.x11_forward
);
595 SetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
);
598 static void hide(HWND hwnd
, int hide
, int minid
, int maxid
) {
600 for (i
= minid
; i
< maxid
; i
++) {
601 HWND ctl
= GetDlgItem(hwnd
, i
);
604 EnableWindow(ctl
, 1);
605 ShowWindow(ctl
, hide ? SW_HIDE
: SW_SHOW
);
607 EnableWindow(ctl
, 0);
612 struct treeview_faff
{
617 static HTREEITEM
treeview_insert(struct treeview_faff
*faff
,
618 int level
, char *text
) {
622 ins
.hParent
= (level
> 0 ? faff
->lastat
[level
-1] : TVI_ROOT
);
623 ins
.hInsertAfter
= faff
->lastat
[level
];
624 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
625 #define INSITEM DUMMYUNIONNAME.item
629 ins
.INSITEM
.mask
= TVIF_TEXT
;
630 ins
.INSITEM
.pszText
= text
;
631 newitem
= TreeView_InsertItem(faff
->treeview
, &ins
);
633 TreeView_Expand(faff
->treeview
, faff
->lastat
[level
-1], TVE_EXPAND
);
634 faff
->lastat
[level
] = newitem
;
635 for (i
= level
+1; i
< 4; i
++) faff
->lastat
[i
] = NULL
;
640 * This _huge_ function is the configuration box.
642 static int GenericMainDlgProc (HWND hwnd
, UINT msg
,
643 WPARAM wParam
, LPARAM lParam
,
646 struct treeview_faff tvfaff
;
649 char filename
[sizeof(cfg
.keyfile
)];
652 char fontstatic
[256];
654 struct servent
* service
;
660 SetWindowLong(hwnd
, GWL_USERDATA
, 0);
664 { /* centre the window */
667 hw
= GetDesktopWindow();
668 if (GetWindowRect (hw
, &rs
) && GetWindowRect (hwnd
, &rd
))
669 MoveWindow (hwnd
, (rs
.right
+ rs
.left
+ rd
.left
- rd
.right
)/2,
670 (rs
.bottom
+ rs
.top
+ rd
.top
- rd
.bottom
)/2,
671 rd
.right
-rd
.left
, rd
.bottom
-rd
.top
, TRUE
);
675 * Create the tree view.
682 r
.left
= 3; r
.right
= r
.left
+ 75;
683 r
.top
= 3; r
.bottom
= r
.top
+ 10;
684 MapDialogRect(hwnd
, &r
);
685 tvstatic
= CreateWindowEx(0, "STATIC", "Cate&gory:",
686 WS_CHILD
| WS_VISIBLE
,
688 r
.right
-r
.left
, r
.bottom
-r
.top
,
689 hwnd
, (HMENU
)IDCX_TVSTATIC
, hinst
, NULL
);
690 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
691 SendMessage(tvstatic
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
693 r
.left
= 3; r
.right
= r
.left
+ 75;
694 r
.top
= 13; r
.bottom
= r
.top
+ 206;
695 MapDialogRect(hwnd
, &r
);
696 treeview
= CreateWindowEx(WS_EX_CLIENTEDGE
, WC_TREEVIEW
, "",
697 WS_CHILD
| WS_VISIBLE
|
698 WS_TABSTOP
| TVS_HASLINES
|
699 TVS_DISABLEDRAGDROP
| TVS_HASBUTTONS
|
700 TVS_LINESATROOT
| TVS_SHOWSELALWAYS
,
702 r
.right
-r
.left
, r
.bottom
-r
.top
,
703 hwnd
, (HMENU
)IDCX_TREEVIEW
, hinst
, NULL
);
704 font
= SendMessage(hwnd
, WM_GETFONT
, 0, 0);
705 SendMessage(treeview
, WM_SETFONT
, font
, MAKELPARAM(TRUE
, 0));
706 tvfaff
.treeview
= treeview
;
707 memset(tvfaff
.lastat
, 0, sizeof(tvfaff
.lastat
));
711 * Create the various panelfuls of controls.
714 /* The Session panel. Accelerators used: [acgo] nprthelsdx */
717 ctlposinit(&cp
, hwnd
, 80, 3, 13);
718 bartitle(&cp
, "Basic options for your PuTTY session",
721 beginbox(&cp
, "Specify your connection by host name",
722 IDC_BOX_SESSION1
, IDC_BOXT_SESSION1
);
724 "Host &Name", IDC_HOSTSTATIC
, IDC_HOST
, 75,
725 "&Port", IDC_PORTSTATIC
, IDC_PORT
, 25, NULL
);
726 if (backends
[3].backend
== NULL
) {
727 /* this is PuTTYtel, so only two protocols available */
728 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
730 "&Telnet", IDC_PROTTELNET
,
731 "R&login", IDC_PROTRLOGIN
, NULL
);
733 radioline(&cp
, "Protocol:", IDC_PROTSTATIC
, 4,
735 "&Telnet", IDC_PROTTELNET
,
736 "R&login", IDC_PROTRLOGIN
,
745 beginbox(&cp
, "Load, save or delete a stored session",
746 IDC_BOX_SESSION2
, IDC_BOXT_SESSION2
);
747 sesssaver(&cp
, "Sav&ed Sessions",
748 IDC_SESSSTATIC
, IDC_SESSEDIT
, IDC_SESSLIST
,
749 "&Load", IDC_SESSLOAD
,
750 "&Save", IDC_SESSSAVE
,
751 "&Delete", IDC_SESSDEL
, NULL
);
754 beginbox(&cp
, NULL
, IDC_BOX_SESSION3
, 0);
755 checkbox(&cp
, "Close Window on E&xit", IDC_CLOSEEXIT
);
758 hsession
= treeview_insert(&tvfaff
, 0, "Session");
761 /* The Terminal panel. Accelerators used: [acgo] &dflbenuw */
764 ctlposinit(&cp
, hwnd
, 80, 3, 13);
765 bartitle(&cp
, "Options controlling the terminal emulation",
767 beginbox(&cp
, "Set various terminal options",
768 IDC_BOX_TERMINAL1
, IDC_BOXT_TERMINAL1
);
769 checkbox(&cp
, "Auto &wrap mode initially on", IDC_WRAPMODE
);
770 checkbox(&cp
, "&DEC Origin Mode initially on", IDC_DECOM
);
771 checkbox(&cp
, "Implicit CR in every &LF", IDC_LFHASCR
);
772 checkbox(&cp
, "&Beep enabled", IDC_BEEP
);
773 checkbox(&cp
, "Use background colour to &erase screen", IDC_BCE
);
774 checkbox(&cp
, "Enable bli&nking text", IDC_BLINKTEXT
);
775 checkbox(&cp
, "&Use local terminal line discipline", IDC_LDISCTERM
);
778 beginbox(&cp
, "Control session logging",
779 IDC_BOX_TERMINAL2
, IDC_BOXT_TERMINAL2
);
781 "Session logging:", IDC_LSTATSTATIC
,
782 "Logging turned &off completely", IDC_LSTATOFF
,
783 "Log printable output only", IDC_LSTATASCII
,
784 "Log all session output", IDC_LSTATRAW
, NULL
);
785 editbutton(&cp
, "Log &file name:",
786 IDC_LGFSTATIC
, IDC_LGFEDIT
, "Bro&wse...",
790 treeview_insert(&tvfaff
, 0, "Terminal");
793 /* The Keyboard panel. Accelerators used: [acgo] h?srvlxvnpmietu */
796 ctlposinit(&cp
, hwnd
, 80, 3, 13);
797 bartitle(&cp
, "Options controlling the effects of keys",
799 beginbox(&cp
, "Change the sequences sent by:",
800 IDC_BOX_KEYBOARD1
, IDC_BOXT_KEYBOARD1
);
801 radioline(&cp
, "The Backspace key", IDC_DELSTATIC
, 2,
802 "Control-&H", IDC_DEL008
,
803 "Control-&? (127)", IDC_DEL127
, NULL
);
804 radioline(&cp
, "The Home and End keys", IDC_HOMESTATIC
, 2,
805 "&Standard", IDC_HOMETILDE
,
806 "&rxvt", IDC_HOMERXVT
, NULL
);
807 radioline(&cp
, "The Function keys and keypad", IDC_FUNCSTATIC
, 4,
808 "ESC[n&~", IDC_FUNCTILDE
,
809 "&Linux", IDC_FUNCLINUX
,
810 "&Xterm R6", IDC_FUNCXTERM
,
811 "&VT400", IDC_FUNCVT400
, NULL
);
813 beginbox(&cp
, "Application keypad settings:",
814 IDC_BOX_KEYBOARD2
, IDC_BOXT_KEYBOARD2
);
816 "Application c&ursor keys totally disabled",
818 radioline(&cp
, "Initial state of cursor keys:", IDC_CURSTATIC
, 2,
819 "&Normal", IDC_CURNORMAL
,
820 "A&pplication", IDC_CURAPPLIC
, NULL
);
822 "Application ke&ypad keys totally disabled",
824 radioline(&cp
, "Initial state of numeric keypad:", IDC_KPSTATIC
, 3,
825 "Nor&mal", IDC_KPNORMAL
,
826 "Appl&ication", IDC_KPAPPLIC
,
827 "N&etHack", IDC_KPNH
, NULL
);
829 beginbox(&cp
, "Enable extra keyboard features:",
830 IDC_BOX_KEYBOARD3
, IDC_BOXT_KEYBOARD3
);
831 checkbox(&cp
, "Application and AltGr ac&t as Compose key",
835 treeview_insert(&tvfaff
, 1, "Keyboard");
838 /* The Window panel. Accelerators used: [acgo] bsdkw4ylpt */
841 ctlposinit(&cp
, hwnd
, 80, 3, 13);
842 bartitle(&cp
, "Options controlling PuTTY's window",
844 beginbox(&cp
, "Set the size of the window",
845 IDC_BOX_WINDOW1
, IDC_BOXT_WINDOW1
);
847 "&Rows", IDC_ROWSSTATIC
, IDC_ROWSEDIT
, 50,
848 "Colu&mns", IDC_COLSSTATIC
, IDC_COLSEDIT
, 50,
850 checkbox(&cp
, "Loc&k window size against resizing", IDC_LOCKSIZE
);
852 beginbox(&cp
, "Control the scrollback in the window",
853 IDC_BOX_WINDOW2
, IDC_BOXT_WINDOW2
);
854 staticedit(&cp
, "Lines of &scrollback",
855 IDC_SAVESTATIC
, IDC_SAVEEDIT
, 50);
856 checkbox(&cp
, "&Display scrollbar", IDC_SCROLLBAR
);
857 checkbox(&cp
, "Reset scrollback on &keypress", IDC_SCROLLKEY
);
858 checkbox(&cp
, "Reset scrollback on dis&play activity",
861 beginbox(&cp
, NULL
, IDC_BOX_WINDOW3
, 0);
862 checkbox(&cp
, "&Warn before closing window", IDC_CLOSEWARN
);
863 checkbox(&cp
, "Window closes on ALT-F&4", IDC_ALTF4
);
864 checkbox(&cp
, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE
);
865 checkbox(&cp
, "System menu appears on A< alone", IDC_ALTONLY
);
866 checkbox(&cp
, "Ensure window is always on &top", IDC_ALWAYSONTOP
);
869 treeview_insert(&tvfaff
, 0, "Window");
872 /* The Appearance panel. Accelerators used: [acgo] rmkhtibluv */
875 ctlposinit(&cp
, hwnd
, 80, 3, 13);
876 bartitle(&cp
, "Options controlling PuTTY's appearance",
877 IDC_TITLE_APPEARANCE
);
878 beginbox(&cp
, "Adjust the use of the cursor",
879 IDC_BOX_APPEARANCE1
, IDC_BOXT_APPEARANCE1
);
880 radioline(&cp
, "Cursor appearance:", IDC_CURSORSTATIC
, 3,
881 "B&lock", IDC_CURBLOCK
,
882 "&Underline", IDC_CURUNDER
,
883 "&Vertical line", IDC_CURVERT
,
885 checkbox(&cp
, "Cursor &blinks", IDC_BLINKCUR
);
887 beginbox(&cp
, "Set the font used in the terminal window",
888 IDC_BOX_APPEARANCE2
, IDC_BOXT_APPEARANCE2
);
889 staticbtn(&cp
, "", IDC_FONTSTATIC
, "C&hange...", IDC_CHOOSEFONT
);
891 beginbox(&cp
, "Adjust the use of the window title",
892 IDC_BOX_APPEARANCE3
, IDC_BOXT_APPEARANCE3
);
894 "Window &title:", IDC_WINTITLE
,
895 IDC_WINEDIT
, 100, NULL
);
896 checkbox(&cp
, "Avoid ever using &icon title", IDC_WINNAME
);
898 beginbox(&cp
, "Adjust the use of the mouse pointer",
899 IDC_BOX_APPEARANCE4
, IDC_BOXT_APPEARANCE4
);
900 checkbox(&cp
, "Hide mouse &pointer when typing in window",
904 treeview_insert(&tvfaff
, 1, "Appearance");
907 /* The Translation panel. Accelerators used: [acgo] xbepnkis */
910 ctlposinit(&cp
, hwnd
, 80, 3, 13);
911 bartitle(&cp
, "Options controlling character set translation",
912 IDC_TITLE_TRANSLATION
);
913 beginbox(&cp
, "Adjust how PuTTY displays line drawing characters",
914 IDC_BOX_TRANSLATION1
, IDC_BOXT_TRANSLATION1
);
916 "Handling of line drawing characters:", IDC_VTSTATIC
,
917 "Font has &XWindows encoding", IDC_VTXWINDOWS
,
918 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI
,
919 "Use font in O&EM mode only", IDC_VTOEMONLY
,
920 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
921 IDC_VTPOORMAN
, NULL
);
923 beginbox(&cp
, "Enable character set translation on received data",
924 IDC_BOX_TRANSLATION2
, IDC_BOXT_TRANSLATION2
);
926 "Character set translation:", IDC_XLATSTATIC
,
928 "&KOI8 / Win-1251", IDC_KOI8WIN1251
,
929 "&ISO-8859-2 / Win-1250", IDC_88592WIN1250
,
930 "&ISO-8859-2 / CP852", IDC_88592CP852
, NULL
);
932 beginbox(&cp
, "Enable character set translation on input data",
933 IDC_BOX_TRANSLATION3
, IDC_BOXT_TRANSLATION3
);
934 checkbox(&cp
, "CAP&S LOCK acts as cyrillic switch",
938 treeview_insert(&tvfaff
, 1, "Translation");
941 /* The Selection panel. Accelerators used: [acgo] wxst */
944 ctlposinit(&cp
, hwnd
, 80, 3, 13);
945 bartitle(&cp
, "Options controlling copy and paste",
946 IDC_TITLE_SELECTION
);
947 beginbox(&cp
, "Control which mouse button does which thing",
948 IDC_BOX_SELECTION1
, IDC_BOXT_SELECTION1
);
949 radiobig(&cp
, "Action of mouse buttons:", IDC_MBSTATIC
,
950 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS
,
951 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM
,
954 beginbox(&cp
, "Control the select-one-word-at-a-time mode",
955 IDC_BOX_SELECTION2
, IDC_BOXT_SELECTION2
);
956 charclass(&cp
, "Character classes:", IDC_CCSTATIC
, IDC_CCLIST
,
957 "&Set", IDC_CCSET
, IDC_CCEDIT
,
958 "&to class", IDC_CCSTATIC2
);
961 treeview_insert(&tvfaff
, 1, "Selection");
964 /* The Colours panel. Accelerators used: [acgo] blum */
967 ctlposinit(&cp
, hwnd
, 80, 3, 13);
968 bartitle(&cp
, "Options controlling use of colours",
970 beginbox(&cp
, "General options for colour usage",
971 IDC_BOX_COLOURS1
, IDC_BOXT_COLOURS1
);
972 checkbox(&cp
, "&Bolded text is a different colour", IDC_BOLDCOLOUR
);
973 checkbox(&cp
, "Attempt to use &logical palettes", IDC_PALETTE
);
975 beginbox(&cp
, "Adjust the precise colours PuTTY displays",
976 IDC_BOX_COLOURS2
, IDC_BOXT_COLOURS2
);
977 colouredit(&cp
, "Select a colo&ur and then click to modify it:",
978 IDC_COLOURSTATIC
, IDC_COLOURLIST
,
979 "&Modify...", IDC_CHANGE
,
980 "Red:", IDC_RSTATIC
, IDC_RVALUE
,
981 "Green:", IDC_GSTATIC
, IDC_GVALUE
,
982 "Blue:", IDC_BSTATIC
, IDC_BVALUE
, NULL
);
985 treeview_insert(&tvfaff
, 1, "Colours");
988 /* The Connection panel. Accelerators used: [acgo] tuk */
991 ctlposinit(&cp
, hwnd
, 80, 3, 13);
992 bartitle(&cp
, "Options controlling the connection", IDC_TITLE_CONNECTION
);
994 beginbox(&cp
, "Data to send to the server",
995 IDC_BOX_CONNECTION1
, IDC_BOXT_CONNECTION1
);
996 staticedit(&cp
, "Terminal-&type string", IDC_TTSTATIC
, IDC_TTEDIT
, 50);
997 staticedit(&cp
, "Auto-login &username", IDC_LOGSTATIC
, IDC_LOGEDIT
, 50);
1000 beginbox(&cp
, "Sending of null packets to keep session active",
1001 IDC_BOX_CONNECTION2
, IDC_BOXT_CONNECTION2
);
1002 staticedit(&cp
, "Seconds between &keepalives (0 to turn off)",
1003 IDC_PINGSTATIC
, IDC_PINGEDIT
, 25);
1006 treeview_insert(&tvfaff
, 0, "Connection");
1009 /* The Telnet panel. Accelerators used: [acgo] svldrbf */
1012 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1014 bartitle(&cp
, "Options controlling Telnet connections", IDC_TITLE_TELNET
);
1015 beginbox(&cp
, "Data to send to the server",
1016 IDC_BOX_TELNET1
, IDC_BOXT_TELNET1
);
1017 staticedit(&cp
, "Terminal-&speed string", IDC_TSSTATIC
, IDC_TSEDIT
, 50);
1018 envsetter(&cp
, "Environment variables:", IDC_ENVSTATIC
,
1019 "&Variable", IDC_VARSTATIC
, IDC_VAREDIT
,
1020 "Va&lue", IDC_VALSTATIC
, IDC_VALEDIT
,
1022 "A&dd", IDC_ENVADD
, "&Remove", IDC_ENVREMOVE
);
1024 beginbox(&cp
, "Telnet protocol adjustments",
1025 IDC_BOX_TELNET2
, IDC_BOXT_TELNET2
);
1026 radioline(&cp
, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC
, 2,
1027 "&BSD (commonplace)", IDC_EMBSD
,
1028 "R&FC 1408 (unusual)", IDC_EMRFC
, NULL
);
1031 treeview_insert(&tvfaff
, 1, "Telnet");
1036 /* The Rlogin Panel */
1039 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1041 bartitle(&cp
, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN
);
1042 beginbox(&cp
, "Data to send to the server",
1043 IDC_BOX_RLOGIN1
, IDC_BOXT_RLOGIN1
);
1044 staticedit(&cp
, "Terminal-&speed string", IDC_R_TSSTATIC
, IDC_R_TSEDIT
, 50);
1045 staticedit(&cp
, "&Local username:", IDC_RLLUSERSTATIC
, IDC_RLLUSEREDIT
, 50);
1048 treeview_insert(&tvfaff
, 1, "Rlogin");
1052 /* The SSH panel. Accelerators used: [acgo] rmakwp123bd */
1053 if (backends
[3].backend
!= NULL
) {
1055 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1057 bartitle(&cp
, "Options controlling SSH connections", IDC_TITLE_SSH
);
1058 beginbox(&cp
, "Data to send to the server",
1059 IDC_BOX_SSH1
, IDC_BOXT_SSH1
);
1061 "&Remote command:", IDC_CMDSTATIC
, IDC_CMDEDIT
, 100,
1064 beginbox(&cp
, "Authentication options",
1065 IDC_BOX_SSH2
, IDC_BOXT_SSH2
);
1066 checkbox(&cp
, "Atte&mpt TIS or CryptoCard authentication",
1068 checkbox(&cp
, "Allow &agent forwarding", IDC_AGENTFWD
);
1069 editbutton(&cp
, "Private &key file for authentication:",
1070 IDC_PKSTATIC
, IDC_PKEDIT
, "Bro&wse...", IDC_PKBUTTON
);
1072 beginbox(&cp
, "Protocol options",
1073 IDC_BOX_SSH3
, IDC_BOXT_SSH3
);
1074 checkbox(&cp
, "Don't allocate a &pseudo-terminal", IDC_NOPTY
);
1075 checkbox(&cp
, "Enable compr&ession", IDC_COMPRESS
);
1076 radioline(&cp
, "Preferred SSH protocol version:",
1077 IDC_SSHPROTSTATIC
, 2,
1078 "&1", IDC_SSHPROT1
, "&2", IDC_SSHPROT2
, NULL
);
1079 radioline(&cp
, "Preferred encryption algorithm:", IDC_CIPHERSTATIC
, 3,
1080 "&3DES", IDC_CIPHER3DES
,
1081 "&Blowfish", IDC_CIPHERBLOWF
,
1082 "&DES", IDC_CIPHERDES
, NULL
);
1083 checkbox(&cp
, "Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1087 treeview_insert(&tvfaff
, 1, "SSH");
1090 /* The Tunnels panel. Accelerators used: [acgo] ex */
1093 ctlposinit(&cp
, hwnd
, 80, 3, 13);
1095 bartitle(&cp
, "Options controlling SSH tunnelling",
1097 beginbox(&cp
, "X11 forwarding options",
1098 IDC_BOX_TUNNELS
, IDC_BOXT_TUNNELS
);
1099 checkbox(&cp
, "&Enable X11 forwarding",
1101 multiedit(&cp
, "&X display location", IDC_X11_DISPSTATIC
,
1102 IDC_X11_DISPLAY
, 50, NULL
);
1105 treeview_insert(&tvfaff
, 2, "Tunnels");
1109 init_dlg_ctrls(hwnd
);
1110 for (i
= 0; i
< nsessions
; i
++)
1111 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1112 0, (LPARAM
) (sessions
[i
]));
1115 * Hide all the controls to start with.
1117 hide(hwnd
, TRUE
, controlstartvalue
, controlendvalue
);
1120 * Put the treeview selection on to the Session panel. This
1121 * should also cause unhiding of the relevant controls.
1123 TreeView_SelectItem(treeview
, hsession
);
1126 * Set focus into the first available control.
1130 ctl
= GetDlgItem(hwnd
, IDC_HOST
);
1131 if (!ctl
) ctl
= GetDlgItem(hwnd
, IDC_CLOSEEXIT
);
1135 SetWindowLong(hwnd
, GWL_USERDATA
, 1);
1139 * Button release should trigger WM_OK if there was a
1140 * previous double click on the session list.
1144 SendMessage (hwnd
, WM_COMMAND
, IDOK
, 0);
1147 if (LOWORD(wParam
) == IDCX_TREEVIEW
&&
1148 ((LPNMHDR
)lParam
)->code
== TVN_SELCHANGED
) {
1149 HTREEITEM i
= TreeView_GetSelection(((LPNMHDR
)lParam
)->hwndFrom
);
1153 item
.pszText
= buffer
;
1154 item
.cchTextMax
= sizeof(buffer
);
1155 item
.mask
= TVIF_TEXT
;
1156 TreeView_GetItem(((LPNMHDR
)lParam
)->hwndFrom
, &item
);
1157 hide(hwnd
, TRUE
, controlstartvalue
, controlendvalue
);
1158 if (!strcmp(buffer
, "Session"))
1159 hide(hwnd
, FALSE
, sessionpanelstart
, sessionpanelend
);
1160 if (!strcmp(buffer
, "Keyboard"))
1161 hide(hwnd
, FALSE
, keyboardpanelstart
, keyboardpanelend
);
1162 if (!strcmp(buffer
, "Terminal"))
1163 hide(hwnd
, FALSE
, terminalpanelstart
, terminalpanelend
);
1164 if (!strcmp(buffer
, "Window"))
1165 hide(hwnd
, FALSE
, windowpanelstart
, windowpanelend
);
1166 if (!strcmp(buffer
, "Appearance"))
1167 hide(hwnd
, FALSE
, appearancepanelstart
, appearancepanelend
);
1168 if (!strcmp(buffer
, "Tunnels"))
1169 hide(hwnd
, FALSE
, tunnelspanelstart
, tunnelspanelend
);
1170 if (!strcmp(buffer
, "Connection"))
1171 hide(hwnd
, FALSE
, connectionpanelstart
, connectionpanelend
);
1172 if (!strcmp(buffer
, "Telnet"))
1173 hide(hwnd
, FALSE
, telnetpanelstart
, telnetpanelend
);
1174 if (!strcmp(buffer
, "Rlogin"))
1175 hide(hwnd
, FALSE
, rloginpanelstart
, rloginpanelend
);
1176 if (!strcmp(buffer
, "SSH"))
1177 hide(hwnd
, FALSE
, sshpanelstart
, sshpanelend
);
1178 if (!strcmp(buffer
, "Selection"))
1179 hide(hwnd
, FALSE
, selectionpanelstart
, selectionpanelend
);
1180 if (!strcmp(buffer
, "Colours"))
1181 hide(hwnd
, FALSE
, colourspanelstart
, colourspanelend
);
1182 if (!strcmp(buffer
, "Translation"))
1183 hide(hwnd
, FALSE
, translationpanelstart
, translationpanelend
);
1185 SetFocus (((LPNMHDR
)lParam
)->hwndFrom
); /* ensure focus stays */
1191 * Only process WM_COMMAND once the dialog is fully formed.
1193 if (GetWindowLong(hwnd
, GWL_USERDATA
) == 1) switch (LOWORD(wParam
)) {
1196 EndDialog (hwnd
, 1);
1201 EndDialog (hwnd
, 0);
1203 case IDC_PROTTELNET
:
1204 case IDC_PROTRLOGIN
:
1207 if (HIWORD(wParam
) == BN_CLICKED
||
1208 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1209 int i
= IsDlgButtonChecked (hwnd
, IDC_PROTSSH
);
1210 int j
= IsDlgButtonChecked (hwnd
, IDC_PROTTELNET
);
1211 int k
= IsDlgButtonChecked (hwnd
, IDC_PROTRLOGIN
);
1212 cfg
.protocol
= i ? PROT_SSH
: j ? PROT_TELNET
: k ? PROT_RLOGIN
: PROT_RAW
;
1213 if ((cfg
.protocol
== PROT_SSH
&& cfg
.port
!= 22) ||
1214 (cfg
.protocol
== PROT_TELNET
&& cfg
.port
!= 23) ||
1215 (cfg
.protocol
== PROT_RLOGIN
&& cfg
.port
!= 513)) {
1216 cfg
.port
= i ?
22 : j ?
23 : 513;
1217 SetDlgItemInt (hwnd
, IDC_PORT
, cfg
.port
, FALSE
);
1222 if (HIWORD(wParam
) == EN_CHANGE
)
1223 GetDlgItemText (hwnd
, IDC_HOST
, cfg
.host
,
1224 sizeof(cfg
.host
)-1);
1227 if (HIWORD(wParam
) == EN_CHANGE
) {
1228 GetDlgItemText (hwnd
, IDC_PORT
, portname
, 31);
1229 if (isdigit(portname
[0]))
1230 MyGetDlgItemInt (hwnd
, IDC_PORT
, &cfg
.port
);
1232 service
= getservbyname(portname
, NULL
);
1233 if (service
) cfg
.port
= ntohs(service
->s_port
);
1239 if (HIWORD(wParam
) == EN_CHANGE
) {
1240 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1242 GetDlgItemText (hwnd
, IDC_SESSEDIT
,
1243 savedsession
, sizeof(savedsession
)-1);
1244 savedsession
[sizeof(savedsession
)-1] = '\0';
1248 if (HIWORD(wParam
) == BN_CLICKED
||
1249 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1254 GetDlgItemText (hwnd
, IDC_SESSEDIT
, str
, sizeof(str
)-1);
1256 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1257 LB_GETCURSEL
, 0, 0);
1262 strcpy (str
, sessions
[n
]);
1264 save_settings (str
, !!strcmp(str
, "Default Settings"), &cfg
);
1265 get_sesslist (FALSE
);
1266 get_sesslist (TRUE
);
1267 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1269 for (i
= 0; i
< nsessions
; i
++)
1270 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1271 0, (LPARAM
) (sessions
[i
]));
1272 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1278 if (LOWORD(wParam
) == IDC_SESSLOAD
&&
1279 HIWORD(wParam
) != BN_CLICKED
&&
1280 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1282 if (LOWORD(wParam
) == IDC_SESSLIST
&&
1283 HIWORD(wParam
) != LBN_DBLCLK
)
1286 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1287 LB_GETCURSEL
, 0, 0);
1293 isdef
= !strcmp(sessions
[n
], "Default Settings");
1294 load_settings (sessions
[n
], !isdef
, &cfg
);
1295 init_dlg_ctrls(hwnd
);
1297 SetDlgItemText(hwnd
, IDC_SESSEDIT
, sessions
[n
]);
1299 SetDlgItemText(hwnd
, IDC_SESSEDIT
, "");
1301 if (LOWORD(wParam
) == IDC_SESSLIST
) {
1303 * A double-click on a saved session should
1304 * actually start the session, not just load it.
1305 * Unless it's Default Settings or some other
1306 * host-less set of saved settings.
1315 if (HIWORD(wParam
) == BN_CLICKED
||
1316 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1317 int n
= SendDlgItemMessage (hwnd
, IDC_SESSLIST
,
1318 LB_GETCURSEL
, 0, 0);
1319 if (n
== LB_ERR
|| n
== 0) {
1323 del_settings(sessions
[n
]);
1324 get_sesslist (FALSE
);
1325 get_sesslist (TRUE
);
1326 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_RESETCONTENT
,
1328 for (i
= 0; i
< nsessions
; i
++)
1329 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_ADDSTRING
,
1330 0, (LPARAM
) (sessions
[i
]));
1331 SendDlgItemMessage (hwnd
, IDC_SESSLIST
, LB_SETCURSEL
,
1335 if (HIWORD(wParam
) == EN_CHANGE
)
1336 MyGetDlgItemInt (hwnd
, IDC_PINGEDIT
, &cfg
.ping_interval
);
1340 if (HIWORD(wParam
) == BN_CLICKED
||
1341 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1342 cfg
.bksp_is_delete
= IsDlgButtonChecked (hwnd
, IDC_DEL127
);
1346 if (HIWORD(wParam
) == BN_CLICKED
||
1347 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1348 cfg
.rxvt_homeend
= IsDlgButtonChecked (hwnd
, IDC_HOMERXVT
);
1351 if (HIWORD(wParam
) == BN_CLICKED
||
1352 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1356 if (HIWORD(wParam
) == BN_CLICKED
||
1357 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1362 if (HIWORD(wParam
) == BN_CLICKED
||
1363 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1364 cfg
.funky_type
= IsDlgButtonChecked (hwnd
, IDC_FUNCLINUX
);
1368 if (HIWORD(wParam
) == BN_CLICKED
||
1369 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1370 cfg
.app_keypad
= IsDlgButtonChecked (hwnd
, IDC_KPAPPLIC
);
1371 cfg
.nethack_keypad
= FALSE
;
1375 if (HIWORD(wParam
) == BN_CLICKED
||
1376 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1377 cfg
.app_keypad
= FALSE
;
1378 cfg
.nethack_keypad
= TRUE
;
1383 if (HIWORD(wParam
) == BN_CLICKED
||
1384 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1385 cfg
.app_cursor
= IsDlgButtonChecked (hwnd
, IDC_CURAPPLIC
);
1388 if (HIWORD(wParam
) == BN_CLICKED
||
1389 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1390 cfg
.no_applic_c
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICC
);
1393 if (HIWORD(wParam
) == BN_CLICKED
||
1394 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1395 cfg
.no_applic_k
= IsDlgButtonChecked (hwnd
, IDC_NOAPPLICK
);
1398 if (HIWORD(wParam
) == BN_CLICKED
||
1399 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1400 cfg
.alt_f4
= IsDlgButtonChecked (hwnd
, IDC_ALTF4
);
1403 if (HIWORD(wParam
) == BN_CLICKED
||
1404 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1405 cfg
.alt_space
= IsDlgButtonChecked (hwnd
, IDC_ALTSPACE
);
1408 if (HIWORD(wParam
) == BN_CLICKED
||
1409 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1410 cfg
.alt_only
= IsDlgButtonChecked (hwnd
, IDC_ALTONLY
);
1413 if (HIWORD(wParam
) == BN_CLICKED
||
1414 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1415 cfg
.ldisc_term
= IsDlgButtonChecked (hwnd
, IDC_LDISCTERM
);
1417 case IDC_ALWAYSONTOP
:
1418 if (HIWORD(wParam
) == BN_CLICKED
||
1419 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1420 cfg
.alwaysontop
= IsDlgButtonChecked (hwnd
, IDC_ALWAYSONTOP
);
1423 if (HIWORD(wParam
) == BN_CLICKED
||
1424 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1425 cfg
.scroll_on_key
= IsDlgButtonChecked (hwnd
, IDC_SCROLLKEY
);
1427 case IDC_SCROLLDISP
:
1428 if (HIWORD(wParam
) == BN_CLICKED
||
1429 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1430 cfg
.scroll_on_disp
= IsDlgButtonChecked (hwnd
, IDC_SCROLLDISP
);
1432 case IDC_COMPOSEKEY
:
1433 if (HIWORD(wParam
) == BN_CLICKED
||
1434 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1435 cfg
.compose_key
= IsDlgButtonChecked (hwnd
, IDC_COMPOSEKEY
);
1438 if (HIWORD(wParam
) == BN_CLICKED
||
1439 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1440 cfg
.wrap_mode
= IsDlgButtonChecked (hwnd
, IDC_WRAPMODE
);
1443 if (HIWORD(wParam
) == BN_CLICKED
||
1444 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1445 cfg
.dec_om
= IsDlgButtonChecked (hwnd
, IDC_DECOM
);
1448 if (HIWORD(wParam
) == BN_CLICKED
||
1449 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1450 cfg
.lfhascr
= IsDlgButtonChecked (hwnd
, IDC_LFHASCR
);
1453 if (HIWORD(wParam
) == EN_CHANGE
)
1454 MyGetDlgItemInt (hwnd
, IDC_ROWSEDIT
, &cfg
.height
);
1457 if (HIWORD(wParam
) == EN_CHANGE
)
1458 MyGetDlgItemInt (hwnd
, IDC_COLSEDIT
, &cfg
.width
);
1461 if (HIWORD(wParam
) == EN_CHANGE
)
1462 MyGetDlgItemInt (hwnd
, IDC_SAVEEDIT
, &cfg
.savelines
);
1464 case IDC_CHOOSEFONT
:
1465 lf
.lfHeight
= cfg
.fontheight
;
1466 lf
.lfWidth
= lf
.lfEscapement
= lf
.lfOrientation
= 0;
1467 lf
.lfItalic
= lf
.lfUnderline
= lf
.lfStrikeOut
= 0;
1468 lf
.lfWeight
= (cfg
.fontisbold ? FW_BOLD
: 0);
1469 lf
.lfCharSet
= cfg
.fontcharset
;
1470 lf
.lfOutPrecision
= OUT_DEFAULT_PRECIS
;
1471 lf
.lfClipPrecision
= CLIP_DEFAULT_PRECIS
;
1472 lf
.lfQuality
= DEFAULT_QUALITY
;
1473 lf
.lfPitchAndFamily
= FIXED_PITCH
| FF_DONTCARE
;
1474 strncpy (lf
.lfFaceName
, cfg
.font
, sizeof(lf
.lfFaceName
)-1);
1475 lf
.lfFaceName
[sizeof(lf
.lfFaceName
)-1] = '\0';
1477 cf
.lStructSize
= sizeof(cf
);
1478 cf
.hwndOwner
= hwnd
;
1480 cf
.Flags
= CF_FIXEDPITCHONLY
| CF_FORCEFONTEXIST
|
1481 CF_INITTOLOGFONTSTRUCT
| CF_SCREENFONTS
;
1483 if (ChooseFont (&cf
)) {
1484 strncpy (cfg
.font
, lf
.lfFaceName
, sizeof(cfg
.font
)-1);
1485 cfg
.font
[sizeof(cfg
.font
)-1] = '\0';
1486 cfg
.fontisbold
= (lf
.lfWeight
== FW_BOLD
);
1487 cfg
.fontcharset
= lf
.lfCharSet
;
1488 cfg
.fontheight
= lf
.lfHeight
;
1489 fmtfont (fontstatic
);
1490 SetDlgItemText (hwnd
, IDC_FONTSTATIC
, fontstatic
);
1494 if (HIWORD(wParam
) == BN_CLICKED
||
1495 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1496 cfg
.beep
= IsDlgButtonChecked (hwnd
, IDC_BEEP
);
1499 if (HIWORD(wParam
) == BN_CLICKED
||
1500 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1501 cfg
.blinktext
= IsDlgButtonChecked (hwnd
, IDC_BLINKTEXT
);
1504 if (HIWORD(wParam
) == BN_CLICKED
||
1505 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1506 cfg
.bce
= IsDlgButtonChecked (hwnd
, IDC_BCE
);
1509 if (HIWORD(wParam
) == BN_CLICKED
||
1510 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1511 cfg
.win_name_always
= IsDlgButtonChecked (hwnd
, IDC_WINNAME
);
1514 if (HIWORD(wParam
) == BN_CLICKED
||
1515 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1516 cfg
.hide_mouseptr
= IsDlgButtonChecked (hwnd
, IDC_HIDEMOUSE
);
1519 if (HIWORD(wParam
) == BN_CLICKED
||
1520 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1521 cfg
.cursor_type
= 0;
1524 if (HIWORD(wParam
) == BN_CLICKED
||
1525 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1526 cfg
.cursor_type
= 1;
1529 if (HIWORD(wParam
) == BN_CLICKED
||
1530 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1531 cfg
.cursor_type
= 2;
1534 if (HIWORD(wParam
) == BN_CLICKED
||
1535 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1536 cfg
.blink_cur
= IsDlgButtonChecked (hwnd
, IDC_BLINKCUR
);
1539 if (HIWORD(wParam
) == BN_CLICKED
||
1540 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1541 cfg
.scrollbar
= IsDlgButtonChecked (hwnd
, IDC_SCROLLBAR
);
1544 if (HIWORD(wParam
) == BN_CLICKED
||
1545 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1546 cfg
.locksize
= IsDlgButtonChecked (hwnd
, IDC_LOCKSIZE
);
1549 if (HIWORD(wParam
) == EN_CHANGE
)
1550 GetDlgItemText (hwnd
, IDC_WINEDIT
, cfg
.wintitle
,
1551 sizeof(cfg
.wintitle
)-1);
1554 if (HIWORD(wParam
) == BN_CLICKED
||
1555 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1556 cfg
.close_on_exit
= IsDlgButtonChecked (hwnd
, IDC_CLOSEEXIT
);
1559 if (HIWORD(wParam
) == BN_CLICKED
||
1560 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1561 cfg
.warn_on_close
= IsDlgButtonChecked (hwnd
, IDC_CLOSEWARN
);
1564 if (HIWORD(wParam
) == EN_CHANGE
)
1565 GetDlgItemText (hwnd
, IDC_TTEDIT
, cfg
.termtype
,
1566 sizeof(cfg
.termtype
)-1);
1569 if (HIWORD(wParam
) == EN_CHANGE
)
1570 GetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.logfilename
,
1571 sizeof(cfg
.logfilename
)-1);
1574 memset(&of
, 0, sizeof(of
));
1575 #ifdef OPENFILENAME_SIZE_VERSION_400
1576 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1578 of
.lStructSize
= sizeof(of
);
1580 of
.hwndOwner
= hwnd
;
1581 of
.lpstrFilter
= "All Files\0*\0\0\0";
1582 of
.lpstrCustomFilter
= NULL
;
1583 of
.nFilterIndex
= 1;
1584 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1585 of
.nMaxFile
= sizeof(filename
);
1586 of
.lpstrFileTitle
= NULL
;
1587 of
.lpstrInitialDir
= NULL
;
1588 of
.lpstrTitle
= "Select session log file";
1590 if (GetSaveFileName(&of
)) {
1591 strcpy(cfg
.keyfile
, filename
);
1592 SetDlgItemText (hwnd
, IDC_LGFEDIT
, cfg
.keyfile
);
1596 case IDC_LSTATASCII
:
1598 if (HIWORD(wParam
) == BN_CLICKED
||
1599 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1600 if (IsDlgButtonChecked (hwnd
, IDC_LSTATOFF
)) cfg
.logtype
= 0;
1601 if (IsDlgButtonChecked (hwnd
, IDC_LSTATASCII
)) cfg
.logtype
= 1;
1602 if (IsDlgButtonChecked (hwnd
, IDC_LSTATRAW
)) cfg
.logtype
= 2;
1607 if (HIWORD(wParam
) == EN_CHANGE
)
1608 GetDlgItemText (hwnd
, LOWORD(wParam
), cfg
.termspeed
,
1609 sizeof(cfg
.termspeed
)-1);
1612 if (HIWORD(wParam
) == EN_CHANGE
)
1613 GetDlgItemText (hwnd
, IDC_LOGEDIT
, cfg
.username
,
1614 sizeof(cfg
.username
)-1);
1616 case IDC_RLLUSEREDIT
:
1617 if (HIWORD(wParam
) == EN_CHANGE
)
1618 GetDlgItemText (hwnd
, IDC_RLLUSEREDIT
, cfg
.localusername
,
1619 sizeof(cfg
.localusername
)-1);
1623 cfg
.rfc_environ
= IsDlgButtonChecked (hwnd
, IDC_EMRFC
);
1626 if (HIWORD(wParam
) == BN_CLICKED
||
1627 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1628 char str
[sizeof(cfg
.environmt
)];
1630 GetDlgItemText (hwnd
, IDC_VAREDIT
, str
, sizeof(str
)-1);
1635 p
= str
+ strlen(str
);
1637 GetDlgItemText (hwnd
, IDC_VALEDIT
, p
, sizeof(str
)-1-(p
-str
));
1647 if ((p
-cfg
.environmt
) + strlen(str
) + 2 < sizeof(cfg
.environmt
)) {
1649 p
[strlen(str
)+1] = '\0';
1650 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_ADDSTRING
,
1652 SetDlgItemText (hwnd
, IDC_VAREDIT
, "");
1653 SetDlgItemText (hwnd
, IDC_VALEDIT
, "");
1655 MessageBox(hwnd
, "Environment too big", "PuTTY Error",
1656 MB_OK
| MB_ICONERROR
);
1661 if (HIWORD(wParam
) != BN_CLICKED
&&
1662 HIWORD(wParam
) != BN_DOUBLECLICKED
)
1664 i
= SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_GETCURSEL
, 0, 0);
1670 SendDlgItemMessage (hwnd
, IDC_ENVLIST
, LB_DELETESTRING
,
1695 if (HIWORD(wParam
) == BN_CLICKED
||
1696 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1697 cfg
.nopty
= IsDlgButtonChecked (hwnd
, IDC_NOPTY
);
1700 if (HIWORD(wParam
) == BN_CLICKED
||
1701 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1702 cfg
.compression
= IsDlgButtonChecked (hwnd
, IDC_COMPRESS
);
1705 if (HIWORD(wParam
) == BN_CLICKED
||
1706 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1707 cfg
.buggymac
= IsDlgButtonChecked (hwnd
, IDC_BUGGYMAC
);
1710 if (HIWORD(wParam
) == BN_CLICKED
||
1711 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1712 cfg
.agentfwd
= IsDlgButtonChecked (hwnd
, IDC_AGENTFWD
);
1714 case IDC_CIPHER3DES
:
1715 case IDC_CIPHERBLOWF
:
1717 if (HIWORD(wParam
) == BN_CLICKED
||
1718 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1719 if (IsDlgButtonChecked (hwnd
, IDC_CIPHER3DES
))
1720 cfg
.cipher
= CIPHER_3DES
;
1721 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERBLOWF
))
1722 cfg
.cipher
= CIPHER_BLOWFISH
;
1723 else if (IsDlgButtonChecked (hwnd
, IDC_CIPHERDES
))
1724 cfg
.cipher
= CIPHER_DES
;
1729 if (HIWORD(wParam
) == BN_CLICKED
||
1730 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1731 if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT1
))
1733 else if (IsDlgButtonChecked (hwnd
, IDC_SSHPROT2
))
1738 if (HIWORD(wParam
) == BN_CLICKED
||
1739 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1740 cfg
.try_tis_auth
= IsDlgButtonChecked (hwnd
, IDC_AUTHTIS
);
1743 if (HIWORD(wParam
) == EN_CHANGE
)
1744 GetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
,
1745 sizeof(cfg
.keyfile
)-1);
1748 if (HIWORD(wParam
) == EN_CHANGE
)
1749 GetDlgItemText (hwnd
, IDC_CMDEDIT
, cfg
.remote_cmd
,
1750 sizeof(cfg
.remote_cmd
)-1);
1753 memset(&of
, 0, sizeof(of
));
1754 #ifdef OPENFILENAME_SIZE_VERSION_400
1755 of
.lStructSize
= OPENFILENAME_SIZE_VERSION_400
;
1757 of
.lStructSize
= sizeof(of
);
1759 of
.hwndOwner
= hwnd
;
1760 of
.lpstrFilter
= "All Files\0*\0\0\0";
1761 of
.lpstrCustomFilter
= NULL
;
1762 of
.nFilterIndex
= 1;
1763 of
.lpstrFile
= filename
; strcpy(filename
, cfg
.keyfile
);
1764 of
.nMaxFile
= sizeof(filename
);
1765 of
.lpstrFileTitle
= NULL
;
1766 of
.lpstrInitialDir
= NULL
;
1767 of
.lpstrTitle
= "Select Public Key File";
1769 if (GetOpenFileName(&of
)) {
1770 strcpy(cfg
.keyfile
, filename
);
1771 SetDlgItemText (hwnd
, IDC_PKEDIT
, cfg
.keyfile
);
1776 cfg
.mouse_is_xterm
= IsDlgButtonChecked (hwnd
, IDC_MBXTERM
);
1782 int n
= GetDlgItemInt (hwnd
, IDC_CCEDIT
, &ok
, FALSE
);
1787 for (i
=0; i
<256; i
++)
1788 if (SendDlgItemMessage (hwnd
, IDC_CCLIST
, LB_GETSEL
,
1791 cfg
.wordness
[i
] = n
;
1792 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1793 LB_DELETESTRING
, i
, 0);
1794 sprintf(str
, "%d\t(0x%02X)\t%c\t%d", i
, i
,
1795 (i
>=0x21 && i
!= 0x7F) ? i
: ' ',
1797 SendDlgItemMessage (hwnd
, IDC_CCLIST
,
1804 case IDC_BOLDCOLOUR
:
1805 if (HIWORD(wParam
) == BN_CLICKED
||
1806 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1808 cfg
.bold_colour
= IsDlgButtonChecked (hwnd
, IDC_BOLDCOLOUR
);
1809 n
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCOUNT
, 0, 0);
1810 if (n
!= 12+10*cfg
.bold_colour
) {
1812 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1813 LB_DELETESTRING
, i
, 0);
1814 for (i
=0; i
<22; i
++)
1815 if (cfg
.bold_colour
|| permcolour
[i
])
1816 SendDlgItemMessage (hwnd
, IDC_COLOURLIST
,
1818 (LPARAM
) colours
[i
]);
1823 if (HIWORD(wParam
) == BN_CLICKED
||
1824 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1825 cfg
.try_palette
= IsDlgButtonChecked (hwnd
, IDC_PALETTE
);
1827 case IDC_COLOURLIST
:
1828 if (HIWORD(wParam
) == LBN_DBLCLK
||
1829 HIWORD(wParam
) == LBN_SELCHANGE
) {
1830 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1832 if (!cfg
.bold_colour
)
1833 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1834 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0], FALSE
);
1835 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1], FALSE
);
1836 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2], FALSE
);
1840 if (HIWORD(wParam
) == BN_CLICKED
||
1841 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1842 static CHOOSECOLOR cc
;
1843 static DWORD custom
[16] = {0}; /* zero initialisers */
1844 int i
= SendDlgItemMessage (hwnd
, IDC_COLOURLIST
, LB_GETCURSEL
,
1846 if (!cfg
.bold_colour
)
1847 i
= (i
< 3 ? i
*2 : i
== 3 ?
5 : i
*2-2);
1848 cc
.lStructSize
= sizeof(cc
);
1849 cc
.hwndOwner
= hwnd
;
1850 cc
.hInstance
= (HWND
)hinst
;
1851 cc
.lpCustColors
= custom
;
1852 cc
.rgbResult
= RGB (cfg
.colours
[i
][0], cfg
.colours
[i
][1],
1854 cc
.Flags
= CC_FULLOPEN
| CC_RGBINIT
;
1855 if (ChooseColor(&cc
)) {
1857 (unsigned char) (cc
.rgbResult
& 0xFF);
1859 (unsigned char) (cc
.rgbResult
>> 8) & 0xFF;
1861 (unsigned char) (cc
.rgbResult
>> 16) & 0xFF;
1862 SetDlgItemInt (hwnd
, IDC_RVALUE
, cfg
.colours
[i
][0],
1864 SetDlgItemInt (hwnd
, IDC_GVALUE
, cfg
.colours
[i
][1],
1866 SetDlgItemInt (hwnd
, IDC_BVALUE
, cfg
.colours
[i
][2],
1872 case IDC_KOI8WIN1251
:
1873 case IDC_88592WIN1250
:
1874 case IDC_88592CP852
:
1875 cfg
.xlat_enablekoiwin
=
1876 IsDlgButtonChecked (hwnd
, IDC_KOI8WIN1251
);
1877 cfg
.xlat_88592w1250
=
1878 IsDlgButtonChecked (hwnd
, IDC_88592WIN1250
);
1879 cfg
.xlat_88592cp852
=
1880 IsDlgButtonChecked (hwnd
, IDC_88592CP852
);
1882 case IDC_CAPSLOCKCYR
:
1883 if (HIWORD(wParam
) == BN_CLICKED
||
1884 HIWORD(wParam
) == BN_DOUBLECLICKED
) {
1885 cfg
.xlat_capslockcyr
=
1886 IsDlgButtonChecked (hwnd
, IDC_CAPSLOCKCYR
);
1889 case IDC_VTXWINDOWS
:
1894 (IsDlgButtonChecked (hwnd
, IDC_VTXWINDOWS
) ? VT_XWINDOWS
:
1895 IsDlgButtonChecked (hwnd
, IDC_VTOEMANSI
) ? VT_OEMANSI
:
1896 IsDlgButtonChecked (hwnd
, IDC_VTOEMONLY
) ? VT_OEMONLY
:
1899 case IDC_X11_FORWARD
:
1900 if (HIWORD(wParam
) == BN_CLICKED
||
1901 HIWORD(wParam
) == BN_DOUBLECLICKED
)
1902 cfg
.x11_forward
= IsDlgButtonChecked (hwnd
, IDC_X11_FORWARD
);
1904 case IDC_X11_DISPLAY
:
1905 if (HIWORD(wParam
) == EN_CHANGE
)
1906 GetDlgItemText (hwnd
, IDC_X11_DISPLAY
, cfg
.x11_display
,
1907 sizeof(cfg
.x11_display
)-1);
1912 EndDialog (hwnd
, 0);
1915 /* Grrr Explorer will maximize Dialogs! */
1917 if (wParam
== SIZE_MAXIMIZED
)
1924 static int CALLBACK
MainDlgProc (HWND hwnd
, UINT msg
,
1925 WPARAM wParam
, LPARAM lParam
) {
1926 static HWND page
= NULL
;
1928 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDOK
) {
1930 if (msg
== WM_COMMAND
&& LOWORD(wParam
) == IDCX_ABOUT
) {
1931 EnableWindow(hwnd
, 0);
1932 DialogBox(hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1933 GetParent(hwnd
), AboutProc
);
1934 EnableWindow(hwnd
, 1);
1935 SetActiveWindow(hwnd
);
1937 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 0);
1940 static int CALLBACK
ReconfDlgProc (HWND hwnd
, UINT msg
,
1941 WPARAM wParam
, LPARAM lParam
) {
1943 return GenericMainDlgProc (hwnd
, msg
, wParam
, lParam
, 1);
1946 void defuse_showwindow(void) {
1948 * Work around the fact that the app's first call to ShowWindow
1949 * will ignore the default in favour of the shell-provided
1954 hwnd
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
1956 ShowWindow(hwnd
, SW_HIDE
);
1957 DestroyWindow(hwnd
);
1961 int do_config (void) {
1965 savedsession
[0] = '\0';
1966 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_MAINBOX
), NULL
, MainDlgProc
);
1967 get_sesslist(FALSE
);
1972 int do_reconfig (HWND hwnd
) {
1976 backup_cfg
= cfg
; /* structure copy */
1977 ret
= DialogBox (hinst
, MAKEINTRESOURCE(IDD_RECONF
), hwnd
, ReconfDlgProc
);
1979 cfg
= backup_cfg
; /* structure copy */
1984 void logevent (char *string
) {
1985 if (nevents
>= negsize
) {
1987 events
= srealloc (events
, negsize
* sizeof(*events
));
1989 events
[nevents
] = smalloc(1+strlen(string
));
1990 strcpy (events
[nevents
], string
);
1994 SendDlgItemMessage (logbox
, IDN_LIST
, LB_ADDSTRING
,
1996 count
= SendDlgItemMessage (logbox
, IDN_LIST
, LB_GETCOUNT
, 0, 0);
1997 SendDlgItemMessage (logbox
, IDN_LIST
, LB_SETTOPINDEX
, count
-1, 0);
2001 void showeventlog (HWND hwnd
) {
2003 logbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_LOGBOX
),
2005 ShowWindow (logbox
, SW_SHOWNORMAL
);
2009 void showabout (HWND hwnd
) {
2011 abtbox
= CreateDialog (hinst
, MAKEINTRESOURCE(IDD_ABOUTBOX
),
2013 ShowWindow (abtbox
, SW_SHOWNORMAL
);
2017 void verify_ssh_host_key(char *host
, int port
, char *keytype
,
2018 char *keystr
, char *fingerprint
) {
2021 static const char absentmsg
[] =
2022 "The server's host key is not cached in the registry. You\n"
2023 "have no guarantee that the server is the computer you\n"
2025 "The server's key fingerprint is:\n"
2027 "If you trust this host, hit Yes to add the key to\n"
2028 "PuTTY's cache and carry on connecting.\n"
2029 "If you do not trust this host, hit No to abandon the\n"
2032 static const char wrongmsg
[] =
2033 "WARNING - POTENTIAL SECURITY BREACH!\n"
2035 "The server's host key does not match the one PuTTY has\n"
2036 "cached in the registry. This means that either the\n"
2037 "server administrator has changed the host key, or you\n"
2038 "have actually connected to another computer pretending\n"
2039 "to be the server.\n"
2040 "The new key fingerprint is:\n"
2042 "If you were expecting this change and trust the new key,\n"
2043 "hit Yes to update PuTTY's cache and continue connecting.\n"
2044 "If you want to carry on connecting but without updating\n"
2045 "the cache, hit No.\n"
2046 "If you want to abandon the connection completely, hit\n"
2047 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2050 static const char mbtitle
[] = "PuTTY Security Alert";
2053 char message
[160+ /* sensible fingerprint max size */
2054 (sizeof(absentmsg
) > sizeof(wrongmsg
) ?
2055 sizeof(absentmsg
) : sizeof(wrongmsg
))];
2058 * Verify the key against the registry.
2060 ret
= verify_host_key(host
, port
, keytype
, keystr
);
2062 if (ret
== 0) /* success - key matched OK */
2064 if (ret
== 2) { /* key was different */
2066 sprintf(message
, wrongmsg
, fingerprint
);
2067 mbret
= MessageBox(NULL
, message
, mbtitle
,
2068 MB_ICONWARNING
| MB_YESNOCANCEL
);
2070 store_host_key(host
, port
, keytype
, keystr
);
2071 if (mbret
== IDCANCEL
)
2074 if (ret
== 1) { /* key was absent */
2076 sprintf(message
, absentmsg
, fingerprint
);
2077 mbret
= MessageBox(NULL
, message
, mbtitle
,
2078 MB_ICONWARNING
| MB_YESNO
);
2081 store_host_key(host
, port
, keytype
, keystr
);
2086 * Ask whether to wipe a session log file before writing to it.
2087 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2089 int askappend(char *filename
) {
2090 static const char mbtitle
[] = "PuTTY Log to File";
2091 static const char msgtemplate
[] =
2092 "The session log file \"%.*s\" already exists.\n"
2093 "You can overwrite it with a new session log,\n"
2094 "append your session log to the end of it,\n"
2095 "or disable session logging for this session.\n"
2096 "Hit Yes to wipe the file, No to append to it,\n"
2097 "or Cancel to disable logging.";
2098 char message
[sizeof(msgtemplate
) + FILENAME_MAX
];
2100 sprintf(message
, msgtemplate
, FILENAME_MAX
, filename
);
2102 mbret
= MessageBox(NULL
, message
, mbtitle
,
2103 MB_ICONQUESTION
| MB_YESNOCANCEL
);
2106 else if (mbret
== IDNO
)