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,
507 translationpanelstart,
508 IDC_TITLE_TRANSLATION,
509 IDC_BOX_TRANSLATION1,
510 IDC_BOX_TRANSLATION2,
511 IDC_BOX_TRANSLATION3,
548 static const char *const colours[] = {
549 "Default Foreground", "Default Bold Foreground",
550 "Default Background", "Default Bold Background",
551 "Cursor Text", "Cursor Colour",
552 "ANSI Black", "ANSI Black Bold",
553 "ANSI Red", "ANSI Red Bold",
554 "ANSI Green", "ANSI Green Bold",
555 "ANSI Yellow", "ANSI Yellow Bold",
556 "ANSI Blue", "ANSI Blue Bold",
557 "ANSI Magenta", "ANSI Magenta Bold",
558 "ANSI Cyan", "ANSI Cyan Bold",
559 "ANSI White", "ANSI White Bold"
561 static const int permcolour[] = {
562 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
563 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
564 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
567 static void fmtfont(char *buf)
569 sprintf(buf, "Font: %s, ", cfg.font);
571 strcat(buf, "bold, ");
572 if (cfg.fontheight == 0)
573 strcat(buf, "default height");
575 sprintf(buf + strlen(buf), "%d-point",
576 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
579 /* 2nd arg: NZ => don't redraw session list (use when loading
581 static void init_dlg_ctrls(HWND hwnd, int keepsess)
584 char fontstatic[256];
586 SetDlgItemText(hwnd, IDC_HOST, cfg.host);
587 SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
590 n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
591 for (i = n; i-- > 0;)
592 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_DELETESTRING, i, 0);
593 for (i = 0; i < nsessions; i++)
594 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_ADDSTRING,
595 0, (LPARAM) (sessions[i]));
597 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
598 CheckRadioButton(hwnd, IDC_PROTRAW, IDC_PROTSSH,
599 cfg.protocol == PROT_SSH ? IDC_PROTSSH :
600 cfg.protocol == PROT_TELNET ? IDC_PROTTELNET :
602 PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW);
603 SetDlgItemInt(hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
605 CheckRadioButton(hwnd, IDC_DEL008, IDC_DEL127,
606 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
607 CheckRadioButton(hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
608 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
609 CheckRadioButton(hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
610 cfg.funky_type == 0 ? IDC_FUNCTILDE :
611 cfg.funky_type == 1 ? IDC_FUNCLINUX :
612 cfg.funky_type == 2 ? IDC_FUNCXTERM :
613 cfg.funky_type == 3 ? IDC_FUNCVT400 :
614 cfg.funky_type == 4 ? IDC_FUNCVT100P :
615 cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE);
616 CheckDlgButton(hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
617 CheckDlgButton(hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
618 CheckRadioButton(hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
619 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
620 CheckRadioButton(hwnd, IDC_KPNORMAL, IDC_KPNH,
621 cfg.nethack_keypad ? IDC_KPNH :
622 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
623 CheckDlgButton(hwnd, IDC_ALTF4, cfg.alt_f4);
624 CheckDlgButton(hwnd, IDC_ALTSPACE, cfg.alt_space);
625 CheckDlgButton(hwnd, IDC_ALTONLY, cfg.alt_only);
626 CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
627 CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
628 CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
629 CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
630 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
631 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
632 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
633 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND :
634 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
635 SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
636 CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
637 CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
638 CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
639 CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
641 CheckDlgButton(hwnd, IDC_WRAPMODE, cfg.wrap_mode);
642 CheckDlgButton(hwnd, IDC_DECOM, cfg.dec_om);
643 CheckDlgButton(hwnd, IDC_LFHASCR, cfg.lfhascr);
644 SetDlgItemInt(hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
645 SetDlgItemInt(hwnd, IDC_COLSEDIT, cfg.width, FALSE);
646 SetDlgItemInt(hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
648 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
649 CheckRadioButton(hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
650 cfg.beep == BELL_DISABLED ? IDC_BELL_DISABLED :
651 cfg.beep == BELL_DEFAULT ? IDC_BELL_DEFAULT :
652 cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
654 BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
655 CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
657 B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
658 B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
659 B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
660 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
661 CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
662 SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
663 MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
664 MySetDlgItemFlt(hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
666 CheckDlgButton(hwnd, IDC_BCE, cfg.bce);
667 CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
669 SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
670 CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
671 CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
672 CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
673 SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
674 CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
675 cfg.cursor_type == 0 ? IDC_CURBLOCK :
676 cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
677 CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
678 CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
679 CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
680 CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZENONE,
681 cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
682 cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
684 CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
685 cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
687 COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
688 CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
690 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
691 SetDlgItemText(hwnd, IDC_TSEDIT, cfg.termspeed);
692 SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
693 SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
694 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
695 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
696 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATRAW,
697 cfg.logtype == 0 ? IDC_LSTATOFF :
698 cfg.logtype == 1 ? IDC_LSTATASCII : IDC_LSTATRAW);
699 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
700 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
701 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
704 char *p = cfg.environmt;
705 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
707 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
713 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0,
718 CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC,
719 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
720 CheckRadioButton(hwnd, IDC_TPASSIVE, IDC_TACTIVE,
721 cfg.passive_telnet ? IDC_TPASSIVE : IDC_TACTIVE);
723 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
724 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
725 CheckDlgButton(hwnd, IDC_NOPTY, cfg.nopty);
726 CheckDlgButton(hwnd, IDC_COMPRESS, cfg.compression);
727 CheckDlgButton(hwnd, IDC_BUGGYMAC, cfg.buggymac);
728 CheckDlgButton(hwnd, IDC_AGENTFWD, cfg.agentfwd);
729 CheckRadioButton(hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
730 cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
731 CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
732 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
733 SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
737 static const struct { char *s; int c; } ciphers[] = {
738 { "3DES", CIPHER_3DES },
739 { "Blowfish", CIPHER_BLOWFISH },
740 { "DES (SSH 1 only)", CIPHER_DES },
741 { "AES (SSH 2 only)", CIPHER_AES },
742 { "-- warn below here --", CIPHER_WARN }
745 /* Set up the "selected ciphers" box. */
746 /* (cipherlist assumed to contain all ciphers) */
747 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_RESETCONTENT, 0, 0);
748 for (i = 0; i < CIPHER_MAX; i++) {
749 int c = cfg.ssh_cipherlist[i];
752 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
753 if (ciphers[j].c == c) {
758 pos = SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_ADDSTRING,
760 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_SETITEMDATA,
767 CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
768 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
769 CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
770 CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
772 static int tabs[4] = { 25, 61, 96, 128 };
773 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
776 for (i = 0; i < 128; i++) {
778 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
779 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg.wordness[i]);
780 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
784 CheckDlgButton(hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
785 CheckDlgButton(hwnd, IDC_PALETTE, cfg.try_palette);
788 n = SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
789 for (i = n; i-- > 0;)
790 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
791 LB_DELETESTRING, i, 0);
792 for (i = 0; i < 22; i++)
793 if (cfg.bold_colour || permcolour[i])
794 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
795 (LPARAM) colours[i]);
797 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
798 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
799 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
800 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
805 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
806 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
807 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
808 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
809 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
812 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
815 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
816 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
817 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
818 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
819 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
822 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
823 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
825 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
826 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
829 struct treeview_faff {
834 static HTREEITEM treeview_insert(struct treeview_faff *faff,
835 int level, char *text)
840 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
841 ins.hInsertAfter = faff->lastat[level];
842 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
843 #define INSITEM DUMMYUNIONNAME.item
847 ins.INSITEM.mask = TVIF_TEXT;
848 ins.INSITEM.pszText = text;
849 newitem = TreeView_InsertItem(faff->treeview, &ins);
851 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
853 faff->lastat[level] = newitem;
854 for (i = level + 1; i < 4; i++)
855 faff->lastat[i] = NULL;
860 * Create the panelfuls of controls in the configuration box.
862 static void create_controls(HWND hwnd, int dlgtype, int panel)
864 if (panel == sessionpanelstart) {
865 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
867 ctlposinit(&cp, hwnd, 80, 3, 13);
868 bartitle(&cp, "Basic options for your PuTTY session",
871 beginbox(&cp, "Specify your connection by host name or IP address",
874 "Host &Name (or IP address)",
875 IDC_HOSTSTATIC, IDC_HOST, 75,
876 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
877 if (backends[3].backend == NULL) {
878 /* this is PuTTYtel, so only three protocols available */
879 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
881 "&Telnet", IDC_PROTTELNET,
882 "Rlog&in", IDC_PROTRLOGIN, NULL);
884 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
886 "&Telnet", IDC_PROTTELNET,
887 "Rlog&in", IDC_PROTRLOGIN,
896 beginbox(&cp, "Load, save or delete a stored session",
898 sesssaver(&cp, "Sav&ed Sessions",
899 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
900 "&Load", IDC_SESSLOAD,
901 "&Save", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
904 beginbox(&cp, NULL, IDC_BOX_SESSION3);
905 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
906 "Always", IDC_COEALWAYS,
907 "Never", IDC_COENEVER,
908 "Only on clean exit", IDC_COENORMAL, NULL);
912 if (panel == loggingpanelstart) {
913 /* The Logging panel. Accelerators used: [acgo] tplfwe */
915 ctlposinit(&cp, hwnd, 80, 3, 13);
916 bartitle(&cp, "Options controlling session logging",
918 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
920 "Session logging:", IDC_LSTATSTATIC,
921 "Logging &turned off completely", IDC_LSTATOFF,
922 "Log &printable output only", IDC_LSTATASCII,
923 "&Log all session output", IDC_LSTATRAW, NULL);
924 editbutton(&cp, "Log &file name:",
925 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
927 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
928 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
930 "What to do if the log file already &exists:",
931 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
932 "Always append to the end of it", IDC_LSTATXAPN,
933 "Ask the user every time", IDC_LSTATXASK, NULL);
937 if (panel == terminalpanelstart) {
938 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
940 ctlposinit(&cp, hwnd, 80, 3, 13);
941 bartitle(&cp, "Options controlling the terminal emulation",
943 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
944 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
945 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
946 checkbox(&cp, "Implicit CR in every &LF", IDC_LFHASCR);
947 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
948 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
950 "An&swerback to ^E:", IDC_ANSWERBACK,
951 IDC_ANSWEREDIT, 100, NULL);
954 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
955 radioline(&cp, "Local ec&ho:", IDC_ECHOSTATIC, 3,
956 "Auto", IDC_ECHOBACKEND,
957 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
958 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
959 "Auto", IDC_EDITBACKEND,
960 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
964 if (panel == bellpanelstart) {
965 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
967 ctlposinit(&cp, hwnd, 80, 3, 13);
968 bartitle(&cp, "Options controlling the terminal bell",
970 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
972 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
973 "None (bell disabled)", IDC_BELL_DISABLED,
974 "Play Windows Default Sound", IDC_BELL_DEFAULT,
975 "Play a custom sound file", IDC_BELL_WAVEFILE,
976 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
977 editbutton(&cp, "Custom sound file to play as a bell:",
978 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
979 "Bro&wse...", IDC_BELL_WAVEBROWSE);
980 radioline(&cp, "Taskbar/caption &indication on bell:",
981 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
982 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
985 beginbox(&cp, "Control the bell overload behaviour",
987 checkbox(&cp, "Bell is temporarily &disabled when over-used",
989 staticedit(&cp, "Over-use means this &many bells...",
990 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
991 staticedit(&cp, "... in &this many seconds",
992 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
994 "The bell is re-enabled after a few seconds of silence.",
995 1, IDC_BELLOVLEXPLAIN);
996 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1001 if (panel == keyboardpanelstart) {
1002 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
1004 ctlposinit(&cp, hwnd, 80, 3, 13);
1006 bartitle(&cp, "Options controlling the effects of keys",
1007 IDC_TITLE_KEYBOARD);
1009 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1010 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1011 "Control-H", IDC_DEL008,
1012 "Control-? (127)", IDC_DEL127, NULL);
1013 radioline(&cp, "The &Home and End keys", IDC_HOMESTATIC, 2,
1014 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1015 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1016 "ESC[n~", IDC_FUNCTILDE,
1017 "Linux", IDC_FUNCLINUX,
1018 "Xterm R6", IDC_FUNCXTERM,
1019 "VT400", IDC_FUNCVT400,
1020 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1022 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1024 "Application c&ursor keys totally disabled",
1026 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1027 "Normal", IDC_CURNORMAL,
1028 "Application", IDC_CURAPPLIC, NULL);
1030 "Application ke&ypad keys totally disabled",
1032 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1033 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1034 "NetHack", IDC_KPNH, NULL);
1036 beginbox(&cp, "Enable extra keyboard features:",
1038 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1039 checkbox(&cp, "Control-Alt is &different from AltGr",
1044 if (panel == windowpanelstart) {
1045 /* The Window panel. Accelerators used: [acgo] rmz sdikp w4ylt f */
1047 ctlposinit(&cp, hwnd, 80, 3, 13);
1048 bartitle(&cp, "Options controlling PuTTY's window",
1050 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1052 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1053 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
1054 radioline(&cp, "Action when the window is resized:", IDC_RESIZESTATIC,
1055 3, "Resi&ze terminal", IDC_RESIZETERM,
1056 "Change fo&nt", IDC_RESIZEFONT,
1057 "Forb&id resizing", IDC_RESIZENONE, NULL);
1059 beginbox(&cp, "Control the scrollback in the window",
1061 staticedit(&cp, "Lines of &scrollback",
1062 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1063 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
1064 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
1065 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1066 checkbox(&cp, "Reset scrollback on dis&play activity",
1069 beginbox(&cp, NULL, IDC_BOX_WINDOW3);
1070 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1071 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1072 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1073 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
1074 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1075 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1079 if (panel == appearancepanelstart) {
1080 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1082 ctlposinit(&cp, hwnd, 80, 3, 13);
1083 /* bartitle(&cp, "Options controlling PuTTY's appearance",
1084 IDC_TITLE_APPEARANCE); */
1085 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1086 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1087 "B&lock", IDC_CURBLOCK,
1088 "&Underline", IDC_CURUNDER,
1089 "&Vertical line", IDC_CURVERT, NULL);
1090 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1092 beginbox(&cp, "Set the font used in the terminal window",
1093 IDC_BOX_APPEARANCE2);
1094 staticbtn(&cp, "", IDC_FONTSTATIC, "C&hange...", IDC_CHOOSEFONT);
1096 beginbox(&cp, "Adjust the use of the window title",
1097 IDC_BOX_APPEARANCE3);
1099 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1100 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
1102 beginbox(&cp, "Adjust the use of the mouse pointer",
1103 IDC_BOX_APPEARANCE4);
1104 checkbox(&cp, "Hide mouse &pointer when typing in window",
1107 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1108 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1110 staticedit(&cp, "Gap between text and window edge",
1111 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
1115 if (panel == translationpanelstart) {
1116 /* The Translation panel. Accelerators used: [acgo] rxbepus */
1118 ctlposinit(&cp, hwnd, 80, 3, 13);
1119 bartitle(&cp, "Options controlling character set translation",
1120 IDC_TITLE_TRANSLATION);
1121 beginbox(&cp, "Character set translation on received data",
1122 IDC_BOX_TRANSLATION1);
1123 combobox(&cp, "&Received data assumed to be in which character set:",
1124 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1126 beginbox(&cp, "Enable character set translation on input data",
1127 IDC_BOX_TRANSLATION2);
1128 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
1131 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
1132 IDC_BOX_TRANSLATION3);
1134 "Handling of line drawing characters:", IDC_VTSTATIC,
1135 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1136 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1137 "Use font in O&EM mode only", IDC_VTOEMONLY,
1138 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
1139 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
1143 if (panel == selectionpanelstart) {
1144 /* The Selection panel. Accelerators used: [acgo] d wxp hst */
1146 ctlposinit(&cp, hwnd, 80, 3, 13);
1147 bartitle(&cp, "Options controlling copy and paste",
1148 IDC_TITLE_SELECTION);
1149 beginbox(&cp, "Translation of pasted characters",
1150 IDC_BOX_SELECTION1);
1152 "&Don't translate line drawing chars into +, - and |",
1155 beginbox(&cp, "Control which mouse button does which thing",
1156 IDC_BOX_SELECTION2);
1157 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1158 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1159 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1162 "Shift overrides a&pplication's use of mouse",
1165 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1166 IDC_BOX_SELECTION3);
1167 charclass(&cp, "C&haracter classes:", IDC_CCSTATIC, IDC_CCLIST,
1168 "&Set", IDC_CCSET, IDC_CCEDIT,
1169 "&to class", IDC_CCSTATIC2);
1173 if (panel == colourspanelstart) {
1174 /* The Colours panel. Accelerators used: [acgo] blum */
1176 ctlposinit(&cp, hwnd, 80, 3, 13);
1177 bartitle(&cp, "Options controlling use of colours",
1179 beginbox(&cp, "General options for colour usage",
1181 checkbox(&cp, "&Bolded text is a different colour",
1183 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1185 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1187 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1188 IDC_COLOURSTATIC, IDC_COLOURLIST,
1189 "&Modify...", IDC_CHANGE,
1190 "Red:", IDC_RSTATIC, IDC_RVALUE,
1191 "Green:", IDC_GSTATIC, IDC_GVALUE,
1192 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1196 if (panel == connectionpanelstart) {
1197 /* The Connection panel. Accelerators used: [acgo] tuk */
1199 ctlposinit(&cp, hwnd, 80, 3, 13);
1200 bartitle(&cp, "Options controlling the connection",
1201 IDC_TITLE_CONNECTION);
1203 beginbox(&cp, "Data to send to the server",
1204 IDC_BOX_CONNECTION1);
1205 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1207 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1211 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1212 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1216 beginbox(&cp, "Sending of null packets to keep session active",
1217 IDC_BOX_CONNECTION2);
1218 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1219 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1223 if (panel == telnetpanelstart) {
1224 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
1226 ctlposinit(&cp, hwnd, 80, 3, 13);
1228 bartitle(&cp, "Options controlling Telnet connections",
1230 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1231 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1233 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1234 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1235 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1236 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1238 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1239 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1240 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1241 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1242 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1243 "Passive", IDC_TPASSIVE, "Active",
1245 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1251 if (panel == rloginpanelstart) {
1252 /* The Rlogin panel. Accelerators used: [acgo] sl */
1254 ctlposinit(&cp, hwnd, 80, 3, 13);
1256 bartitle(&cp, "Options controlling Rlogin connections",
1258 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1259 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1261 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1262 IDC_RLLUSEREDIT, 50);
1267 if (panel == sshpanelstart) {
1268 /* The SSH panel. Accelerators used: [acgo] r pe12i s */
1270 ctlposinit(&cp, hwnd, 80, 3, 13);
1272 bartitle(&cp, "Options controlling SSH connections",
1274 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1276 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1279 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
1280 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1281 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1282 radioline(&cp, "Preferred SSH protocol version:",
1283 IDC_SSHPROTSTATIC, 2,
1284 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL);
1285 checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1288 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1289 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1290 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1296 if (panel == sshauthpanelstart) {
1297 /* The SSH authentication panel. Accelerators used: [acgo] m fkw */
1299 ctlposinit(&cp, hwnd, 80, 3, 13);
1301 bartitle(&cp, "Options controlling SSH authentication",
1303 beginbox(&cp, "Authentication methods",
1305 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication",
1308 beginbox(&cp, "Authentication parameters",
1310 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
1311 editbutton(&cp, "Private &key file for authentication:",
1312 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
1318 if (panel == tunnelspanelstart) {
1319 /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */
1321 ctlposinit(&cp, hwnd, 80, 3, 13);
1323 bartitle(&cp, "Options controlling SSH tunnelling",
1325 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
1326 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
1327 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
1328 IDC_X11_DISPLAY, 50, NULL);
1330 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
1331 checkbox(&cp, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL);
1332 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
1333 "&Remove", IDC_PFWDREMOVE);
1334 fwdsetter(&cp, IDC_PFWDLIST,
1335 "Add new forwarded port:", IDC_PFWDSTATIC2,
1336 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
1337 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
1338 "A&dd", IDC_PFWDADD);
1339 bareradioline(&cp, 2,
1340 "&Local", IDC_PFWDLOCAL, "Re&mote", IDC_PFWDREMOTE, NULL);
1348 * Helper function to load the session selected in SESSLIST
1349 * if any, as this is done in more than one place in
1350 * GenericMainDlgProc(). 0 => failure.
1352 static int load_selected_session(HWND hwnd)
1354 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1355 LB_GETCURSEL, 0, 0);
1361 isdef = !strcmp(sessions[n], "Default Settings");
1362 load_settings(sessions[n], !isdef, &cfg);
1363 init_dlg_ctrls(hwnd, TRUE);
1365 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
1367 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
1368 /* Restore the selection, which will have been clobbered by
1369 * SESSEDIT handling. */
1370 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
1375 * This function is the configuration box.
1377 static int GenericMainDlgProc(HWND hwnd, UINT msg,
1378 WPARAM wParam, LPARAM lParam, int dlgtype)
1381 struct treeview_faff tvfaff;
1384 char filename[sizeof(cfg.keyfile)];
1387 char fontstatic[256];
1389 struct servent *service;
1391 static UINT draglistmsg = WM_NULL;
1396 SetWindowLong(hwnd, GWL_USERDATA, 0);
1397 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
1398 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
1400 * Centre the window.
1402 { /* centre the window */
1405 hw = GetDesktopWindow();
1406 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
1408 (rs.right + rs.left + rd.left - rd.right) / 2,
1409 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
1410 rd.right - rd.left, rd.bottom - rd.top, TRUE);
1414 * Create the tree view.
1422 r.right = r.left + 75;
1424 r.bottom = r.top + 10;
1425 MapDialogRect(hwnd, &r);
1426 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
1427 WS_CHILD | WS_VISIBLE,
1429 r.right - r.left, r.bottom - r.top,
1430 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
1432 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1433 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1436 r.right = r.left + 75;
1438 r.bottom = r.top + 219;
1439 MapDialogRect(hwnd, &r);
1440 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
1441 WS_CHILD | WS_VISIBLE |
1442 WS_TABSTOP | TVS_HASLINES |
1443 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
1445 TVS_SHOWSELALWAYS, r.left, r.top,
1446 r.right - r.left, r.bottom - r.top,
1447 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
1449 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1450 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1451 tvfaff.treeview = treeview;
1452 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
1456 * Set up the tree view contents.
1458 hsession = treeview_insert(&tvfaff, 0, "Session");
1459 treeview_insert(&tvfaff, 1, "Logging");
1460 treeview_insert(&tvfaff, 0, "Terminal");
1461 treeview_insert(&tvfaff, 1, "Keyboard");
1462 treeview_insert(&tvfaff, 1, "Bell");
1463 treeview_insert(&tvfaff, 0, "Window");
1464 treeview_insert(&tvfaff, 1, "Appearance");
1465 treeview_insert(&tvfaff, 1, "Translation");
1466 treeview_insert(&tvfaff, 1, "Selection");
1467 treeview_insert(&tvfaff, 1, "Colours");
1468 treeview_insert(&tvfaff, 0, "Connection");
1470 treeview_insert(&tvfaff, 1, "Telnet");
1471 treeview_insert(&tvfaff, 1, "Rlogin");
1472 if (backends[3].backend != NULL) {
1473 treeview_insert(&tvfaff, 1, "SSH");
1474 /* XXX long name is ugly */
1475 /* XXX make it closed by default? */
1476 treeview_insert(&tvfaff, 2, "Auth");
1477 treeview_insert(&tvfaff, 2, "Tunnels");
1482 * Put the treeview selection on to the Session panel. This
1483 * should also cause creation of the relevant controls.
1485 TreeView_SelectItem(treeview, hsession);
1488 * Set focus into the first available control.
1492 ctl = GetDlgItem(hwnd, IDC_HOST);
1494 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
1498 SetWindowLong(hwnd, GWL_USERDATA, 1);
1499 sesslist_has_focus = 0;
1503 * Button release should trigger WM_OK if there was a
1504 * previous double click on the session list.
1508 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
1511 if (LOWORD(wParam) == IDCX_TREEVIEW &&
1512 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
1514 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
1519 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
1522 item.pszText = buffer;
1523 item.cchTextMax = sizeof(buffer);
1524 item.mask = TVIF_TEXT;
1525 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
1526 for (j = controlstartvalue; j < controlendvalue; j++) {
1527 HWND item = GetDlgItem(hwnd, j);
1529 DestroyWindow(item);
1531 if (!strcmp(buffer, "Session"))
1532 create_controls(hwnd, dlgtype, sessionpanelstart);
1533 if (!strcmp(buffer, "Logging"))
1534 create_controls(hwnd, dlgtype, loggingpanelstart);
1535 if (!strcmp(buffer, "Keyboard"))
1536 create_controls(hwnd, dlgtype, keyboardpanelstart);
1537 if (!strcmp(buffer, "Terminal"))
1538 create_controls(hwnd, dlgtype, terminalpanelstart);
1539 if (!strcmp(buffer, "Bell"))
1540 create_controls(hwnd, dlgtype, bellpanelstart);
1541 if (!strcmp(buffer, "Window"))
1542 create_controls(hwnd, dlgtype, windowpanelstart);
1543 if (!strcmp(buffer, "Appearance"))
1544 create_controls(hwnd, dlgtype, appearancepanelstart);
1545 if (!strcmp(buffer, "Tunnels"))
1546 create_controls(hwnd, dlgtype, tunnelspanelstart);
1547 if (!strcmp(buffer, "Connection"))
1548 create_controls(hwnd, dlgtype, connectionpanelstart);
1549 if (!strcmp(buffer, "Telnet"))
1550 create_controls(hwnd, dlgtype, telnetpanelstart);
1551 if (!strcmp(buffer, "Rlogin"))
1552 create_controls(hwnd, dlgtype, rloginpanelstart);
1553 if (!strcmp(buffer, "SSH"))
1554 create_controls(hwnd, dlgtype, sshpanelstart);
1555 if (!strcmp(buffer, "Auth"))
1556 create_controls(hwnd, dlgtype, sshauthpanelstart);
1557 if (!strcmp(buffer, "Selection"))
1558 create_controls(hwnd, dlgtype, selectionpanelstart);
1559 if (!strcmp(buffer, "Colours"))
1560 create_controls(hwnd, dlgtype, colourspanelstart);
1561 if (!strcmp(buffer, "Translation"))
1562 create_controls(hwnd, dlgtype, translationpanelstart);
1564 init_dlg_ctrls(hwnd, FALSE);
1566 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
1567 InvalidateRect (hwnd, NULL, TRUE);
1569 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
1575 * Only process WM_COMMAND once the dialog is fully formed.
1577 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
1578 switch (LOWORD(wParam)) {
1580 /* Behaviour of the "Open" button is different if the
1581 * session list has focus, *unless* the user just
1582 * double-clicked... */
1583 if (sesslist_has_focus && !readytogo) {
1584 if (!load_selected_session(hwnd)) {
1589 /* If at this point we have a valid session, go! */
1598 case IDC_PROTTELNET:
1599 case IDC_PROTRLOGIN:
1602 if (HIWORD(wParam) == BN_CLICKED ||
1603 HIWORD(wParam) == BN_DOUBLECLICKED) {
1604 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
1605 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
1606 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
1608 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
1610 if ((cfg.protocol == PROT_SSH && cfg.port != 22)
1611 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
1612 || (cfg.protocol == PROT_RLOGIN
1613 && cfg.port != 513)) {
1614 cfg.port = i ? 22 : j ? 23 : 513;
1615 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
1620 if (HIWORD(wParam) == EN_CHANGE)
1621 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
1622 sizeof(cfg.host) - 1);
1625 if (HIWORD(wParam) == EN_CHANGE) {
1626 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
1627 if (isdigit(portname[0]))
1628 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
1630 service = getservbyname(portname, NULL);
1632 cfg.port = ntohs(service->s_port);
1639 if (HIWORD(wParam) == EN_CHANGE) {
1640 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
1642 GetDlgItemText(hwnd, IDC_SESSEDIT,
1643 savedsession, sizeof(savedsession) - 1);
1644 savedsession[sizeof(savedsession) - 1] = '\0';
1648 if (HIWORD(wParam) == BN_CLICKED ||
1649 HIWORD(wParam) == BN_DOUBLECLICKED) {
1654 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
1657 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1658 LB_GETCURSEL, 0, 0);
1663 strcpy(str, sessions[n]);
1665 save_settings(str, !!strcmp(str, "Default Settings"),
1667 get_sesslist(FALSE);
1669 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
1671 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
1673 for (i = 0; i < nsessions; i++)
1674 SendDlgItemMessage(hwnd, IDC_SESSLIST,
1676 (LPARAM) (sessions[i]));
1677 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
1679 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
1681 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
1687 if (LOWORD(wParam) == IDC_SESSLIST) {
1688 if (HIWORD(wParam) == LBN_SETFOCUS)
1689 sesslist_has_focus = 1;
1690 else if (HIWORD(wParam) == LBN_KILLFOCUS)
1691 sesslist_has_focus = 0;
1693 if (LOWORD(wParam) == IDC_SESSLOAD &&
1694 HIWORD(wParam) != BN_CLICKED &&
1695 HIWORD(wParam) != BN_DOUBLECLICKED) break;
1696 if (LOWORD(wParam) == IDC_SESSLIST &&
1697 HIWORD(wParam) != LBN_DBLCLK) break;
1698 /* Load the session selected in SESSLIST. */
1699 if (load_selected_session(hwnd) &&
1700 LOWORD(wParam) == IDC_SESSLIST) {
1702 * A double-click on a saved session should
1703 * actually start the session, not just load it.
1704 * Unless it's Default Settings or some other
1705 * host-less set of saved settings.
1714 if (HIWORD(wParam) == BN_CLICKED ||
1715 HIWORD(wParam) == BN_DOUBLECLICKED) {
1716 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1717 LB_GETCURSEL, 0, 0);
1718 if (n == LB_ERR || n == 0) {
1722 del_settings(sessions[n]);
1723 get_sesslist(FALSE);
1725 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
1727 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
1729 for (i = 0; i < nsessions; i++)
1730 SendDlgItemMessage(hwnd, IDC_SESSLIST,
1732 (LPARAM) (sessions[i]));
1733 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
1735 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
1737 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
1741 if (HIWORD(wParam) == EN_CHANGE)
1742 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
1743 &cfg.ping_interval);
1747 if (HIWORD(wParam) == BN_CLICKED ||
1748 HIWORD(wParam) == BN_DOUBLECLICKED)
1749 cfg.bksp_is_delete =
1750 IsDlgButtonChecked(hwnd, IDC_DEL127);
1754 if (HIWORD(wParam) == BN_CLICKED ||
1755 HIWORD(wParam) == BN_DOUBLECLICKED)
1757 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
1763 case IDC_FUNCVT100P:
1765 if (HIWORD(wParam) == BN_CLICKED ||
1766 HIWORD(wParam) == BN_DOUBLECLICKED)
1767 switch (LOWORD(wParam)) {
1780 case IDC_FUNCVT100P:
1790 if (HIWORD(wParam) == BN_CLICKED ||
1791 HIWORD(wParam) == BN_DOUBLECLICKED) {
1793 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
1794 cfg.nethack_keypad = FALSE;
1798 if (HIWORD(wParam) == BN_CLICKED ||
1799 HIWORD(wParam) == BN_DOUBLECLICKED) {
1800 cfg.app_keypad = FALSE;
1801 cfg.nethack_keypad = TRUE;
1806 if (HIWORD(wParam) == BN_CLICKED ||
1807 HIWORD(wParam) == BN_DOUBLECLICKED)
1809 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
1812 if (HIWORD(wParam) == BN_CLICKED ||
1813 HIWORD(wParam) == BN_DOUBLECLICKED)
1815 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
1818 if (HIWORD(wParam) == BN_CLICKED ||
1819 HIWORD(wParam) == BN_DOUBLECLICKED)
1821 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
1824 if (HIWORD(wParam) == BN_CLICKED ||
1825 HIWORD(wParam) == BN_DOUBLECLICKED)
1826 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
1829 if (HIWORD(wParam) == BN_CLICKED ||
1830 HIWORD(wParam) == BN_DOUBLECLICKED)
1832 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
1835 if (HIWORD(wParam) == BN_CLICKED ||
1836 HIWORD(wParam) == BN_DOUBLECLICKED)
1838 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
1840 case IDC_ECHOBACKEND:
1843 if (HIWORD(wParam) == BN_CLICKED ||
1844 HIWORD(wParam) == BN_DOUBLECLICKED) {
1845 if (LOWORD(wParam) == IDC_ECHOBACKEND)
1846 cfg.localecho = LD_BACKEND;
1847 if (LOWORD(wParam) == IDC_ECHOYES)
1848 cfg.localecho = LD_YES;
1849 if (LOWORD(wParam) == IDC_ECHONO)
1850 cfg.localecho = LD_NO;
1853 case IDC_EDITBACKEND:
1856 if (HIWORD(wParam) == BN_CLICKED ||
1857 HIWORD(wParam) == BN_DOUBLECLICKED) {
1858 if (LOWORD(wParam) == IDC_EDITBACKEND)
1859 cfg.localedit = LD_BACKEND;
1860 if (LOWORD(wParam) == IDC_EDITYES)
1861 cfg.localedit = LD_YES;
1862 if (LOWORD(wParam) == IDC_EDITNO)
1863 cfg.localedit = LD_NO;
1866 case IDC_ANSWEREDIT:
1867 if (HIWORD(wParam) == EN_CHANGE)
1868 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
1869 sizeof(cfg.answerback) - 1);
1871 case IDC_ALWAYSONTOP:
1872 if (HIWORD(wParam) == BN_CLICKED ||
1873 HIWORD(wParam) == BN_DOUBLECLICKED)
1875 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
1877 case IDC_FULLSCREENONALTENTER:
1878 if (HIWORD(wParam) == BN_CLICKED ||
1879 HIWORD(wParam) == BN_DOUBLECLICKED)
1880 cfg.fullscreenonaltenter =
1881 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
1884 if (HIWORD(wParam) == BN_CLICKED ||
1885 HIWORD(wParam) == BN_DOUBLECLICKED)
1887 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
1889 case IDC_SCROLLDISP:
1890 if (HIWORD(wParam) == BN_CLICKED ||
1891 HIWORD(wParam) == BN_DOUBLECLICKED)
1892 cfg.scroll_on_disp =
1893 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
1895 case IDC_COMPOSEKEY:
1896 if (HIWORD(wParam) == BN_CLICKED ||
1897 HIWORD(wParam) == BN_DOUBLECLICKED)
1899 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
1901 case IDC_CTRLALTKEYS:
1902 if (HIWORD(wParam) == BN_CLICKED ||
1903 HIWORD(wParam) == BN_DOUBLECLICKED)
1905 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
1908 if (HIWORD(wParam) == BN_CLICKED ||
1909 HIWORD(wParam) == BN_DOUBLECLICKED)
1910 cfg.telnet_keyboard =
1911 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
1914 if (HIWORD(wParam) == BN_CLICKED ||
1915 HIWORD(wParam) == BN_DOUBLECLICKED)
1917 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
1920 if (HIWORD(wParam) == BN_CLICKED ||
1921 HIWORD(wParam) == BN_DOUBLECLICKED)
1922 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
1925 if (HIWORD(wParam) == BN_CLICKED ||
1926 HIWORD(wParam) == BN_DOUBLECLICKED)
1928 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
1931 if (HIWORD(wParam) == EN_CHANGE)
1932 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
1935 if (HIWORD(wParam) == EN_CHANGE)
1936 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
1939 if (HIWORD(wParam) == EN_CHANGE)
1940 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
1942 case IDC_CHOOSEFONT:
1945 lf.lfHeight = -MulDiv(cfg.fontheight,
1946 GetDeviceCaps(hdc, LOGPIXELSY),
1950 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
1951 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
1952 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
1953 lf.lfCharSet = cfg.fontcharset;
1954 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
1955 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
1956 lf.lfQuality = DEFAULT_QUALITY;
1957 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
1958 strncpy(lf.lfFaceName, cfg.font,
1959 sizeof(lf.lfFaceName) - 1);
1960 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
1962 cf.lStructSize = sizeof(cf);
1963 cf.hwndOwner = hwnd;
1965 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
1966 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
1968 if (ChooseFont(&cf)) {
1969 strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
1970 cfg.font[sizeof(cfg.font) - 1] = '\0';
1971 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
1972 cfg.fontcharset = lf.lfCharSet;
1973 cfg.fontheight = cf.iPointSize / 10;
1974 fmtfont(fontstatic);
1975 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
1978 case IDC_BELL_DISABLED:
1979 case IDC_BELL_DEFAULT:
1980 case IDC_BELL_WAVEFILE:
1981 case IDC_BELL_VISUAL:
1982 if (HIWORD(wParam) == BN_CLICKED ||
1983 HIWORD(wParam) == BN_DOUBLECLICKED) {
1984 if (LOWORD(wParam) == IDC_BELL_DISABLED)
1985 cfg.beep = BELL_DISABLED;
1986 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
1987 cfg.beep = BELL_DEFAULT;
1988 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
1989 cfg.beep = BELL_WAVEFILE;
1990 if (LOWORD(wParam) == IDC_BELL_VISUAL)
1991 cfg.beep = BELL_VISUAL;
1994 case IDC_B_IND_DISABLED:
1995 case IDC_B_IND_FLASH:
1996 case IDC_B_IND_STEADY:
1997 if (HIWORD(wParam) == BN_CLICKED ||
1998 HIWORD(wParam) == BN_DOUBLECLICKED) {
1999 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2000 cfg.beep_ind = B_IND_DISABLED;
2001 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2002 cfg.beep_ind = B_IND_FLASH;
2003 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2004 cfg.beep_ind = B_IND_STEADY;
2007 case IDC_BELL_WAVEBROWSE:
2008 memset(&of, 0, sizeof(of));
2009 #ifdef OPENFILENAME_SIZE_VERSION_400
2010 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2012 of.lStructSize = sizeof(of);
2014 of.hwndOwner = hwnd;
2015 of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2016 of.lpstrCustomFilter = NULL;
2017 of.nFilterIndex = 1;
2018 of.lpstrFile = filename;
2019 strcpy(filename, cfg.bell_wavefile);
2020 of.nMaxFile = sizeof(filename);
2021 of.lpstrFileTitle = NULL;
2022 of.lpstrInitialDir = NULL;
2023 of.lpstrTitle = "Select Bell Sound File";
2025 if (GetOpenFileName(&of)) {
2026 strcpy(cfg.bell_wavefile, filename);
2027 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2031 case IDC_BELL_WAVEEDIT:
2032 if (HIWORD(wParam) == EN_CHANGE)
2033 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2035 sizeof(cfg.bell_wavefile) - 1);
2038 if (HIWORD(wParam) == BN_CLICKED ||
2039 HIWORD(wParam) == BN_DOUBLECLICKED)
2041 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2044 if (HIWORD(wParam) == EN_CHANGE)
2045 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2048 if (HIWORD(wParam) == EN_CHANGE)
2049 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2053 if (HIWORD(wParam) == EN_CHANGE)
2054 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2058 if (HIWORD(wParam) == BN_CLICKED ||
2059 HIWORD(wParam) == BN_DOUBLECLICKED)
2061 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2064 if (HIWORD(wParam) == BN_CLICKED ||
2065 HIWORD(wParam) == BN_DOUBLECLICKED)
2066 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2069 if (HIWORD(wParam) == BN_CLICKED ||
2070 HIWORD(wParam) == BN_DOUBLECLICKED)
2071 cfg.win_name_always =
2072 IsDlgButtonChecked(hwnd, IDC_WINNAME);
2075 if (HIWORD(wParam) == BN_CLICKED ||
2076 HIWORD(wParam) == BN_DOUBLECLICKED)
2078 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2080 case IDC_SUNKENEDGE:
2081 if (HIWORD(wParam) == BN_CLICKED ||
2082 HIWORD(wParam) == BN_DOUBLECLICKED)
2084 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2087 if (HIWORD(wParam) == EN_CHANGE)
2088 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2089 &cfg.window_border);
2090 if (cfg.window_border > 32)
2091 cfg.window_border = 32;
2094 if (HIWORD(wParam) == BN_CLICKED ||
2095 HIWORD(wParam) == BN_DOUBLECLICKED)
2096 cfg.cursor_type = 0;
2099 if (HIWORD(wParam) == BN_CLICKED ||
2100 HIWORD(wParam) == BN_DOUBLECLICKED)
2101 cfg.cursor_type = 1;
2104 if (HIWORD(wParam) == BN_CLICKED ||
2105 HIWORD(wParam) == BN_DOUBLECLICKED)
2106 cfg.cursor_type = 2;
2109 if (HIWORD(wParam) == BN_CLICKED ||
2110 HIWORD(wParam) == BN_DOUBLECLICKED)
2112 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2115 if (HIWORD(wParam) == BN_CLICKED ||
2116 HIWORD(wParam) == BN_DOUBLECLICKED)
2118 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2120 case IDC_SCROLLBARFULLSCREEN:
2121 if (HIWORD(wParam) == BN_CLICKED ||
2122 HIWORD(wParam) == BN_DOUBLECLICKED)
2123 cfg.scrollbar_in_fullscreen =
2124 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2126 case IDC_RESIZETERM:
2127 case IDC_RESIZEFONT:
2128 case IDC_RESIZENONE:
2129 if (HIWORD(wParam) == BN_CLICKED ||
2130 HIWORD(wParam) == BN_DOUBLECLICKED) {
2132 IsDlgButtonChecked(hwnd,
2133 IDC_RESIZETERM) ? RESIZE_TERM :
2134 IsDlgButtonChecked(hwnd,
2135 IDC_RESIZEFONT) ? RESIZE_FONT :
2140 if (HIWORD(wParam) == EN_CHANGE)
2141 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2142 sizeof(cfg.wintitle) - 1);
2147 if (HIWORD(wParam) == BN_CLICKED ||
2148 HIWORD(wParam) == BN_DOUBLECLICKED) {
2150 IsDlgButtonChecked(hwnd,
2151 IDC_COEALWAYS) ? COE_ALWAYS :
2152 IsDlgButtonChecked(hwnd,
2153 IDC_COENEVER) ? COE_NEVER :
2158 if (HIWORD(wParam) == BN_CLICKED ||
2159 HIWORD(wParam) == BN_DOUBLECLICKED)
2161 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
2164 if (HIWORD(wParam) == EN_CHANGE)
2165 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
2166 sizeof(cfg.termtype) - 1);
2169 if (HIWORD(wParam) == EN_CHANGE)
2170 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
2171 sizeof(cfg.logfilename) - 1);
2174 memset(&of, 0, sizeof(of));
2175 #ifdef OPENFILENAME_SIZE_VERSION_400
2176 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2178 of.lStructSize = sizeof(of);
2180 of.hwndOwner = hwnd;
2181 of.lpstrFilter = "All Files\0*\0\0\0";
2182 of.lpstrCustomFilter = NULL;
2183 of.nFilterIndex = 1;
2184 of.lpstrFile = filename;
2185 strcpy(filename, cfg.logfilename);
2186 of.nMaxFile = sizeof(filename);
2187 of.lpstrFileTitle = NULL;
2188 of.lpstrInitialDir = NULL;
2189 of.lpstrTitle = "Select session log file";
2191 if (GetSaveFileName(&of)) {
2192 strcpy(cfg.logfilename, filename);
2193 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
2197 case IDC_LSTATASCII:
2199 if (HIWORD(wParam) == BN_CLICKED ||
2200 HIWORD(wParam) == BN_DOUBLECLICKED) {
2201 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
2203 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
2205 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
2212 if (HIWORD(wParam) == BN_CLICKED ||
2213 HIWORD(wParam) == BN_DOUBLECLICKED) {
2214 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
2215 cfg.logxfovr = LGXF_ASK;
2216 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
2217 cfg.logxfovr = LGXF_APN;
2218 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
2219 cfg.logxfovr = LGXF_OVR;
2224 if (HIWORD(wParam) == EN_CHANGE)
2225 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
2226 sizeof(cfg.termspeed) - 1);
2229 if (HIWORD(wParam) == EN_CHANGE)
2230 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
2231 sizeof(cfg.username) - 1);
2233 case IDC_RLLUSEREDIT:
2234 if (HIWORD(wParam) == EN_CHANGE)
2235 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
2237 sizeof(cfg.localusername) - 1);
2241 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
2245 cfg.passive_telnet =
2246 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
2249 if (HIWORD(wParam) == BN_CLICKED ||
2250 HIWORD(wParam) == BN_DOUBLECLICKED) {
2251 char str[sizeof(cfg.environmt)];
2253 GetDlgItemText(hwnd, IDC_VAREDIT, str,
2259 p = str + strlen(str);
2261 GetDlgItemText(hwnd, IDC_VALEDIT, p,
2262 sizeof(str) - 1 - (p - str));
2273 if ((p - cfg.environmt) + strlen(str) + 2 <
2274 sizeof(cfg.environmt)) {
2276 p[strlen(str) + 1] = '\0';
2277 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
2279 SetDlgItemText(hwnd, IDC_VAREDIT, "");
2280 SetDlgItemText(hwnd, IDC_VALEDIT, "");
2282 MessageBox(hwnd, "Environment too big",
2283 "PuTTY Error", MB_OK | MB_ICONERROR);
2288 if (HIWORD(wParam) != BN_CLICKED &&
2289 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2291 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
2298 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
2325 if (HIWORD(wParam) == BN_CLICKED ||
2326 HIWORD(wParam) == BN_DOUBLECLICKED)
2327 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
2330 if (HIWORD(wParam) == BN_CLICKED ||
2331 HIWORD(wParam) == BN_DOUBLECLICKED)
2333 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
2336 if (HIWORD(wParam) == BN_CLICKED ||
2337 HIWORD(wParam) == BN_DOUBLECLICKED)
2339 IsDlgButtonChecked(hwnd, IDC_BUGGYMAC);
2342 if (HIWORD(wParam) == BN_CLICKED ||
2343 HIWORD(wParam) == BN_DOUBLECLICKED)
2345 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
2347 case IDC_CIPHERLIST:
2350 handle_prefslist(&cipherlist,
2351 cfg.ssh_cipherlist, CIPHER_MAX,
2352 0, hwnd, wParam, lParam);
2356 if (HIWORD(wParam) == BN_CLICKED ||
2357 HIWORD(wParam) == BN_DOUBLECLICKED) {
2358 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
2360 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
2365 if (HIWORD(wParam) == BN_CLICKED ||
2366 HIWORD(wParam) == BN_DOUBLECLICKED)
2368 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
2371 if (HIWORD(wParam) == EN_CHANGE)
2372 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
2373 sizeof(cfg.keyfile) - 1);
2376 if (HIWORD(wParam) == EN_CHANGE)
2377 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
2378 sizeof(cfg.remote_cmd) - 1);
2381 memset(&of, 0, sizeof(of));
2382 #ifdef OPENFILENAME_SIZE_VERSION_400
2383 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2385 of.lStructSize = sizeof(of);
2387 of.hwndOwner = hwnd;
2388 of.lpstrFilter = "All Files\0*\0\0\0";
2389 of.lpstrCustomFilter = NULL;
2390 of.nFilterIndex = 1;
2391 of.lpstrFile = filename;
2392 strcpy(filename, cfg.keyfile);
2393 of.nMaxFile = sizeof(filename);
2394 of.lpstrFileTitle = NULL;
2395 of.lpstrInitialDir = NULL;
2396 of.lpstrTitle = "Select Private Key File";
2398 if (GetOpenFileName(&of)) {
2399 strcpy(cfg.keyfile, filename);
2400 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
2404 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
2408 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
2410 case IDC_MOUSEOVERRIDE:
2411 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
2417 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
2422 for (i = 0; i < 128; i++)
2423 if (SendDlgItemMessage
2424 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
2426 cfg.wordness[i] = n;
2427 SendDlgItemMessage(hwnd, IDC_CCLIST,
2428 LB_DELETESTRING, i, 0);
2429 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
2430 (i >= 0x21 && i != 0x7F) ? i : ' ',
2432 SendDlgItemMessage(hwnd, IDC_CCLIST,
2439 case IDC_BOLDCOLOUR:
2440 if (HIWORD(wParam) == BN_CLICKED ||
2441 HIWORD(wParam) == BN_DOUBLECLICKED) {
2444 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
2445 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
2448 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2450 if (n != 12 + 10 * cfg.bold_colour) {
2451 for (i = n; i-- > 0;)
2452 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2453 LB_DELETESTRING, i, 0);
2454 for (i = 0; i < 22; i++)
2455 if (cfg.bold_colour || permcolour[i])
2456 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2458 (LPARAM) colours[i]);
2460 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
2462 InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
2467 if (HIWORD(wParam) == BN_CLICKED ||
2468 HIWORD(wParam) == BN_DOUBLECLICKED)
2470 IsDlgButtonChecked(hwnd, IDC_PALETTE);
2472 case IDC_COLOURLIST:
2473 if (HIWORD(wParam) == LBN_DBLCLK ||
2474 HIWORD(wParam) == LBN_SELCHANGE) {
2476 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2479 if (!cfg.bold_colour)
2480 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
2481 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
2483 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
2485 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
2490 if (HIWORD(wParam) == BN_CLICKED ||
2491 HIWORD(wParam) == BN_DOUBLECLICKED) {
2492 static CHOOSECOLOR cc;
2493 static DWORD custom[16] = { 0 }; /* zero initialisers */
2495 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2498 if (!cfg.bold_colour)
2499 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
2500 cc.lStructSize = sizeof(cc);
2501 cc.hwndOwner = hwnd;
2502 cc.hInstance = (HWND) hinst;
2503 cc.lpCustColors = custom;
2505 RGB(cfg.colours[i][0], cfg.colours[i][1],
2507 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
2508 if (ChooseColor(&cc)) {
2510 (unsigned char) (cc.rgbResult & 0xFF);
2512 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
2514 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
2515 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
2517 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
2519 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
2525 if (HIWORD(wParam) == CBN_SELCHANGE) {
2526 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
2527 CB_GETCURSEL, 0, 0);
2528 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
2529 index, (LPARAM)cfg.line_codepage);
2530 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
2531 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
2532 sizeof(cfg.line_codepage) - 1);
2533 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
2534 strcpy(cfg.line_codepage,
2535 cp_name(decode_codepage(cfg.line_codepage)));
2536 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
2539 case IDC_CAPSLOCKCYR:
2540 if (HIWORD(wParam) == BN_CLICKED ||
2541 HIWORD(wParam) == BN_DOUBLECLICKED) {
2542 cfg.xlat_capslockcyr =
2543 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
2546 case IDC_VTXWINDOWS:
2552 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
2553 : IsDlgButtonChecked(hwnd,
2554 IDC_VTOEMANSI) ? VT_OEMANSI :
2555 IsDlgButtonChecked(hwnd,
2556 IDC_VTOEMONLY) ? VT_OEMONLY :
2557 IsDlgButtonChecked(hwnd,
2558 IDC_VTUNICODE) ? VT_UNICODE :
2561 case IDC_X11_FORWARD:
2562 if (HIWORD(wParam) == BN_CLICKED ||
2563 HIWORD(wParam) == BN_DOUBLECLICKED)
2565 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
2568 if (HIWORD(wParam) == BN_CLICKED ||
2569 HIWORD(wParam) == BN_DOUBLECLICKED)
2570 cfg.lport_acceptall =
2571 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
2573 case IDC_X11_DISPLAY:
2574 if (HIWORD(wParam) == EN_CHANGE)
2575 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
2576 sizeof(cfg.x11_display) - 1);
2579 if (HIWORD(wParam) == BN_CLICKED ||
2580 HIWORD(wParam) == BN_DOUBLECLICKED) {
2581 char str[sizeof(cfg.portfwd)];
2583 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
2587 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
2591 "You need to specify a source port number",
2592 "PuTTY Error", MB_OK | MB_ICONERROR);
2595 p = str + strlen(str);
2597 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
2598 sizeof(str) - 1 - (p - str));
2599 if (!*p || !strchr(p, ':')) {
2601 "You need to specify a destination address\n"
2602 "in the form \"host.name:port\"",
2603 "PuTTY Error", MB_OK | MB_ICONERROR);
2612 if ((p - cfg.portfwd) + strlen(str) + 2 <
2613 sizeof(cfg.portfwd)) {
2615 p[strlen(str) + 1] = '\0';
2616 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
2618 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
2619 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
2621 MessageBox(hwnd, "Too many forwardings",
2622 "PuTTY Error", MB_OK | MB_ICONERROR);
2626 case IDC_PFWDREMOVE:
2627 if (HIWORD(wParam) != BN_CLICKED &&
2628 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2629 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
2630 LB_GETCURSEL, 0, 0);
2636 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
2668 /* Grrr Explorer will maximize Dialogs! */
2670 if (wParam == SIZE_MAXIMIZED)
2676 * Handle application-defined messages eg. DragListBox
2678 /* First find out what the number is (once). */
2679 if (draglistmsg == WM_NULL)
2680 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
2682 if (msg == draglistmsg) {
2683 /* Only process once dialog is fully formed. */
2684 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
2685 case IDC_CIPHERLIST:
2686 return handle_prefslist(&cipherlist,
2687 cfg.ssh_cipherlist, CIPHER_MAX,
2688 1, hwnd, wParam, lParam);
2697 static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
2698 WPARAM wParam, LPARAM lParam)
2700 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
2702 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
2703 EnableWindow(hwnd, 0);
2704 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
2705 EnableWindow(hwnd, 1);
2706 SetActiveWindow(hwnd);
2708 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
2711 static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
2712 WPARAM wParam, LPARAM lParam)
2714 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
2717 void defuse_showwindow(void)
2720 * Work around the fact that the app's first call to ShowWindow
2721 * will ignore the default in favour of the shell-provided
2726 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
2728 ShowWindow(hwnd, SW_HIDE);
2729 SetActiveWindow(hwnd);
2730 DestroyWindow(hwnd);
2739 savedsession[0] = '\0';
2741 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
2742 get_sesslist(FALSE);
2747 int do_reconfig(HWND hwnd)
2752 backup_cfg = cfg; /* structure copy */
2754 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
2756 cfg = backup_cfg; /* structure copy */
2761 void logevent(char *string)
2766 if (nevents >= negsize) {
2768 events = srealloc(events, negsize * sizeof(*events));
2772 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
2775 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
2776 strcpy(events[nevents], timebuf);
2777 strcat(events[nevents], string);
2780 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
2781 0, (LPARAM) events[nevents]);
2782 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
2783 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
2788 void showeventlog(HWND hwnd)
2791 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
2793 ShowWindow(logbox, SW_SHOWNORMAL);
2795 SetActiveWindow(logbox);
2798 void showabout(HWND hwnd)
2800 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
2803 void verify_ssh_host_key(char *host, int port, char *keytype,
2804 char *keystr, char *fingerprint)
2808 static const char absentmsg[] =
2809 "The server's host key is not cached in the registry. You\n"
2810 "have no guarantee that the server is the computer you\n"
2812 "The server's key fingerprint is:\n"
2814 "If you trust this host, hit Yes to add the key to\n"
2815 "PuTTY's cache and carry on connecting.\n"
2816 "If you want to carry on connecting just once, without\n"
2817 "adding the key to the cache, hit No.\n"
2818 "If you do not trust this host, hit Cancel to abandon the\n"
2821 static const char wrongmsg[] =
2822 "WARNING - POTENTIAL SECURITY BREACH!\n"
2824 "The server's host key does not match the one PuTTY has\n"
2825 "cached in the registry. This means that either the\n"
2826 "server administrator has changed the host key, or you\n"
2827 "have actually connected to another computer pretending\n"
2828 "to be the server.\n"
2829 "The new key fingerprint is:\n"
2831 "If you were expecting this change and trust the new key,\n"
2832 "hit Yes to update PuTTY's cache and continue connecting.\n"
2833 "If you want to carry on connecting but without updating\n"
2834 "the cache, hit No.\n"
2835 "If you want to abandon the connection completely, hit\n"
2836 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
2838 static const char mbtitle[] = "PuTTY Security Alert";
2841 /* sensible fingerprint max size */
2842 (sizeof(absentmsg) > sizeof(wrongmsg) ?
2843 sizeof(absentmsg) : sizeof(wrongmsg))];
2846 * Verify the key against the registry.
2848 ret = verify_host_key(host, port, keytype, keystr);
2850 if (ret == 0) /* success - key matched OK */
2852 if (ret == 2) { /* key was different */
2854 sprintf(message, wrongmsg, fingerprint);
2855 mbret = MessageBox(NULL, message, mbtitle,
2856 MB_ICONWARNING | MB_YESNOCANCEL);
2858 store_host_key(host, port, keytype, keystr);
2859 if (mbret == IDCANCEL)
2862 if (ret == 1) { /* key was absent */
2864 sprintf(message, absentmsg, fingerprint);
2865 mbret = MessageBox(NULL, message, mbtitle,
2866 MB_ICONWARNING | MB_YESNOCANCEL);
2868 store_host_key(host, port, keytype, keystr);
2869 if (mbret == IDCANCEL)
2875 * Ask whether the selected cipher is acceptable (since it was
2876 * below the configured 'warn' threshold).
2877 * cs: 0 = both ways, 1 = client->server, 2 = server->client
2879 void askcipher(char *ciphername, int cs)
2881 static const char mbtitle[] = "PuTTY Security Alert";
2882 static const char msg[] =
2883 "The first %.35scipher supported by the server\n"
2884 "is %.64s, which is below the configured\n"
2885 "warning threshold.\n"
2886 "Do you want to continue with this connection?\n";
2887 /* guessed cipher name + type max length */
2888 char message[100 + sizeof(msg)];
2891 sprintf(message, msg,
2893 (cs == 1) ? "client-to-server " :
2894 "server-to-client ",
2896 mbret = MessageBox(NULL, message, mbtitle,
2897 MB_ICONWARNING | MB_YESNO);
2905 * Ask whether to wipe a session log file before writing to it.
2906 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2908 int askappend(char *filename)
2910 static const char mbtitle[] = "PuTTY Log to File";
2911 static const char msgtemplate[] =
2912 "The session log file \"%.*s\" already exists.\n"
2913 "You can overwrite it with a new session log,\n"
2914 "append your session log to the end of it,\n"
2915 "or disable session logging for this session.\n"
2916 "Hit Yes to wipe the file, No to append to it,\n"
2917 "or Cancel to disable logging.";
2918 char message[sizeof(msgtemplate) + FILENAME_MAX];
2920 if (cfg.logxfovr != LGXF_ASK) {
2921 return ((cfg.logxfovr == LGXF_OVR) ? 2 : 1);
2923 sprintf(message, msgtemplate, FILENAME_MAX, filename);
2925 mbret = MessageBox(NULL, message, mbtitle,
2926 MB_ICONQUESTION | MB_YESNOCANCEL);
2929 else if (mbret == IDNO)