15 static char **events = NULL;
16 static int nevents = 0, negsize = 0;
19 static int sesslist_has_focus;
21 static struct prefslist cipherlist;
23 void force_normal(HWND hwnd)
25 static int recurse = 0;
33 wp.length = sizeof(wp);
34 if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) {
35 wp.showCmd = SW_SHOWNORMAL;
36 SetWindowPlacement(hwnd, &wp);
41 static void MyGetDlgItemInt(HWND hwnd, int id, int *result)
45 n = GetDlgItemInt(hwnd, id, &ok, FALSE);
50 static void MyGetDlgItemFlt(HWND hwnd, int id, int *result, int scale)
54 ok = GetDlgItemText(hwnd, id, text, sizeof(text) - 1);
56 *result = (int) (scale * atof(text));
59 static void MySetDlgItemFlt(HWND hwnd, int id, double value)
62 sprintf(text, "%g", value);
63 SetDlgItemText(hwnd, id, text);
66 static int CALLBACK LogProc(HWND hwnd, UINT msg,
67 WPARAM wParam, LPARAM lParam)
74 static int tabs[4] = { 78, 108 };
75 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
78 for (i = 0; i < nevents; i++)
79 SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
80 0, (LPARAM) events[i]);
83 switch (LOWORD(wParam)) {
87 SetActiveWindow(GetParent(hwnd));
91 if (HIWORD(wParam) == BN_CLICKED ||
92 HIWORD(wParam) == BN_DOUBLECLICKED) {
95 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
96 LB_GETSELCOUNT, 0, 0);
97 if (selcount == 0) { /* don't even try to copy zero items */
102 selitems = smalloc(selcount * sizeof(int));
104 int count = SendDlgItemMessage(hwnd, IDN_LIST,
111 static unsigned char sel_nl[] = SEL_NL;
113 if (count == 0) { /* can't copy zero stuff */
119 for (i = 0; i < count; i++)
121 strlen(events[selitems[i]]) + sizeof(sel_nl);
123 clipdata = smalloc(size);
126 for (i = 0; i < count; i++) {
127 char *q = events[selitems[i]];
128 int qlen = strlen(q);
131 memcpy(p, sel_nl, sizeof(sel_nl));
134 write_aclip(clipdata, size, TRUE);
139 for (i = 0; i < nevents; i++)
140 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
149 SetActiveWindow(GetParent(hwnd));
156 static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
157 WPARAM wParam, LPARAM lParam)
163 switch (LOWORD(wParam)) {
176 static int CALLBACK AboutProc(HWND hwnd, UINT msg,
177 WPARAM wParam, LPARAM lParam)
181 SetDlgItemText(hwnd, IDA_VERSION, ver);
184 switch (LOWORD(wParam)) {
187 EndDialog(hwnd, TRUE);
190 EnableWindow(hwnd, 0);
191 DialogBox(hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
193 EnableWindow(hwnd, 1);
194 SetActiveWindow(hwnd);
198 /* Load web browser */
199 ShellExecute(hwnd, "open",
200 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
201 0, 0, SW_SHOWDEFAULT);
206 EndDialog(hwnd, TRUE);
213 * Null dialog procedure.
215 static int CALLBACK NullDlgProc(HWND hwnd, UINT msg,
216 WPARAM wParam, LPARAM lParam)
221 static char savedsession[2048];
224 IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
362 IDC_SCROLLBARFULLSCREEN,
372 IDC_FULLSCREENONALTENTER,
375 appearancepanelstart,
376 IDC_TITLE_APPEARANCE,
398 connectionpanelstart,
399 IDC_TITLE_CONNECTION,
511 translationpanelstart,
512 IDC_TITLE_TRANSLATION,
513 IDC_BOX_TRANSLATION1,
514 IDC_BOX_TRANSLATION2,
515 IDC_BOX_TRANSLATION3,
552 static const char *const colours[] = {
553 "Default Foreground", "Default Bold Foreground",
554 "Default Background", "Default Bold Background",
555 "Cursor Text", "Cursor Colour",
556 "ANSI Black", "ANSI Black Bold",
557 "ANSI Red", "ANSI Red Bold",
558 "ANSI Green", "ANSI Green Bold",
559 "ANSI Yellow", "ANSI Yellow Bold",
560 "ANSI Blue", "ANSI Blue Bold",
561 "ANSI Magenta", "ANSI Magenta Bold",
562 "ANSI Cyan", "ANSI Cyan Bold",
563 "ANSI White", "ANSI White Bold"
565 static const int permcolour[] = {
566 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
567 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
568 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
571 static void fmtfont(char *buf)
573 sprintf(buf, "Font: %s, ", cfg.font);
575 strcat(buf, "bold, ");
576 if (cfg.fontheight == 0)
577 strcat(buf, "default height");
579 sprintf(buf + strlen(buf), "%d-point",
580 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
583 /* 2nd arg: NZ => don't redraw session list (use when loading
585 static void init_dlg_ctrls(HWND hwnd, int keepsess)
588 char fontstatic[256];
590 SetDlgItemText(hwnd, IDC_HOST, cfg.host);
591 SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
594 n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
595 for (i = n; i-- > 0;)
596 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_DELETESTRING, i, 0);
597 for (i = 0; i < nsessions; i++)
598 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_ADDSTRING,
599 0, (LPARAM) (sessions[i]));
601 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
602 CheckRadioButton(hwnd, IDC_PROTRAW, IDC_PROTSSH,
603 cfg.protocol == PROT_SSH ? IDC_PROTSSH :
604 cfg.protocol == PROT_TELNET ? IDC_PROTTELNET :
606 PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW);
607 SetDlgItemInt(hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
609 CheckRadioButton(hwnd, IDC_DEL008, IDC_DEL127,
610 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
611 CheckRadioButton(hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
612 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
613 CheckRadioButton(hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
614 cfg.funky_type == 0 ? IDC_FUNCTILDE :
615 cfg.funky_type == 1 ? IDC_FUNCLINUX :
616 cfg.funky_type == 2 ? IDC_FUNCXTERM :
617 cfg.funky_type == 3 ? IDC_FUNCVT400 :
618 cfg.funky_type == 4 ? IDC_FUNCVT100P :
619 cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE);
620 CheckDlgButton(hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
621 CheckDlgButton(hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
622 CheckRadioButton(hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
623 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
624 CheckRadioButton(hwnd, IDC_KPNORMAL, IDC_KPNH,
625 cfg.nethack_keypad ? IDC_KPNH :
626 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
627 CheckDlgButton(hwnd, IDC_ALTF4, cfg.alt_f4);
628 CheckDlgButton(hwnd, IDC_ALTSPACE, cfg.alt_space);
629 CheckDlgButton(hwnd, IDC_ALTONLY, cfg.alt_only);
630 CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
631 CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
632 CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
633 CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
634 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
635 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
636 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
637 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND :
638 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
639 SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
640 CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
641 CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
642 CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
643 CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
645 CheckDlgButton(hwnd, IDC_WRAPMODE, cfg.wrap_mode);
646 CheckDlgButton(hwnd, IDC_DECOM, cfg.dec_om);
647 CheckDlgButton(hwnd, IDC_LFHASCR, cfg.lfhascr);
648 SetDlgItemInt(hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
649 SetDlgItemInt(hwnd, IDC_COLSEDIT, cfg.width, FALSE);
650 SetDlgItemInt(hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
652 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
653 CheckRadioButton(hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
654 cfg.beep == BELL_DISABLED ? IDC_BELL_DISABLED :
655 cfg.beep == BELL_DEFAULT ? IDC_BELL_DEFAULT :
656 cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
658 BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
659 CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
661 B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
662 B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
663 B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
664 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
665 CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
666 SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
667 MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
668 MySetDlgItemFlt(hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
670 CheckDlgButton(hwnd, IDC_BCE, cfg.bce);
671 CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
673 SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
674 CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
675 CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
676 CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
677 SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
678 CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
679 cfg.cursor_type == 0 ? IDC_CURBLOCK :
680 cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
681 CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
682 CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
683 CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
684 CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZENONE,
685 cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
686 cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
688 CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
689 cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
691 COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
692 CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
694 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
695 SetDlgItemText(hwnd, IDC_TSEDIT, cfg.termspeed);
696 SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
697 SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
698 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
699 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
700 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATRAW,
701 cfg.logtype == 0 ? IDC_LSTATOFF :
702 cfg.logtype == 1 ? IDC_LSTATASCII : IDC_LSTATRAW);
703 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
704 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
705 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
708 char *p = cfg.environmt;
709 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
711 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
717 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0,
722 CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC,
723 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
724 CheckRadioButton(hwnd, IDC_TPASSIVE, IDC_TACTIVE,
725 cfg.passive_telnet ? IDC_TPASSIVE : IDC_TACTIVE);
727 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
728 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
729 CheckDlgButton(hwnd, IDC_NOPTY, cfg.nopty);
730 CheckDlgButton(hwnd, IDC_COMPRESS, cfg.compression);
731 CheckDlgButton(hwnd, IDC_BUGGYMAC, cfg.buggymac);
732 CheckDlgButton(hwnd, IDC_AGENTFWD, cfg.agentfwd);
733 CheckRadioButton(hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
734 cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
735 CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
736 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
737 SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
741 static const struct { char *s; int c; } ciphers[] = {
742 { "3DES", CIPHER_3DES },
743 { "Blowfish", CIPHER_BLOWFISH },
744 { "DES (SSH 1 only)", CIPHER_DES },
745 { "AES (SSH 2 only)", CIPHER_AES },
746 { "-- warn below here --", CIPHER_WARN }
749 /* Set up the "selected ciphers" box. */
750 /* (cipherlist assumed to contain all ciphers) */
751 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_RESETCONTENT, 0, 0);
752 for (i = 0; i < CIPHER_MAX; i++) {
753 int c = cfg.ssh_cipherlist[i];
756 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
757 if (ciphers[j].c == c) {
762 pos = SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_ADDSTRING,
764 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_SETITEMDATA,
770 CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
771 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
772 CheckRadioButton(hwnd, IDC_SELTYPELEX, IDC_SELTYPERECT,
773 cfg.rect_select == 0 ? IDC_SELTYPELEX : IDC_SELTYPERECT);
774 CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
775 CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
776 CheckDlgButton(hwnd, IDC_RTFPASTE, cfg.rtf_paste);
778 static int tabs[4] = { 25, 61, 96, 128 };
779 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
782 for (i = 0; i < 128; i++) {
784 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
785 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg.wordness[i]);
786 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
790 CheckDlgButton(hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
791 CheckDlgButton(hwnd, IDC_PALETTE, cfg.try_palette);
794 n = SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
795 for (i = n; i-- > 0;)
796 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
797 LB_DELETESTRING, i, 0);
798 for (i = 0; i < 22; i++)
799 if (cfg.bold_colour || permcolour[i])
800 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
801 (LPARAM) colours[i]);
803 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
804 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
805 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
806 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
811 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
812 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
813 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
814 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
815 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
818 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
821 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
822 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
823 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
824 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
825 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
828 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
829 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
831 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
832 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
835 struct treeview_faff {
840 static HTREEITEM treeview_insert(struct treeview_faff *faff,
841 int level, char *text)
846 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
847 ins.hInsertAfter = faff->lastat[level];
848 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
849 #define INSITEM DUMMYUNIONNAME.item
853 ins.INSITEM.mask = TVIF_TEXT;
854 ins.INSITEM.pszText = text;
855 newitem = TreeView_InsertItem(faff->treeview, &ins);
857 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
859 faff->lastat[level] = newitem;
860 for (i = level + 1; i < 4; i++)
861 faff->lastat[i] = NULL;
866 * Create the panelfuls of controls in the configuration box.
868 static void create_controls(HWND hwnd, int dlgtype, int panel)
870 if (panel == sessionpanelstart) {
871 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
873 ctlposinit(&cp, hwnd, 80, 3, 13);
874 bartitle(&cp, "Basic options for your PuTTY session",
877 beginbox(&cp, "Specify your connection by host name or IP address",
880 "Host &Name (or IP address)",
881 IDC_HOSTSTATIC, IDC_HOST, 75,
882 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
883 if (backends[3].backend == NULL) {
884 /* this is PuTTYtel, so only three protocols available */
885 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
887 "&Telnet", IDC_PROTTELNET,
888 "Rlog&in", IDC_PROTRLOGIN, NULL);
890 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
892 "&Telnet", IDC_PROTTELNET,
893 "Rlog&in", IDC_PROTRLOGIN,
902 beginbox(&cp, "Load, save or delete a stored session",
904 sesssaver(&cp, "Sav&ed Sessions",
905 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
906 "&Load", IDC_SESSLOAD,
907 "&Save", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
910 beginbox(&cp, NULL, IDC_BOX_SESSION3);
911 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
912 "Always", IDC_COEALWAYS,
913 "Never", IDC_COENEVER,
914 "Only on clean exit", IDC_COENORMAL, NULL);
918 if (panel == loggingpanelstart) {
919 /* The Logging panel. Accelerators used: [acgo] tplfwe */
921 ctlposinit(&cp, hwnd, 80, 3, 13);
922 bartitle(&cp, "Options controlling session logging",
924 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
926 "Session logging:", IDC_LSTATSTATIC,
927 "Logging &turned off completely", IDC_LSTATOFF,
928 "Log &printable output only", IDC_LSTATASCII,
929 "&Log all session output", IDC_LSTATRAW, NULL);
930 editbutton(&cp, "Log &file name:",
931 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
933 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
934 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
936 "What to do if the log file already &exists:",
937 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
938 "Always append to the end of it", IDC_LSTATXAPN,
939 "Ask the user every time", IDC_LSTATXASK, NULL);
943 if (panel == terminalpanelstart) {
944 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
946 ctlposinit(&cp, hwnd, 80, 3, 13);
947 bartitle(&cp, "Options controlling the terminal emulation",
949 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
950 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
951 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
952 checkbox(&cp, "Implicit CR in every &LF", IDC_LFHASCR);
953 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
954 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
956 "An&swerback to ^E:", IDC_ANSWERBACK,
957 IDC_ANSWEREDIT, 100, NULL);
960 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
961 radioline(&cp, "Local ec&ho:", IDC_ECHOSTATIC, 3,
962 "Auto", IDC_ECHOBACKEND,
963 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
964 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
965 "Auto", IDC_EDITBACKEND,
966 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
970 if (panel == bellpanelstart) {
971 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
973 ctlposinit(&cp, hwnd, 80, 3, 13);
974 bartitle(&cp, "Options controlling the terminal bell",
976 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
978 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
979 "None (bell disabled)", IDC_BELL_DISABLED,
980 "Play Windows Default Sound", IDC_BELL_DEFAULT,
981 "Play a custom sound file", IDC_BELL_WAVEFILE,
982 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
983 editbutton(&cp, "Custom sound file to play as a bell:",
984 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
985 "Bro&wse...", IDC_BELL_WAVEBROWSE);
986 radioline(&cp, "Taskbar/caption &indication on bell:",
987 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
988 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
991 beginbox(&cp, "Control the bell overload behaviour",
993 checkbox(&cp, "Bell is temporarily &disabled when over-used",
995 staticedit(&cp, "Over-use means this &many bells...",
996 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
997 staticedit(&cp, "... in &this many seconds",
998 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
1000 "The bell is re-enabled after a few seconds of silence.",
1001 1, IDC_BELLOVLEXPLAIN);
1002 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1007 if (panel == keyboardpanelstart) {
1008 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
1010 ctlposinit(&cp, hwnd, 80, 3, 13);
1012 bartitle(&cp, "Options controlling the effects of keys",
1013 IDC_TITLE_KEYBOARD);
1015 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1016 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1017 "Control-H", IDC_DEL008,
1018 "Control-? (127)", IDC_DEL127, NULL);
1019 radioline(&cp, "The &Home and End keys", IDC_HOMESTATIC, 2,
1020 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1021 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1022 "ESC[n~", IDC_FUNCTILDE,
1023 "Linux", IDC_FUNCLINUX,
1024 "Xterm R6", IDC_FUNCXTERM,
1025 "VT400", IDC_FUNCVT400,
1026 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1028 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1030 "Application c&ursor keys totally disabled",
1032 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1033 "Normal", IDC_CURNORMAL,
1034 "Application", IDC_CURAPPLIC, NULL);
1036 "Application ke&ypad keys totally disabled",
1038 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1039 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1040 "NetHack", IDC_KPNH, NULL);
1042 beginbox(&cp, "Enable extra keyboard features:",
1044 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1045 checkbox(&cp, "Control-Alt is &different from AltGr",
1050 if (panel == windowpanelstart) {
1051 /* The Window panel. Accelerators used: [acgo] rmznb sdikp w4ylt f */
1053 ctlposinit(&cp, hwnd, 80, 3, 13);
1054 bartitle(&cp, "Options controlling PuTTY's window",
1056 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1058 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1059 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
1060 radioline(&cp, "Action when the window is resized:", IDC_RESIZESTATIC,
1061 3, "Resi&ze terminal", IDC_RESIZETERM,
1062 "Change fo&nt", IDC_RESIZEFONT,
1063 "For&bid resizing", IDC_RESIZENONE, NULL);
1065 beginbox(&cp, "Control the scrollback in the window",
1067 staticedit(&cp, "Lines of &scrollback",
1068 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1069 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
1070 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
1071 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1072 checkbox(&cp, "Reset scrollback on dis&play activity",
1075 beginbox(&cp, NULL, IDC_BOX_WINDOW3);
1076 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1077 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1078 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1079 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
1080 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1081 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1085 if (panel == appearancepanelstart) {
1086 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1088 ctlposinit(&cp, hwnd, 80, 3, 13);
1089 /* bartitle(&cp, "Options controlling PuTTY's appearance",
1090 IDC_TITLE_APPEARANCE); */
1091 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1092 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1093 "B&lock", IDC_CURBLOCK,
1094 "&Underline", IDC_CURUNDER,
1095 "&Vertical line", IDC_CURVERT, NULL);
1096 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1098 beginbox(&cp, "Set the font used in the terminal window",
1099 IDC_BOX_APPEARANCE2);
1100 staticbtn(&cp, "", IDC_FONTSTATIC, "C&hange...", IDC_CHOOSEFONT);
1102 beginbox(&cp, "Adjust the use of the window title",
1103 IDC_BOX_APPEARANCE3);
1105 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1106 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
1108 beginbox(&cp, "Adjust the use of the mouse pointer",
1109 IDC_BOX_APPEARANCE4);
1110 checkbox(&cp, "Hide mouse &pointer when typing in window",
1113 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1114 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1116 staticedit(&cp, "Gap between text and window edge",
1117 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
1121 if (panel == translationpanelstart) {
1122 /* The Translation panel. Accelerators used: [acgo] rxbepus */
1124 ctlposinit(&cp, hwnd, 80, 3, 13);
1125 bartitle(&cp, "Options controlling character set translation",
1126 IDC_TITLE_TRANSLATION);
1127 beginbox(&cp, "Character set translation on received data",
1128 IDC_BOX_TRANSLATION1);
1129 combobox(&cp, "&Received data assumed to be in which character set:",
1130 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1132 beginbox(&cp, "Enable character set translation on input data",
1133 IDC_BOX_TRANSLATION2);
1134 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
1137 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
1138 IDC_BOX_TRANSLATION3);
1140 "Handling of line drawing characters:", IDC_VTSTATIC,
1141 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1142 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1143 "Use font in O&EM mode only", IDC_VTOEMONLY,
1144 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1145 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
1149 if (panel == selectionpanelstart) {
1150 /* The Selection panel. Accelerators used: [acgo] df wxp hst nr */
1152 ctlposinit(&cp, hwnd, 80, 3, 13);
1153 bartitle(&cp, "Options controlling copy and paste",
1154 IDC_TITLE_SELECTION);
1155 beginbox(&cp, "Translation of pasted characters",
1156 IDC_BOX_SELECTION1);
1158 "&Don't translate line drawing chars into +, - and |",
1161 "Paste to clipboard in RT&F as well as plain text",
1164 beginbox(&cp, "Control which mouse button does which thing",
1165 IDC_BOX_SELECTION2);
1166 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1167 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1168 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1171 "Shift overrides a&pplication's use of mouse",
1174 "Default selection mode (Alt+drag does the other one):",
1175 IDC_SELTYPESTATIC, 2,
1176 "&Normal", IDC_SELTYPELEX,
1177 "&Rectangular block", IDC_SELTYPERECT, NULL);
1179 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1180 IDC_BOX_SELECTION3);
1181 charclass(&cp, "C&haracter classes:", IDC_CCSTATIC, IDC_CCLIST,
1182 "&Set", IDC_CCSET, IDC_CCEDIT,
1183 "&to class", IDC_CCSTATIC2);
1187 if (panel == colourspanelstart) {
1188 /* The Colours panel. Accelerators used: [acgo] blum */
1190 ctlposinit(&cp, hwnd, 80, 3, 13);
1191 bartitle(&cp, "Options controlling use of colours",
1193 beginbox(&cp, "General options for colour usage",
1195 checkbox(&cp, "&Bolded text is a different colour",
1197 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1199 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1201 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1202 IDC_COLOURSTATIC, IDC_COLOURLIST,
1203 "&Modify...", IDC_CHANGE,
1204 "Red:", IDC_RSTATIC, IDC_RVALUE,
1205 "Green:", IDC_GSTATIC, IDC_GVALUE,
1206 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1210 if (panel == connectionpanelstart) {
1211 /* The Connection panel. Accelerators used: [acgo] tuk */
1213 ctlposinit(&cp, hwnd, 80, 3, 13);
1214 bartitle(&cp, "Options controlling the connection",
1215 IDC_TITLE_CONNECTION);
1217 beginbox(&cp, "Data to send to the server",
1218 IDC_BOX_CONNECTION1);
1219 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1221 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1225 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1226 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1230 beginbox(&cp, "Sending of null packets to keep session active",
1231 IDC_BOX_CONNECTION2);
1232 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1233 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1237 if (panel == telnetpanelstart) {
1238 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
1240 ctlposinit(&cp, hwnd, 80, 3, 13);
1242 bartitle(&cp, "Options controlling Telnet connections",
1244 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1245 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1247 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1248 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1249 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1250 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1252 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1253 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1254 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1255 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1256 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1257 "Passive", IDC_TPASSIVE, "Active",
1259 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1265 if (panel == rloginpanelstart) {
1266 /* The Rlogin panel. Accelerators used: [acgo] sl */
1268 ctlposinit(&cp, hwnd, 80, 3, 13);
1270 bartitle(&cp, "Options controlling Rlogin connections",
1272 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1273 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1275 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1276 IDC_RLLUSEREDIT, 50);
1281 if (panel == sshpanelstart) {
1282 /* The SSH panel. Accelerators used: [acgo] r pe12i s */
1284 ctlposinit(&cp, hwnd, 80, 3, 13);
1286 bartitle(&cp, "Options controlling SSH connections",
1288 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1290 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1293 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
1294 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1295 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1296 radioline(&cp, "Preferred SSH protocol version:",
1297 IDC_SSHPROTSTATIC, 2,
1298 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL);
1299 checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1302 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1303 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1304 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1310 if (panel == sshauthpanelstart) {
1311 /* The SSH authentication panel. Accelerators used: [acgo] m fkw */
1313 ctlposinit(&cp, hwnd, 80, 3, 13);
1315 bartitle(&cp, "Options controlling SSH authentication",
1317 beginbox(&cp, "Authentication methods",
1319 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication",
1322 beginbox(&cp, "Authentication parameters",
1324 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
1325 editbutton(&cp, "Private &key file for authentication:",
1326 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
1332 if (panel == tunnelspanelstart) {
1333 /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */
1335 ctlposinit(&cp, hwnd, 80, 3, 13);
1337 bartitle(&cp, "Options controlling SSH tunnelling",
1339 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
1340 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
1341 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
1342 IDC_X11_DISPLAY, 50, NULL);
1344 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
1345 checkbox(&cp, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL);
1346 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
1347 "&Remove", IDC_PFWDREMOVE);
1348 fwdsetter(&cp, IDC_PFWDLIST,
1349 "Add new forwarded port:", IDC_PFWDSTATIC2,
1350 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
1351 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
1352 "A&dd", IDC_PFWDADD);
1353 bareradioline(&cp, 2,
1354 "&Local", IDC_PFWDLOCAL, "Re&mote", IDC_PFWDREMOTE, NULL);
1362 * Helper function to load the session selected in SESSLIST
1363 * if any, as this is done in more than one place in
1364 * GenericMainDlgProc(). 0 => failure.
1366 static int load_selected_session(HWND hwnd)
1368 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1369 LB_GETCURSEL, 0, 0);
1375 isdef = !strcmp(sessions[n], "Default Settings");
1376 load_settings(sessions[n], !isdef, &cfg);
1377 init_dlg_ctrls(hwnd, TRUE);
1379 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
1381 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
1382 /* Restore the selection, which will have been clobbered by
1383 * SESSEDIT handling. */
1384 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
1389 * This function is the configuration box.
1391 static int GenericMainDlgProc(HWND hwnd, UINT msg,
1392 WPARAM wParam, LPARAM lParam, int dlgtype)
1395 struct treeview_faff tvfaff;
1398 char filename[sizeof(cfg.keyfile)];
1401 char fontstatic[256];
1403 struct servent *service;
1405 static UINT draglistmsg = WM_NULL;
1410 SetWindowLong(hwnd, GWL_USERDATA, 0);
1411 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
1412 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
1414 * Centre the window.
1416 { /* centre the window */
1419 hw = GetDesktopWindow();
1420 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
1422 (rs.right + rs.left + rd.left - rd.right) / 2,
1423 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
1424 rd.right - rd.left, rd.bottom - rd.top, TRUE);
1428 * Create the tree view.
1436 r.right = r.left + 75;
1438 r.bottom = r.top + 10;
1439 MapDialogRect(hwnd, &r);
1440 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
1441 WS_CHILD | WS_VISIBLE,
1443 r.right - r.left, r.bottom - r.top,
1444 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
1446 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1447 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1450 r.right = r.left + 75;
1452 r.bottom = r.top + 219;
1453 MapDialogRect(hwnd, &r);
1454 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
1455 WS_CHILD | WS_VISIBLE |
1456 WS_TABSTOP | TVS_HASLINES |
1457 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
1459 TVS_SHOWSELALWAYS, r.left, r.top,
1460 r.right - r.left, r.bottom - r.top,
1461 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
1463 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1464 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1465 tvfaff.treeview = treeview;
1466 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
1470 * Set up the tree view contents.
1472 hsession = treeview_insert(&tvfaff, 0, "Session");
1473 treeview_insert(&tvfaff, 1, "Logging");
1474 treeview_insert(&tvfaff, 0, "Terminal");
1475 treeview_insert(&tvfaff, 1, "Keyboard");
1476 treeview_insert(&tvfaff, 1, "Bell");
1477 treeview_insert(&tvfaff, 0, "Window");
1478 treeview_insert(&tvfaff, 1, "Appearance");
1479 treeview_insert(&tvfaff, 1, "Translation");
1480 treeview_insert(&tvfaff, 1, "Selection");
1481 treeview_insert(&tvfaff, 1, "Colours");
1482 treeview_insert(&tvfaff, 0, "Connection");
1484 treeview_insert(&tvfaff, 1, "Telnet");
1485 treeview_insert(&tvfaff, 1, "Rlogin");
1486 if (backends[3].backend != NULL) {
1487 treeview_insert(&tvfaff, 1, "SSH");
1488 /* XXX long name is ugly */
1489 /* XXX make it closed by default? */
1490 treeview_insert(&tvfaff, 2, "Auth");
1491 treeview_insert(&tvfaff, 2, "Tunnels");
1496 * Put the treeview selection on to the Session panel. This
1497 * should also cause creation of the relevant controls.
1499 TreeView_SelectItem(treeview, hsession);
1502 * Set focus into the first available control.
1506 ctl = GetDlgItem(hwnd, IDC_HOST);
1508 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
1512 SetWindowLong(hwnd, GWL_USERDATA, 1);
1513 sesslist_has_focus = 0;
1517 * Button release should trigger WM_OK if there was a
1518 * previous double click on the session list.
1522 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
1525 if (LOWORD(wParam) == IDCX_TREEVIEW &&
1526 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
1528 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
1533 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
1536 item.pszText = buffer;
1537 item.cchTextMax = sizeof(buffer);
1538 item.mask = TVIF_TEXT;
1539 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
1540 for (j = controlstartvalue; j < controlendvalue; j++) {
1541 HWND item = GetDlgItem(hwnd, j);
1543 DestroyWindow(item);
1545 if (!strcmp(buffer, "Session"))
1546 create_controls(hwnd, dlgtype, sessionpanelstart);
1547 if (!strcmp(buffer, "Logging"))
1548 create_controls(hwnd, dlgtype, loggingpanelstart);
1549 if (!strcmp(buffer, "Keyboard"))
1550 create_controls(hwnd, dlgtype, keyboardpanelstart);
1551 if (!strcmp(buffer, "Terminal"))
1552 create_controls(hwnd, dlgtype, terminalpanelstart);
1553 if (!strcmp(buffer, "Bell"))
1554 create_controls(hwnd, dlgtype, bellpanelstart);
1555 if (!strcmp(buffer, "Window"))
1556 create_controls(hwnd, dlgtype, windowpanelstart);
1557 if (!strcmp(buffer, "Appearance"))
1558 create_controls(hwnd, dlgtype, appearancepanelstart);
1559 if (!strcmp(buffer, "Tunnels"))
1560 create_controls(hwnd, dlgtype, tunnelspanelstart);
1561 if (!strcmp(buffer, "Connection"))
1562 create_controls(hwnd, dlgtype, connectionpanelstart);
1563 if (!strcmp(buffer, "Telnet"))
1564 create_controls(hwnd, dlgtype, telnetpanelstart);
1565 if (!strcmp(buffer, "Rlogin"))
1566 create_controls(hwnd, dlgtype, rloginpanelstart);
1567 if (!strcmp(buffer, "SSH"))
1568 create_controls(hwnd, dlgtype, sshpanelstart);
1569 if (!strcmp(buffer, "Auth"))
1570 create_controls(hwnd, dlgtype, sshauthpanelstart);
1571 if (!strcmp(buffer, "Selection"))
1572 create_controls(hwnd, dlgtype, selectionpanelstart);
1573 if (!strcmp(buffer, "Colours"))
1574 create_controls(hwnd, dlgtype, colourspanelstart);
1575 if (!strcmp(buffer, "Translation"))
1576 create_controls(hwnd, dlgtype, translationpanelstart);
1578 init_dlg_ctrls(hwnd, FALSE);
1580 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
1581 InvalidateRect (hwnd, NULL, TRUE);
1583 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
1589 * Only process WM_COMMAND once the dialog is fully formed.
1591 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
1592 switch (LOWORD(wParam)) {
1594 /* Behaviour of the "Open" button is different if the
1595 * session list has focus, *unless* the user just
1596 * double-clicked... */
1597 if (sesslist_has_focus && !readytogo) {
1598 if (!load_selected_session(hwnd)) {
1603 /* If at this point we have a valid session, go! */
1612 case IDC_PROTTELNET:
1613 case IDC_PROTRLOGIN:
1616 if (HIWORD(wParam) == BN_CLICKED ||
1617 HIWORD(wParam) == BN_DOUBLECLICKED) {
1618 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
1619 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
1620 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
1622 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
1624 if ((cfg.protocol == PROT_SSH && cfg.port != 22)
1625 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
1626 || (cfg.protocol == PROT_RLOGIN
1627 && cfg.port != 513)) {
1628 cfg.port = i ? 22 : j ? 23 : 513;
1629 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
1634 if (HIWORD(wParam) == EN_CHANGE)
1635 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
1636 sizeof(cfg.host) - 1);
1639 if (HIWORD(wParam) == EN_CHANGE) {
1640 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
1641 if (isdigit(portname[0]))
1642 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
1644 service = getservbyname(portname, NULL);
1646 cfg.port = ntohs(service->s_port);
1653 if (HIWORD(wParam) == EN_CHANGE) {
1654 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
1656 GetDlgItemText(hwnd, IDC_SESSEDIT,
1657 savedsession, sizeof(savedsession) - 1);
1658 savedsession[sizeof(savedsession) - 1] = '\0';
1662 if (HIWORD(wParam) == BN_CLICKED ||
1663 HIWORD(wParam) == BN_DOUBLECLICKED) {
1668 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
1671 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1672 LB_GETCURSEL, 0, 0);
1677 strcpy(str, sessions[n]);
1679 save_settings(str, !!strcmp(str, "Default Settings"),
1681 get_sesslist(FALSE);
1683 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
1685 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
1687 for (i = 0; i < nsessions; i++)
1688 SendDlgItemMessage(hwnd, IDC_SESSLIST,
1690 (LPARAM) (sessions[i]));
1691 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
1693 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
1695 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
1701 if (LOWORD(wParam) == IDC_SESSLIST) {
1702 if (HIWORD(wParam) == LBN_SETFOCUS)
1703 sesslist_has_focus = 1;
1704 else if (HIWORD(wParam) == LBN_KILLFOCUS)
1705 sesslist_has_focus = 0;
1707 if (LOWORD(wParam) == IDC_SESSLOAD &&
1708 HIWORD(wParam) != BN_CLICKED &&
1709 HIWORD(wParam) != BN_DOUBLECLICKED) break;
1710 if (LOWORD(wParam) == IDC_SESSLIST &&
1711 HIWORD(wParam) != LBN_DBLCLK) break;
1712 /* Load the session selected in SESSLIST. */
1713 if (load_selected_session(hwnd) &&
1714 LOWORD(wParam) == IDC_SESSLIST) {
1716 * A double-click on a saved session should
1717 * actually start the session, not just load it.
1718 * Unless it's Default Settings or some other
1719 * host-less set of saved settings.
1728 if (HIWORD(wParam) == BN_CLICKED ||
1729 HIWORD(wParam) == BN_DOUBLECLICKED) {
1730 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1731 LB_GETCURSEL, 0, 0);
1732 if (n == LB_ERR || n == 0) {
1736 del_settings(sessions[n]);
1737 get_sesslist(FALSE);
1739 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
1741 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
1743 for (i = 0; i < nsessions; i++)
1744 SendDlgItemMessage(hwnd, IDC_SESSLIST,
1746 (LPARAM) (sessions[i]));
1747 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
1749 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
1751 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
1755 if (HIWORD(wParam) == EN_CHANGE)
1756 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
1757 &cfg.ping_interval);
1761 if (HIWORD(wParam) == BN_CLICKED ||
1762 HIWORD(wParam) == BN_DOUBLECLICKED)
1763 cfg.bksp_is_delete =
1764 IsDlgButtonChecked(hwnd, IDC_DEL127);
1768 if (HIWORD(wParam) == BN_CLICKED ||
1769 HIWORD(wParam) == BN_DOUBLECLICKED)
1771 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
1777 case IDC_FUNCVT100P:
1779 if (HIWORD(wParam) == BN_CLICKED ||
1780 HIWORD(wParam) == BN_DOUBLECLICKED)
1781 switch (LOWORD(wParam)) {
1794 case IDC_FUNCVT100P:
1804 if (HIWORD(wParam) == BN_CLICKED ||
1805 HIWORD(wParam) == BN_DOUBLECLICKED) {
1807 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
1808 cfg.nethack_keypad = FALSE;
1812 if (HIWORD(wParam) == BN_CLICKED ||
1813 HIWORD(wParam) == BN_DOUBLECLICKED) {
1814 cfg.app_keypad = FALSE;
1815 cfg.nethack_keypad = TRUE;
1820 if (HIWORD(wParam) == BN_CLICKED ||
1821 HIWORD(wParam) == BN_DOUBLECLICKED)
1823 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
1826 if (HIWORD(wParam) == BN_CLICKED ||
1827 HIWORD(wParam) == BN_DOUBLECLICKED)
1829 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
1832 if (HIWORD(wParam) == BN_CLICKED ||
1833 HIWORD(wParam) == BN_DOUBLECLICKED)
1835 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
1838 if (HIWORD(wParam) == BN_CLICKED ||
1839 HIWORD(wParam) == BN_DOUBLECLICKED)
1840 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
1843 if (HIWORD(wParam) == BN_CLICKED ||
1844 HIWORD(wParam) == BN_DOUBLECLICKED)
1846 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
1849 if (HIWORD(wParam) == BN_CLICKED ||
1850 HIWORD(wParam) == BN_DOUBLECLICKED)
1852 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
1854 case IDC_ECHOBACKEND:
1857 if (HIWORD(wParam) == BN_CLICKED ||
1858 HIWORD(wParam) == BN_DOUBLECLICKED) {
1859 if (LOWORD(wParam) == IDC_ECHOBACKEND)
1860 cfg.localecho = LD_BACKEND;
1861 if (LOWORD(wParam) == IDC_ECHOYES)
1862 cfg.localecho = LD_YES;
1863 if (LOWORD(wParam) == IDC_ECHONO)
1864 cfg.localecho = LD_NO;
1867 case IDC_EDITBACKEND:
1870 if (HIWORD(wParam) == BN_CLICKED ||
1871 HIWORD(wParam) == BN_DOUBLECLICKED) {
1872 if (LOWORD(wParam) == IDC_EDITBACKEND)
1873 cfg.localedit = LD_BACKEND;
1874 if (LOWORD(wParam) == IDC_EDITYES)
1875 cfg.localedit = LD_YES;
1876 if (LOWORD(wParam) == IDC_EDITNO)
1877 cfg.localedit = LD_NO;
1880 case IDC_ANSWEREDIT:
1881 if (HIWORD(wParam) == EN_CHANGE)
1882 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
1883 sizeof(cfg.answerback) - 1);
1885 case IDC_ALWAYSONTOP:
1886 if (HIWORD(wParam) == BN_CLICKED ||
1887 HIWORD(wParam) == BN_DOUBLECLICKED)
1889 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
1891 case IDC_FULLSCREENONALTENTER:
1892 if (HIWORD(wParam) == BN_CLICKED ||
1893 HIWORD(wParam) == BN_DOUBLECLICKED)
1894 cfg.fullscreenonaltenter =
1895 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
1898 if (HIWORD(wParam) == BN_CLICKED ||
1899 HIWORD(wParam) == BN_DOUBLECLICKED)
1901 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
1903 case IDC_SCROLLDISP:
1904 if (HIWORD(wParam) == BN_CLICKED ||
1905 HIWORD(wParam) == BN_DOUBLECLICKED)
1906 cfg.scroll_on_disp =
1907 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
1909 case IDC_COMPOSEKEY:
1910 if (HIWORD(wParam) == BN_CLICKED ||
1911 HIWORD(wParam) == BN_DOUBLECLICKED)
1913 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
1915 case IDC_CTRLALTKEYS:
1916 if (HIWORD(wParam) == BN_CLICKED ||
1917 HIWORD(wParam) == BN_DOUBLECLICKED)
1919 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
1922 if (HIWORD(wParam) == BN_CLICKED ||
1923 HIWORD(wParam) == BN_DOUBLECLICKED)
1924 cfg.telnet_keyboard =
1925 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
1928 if (HIWORD(wParam) == BN_CLICKED ||
1929 HIWORD(wParam) == BN_DOUBLECLICKED)
1931 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
1934 if (HIWORD(wParam) == BN_CLICKED ||
1935 HIWORD(wParam) == BN_DOUBLECLICKED)
1936 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
1939 if (HIWORD(wParam) == BN_CLICKED ||
1940 HIWORD(wParam) == BN_DOUBLECLICKED)
1942 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
1945 if (HIWORD(wParam) == EN_CHANGE)
1946 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
1949 if (HIWORD(wParam) == EN_CHANGE)
1950 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
1953 if (HIWORD(wParam) == EN_CHANGE)
1954 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
1956 case IDC_CHOOSEFONT:
1959 lf.lfHeight = -MulDiv(cfg.fontheight,
1960 GetDeviceCaps(hdc, LOGPIXELSY),
1964 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
1965 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
1966 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
1967 lf.lfCharSet = cfg.fontcharset;
1968 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
1969 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
1970 lf.lfQuality = DEFAULT_QUALITY;
1971 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
1972 strncpy(lf.lfFaceName, cfg.font,
1973 sizeof(lf.lfFaceName) - 1);
1974 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
1976 cf.lStructSize = sizeof(cf);
1977 cf.hwndOwner = hwnd;
1979 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
1980 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
1982 if (ChooseFont(&cf)) {
1983 strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
1984 cfg.font[sizeof(cfg.font) - 1] = '\0';
1985 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
1986 cfg.fontcharset = lf.lfCharSet;
1987 cfg.fontheight = cf.iPointSize / 10;
1988 fmtfont(fontstatic);
1989 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
1992 case IDC_BELL_DISABLED:
1993 case IDC_BELL_DEFAULT:
1994 case IDC_BELL_WAVEFILE:
1995 case IDC_BELL_VISUAL:
1996 if (HIWORD(wParam) == BN_CLICKED ||
1997 HIWORD(wParam) == BN_DOUBLECLICKED) {
1998 if (LOWORD(wParam) == IDC_BELL_DISABLED)
1999 cfg.beep = BELL_DISABLED;
2000 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
2001 cfg.beep = BELL_DEFAULT;
2002 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
2003 cfg.beep = BELL_WAVEFILE;
2004 if (LOWORD(wParam) == IDC_BELL_VISUAL)
2005 cfg.beep = BELL_VISUAL;
2008 case IDC_B_IND_DISABLED:
2009 case IDC_B_IND_FLASH:
2010 case IDC_B_IND_STEADY:
2011 if (HIWORD(wParam) == BN_CLICKED ||
2012 HIWORD(wParam) == BN_DOUBLECLICKED) {
2013 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2014 cfg.beep_ind = B_IND_DISABLED;
2015 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2016 cfg.beep_ind = B_IND_FLASH;
2017 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2018 cfg.beep_ind = B_IND_STEADY;
2021 case IDC_BELL_WAVEBROWSE:
2022 memset(&of, 0, sizeof(of));
2023 #ifdef OPENFILENAME_SIZE_VERSION_400
2024 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2026 of.lStructSize = sizeof(of);
2028 of.hwndOwner = hwnd;
2029 of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2030 of.lpstrCustomFilter = NULL;
2031 of.nFilterIndex = 1;
2032 of.lpstrFile = filename;
2033 strcpy(filename, cfg.bell_wavefile);
2034 of.nMaxFile = sizeof(filename);
2035 of.lpstrFileTitle = NULL;
2036 of.lpstrInitialDir = NULL;
2037 of.lpstrTitle = "Select Bell Sound File";
2039 if (GetOpenFileName(&of)) {
2040 strcpy(cfg.bell_wavefile, filename);
2041 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2045 case IDC_BELL_WAVEEDIT:
2046 if (HIWORD(wParam) == EN_CHANGE)
2047 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2049 sizeof(cfg.bell_wavefile) - 1);
2052 if (HIWORD(wParam) == BN_CLICKED ||
2053 HIWORD(wParam) == BN_DOUBLECLICKED)
2055 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2058 if (HIWORD(wParam) == EN_CHANGE)
2059 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2062 if (HIWORD(wParam) == EN_CHANGE)
2063 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2067 if (HIWORD(wParam) == EN_CHANGE)
2068 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2072 if (HIWORD(wParam) == BN_CLICKED ||
2073 HIWORD(wParam) == BN_DOUBLECLICKED)
2075 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2078 if (HIWORD(wParam) == BN_CLICKED ||
2079 HIWORD(wParam) == BN_DOUBLECLICKED)
2080 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2083 if (HIWORD(wParam) == BN_CLICKED ||
2084 HIWORD(wParam) == BN_DOUBLECLICKED)
2085 cfg.win_name_always =
2086 IsDlgButtonChecked(hwnd, IDC_WINNAME);
2089 if (HIWORD(wParam) == BN_CLICKED ||
2090 HIWORD(wParam) == BN_DOUBLECLICKED)
2092 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2094 case IDC_SUNKENEDGE:
2095 if (HIWORD(wParam) == BN_CLICKED ||
2096 HIWORD(wParam) == BN_DOUBLECLICKED)
2098 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2101 if (HIWORD(wParam) == EN_CHANGE)
2102 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2103 &cfg.window_border);
2104 if (cfg.window_border > 32)
2105 cfg.window_border = 32;
2108 if (HIWORD(wParam) == BN_CLICKED ||
2109 HIWORD(wParam) == BN_DOUBLECLICKED)
2110 cfg.cursor_type = 0;
2113 if (HIWORD(wParam) == BN_CLICKED ||
2114 HIWORD(wParam) == BN_DOUBLECLICKED)
2115 cfg.cursor_type = 1;
2118 if (HIWORD(wParam) == BN_CLICKED ||
2119 HIWORD(wParam) == BN_DOUBLECLICKED)
2120 cfg.cursor_type = 2;
2123 if (HIWORD(wParam) == BN_CLICKED ||
2124 HIWORD(wParam) == BN_DOUBLECLICKED)
2126 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2129 if (HIWORD(wParam) == BN_CLICKED ||
2130 HIWORD(wParam) == BN_DOUBLECLICKED)
2132 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2134 case IDC_SCROLLBARFULLSCREEN:
2135 if (HIWORD(wParam) == BN_CLICKED ||
2136 HIWORD(wParam) == BN_DOUBLECLICKED)
2137 cfg.scrollbar_in_fullscreen =
2138 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2140 case IDC_RESIZETERM:
2141 case IDC_RESIZEFONT:
2142 case IDC_RESIZENONE:
2143 if (HIWORD(wParam) == BN_CLICKED ||
2144 HIWORD(wParam) == BN_DOUBLECLICKED) {
2146 IsDlgButtonChecked(hwnd,
2147 IDC_RESIZETERM) ? RESIZE_TERM :
2148 IsDlgButtonChecked(hwnd,
2149 IDC_RESIZEFONT) ? RESIZE_FONT :
2154 if (HIWORD(wParam) == EN_CHANGE)
2155 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2156 sizeof(cfg.wintitle) - 1);
2161 if (HIWORD(wParam) == BN_CLICKED ||
2162 HIWORD(wParam) == BN_DOUBLECLICKED) {
2164 IsDlgButtonChecked(hwnd,
2165 IDC_COEALWAYS) ? COE_ALWAYS :
2166 IsDlgButtonChecked(hwnd,
2167 IDC_COENEVER) ? COE_NEVER :
2172 if (HIWORD(wParam) == BN_CLICKED ||
2173 HIWORD(wParam) == BN_DOUBLECLICKED)
2175 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
2178 if (HIWORD(wParam) == EN_CHANGE)
2179 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
2180 sizeof(cfg.termtype) - 1);
2183 if (HIWORD(wParam) == EN_CHANGE)
2184 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
2185 sizeof(cfg.logfilename) - 1);
2188 memset(&of, 0, sizeof(of));
2189 #ifdef OPENFILENAME_SIZE_VERSION_400
2190 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2192 of.lStructSize = sizeof(of);
2194 of.hwndOwner = hwnd;
2195 of.lpstrFilter = "All Files\0*\0\0\0";
2196 of.lpstrCustomFilter = NULL;
2197 of.nFilterIndex = 1;
2198 of.lpstrFile = filename;
2199 strcpy(filename, cfg.logfilename);
2200 of.nMaxFile = sizeof(filename);
2201 of.lpstrFileTitle = NULL;
2202 of.lpstrInitialDir = NULL;
2203 of.lpstrTitle = "Select session log file";
2205 if (GetSaveFileName(&of)) {
2206 strcpy(cfg.logfilename, filename);
2207 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
2211 case IDC_LSTATASCII:
2213 if (HIWORD(wParam) == BN_CLICKED ||
2214 HIWORD(wParam) == BN_DOUBLECLICKED) {
2215 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
2217 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
2219 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
2226 if (HIWORD(wParam) == BN_CLICKED ||
2227 HIWORD(wParam) == BN_DOUBLECLICKED) {
2228 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
2229 cfg.logxfovr = LGXF_ASK;
2230 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
2231 cfg.logxfovr = LGXF_APN;
2232 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
2233 cfg.logxfovr = LGXF_OVR;
2238 if (HIWORD(wParam) == EN_CHANGE)
2239 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
2240 sizeof(cfg.termspeed) - 1);
2243 if (HIWORD(wParam) == EN_CHANGE)
2244 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
2245 sizeof(cfg.username) - 1);
2247 case IDC_RLLUSEREDIT:
2248 if (HIWORD(wParam) == EN_CHANGE)
2249 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
2251 sizeof(cfg.localusername) - 1);
2255 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
2259 cfg.passive_telnet =
2260 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
2263 if (HIWORD(wParam) == BN_CLICKED ||
2264 HIWORD(wParam) == BN_DOUBLECLICKED) {
2265 char str[sizeof(cfg.environmt)];
2267 GetDlgItemText(hwnd, IDC_VAREDIT, str,
2273 p = str + strlen(str);
2275 GetDlgItemText(hwnd, IDC_VALEDIT, p,
2276 sizeof(str) - 1 - (p - str));
2287 if ((p - cfg.environmt) + strlen(str) + 2 <
2288 sizeof(cfg.environmt)) {
2290 p[strlen(str) + 1] = '\0';
2291 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
2293 SetDlgItemText(hwnd, IDC_VAREDIT, "");
2294 SetDlgItemText(hwnd, IDC_VALEDIT, "");
2296 MessageBox(hwnd, "Environment too big",
2297 "PuTTY Error", MB_OK | MB_ICONERROR);
2302 if (HIWORD(wParam) != BN_CLICKED &&
2303 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2305 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
2312 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
2339 if (HIWORD(wParam) == BN_CLICKED ||
2340 HIWORD(wParam) == BN_DOUBLECLICKED)
2341 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
2344 if (HIWORD(wParam) == BN_CLICKED ||
2345 HIWORD(wParam) == BN_DOUBLECLICKED)
2347 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
2350 if (HIWORD(wParam) == BN_CLICKED ||
2351 HIWORD(wParam) == BN_DOUBLECLICKED)
2353 IsDlgButtonChecked(hwnd, IDC_BUGGYMAC);
2356 if (HIWORD(wParam) == BN_CLICKED ||
2357 HIWORD(wParam) == BN_DOUBLECLICKED)
2359 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
2361 case IDC_CIPHERLIST:
2364 handle_prefslist(&cipherlist,
2365 cfg.ssh_cipherlist, CIPHER_MAX,
2366 0, hwnd, wParam, lParam);
2370 if (HIWORD(wParam) == BN_CLICKED ||
2371 HIWORD(wParam) == BN_DOUBLECLICKED) {
2372 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
2374 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
2379 if (HIWORD(wParam) == BN_CLICKED ||
2380 HIWORD(wParam) == BN_DOUBLECLICKED)
2382 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
2385 if (HIWORD(wParam) == EN_CHANGE)
2386 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
2387 sizeof(cfg.keyfile) - 1);
2390 if (HIWORD(wParam) == EN_CHANGE)
2391 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
2392 sizeof(cfg.remote_cmd) - 1);
2395 memset(&of, 0, sizeof(of));
2396 #ifdef OPENFILENAME_SIZE_VERSION_400
2397 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2399 of.lStructSize = sizeof(of);
2401 of.hwndOwner = hwnd;
2402 of.lpstrFilter = "All Files\0*\0\0\0";
2403 of.lpstrCustomFilter = NULL;
2404 of.nFilterIndex = 1;
2405 of.lpstrFile = filename;
2406 strcpy(filename, cfg.keyfile);
2407 of.nMaxFile = sizeof(filename);
2408 of.lpstrFileTitle = NULL;
2409 of.lpstrInitialDir = NULL;
2410 of.lpstrTitle = "Select Private Key File";
2412 if (GetOpenFileName(&of)) {
2413 strcpy(cfg.keyfile, filename);
2414 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
2418 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
2421 cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
2425 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
2427 case IDC_SELTYPELEX:
2428 case IDC_SELTYPERECT:
2429 cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
2431 case IDC_MOUSEOVERRIDE:
2432 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
2438 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
2443 for (i = 0; i < 128; i++)
2444 if (SendDlgItemMessage
2445 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
2447 cfg.wordness[i] = n;
2448 SendDlgItemMessage(hwnd, IDC_CCLIST,
2449 LB_DELETESTRING, i, 0);
2450 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
2451 (i >= 0x21 && i != 0x7F) ? i : ' ',
2453 SendDlgItemMessage(hwnd, IDC_CCLIST,
2460 case IDC_BOLDCOLOUR:
2461 if (HIWORD(wParam) == BN_CLICKED ||
2462 HIWORD(wParam) == BN_DOUBLECLICKED) {
2465 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
2466 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
2469 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2471 if (n != 12 + 10 * cfg.bold_colour) {
2472 for (i = n; i-- > 0;)
2473 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2474 LB_DELETESTRING, i, 0);
2475 for (i = 0; i < 22; i++)
2476 if (cfg.bold_colour || permcolour[i])
2477 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2479 (LPARAM) colours[i]);
2481 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
2483 InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
2488 if (HIWORD(wParam) == BN_CLICKED ||
2489 HIWORD(wParam) == BN_DOUBLECLICKED)
2491 IsDlgButtonChecked(hwnd, IDC_PALETTE);
2493 case IDC_COLOURLIST:
2494 if (HIWORD(wParam) == LBN_DBLCLK ||
2495 HIWORD(wParam) == LBN_SELCHANGE) {
2497 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2500 if (!cfg.bold_colour)
2501 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
2502 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
2504 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
2506 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
2511 if (HIWORD(wParam) == BN_CLICKED ||
2512 HIWORD(wParam) == BN_DOUBLECLICKED) {
2513 static CHOOSECOLOR cc;
2514 static DWORD custom[16] = { 0 }; /* zero initialisers */
2516 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2519 if (!cfg.bold_colour)
2520 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
2521 cc.lStructSize = sizeof(cc);
2522 cc.hwndOwner = hwnd;
2523 cc.hInstance = (HWND) hinst;
2524 cc.lpCustColors = custom;
2526 RGB(cfg.colours[i][0], cfg.colours[i][1],
2528 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
2529 if (ChooseColor(&cc)) {
2531 (unsigned char) (cc.rgbResult & 0xFF);
2533 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
2535 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
2536 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
2538 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
2540 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
2546 if (HIWORD(wParam) == CBN_SELCHANGE) {
2547 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
2548 CB_GETCURSEL, 0, 0);
2549 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
2550 index, (LPARAM)cfg.line_codepage);
2551 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
2552 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
2553 sizeof(cfg.line_codepage) - 1);
2554 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
2555 strcpy(cfg.line_codepage,
2556 cp_name(decode_codepage(cfg.line_codepage)));
2557 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
2560 case IDC_CAPSLOCKCYR:
2561 if (HIWORD(wParam) == BN_CLICKED ||
2562 HIWORD(wParam) == BN_DOUBLECLICKED) {
2563 cfg.xlat_capslockcyr =
2564 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
2567 case IDC_VTXWINDOWS:
2573 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
2574 : IsDlgButtonChecked(hwnd,
2575 IDC_VTOEMANSI) ? VT_OEMANSI :
2576 IsDlgButtonChecked(hwnd,
2577 IDC_VTOEMONLY) ? VT_OEMONLY :
2578 IsDlgButtonChecked(hwnd,
2579 IDC_VTUNICODE) ? VT_UNICODE :
2582 case IDC_X11_FORWARD:
2583 if (HIWORD(wParam) == BN_CLICKED ||
2584 HIWORD(wParam) == BN_DOUBLECLICKED)
2586 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
2589 if (HIWORD(wParam) == BN_CLICKED ||
2590 HIWORD(wParam) == BN_DOUBLECLICKED)
2591 cfg.lport_acceptall =
2592 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
2594 case IDC_X11_DISPLAY:
2595 if (HIWORD(wParam) == EN_CHANGE)
2596 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
2597 sizeof(cfg.x11_display) - 1);
2600 if (HIWORD(wParam) == BN_CLICKED ||
2601 HIWORD(wParam) == BN_DOUBLECLICKED) {
2602 char str[sizeof(cfg.portfwd)];
2604 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
2608 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
2612 "You need to specify a source port number",
2613 "PuTTY Error", MB_OK | MB_ICONERROR);
2616 p = str + strlen(str);
2618 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
2619 sizeof(str) - 1 - (p - str));
2620 if (!*p || !strchr(p, ':')) {
2622 "You need to specify a destination address\n"
2623 "in the form \"host.name:port\"",
2624 "PuTTY Error", MB_OK | MB_ICONERROR);
2633 if ((p - cfg.portfwd) + strlen(str) + 2 <
2634 sizeof(cfg.portfwd)) {
2636 p[strlen(str) + 1] = '\0';
2637 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
2639 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
2640 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
2642 MessageBox(hwnd, "Too many forwardings",
2643 "PuTTY Error", MB_OK | MB_ICONERROR);
2647 case IDC_PFWDREMOVE:
2648 if (HIWORD(wParam) != BN_CLICKED &&
2649 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2650 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
2651 LB_GETCURSEL, 0, 0);
2657 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
2689 /* Grrr Explorer will maximize Dialogs! */
2691 if (wParam == SIZE_MAXIMIZED)
2697 * Handle application-defined messages eg. DragListBox
2699 /* First find out what the number is (once). */
2700 if (draglistmsg == WM_NULL)
2701 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
2703 if (msg == draglistmsg) {
2704 /* Only process once dialog is fully formed. */
2705 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
2706 case IDC_CIPHERLIST:
2707 return handle_prefslist(&cipherlist,
2708 cfg.ssh_cipherlist, CIPHER_MAX,
2709 1, hwnd, wParam, lParam);
2718 static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
2719 WPARAM wParam, LPARAM lParam)
2721 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
2723 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
2724 EnableWindow(hwnd, 0);
2725 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
2726 EnableWindow(hwnd, 1);
2727 SetActiveWindow(hwnd);
2729 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
2732 static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
2733 WPARAM wParam, LPARAM lParam)
2735 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
2738 void defuse_showwindow(void)
2741 * Work around the fact that the app's first call to ShowWindow
2742 * will ignore the default in favour of the shell-provided
2747 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
2749 ShowWindow(hwnd, SW_HIDE);
2750 SetActiveWindow(hwnd);
2751 DestroyWindow(hwnd);
2760 savedsession[0] = '\0';
2762 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
2763 get_sesslist(FALSE);
2768 int do_reconfig(HWND hwnd)
2773 backup_cfg = cfg; /* structure copy */
2775 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
2777 cfg = backup_cfg; /* structure copy */
2782 void logevent(char *string)
2787 if (nevents >= negsize) {
2789 events = srealloc(events, negsize * sizeof(*events));
2793 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
2796 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
2797 strcpy(events[nevents], timebuf);
2798 strcat(events[nevents], string);
2801 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
2802 0, (LPARAM) events[nevents]);
2803 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
2804 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
2809 void showeventlog(HWND hwnd)
2812 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
2814 ShowWindow(logbox, SW_SHOWNORMAL);
2816 SetActiveWindow(logbox);
2819 void showabout(HWND hwnd)
2821 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
2824 void verify_ssh_host_key(char *host, int port, char *keytype,
2825 char *keystr, char *fingerprint)
2829 static const char absentmsg[] =
2830 "The server's host key is not cached in the registry. You\n"
2831 "have no guarantee that the server is the computer you\n"
2833 "The server's key fingerprint is:\n"
2835 "If you trust this host, hit Yes to add the key to\n"
2836 "PuTTY's cache and carry on connecting.\n"
2837 "If you want to carry on connecting just once, without\n"
2838 "adding the key to the cache, hit No.\n"
2839 "If you do not trust this host, hit Cancel to abandon the\n"
2842 static const char wrongmsg[] =
2843 "WARNING - POTENTIAL SECURITY BREACH!\n"
2845 "The server's host key does not match the one PuTTY has\n"
2846 "cached in the registry. This means that either the\n"
2847 "server administrator has changed the host key, or you\n"
2848 "have actually connected to another computer pretending\n"
2849 "to be the server.\n"
2850 "The new key fingerprint is:\n"
2852 "If you were expecting this change and trust the new key,\n"
2853 "hit Yes to update PuTTY's cache and continue connecting.\n"
2854 "If you want to carry on connecting but without updating\n"
2855 "the cache, hit No.\n"
2856 "If you want to abandon the connection completely, hit\n"
2857 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
2859 static const char mbtitle[] = "PuTTY Security Alert";
2862 /* sensible fingerprint max size */
2863 (sizeof(absentmsg) > sizeof(wrongmsg) ?
2864 sizeof(absentmsg) : sizeof(wrongmsg))];
2867 * Verify the key against the registry.
2869 ret = verify_host_key(host, port, keytype, keystr);
2871 if (ret == 0) /* success - key matched OK */
2873 if (ret == 2) { /* key was different */
2875 sprintf(message, wrongmsg, fingerprint);
2876 mbret = MessageBox(NULL, message, mbtitle,
2877 MB_ICONWARNING | MB_YESNOCANCEL);
2879 store_host_key(host, port, keytype, keystr);
2880 if (mbret == IDCANCEL)
2883 if (ret == 1) { /* key was absent */
2885 sprintf(message, absentmsg, fingerprint);
2886 mbret = MessageBox(NULL, message, mbtitle,
2887 MB_ICONWARNING | MB_YESNOCANCEL);
2889 store_host_key(host, port, keytype, keystr);
2890 if (mbret == IDCANCEL)
2896 * Ask whether the selected cipher is acceptable (since it was
2897 * below the configured 'warn' threshold).
2898 * cs: 0 = both ways, 1 = client->server, 2 = server->client
2900 void askcipher(char *ciphername, int cs)
2902 static const char mbtitle[] = "PuTTY Security Alert";
2903 static const char msg[] =
2904 "The first %.35scipher supported by the server\n"
2905 "is %.64s, which is below the configured\n"
2906 "warning threshold.\n"
2907 "Do you want to continue with this connection?\n";
2908 /* guessed cipher name + type max length */
2909 char message[100 + sizeof(msg)];
2912 sprintf(message, msg,
2914 (cs == 1) ? "client-to-server " :
2915 "server-to-client ",
2917 mbret = MessageBox(NULL, message, mbtitle,
2918 MB_ICONWARNING | MB_YESNO);
2926 * Ask whether to wipe a session log file before writing to it.
2927 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2929 int askappend(char *filename)
2931 static const char mbtitle[] = "PuTTY Log to File";
2932 static const char msgtemplate[] =
2933 "The session log file \"%.*s\" already exists.\n"
2934 "You can overwrite it with a new session log,\n"
2935 "append your session log to the end of it,\n"
2936 "or disable session logging for this session.\n"
2937 "Hit Yes to wipe the file, No to append to it,\n"
2938 "or Cancel to disable logging.";
2939 char message[sizeof(msgtemplate) + FILENAME_MAX];
2941 if (cfg.logxfovr != LGXF_ASK) {
2942 return ((cfg.logxfovr == LGXF_OVR) ? 2 : 1);
2944 sprintf(message, msgtemplate, FILENAME_MAX, filename);
2946 mbret = MessageBox(NULL, message, mbtitle,
2947 MB_ICONQUESTION | MB_YESNOCANCEL);
2950 else if (mbret == IDNO)