15 static char **events = NULL;
16 static int nevents = 0, negsize = 0;
20 void force_normal(HWND hwnd)
22 static int recurse = 0;
29 wp.length = sizeof(wp);
30 if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED)
32 wp.showCmd = SW_SHOWNORMAL;
33 SetWindowPlacement(hwnd, &wp);
38 static void MyGetDlgItemInt (HWND hwnd, int id, int *result) {
41 n = GetDlgItemInt (hwnd, id, &ok, FALSE);
46 static int CALLBACK LogProc (HWND hwnd, UINT msg,
47 WPARAM wParam, LPARAM lParam) {
53 static int tabs[4] = {78, 108};
54 SendDlgItemMessage (hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
57 for (i=0; i<nevents; i++)
58 SendDlgItemMessage (hwnd, IDN_LIST, LB_ADDSTRING,
59 0, (LPARAM)events[i]);
62 switch (LOWORD(wParam)) {
66 SetActiveWindow(GetParent(hwnd));
70 if (HIWORD(wParam) == BN_CLICKED ||
71 HIWORD(wParam) == BN_DOUBLECLICKED) {
74 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
75 LB_GETSELCOUNT, 0, 0);
76 if (selcount == 0) { /* don't even try to copy zero items */
81 selitems = smalloc(selcount * sizeof(int));
83 int count = SendDlgItemMessage(hwnd, IDN_LIST,
85 selcount, (LPARAM)selitems);
89 static unsigned char sel_nl[] = SEL_NL;
91 if (count == 0) { /* can't copy zero stuff */
97 for (i = 0; i < count; i++)
98 size += strlen(events[selitems[i]]) + sizeof(sel_nl);
100 clipdata = smalloc(size);
103 for (i = 0; i < count; i++) {
104 char *q = events[selitems[i]];
105 int qlen = strlen(q);
108 memcpy(p, sel_nl, sizeof(sel_nl));
111 write_clip(clipdata, size, TRUE);
116 for (i = 0; i < nevents; i++)
117 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
126 SetActiveWindow(GetParent(hwnd));
127 DestroyWindow (hwnd);
133 static int CALLBACK LicenceProc (HWND hwnd, UINT msg,
134 WPARAM wParam, LPARAM lParam) {
139 switch (LOWORD(wParam)) {
152 static int CALLBACK AboutProc (HWND hwnd, UINT msg,
153 WPARAM wParam, LPARAM lParam) {
156 SetDlgItemText (hwnd, IDA_VERSION, ver);
159 switch (LOWORD(wParam)) {
162 EndDialog(hwnd, TRUE);
165 EnableWindow(hwnd, 0);
166 DialogBox (hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
168 EnableWindow(hwnd, 1);
169 SetActiveWindow(hwnd);
173 /* Load web browser */
174 ShellExecute(hwnd, "open",
175 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
176 0, 0, SW_SHOWDEFAULT);
181 EndDialog(hwnd, TRUE);
188 * Null dialog procedure.
190 static int CALLBACK NullDlgProc (HWND hwnd, UINT msg,
191 WPARAM wParam, LPARAM lParam) {
195 static char savedsession[2048];
197 enum { IDCX_ABOUT = IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
327 appearancepanelstart,
328 IDC_TITLE_APPEARANCE,
346 connectionpanelstart,
347 IDC_TITLE_CONNECTION,
445 translationpanelstart,
446 IDC_TITLE_TRANSLATION,
447 IDC_BOX_TRANSLATION1,
448 IDC_BOX_TRANSLATION2,
449 IDC_BOX_TRANSLATION3,
474 static const char *const colours[] = {
475 "Default Foreground", "Default Bold Foreground",
476 "Default Background", "Default Bold Background",
477 "Cursor Text", "Cursor Colour",
478 "ANSI Black", "ANSI Black Bold",
479 "ANSI Red", "ANSI Red Bold",
480 "ANSI Green", "ANSI Green Bold",
481 "ANSI Yellow", "ANSI Yellow Bold",
482 "ANSI Blue", "ANSI Blue Bold",
483 "ANSI Magenta", "ANSI Magenta Bold",
484 "ANSI Cyan", "ANSI Cyan Bold",
485 "ANSI White", "ANSI White Bold"
487 static const int permcolour[] = {
488 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
489 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
490 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
493 static void fmtfont (char *buf) {
494 sprintf (buf, "Font: %s, ", cfg.font);
496 strcat(buf, "bold, ");
497 if (cfg.fontheight == 0)
498 strcat (buf, "default height");
500 sprintf (buf+strlen(buf), "%d-point",
501 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
504 static void init_dlg_ctrls(HWND hwnd) {
506 char fontstatic[256];
508 SetDlgItemText (hwnd, IDC_HOST, cfg.host);
509 SetDlgItemText (hwnd, IDC_SESSEDIT, savedsession);
512 n = SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
514 SendDlgItemMessage (hwnd, IDC_SESSLIST,
515 LB_DELETESTRING, i, 0);
516 for (i = 0; i < nsessions; i++)
517 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_ADDSTRING,
518 0, (LPARAM) (sessions[i]));
520 SetDlgItemInt (hwnd, IDC_PORT, cfg.port, FALSE);
521 CheckRadioButton (hwnd, IDC_PROTRAW, IDC_PROTSSH,
522 cfg.protocol==PROT_SSH ? IDC_PROTSSH :
523 cfg.protocol==PROT_TELNET ? IDC_PROTTELNET :
524 cfg.protocol==PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW );
525 SetDlgItemInt (hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
527 CheckRadioButton (hwnd, IDC_DEL008, IDC_DEL127,
528 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
529 CheckRadioButton (hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
530 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
531 CheckRadioButton (hwnd, IDC_FUNCTILDE, IDC_FUNCVT400,
532 cfg.funky_type == 0 ? IDC_FUNCTILDE :
533 cfg.funky_type == 1 ? IDC_FUNCLINUX :
534 cfg.funky_type == 2 ? IDC_FUNCXTERM :
535 cfg.funky_type == 3 ? IDC_FUNCVT400 :
537 CheckDlgButton (hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
538 CheckDlgButton (hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
539 CheckRadioButton (hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
540 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
541 CheckRadioButton (hwnd, IDC_KPNORMAL, IDC_KPNH,
542 cfg.nethack_keypad ? IDC_KPNH :
543 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
544 CheckDlgButton (hwnd, IDC_ALTF4, cfg.alt_f4);
545 CheckDlgButton (hwnd, IDC_ALTSPACE, cfg.alt_space);
546 CheckDlgButton (hwnd, IDC_ALTONLY, cfg.alt_only);
547 CheckDlgButton (hwnd, IDC_COMPOSEKEY, cfg.compose_key);
548 CheckDlgButton (hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
549 CheckRadioButton (hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
550 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND:
551 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
552 CheckRadioButton (hwnd, IDC_EDITBACKEND, IDC_EDITNO,
553 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND:
554 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
555 SetDlgItemText (hwnd, IDC_ANSWEREDIT, cfg.answerback);
556 CheckDlgButton (hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
557 CheckDlgButton (hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
558 CheckDlgButton (hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
560 CheckDlgButton (hwnd, IDC_WRAPMODE, cfg.wrap_mode);
561 CheckDlgButton (hwnd, IDC_DECOM, cfg.dec_om);
562 CheckDlgButton (hwnd, IDC_LFHASCR, cfg.lfhascr);
563 SetDlgItemInt (hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
564 SetDlgItemInt (hwnd, IDC_COLSEDIT, cfg.width, FALSE);
565 SetDlgItemInt (hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
566 fmtfont (fontstatic);
567 SetDlgItemText (hwnd, IDC_FONTSTATIC, fontstatic);
568 CheckRadioButton (hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
569 cfg.beep==0 ? IDC_BELL_DISABLED :
570 cfg.beep==1 ? IDC_BELL_DEFAULT : IDC_BELL_VISUAL);
571 CheckDlgButton (hwnd, IDC_BELLOVL, cfg.bellovl);
572 SetDlgItemInt (hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
573 SetDlgItemInt (hwnd, IDC_BELLOVLT, cfg.bellovl_t, FALSE);
574 SetDlgItemInt (hwnd, IDC_BELLOVLS, cfg.bellovl_s, FALSE);
576 CheckDlgButton (hwnd, IDC_BCE, cfg.bce);
577 CheckDlgButton (hwnd, IDC_BLINKTEXT, cfg.blinktext);
579 SetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle);
580 CheckDlgButton (hwnd, IDC_WINNAME, cfg.win_name_always);
581 CheckDlgButton (hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
582 CheckRadioButton (hwnd, IDC_CURBLOCK, IDC_CURVERT,
583 cfg.cursor_type==0 ? IDC_CURBLOCK :
584 cfg.cursor_type==1 ? IDC_CURUNDER : IDC_CURVERT);
585 CheckDlgButton (hwnd, IDC_BLINKCUR, cfg.blink_cur);
586 CheckDlgButton (hwnd, IDC_SCROLLBAR, cfg.scrollbar);
587 CheckDlgButton (hwnd, IDC_LOCKSIZE, cfg.locksize);
588 CheckRadioButton (hwnd, IDC_COEALWAYS, IDC_COENORMAL,
589 cfg.close_on_exit==COE_NORMAL ? IDC_COENORMAL :
590 cfg.close_on_exit==COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
591 CheckDlgButton (hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
593 SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype);
594 SetDlgItemText (hwnd, IDC_TSEDIT, cfg.termspeed);
595 SetDlgItemText (hwnd, IDC_R_TSEDIT, cfg.termspeed);
596 SetDlgItemText (hwnd, IDC_RLLUSEREDIT, cfg.localusername);
597 SetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username);
598 SetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename);
599 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATRAW,
600 cfg.logtype == 0 ? IDC_LSTATOFF :
601 cfg.logtype == 1 ? IDC_LSTATASCII :
604 char *p = cfg.environmt;
606 SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
611 CheckRadioButton (hwnd, IDC_EMBSD, IDC_EMRFC,
612 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
614 SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype);
615 SetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username);
616 CheckDlgButton (hwnd, IDC_NOPTY, cfg.nopty);
617 CheckDlgButton (hwnd, IDC_COMPRESS, cfg.compression);
618 CheckDlgButton (hwnd, IDC_BUGGYMAC, cfg.buggymac);
619 CheckDlgButton (hwnd, IDC_AGENTFWD, cfg.agentfwd);
620 CheckRadioButton (hwnd, IDC_CIPHER3DES, IDC_CIPHERAES,
621 cfg.cipher == CIPHER_BLOWFISH ? IDC_CIPHERBLOWF :
622 cfg.cipher == CIPHER_DES ? IDC_CIPHERDES :
623 cfg.cipher == CIPHER_AES ? IDC_CIPHERAES :
625 CheckRadioButton (hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
626 cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
627 CheckDlgButton (hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
628 SetDlgItemText (hwnd, IDC_PKEDIT, cfg.keyfile);
629 SetDlgItemText (hwnd, IDC_CMDEDIT, cfg.remote_cmd);
631 CheckRadioButton (hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
632 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
633 CheckDlgButton (hwnd, IDC_RAWCNP, cfg.rawcnp);
635 static int tabs[4] = {25, 61, 96, 128};
636 SendDlgItemMessage (hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
639 for (i=0; i<256; i++) {
641 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
642 (i>=0x21 && i != 0x7F) ? i : ' ',
644 SendDlgItemMessage (hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
648 CheckDlgButton (hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
649 CheckDlgButton (hwnd, IDC_PALETTE, cfg.try_palette);
652 n = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
654 SendDlgItemMessage (hwnd, IDC_COLOURLIST,
655 LB_DELETESTRING, i, 0);
657 if (cfg.bold_colour || permcolour[i])
658 SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
659 (LPARAM) colours[i]);
661 SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
662 SetDlgItemInt (hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
663 SetDlgItemInt (hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
664 SetDlgItemInt (hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
666 CheckRadioButton (hwnd, IDC_NOXLAT, IDC_88592CP852,
667 cfg.xlat_88592w1250 ? IDC_88592WIN1250 :
668 cfg.xlat_88592cp852 ? IDC_88592CP852 :
669 cfg.xlat_enablekoiwin ? IDC_KOI8WIN1251 :
671 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
672 CheckRadioButton (hwnd, IDC_VTXWINDOWS, IDC_VTPOORMAN,
673 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
674 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
675 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
678 CheckDlgButton (hwnd, IDC_X11_FORWARD, cfg.x11_forward);
679 SetDlgItemText (hwnd, IDC_X11_DISPLAY, cfg.x11_display);
682 struct treeview_faff {
687 static HTREEITEM treeview_insert(struct treeview_faff *faff,
688 int level, char *text) {
692 ins.hParent = (level > 0 ? faff->lastat[level-1] : TVI_ROOT);
693 ins.hInsertAfter = faff->lastat[level];
694 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
695 #define INSITEM DUMMYUNIONNAME.item
699 ins.INSITEM.mask = TVIF_TEXT;
700 ins.INSITEM.pszText = text;
701 newitem = TreeView_InsertItem(faff->treeview, &ins);
703 TreeView_Expand(faff->treeview, faff->lastat[level-1], TVE_EXPAND);
704 faff->lastat[level] = newitem;
705 for (i = level+1; i < 4; i++) faff->lastat[i] = NULL;
710 * Create the panelfuls of controls in the configuration box.
712 static void create_controls(HWND hwnd, int dlgtype, int panel) {
713 if (panel == sessionpanelstart) {
714 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
716 ctlposinit(&cp, hwnd, 80, 3, 13);
717 bartitle(&cp, "Basic options for your PuTTY session",
720 beginbox(&cp, "Specify your connection by host name",
723 "Host &Name", IDC_HOSTSTATIC, IDC_HOST, 75,
724 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
725 if (backends[3].backend == NULL) {
726 /* this is PuTTYtel, so only three protocols available */
727 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
729 "&Telnet", IDC_PROTTELNET,
730 "Rlog&in", IDC_PROTRLOGIN, NULL);
732 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
734 "&Telnet", IDC_PROTTELNET,
735 "Rlog&in", IDC_PROTRLOGIN,
744 beginbox(&cp, "Load, save or delete a stored session",
746 sesssaver(&cp, "Sav&ed Sessions",
747 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
748 "&Load", IDC_SESSLOAD,
749 "&Save", IDC_SESSSAVE,
750 "&Delete", IDC_SESSDEL, NULL);
753 beginbox(&cp, NULL, IDC_BOX_SESSION3);
754 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
755 "Always", IDC_COEALWAYS,
756 "Never", IDC_COENEVER,
757 "Only on clean exit", IDC_COENORMAL, NULL);
761 if (panel == loggingpanelstart) {
762 /* The Logging panel. Accelerators used: [acgo] tplfw */
764 ctlposinit(&cp, hwnd, 80, 3, 13);
765 bartitle(&cp, "Options controlling session logging",
767 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
769 "Session logging:", IDC_LSTATSTATIC,
770 "Logging &turned off completely", IDC_LSTATOFF,
771 "Log &printable output only", IDC_LSTATASCII,
772 "&Log all session output", IDC_LSTATRAW, NULL);
773 editbutton(&cp, "Log &file name:",
774 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
779 if (panel == terminalpanelstart) {
780 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
782 ctlposinit(&cp, hwnd, 80, 3, 13);
783 bartitle(&cp, "Options controlling the terminal emulation",
785 beginbox(&cp, "Set various terminal options",
787 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
788 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
789 checkbox(&cp, "Implicit CR in every &LF", IDC_LFHASCR);
790 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
791 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
793 "An&swerback to ^E:", IDC_ANSWERBACK,
794 IDC_ANSWEREDIT, 100, NULL);
797 beginbox(&cp, "Line discipline options",
799 radioline(&cp, "Local ec&ho:", IDC_ECHOSTATIC, 3,
800 "Auto", IDC_ECHOBACKEND,
801 "Force on", IDC_ECHOYES,
802 "Force off", IDC_ECHONO, NULL);
803 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
804 "Auto", IDC_EDITBACKEND,
805 "Force on", IDC_EDITYES,
806 "Force off", IDC_EDITNO, NULL);
810 if (panel == bellpanelstart) {
811 /* The Bell panel. Accelerators used: [acgo] bdsm */
813 ctlposinit(&cp, hwnd, 80, 3, 13);
814 bartitle(&cp, "Options controlling the terminal bell",
816 beginbox(&cp, "Set the style of bell",
819 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
820 "None (bell disabled)", IDC_BELL_DISABLED,
821 "Play Windows Default Sound", IDC_BELL_DEFAULT,
822 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
824 beginbox(&cp, "Control the bell overload behaviour",
826 checkbox(&cp, "Bell is temporarily &disabled when over-used",
828 staticedit(&cp, "Over-use means this &many bells...",
829 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
830 staticedit(&cp, "... in this many &seconds",
831 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
832 statictext(&cp, "The bell is re-enabled after a few seconds of silence.",
834 staticedit(&cp, "Seconds of silence required",
835 IDC_BELLOVLSSTATIC, IDC_BELLOVLS, 20);
839 if (panel == keyboardpanelstart) {
840 /* The Keyboard panel. Accelerators used: [acgo] h?sr~lxvunpymietd */
842 ctlposinit(&cp, hwnd, 80, 3, 13);
843 bartitle(&cp, "Options controlling the effects of keys",
845 beginbox(&cp, "Change the sequences sent by:",
847 radioline(&cp, "The Backspace key", IDC_DELSTATIC, 2,
848 "Control-&H", IDC_DEL008,
849 "Control-&? (127)", IDC_DEL127, NULL);
850 radioline(&cp, "The Home and End keys", IDC_HOMESTATIC, 2,
851 "&Standard", IDC_HOMETILDE,
852 "&rxvt", IDC_HOMERXVT, NULL);
853 radioline(&cp, "The Function keys and keypad", IDC_FUNCSTATIC, 4,
854 "ESC[n&~", IDC_FUNCTILDE,
855 "&Linux", IDC_FUNCLINUX,
856 "&Xterm R6", IDC_FUNCXTERM,
857 "&VT400", IDC_FUNCVT400, NULL);
859 beginbox(&cp, "Application keypad settings:",
862 "Application c&ursor keys totally disabled",
864 radioline(&cp, "Initial state of cursor keys:", IDC_CURSTATIC, 2,
865 "&Normal", IDC_CURNORMAL,
866 "A&pplication", IDC_CURAPPLIC, NULL);
868 "Application ke&ypad keys totally disabled",
870 radioline(&cp, "Initial state of numeric keypad:", IDC_KPSTATIC, 3,
871 "Nor&mal", IDC_KPNORMAL,
872 "Appl&ication", IDC_KPAPPLIC,
873 "N&etHack", IDC_KPNH, NULL);
875 beginbox(&cp, "Enable extra keyboard features:",
877 checkbox(&cp, "AltGr ac&ts as Compose key",
879 checkbox(&cp, "Control-Alt is &different from AltGr",
884 if (panel == windowpanelstart) {
885 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
887 ctlposinit(&cp, hwnd, 80, 3, 13);
888 bartitle(&cp, "Options controlling PuTTY's window",
890 beginbox(&cp, "Set the size of the window",
893 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
894 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50,
896 checkbox(&cp, "Lock window size against resi&zing", IDC_LOCKSIZE);
898 beginbox(&cp, "Control the scrollback in the window",
900 staticedit(&cp, "Lines of &scrollback",
901 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
902 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
903 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
904 checkbox(&cp, "Reset scrollback on dis&play activity",
907 beginbox(&cp, NULL, IDC_BOX_WINDOW3);
908 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
909 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
910 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
911 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
912 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
916 if (panel == appearancepanelstart) {
917 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p */
919 ctlposinit(&cp, hwnd, 80, 3, 13);
920 bartitle(&cp, "Options controlling PuTTY's appearance",
921 IDC_TITLE_APPEARANCE);
922 beginbox(&cp, "Adjust the use of the cursor",
923 IDC_BOX_APPEARANCE1);
924 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
925 "B&lock", IDC_CURBLOCK,
926 "&Underline", IDC_CURUNDER,
927 "&Vertical line", IDC_CURVERT,
929 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
931 beginbox(&cp, "Set the font used in the terminal window",
932 IDC_BOX_APPEARANCE2);
933 staticbtn(&cp, "", IDC_FONTSTATIC, "C&hange...", IDC_CHOOSEFONT);
935 beginbox(&cp, "Adjust the use of the window title",
936 IDC_BOX_APPEARANCE3);
938 "Window &title:", IDC_WINTITLE,
939 IDC_WINEDIT, 100, NULL);
940 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
942 beginbox(&cp, "Adjust the use of the mouse pointer",
943 IDC_BOX_APPEARANCE4);
944 checkbox(&cp, "Hide mouse &pointer when typing in window",
949 if (panel == translationpanelstart) {
950 /* The Translation panel. Accelerators used: [acgo] xbep t s */
952 ctlposinit(&cp, hwnd, 80, 3, 13);
953 bartitle(&cp, "Options controlling character set translation",
954 IDC_TITLE_TRANSLATION);
955 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
956 IDC_BOX_TRANSLATION1);
958 "Handling of line drawing characters:", IDC_VTSTATIC,
959 "Font has &XWindows encoding", IDC_VTXWINDOWS,
960 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
961 "Use font in O&EM mode only", IDC_VTOEMONLY,
962 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
963 IDC_VTPOORMAN, NULL);
965 beginbox(&cp, "Enable character set translation on received data",
966 IDC_BOX_TRANSLATION2);
968 "Character set &translation:", IDC_XLATSTATIC,
970 "KOI8 / Win-1251", IDC_KOI8WIN1251,
971 "ISO-8859-2 / Win-1250", IDC_88592WIN1250,
972 "ISO-8859-2 / CP852", IDC_88592CP852, NULL);
974 beginbox(&cp, "Enable character set translation on input data",
975 IDC_BOX_TRANSLATION3);
976 checkbox(&cp, "CAP&S LOCK acts as cyrillic switch",
981 if (panel == selectionpanelstart) {
982 /* The Selection panel. Accelerators used: [acgo] d wx hst */
984 ctlposinit(&cp, hwnd, 80, 3, 13);
985 bartitle(&cp, "Options controlling copy and paste",
986 IDC_TITLE_SELECTION);
987 beginbox(&cp, "Translation of pasted characters",
989 checkbox(&cp, "&Don't translate line drawing chars into +, - and |",
992 beginbox(&cp, "Control which mouse button does which thing",
994 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
995 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
996 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
999 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1000 IDC_BOX_SELECTION3);
1001 charclass(&cp, "C&haracter classes:", IDC_CCSTATIC, IDC_CCLIST,
1002 "&Set", IDC_CCSET, IDC_CCEDIT,
1003 "&to class", IDC_CCSTATIC2);
1007 if (panel == colourspanelstart) {
1008 /* The Colours panel. Accelerators used: [acgo] blum */
1010 ctlposinit(&cp, hwnd, 80, 3, 13);
1011 bartitle(&cp, "Options controlling use of colours",
1013 beginbox(&cp, "General options for colour usage",
1015 checkbox(&cp, "&Bolded text is a different colour", IDC_BOLDCOLOUR);
1016 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1018 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1020 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1021 IDC_COLOURSTATIC, IDC_COLOURLIST,
1022 "&Modify...", IDC_CHANGE,
1023 "Red:", IDC_RSTATIC, IDC_RVALUE,
1024 "Green:", IDC_GSTATIC, IDC_GVALUE,
1025 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1029 if (panel == connectionpanelstart) {
1030 /* The Connection panel. Accelerators used: [acgo] tuk */
1032 ctlposinit(&cp, hwnd, 80, 3, 13);
1033 bartitle(&cp, "Options controlling the connection", IDC_TITLE_CONNECTION);
1035 beginbox(&cp, "Data to send to the server",
1036 IDC_BOX_CONNECTION1);
1037 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC, IDC_TTEDIT, 50);
1038 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC, IDC_LOGEDIT, 50);
1041 beginbox(&cp, "Sending of null packets to keep session active",
1042 IDC_BOX_CONNECTION2);
1043 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1044 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1048 if (panel == telnetpanelstart) {
1049 /* The Telnet panel. Accelerators used: [acgo] svldr bf */
1051 ctlposinit(&cp, hwnd, 80, 3, 13);
1053 bartitle(&cp, "Options controlling Telnet connections", IDC_TITLE_TELNET);
1054 beginbox(&cp, "Data to send to the server",
1056 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC, IDC_TSEDIT, 50);
1057 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1058 "&Variable", IDC_VARSTATIC, IDC_VAREDIT,
1059 "Va&lue", IDC_VALSTATIC, IDC_VALEDIT,
1061 "A&dd", IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1063 beginbox(&cp, "Telnet protocol adjustments",
1065 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC, 2,
1066 "&BSD (commonplace)", IDC_EMBSD,
1067 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1072 if (panel == rloginpanelstart) {
1073 /* The Rlogin panel. Accelerators used: [acgo] sl */
1075 ctlposinit(&cp, hwnd, 80, 3, 13);
1077 bartitle(&cp, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN);
1078 beginbox(&cp, "Data to send to the server",
1080 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC, IDC_R_TSEDIT, 50);
1081 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC, IDC_RLLUSEREDIT, 50);
1086 if (panel == sshpanelstart) {
1087 /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bds i */
1089 ctlposinit(&cp, hwnd, 80, 3, 13);
1091 bartitle(&cp, "Options controlling SSH connections", IDC_TITLE_SSH);
1092 beginbox(&cp, "Data to send to the server",
1095 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1098 beginbox(&cp, "Authentication options",
1100 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication",
1102 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
1103 editbutton(&cp, "Private &key file for authentication:",
1104 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...", IDC_PKBUTTON);
1106 beginbox(&cp, "Protocol options",
1108 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1109 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1110 radioline(&cp, "Preferred SSH protocol version:",
1111 IDC_SSHPROTSTATIC, 2,
1112 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL);
1113 radioline(&cp, "Preferred encryption algorithm:", IDC_CIPHERSTATIC, 4,
1114 "&3DES", IDC_CIPHER3DES,
1115 "&Blowfish", IDC_CIPHERBLOWF,
1116 "&DES", IDC_CIPHERDES,
1117 "AE&S", IDC_CIPHERAES,
1119 checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1125 if (panel == tunnelspanelstart) {
1126 /* The Tunnels panel. Accelerators used: [acgo] ex */
1128 ctlposinit(&cp, hwnd, 80, 3, 13);
1130 bartitle(&cp, "Options controlling SSH tunnelling",
1132 beginbox(&cp, "X11 forwarding options",
1134 checkbox(&cp, "&Enable X11 forwarding",
1136 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
1137 IDC_X11_DISPLAY, 50, NULL);
1144 * This function is the configuration box.
1146 static int GenericMainDlgProc (HWND hwnd, UINT msg,
1147 WPARAM wParam, LPARAM lParam,
1150 struct treeview_faff tvfaff;
1153 char filename[sizeof(cfg.keyfile)];
1156 char fontstatic[256];
1158 struct servent * service;
1164 SetWindowLong(hwnd, GWL_USERDATA, 0);
1166 * Centre the window.
1168 { /* centre the window */
1171 hw = GetDesktopWindow();
1172 if (GetWindowRect (hw, &rs) && GetWindowRect (hwnd, &rd))
1173 MoveWindow (hwnd, (rs.right + rs.left + rd.left - rd.right)/2,
1174 (rs.bottom + rs.top + rd.top - rd.bottom)/2,
1175 rd.right-rd.left, rd.bottom-rd.top, TRUE);
1179 * Create the tree view.
1186 r.left = 3; r.right = r.left + 75;
1187 r.top = 3; r.bottom = r.top + 10;
1188 MapDialogRect(hwnd, &r);
1189 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
1190 WS_CHILD | WS_VISIBLE,
1192 r.right-r.left, r.bottom-r.top,
1193 hwnd, (HMENU)IDCX_TVSTATIC, hinst, NULL);
1194 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1195 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1197 r.left = 3; r.right = r.left + 75;
1198 r.top = 13; r.bottom = r.top + 206;
1199 MapDialogRect(hwnd, &r);
1200 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
1201 WS_CHILD | WS_VISIBLE |
1202 WS_TABSTOP | TVS_HASLINES |
1203 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS |
1204 TVS_LINESATROOT | TVS_SHOWSELALWAYS,
1206 r.right-r.left, r.bottom-r.top,
1207 hwnd, (HMENU)IDCX_TREEVIEW, hinst, NULL);
1208 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1209 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1210 tvfaff.treeview = treeview;
1211 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
1215 * Set up the tree view contents.
1217 hsession = treeview_insert(&tvfaff, 0, "Session");
1218 treeview_insert(&tvfaff, 1, "Logging");
1219 treeview_insert(&tvfaff, 0, "Terminal");
1220 treeview_insert(&tvfaff, 1, "Keyboard");
1221 treeview_insert(&tvfaff, 1, "Bell");
1222 treeview_insert(&tvfaff, 0, "Window");
1223 treeview_insert(&tvfaff, 1, "Appearance");
1224 treeview_insert(&tvfaff, 1, "Translation");
1225 treeview_insert(&tvfaff, 1, "Selection");
1226 treeview_insert(&tvfaff, 1, "Colours");
1227 treeview_insert(&tvfaff, 0, "Connection");
1229 treeview_insert(&tvfaff, 1, "Telnet");
1230 treeview_insert(&tvfaff, 1, "Rlogin");
1231 if (backends[3].backend != NULL) {
1232 treeview_insert(&tvfaff, 1, "SSH");
1233 treeview_insert(&tvfaff, 2, "Tunnels");
1238 * Put the treeview selection on to the Session panel. This
1239 * should also cause creation of the relevant controls.
1241 TreeView_SelectItem(treeview, hsession);
1244 * Set focus into the first available control.
1248 ctl = GetDlgItem(hwnd, IDC_HOST);
1249 if (!ctl) ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
1253 SetWindowLong(hwnd, GWL_USERDATA, 1);
1257 * Button release should trigger WM_OK if there was a
1258 * previous double click on the session list.
1262 SendMessage (hwnd, WM_COMMAND, IDOK, 0);
1265 if (LOWORD(wParam) == IDCX_TREEVIEW &&
1266 ((LPNMHDR)lParam)->code == TVN_SELCHANGED) {
1267 HTREEITEM i = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom);
1272 item.pszText = buffer;
1273 item.cchTextMax = sizeof(buffer);
1274 item.mask = TVIF_TEXT;
1275 TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
1276 for (j = controlstartvalue; j < controlendvalue; j++) {
1277 HWND item = GetDlgItem(hwnd, j);
1279 DestroyWindow(item);
1281 if (!strcmp(buffer, "Session"))
1282 create_controls(hwnd, dlgtype, sessionpanelstart);
1283 if (!strcmp(buffer, "Logging"))
1284 create_controls(hwnd, dlgtype, loggingpanelstart);
1285 if (!strcmp(buffer, "Keyboard"))
1286 create_controls(hwnd, dlgtype, keyboardpanelstart);
1287 if (!strcmp(buffer, "Terminal"))
1288 create_controls(hwnd, dlgtype, terminalpanelstart);
1289 if (!strcmp(buffer, "Bell"))
1290 create_controls(hwnd, dlgtype, bellpanelstart);
1291 if (!strcmp(buffer, "Window"))
1292 create_controls(hwnd, dlgtype, windowpanelstart);
1293 if (!strcmp(buffer, "Appearance"))
1294 create_controls(hwnd, dlgtype, appearancepanelstart);
1295 if (!strcmp(buffer, "Tunnels"))
1296 create_controls(hwnd, dlgtype, tunnelspanelstart);
1297 if (!strcmp(buffer, "Connection"))
1298 create_controls(hwnd, dlgtype, connectionpanelstart);
1299 if (!strcmp(buffer, "Telnet"))
1300 create_controls(hwnd, dlgtype, telnetpanelstart);
1301 if (!strcmp(buffer, "Rlogin"))
1302 create_controls(hwnd, dlgtype, rloginpanelstart);
1303 if (!strcmp(buffer, "SSH"))
1304 create_controls(hwnd, dlgtype, sshpanelstart);
1305 if (!strcmp(buffer, "Selection"))
1306 create_controls(hwnd, dlgtype, selectionpanelstart);
1307 if (!strcmp(buffer, "Colours"))
1308 create_controls(hwnd, dlgtype, colourspanelstart);
1309 if (!strcmp(buffer, "Translation"))
1310 create_controls(hwnd, dlgtype, translationpanelstart);
1312 init_dlg_ctrls(hwnd);
1314 SetFocus (((LPNMHDR)lParam)->hwndFrom); /* ensure focus stays */
1320 * Only process WM_COMMAND once the dialog is fully formed.
1322 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
1325 EndDialog (hwnd, 1);
1330 EndDialog (hwnd, 0);
1332 case IDC_PROTTELNET:
1333 case IDC_PROTRLOGIN:
1336 if (HIWORD(wParam) == BN_CLICKED ||
1337 HIWORD(wParam) == BN_DOUBLECLICKED) {
1338 int i = IsDlgButtonChecked (hwnd, IDC_PROTSSH);
1339 int j = IsDlgButtonChecked (hwnd, IDC_PROTTELNET);
1340 int k = IsDlgButtonChecked (hwnd, IDC_PROTRLOGIN);
1341 cfg.protocol = i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN : PROT_RAW ;
1342 if ((cfg.protocol == PROT_SSH && cfg.port != 22) ||
1343 (cfg.protocol == PROT_TELNET && cfg.port != 23) ||
1344 (cfg.protocol == PROT_RLOGIN && cfg.port != 513)) {
1345 cfg.port = i ? 22 : j ? 23 : 513;
1346 SetDlgItemInt (hwnd, IDC_PORT, cfg.port, FALSE);
1351 if (HIWORD(wParam) == EN_CHANGE)
1352 GetDlgItemText (hwnd, IDC_HOST, cfg.host,
1353 sizeof(cfg.host)-1);
1356 if (HIWORD(wParam) == EN_CHANGE) {
1357 GetDlgItemText (hwnd, IDC_PORT, portname, 31);
1358 if (isdigit(portname[0]))
1359 MyGetDlgItemInt (hwnd, IDC_PORT, &cfg.port);
1361 service = getservbyname(portname, NULL);
1362 if (service) cfg.port = ntohs(service->s_port);
1368 if (HIWORD(wParam) == EN_CHANGE) {
1369 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_SETCURSEL,
1371 GetDlgItemText (hwnd, IDC_SESSEDIT,
1372 savedsession, sizeof(savedsession)-1);
1373 savedsession[sizeof(savedsession)-1] = '\0';
1377 if (HIWORD(wParam) == BN_CLICKED ||
1378 HIWORD(wParam) == BN_DOUBLECLICKED) {
1383 GetDlgItemText (hwnd, IDC_SESSEDIT, str, sizeof(str)-1);
1385 int n = SendDlgItemMessage (hwnd, IDC_SESSLIST,
1386 LB_GETCURSEL, 0, 0);
1391 strcpy (str, sessions[n]);
1393 save_settings (str, !!strcmp(str, "Default Settings"), &cfg);
1394 get_sesslist (FALSE);
1395 get_sesslist (TRUE);
1396 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_RESETCONTENT,
1398 for (i = 0; i < nsessions; i++)
1399 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_ADDSTRING,
1400 0, (LPARAM) (sessions[i]));
1401 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_SETCURSEL,
1407 if (LOWORD(wParam) == IDC_SESSLOAD &&
1408 HIWORD(wParam) != BN_CLICKED &&
1409 HIWORD(wParam) != BN_DOUBLECLICKED)
1411 if (LOWORD(wParam) == IDC_SESSLIST &&
1412 HIWORD(wParam) != LBN_DBLCLK)
1415 int n = SendDlgItemMessage (hwnd, IDC_SESSLIST,
1416 LB_GETCURSEL, 0, 0);
1422 isdef = !strcmp(sessions[n], "Default Settings");
1423 load_settings (sessions[n], !isdef, &cfg);
1424 init_dlg_ctrls(hwnd);
1426 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
1428 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
1430 if (LOWORD(wParam) == IDC_SESSLIST) {
1432 * A double-click on a saved session should
1433 * actually start the session, not just load it.
1434 * Unless it's Default Settings or some other
1435 * host-less set of saved settings.
1444 if (HIWORD(wParam) == BN_CLICKED ||
1445 HIWORD(wParam) == BN_DOUBLECLICKED) {
1446 int n = SendDlgItemMessage (hwnd, IDC_SESSLIST,
1447 LB_GETCURSEL, 0, 0);
1448 if (n == LB_ERR || n == 0) {
1452 del_settings(sessions[n]);
1453 get_sesslist (FALSE);
1454 get_sesslist (TRUE);
1455 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_RESETCONTENT,
1457 for (i = 0; i < nsessions; i++)
1458 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_ADDSTRING,
1459 0, (LPARAM) (sessions[i]));
1460 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_SETCURSEL,
1464 if (HIWORD(wParam) == EN_CHANGE)
1465 MyGetDlgItemInt (hwnd, IDC_PINGEDIT, &cfg.ping_interval);
1469 if (HIWORD(wParam) == BN_CLICKED ||
1470 HIWORD(wParam) == BN_DOUBLECLICKED)
1471 cfg.bksp_is_delete = IsDlgButtonChecked (hwnd, IDC_DEL127);
1475 if (HIWORD(wParam) == BN_CLICKED ||
1476 HIWORD(wParam) == BN_DOUBLECLICKED)
1477 cfg.rxvt_homeend = IsDlgButtonChecked (hwnd, IDC_HOMERXVT);
1480 if (HIWORD(wParam) == BN_CLICKED ||
1481 HIWORD(wParam) == BN_DOUBLECLICKED)
1485 if (HIWORD(wParam) == BN_CLICKED ||
1486 HIWORD(wParam) == BN_DOUBLECLICKED)
1491 if (HIWORD(wParam) == BN_CLICKED ||
1492 HIWORD(wParam) == BN_DOUBLECLICKED)
1493 cfg.funky_type = IsDlgButtonChecked (hwnd, IDC_FUNCLINUX);
1497 if (HIWORD(wParam) == BN_CLICKED ||
1498 HIWORD(wParam) == BN_DOUBLECLICKED) {
1499 cfg.app_keypad = IsDlgButtonChecked (hwnd, IDC_KPAPPLIC);
1500 cfg.nethack_keypad = FALSE;
1504 if (HIWORD(wParam) == BN_CLICKED ||
1505 HIWORD(wParam) == BN_DOUBLECLICKED) {
1506 cfg.app_keypad = FALSE;
1507 cfg.nethack_keypad = TRUE;
1512 if (HIWORD(wParam) == BN_CLICKED ||
1513 HIWORD(wParam) == BN_DOUBLECLICKED)
1514 cfg.app_cursor = IsDlgButtonChecked (hwnd, IDC_CURAPPLIC);
1517 if (HIWORD(wParam) == BN_CLICKED ||
1518 HIWORD(wParam) == BN_DOUBLECLICKED)
1519 cfg.no_applic_c = IsDlgButtonChecked (hwnd, IDC_NOAPPLICC);
1522 if (HIWORD(wParam) == BN_CLICKED ||
1523 HIWORD(wParam) == BN_DOUBLECLICKED)
1524 cfg.no_applic_k = IsDlgButtonChecked (hwnd, IDC_NOAPPLICK);
1527 if (HIWORD(wParam) == BN_CLICKED ||
1528 HIWORD(wParam) == BN_DOUBLECLICKED)
1529 cfg.alt_f4 = IsDlgButtonChecked (hwnd, IDC_ALTF4);
1532 if (HIWORD(wParam) == BN_CLICKED ||
1533 HIWORD(wParam) == BN_DOUBLECLICKED)
1534 cfg.alt_space = IsDlgButtonChecked (hwnd, IDC_ALTSPACE);
1537 if (HIWORD(wParam) == BN_CLICKED ||
1538 HIWORD(wParam) == BN_DOUBLECLICKED)
1539 cfg.alt_only = IsDlgButtonChecked (hwnd, IDC_ALTONLY);
1541 case IDC_ECHOBACKEND:
1544 if (HIWORD(wParam) == BN_CLICKED ||
1545 HIWORD(wParam) == BN_DOUBLECLICKED) {
1546 if (LOWORD(wParam)==IDC_ECHOBACKEND) cfg.localecho=LD_BACKEND;
1547 if (LOWORD(wParam)==IDC_ECHOYES) cfg.localecho=LD_YES;
1548 if (LOWORD(wParam)==IDC_ECHONO) cfg.localecho=LD_NO;
1551 case IDC_EDITBACKEND:
1554 if (HIWORD(wParam) == BN_CLICKED ||
1555 HIWORD(wParam) == BN_DOUBLECLICKED) {
1556 if (LOWORD(wParam)==IDC_EDITBACKEND) cfg.localedit=LD_BACKEND;
1557 if (LOWORD(wParam)==IDC_EDITYES) cfg.localedit=LD_YES;
1558 if (LOWORD(wParam)==IDC_EDITNO) cfg.localedit=LD_NO;
1561 case IDC_ANSWEREDIT:
1562 if (HIWORD(wParam) == EN_CHANGE)
1563 GetDlgItemText (hwnd, IDC_ANSWEREDIT, cfg.answerback,
1564 sizeof(cfg.answerback)-1);
1566 case IDC_ALWAYSONTOP:
1567 if (HIWORD(wParam) == BN_CLICKED ||
1568 HIWORD(wParam) == BN_DOUBLECLICKED)
1569 cfg.alwaysontop = IsDlgButtonChecked (hwnd, IDC_ALWAYSONTOP);
1572 if (HIWORD(wParam) == BN_CLICKED ||
1573 HIWORD(wParam) == BN_DOUBLECLICKED)
1574 cfg.scroll_on_key = IsDlgButtonChecked (hwnd, IDC_SCROLLKEY);
1576 case IDC_SCROLLDISP:
1577 if (HIWORD(wParam) == BN_CLICKED ||
1578 HIWORD(wParam) == BN_DOUBLECLICKED)
1579 cfg.scroll_on_disp = IsDlgButtonChecked (hwnd, IDC_SCROLLDISP);
1581 case IDC_COMPOSEKEY:
1582 if (HIWORD(wParam) == BN_CLICKED ||
1583 HIWORD(wParam) == BN_DOUBLECLICKED)
1584 cfg.compose_key = IsDlgButtonChecked (hwnd, IDC_COMPOSEKEY);
1586 case IDC_CTRLALTKEYS:
1587 if (HIWORD(wParam) == BN_CLICKED ||
1588 HIWORD(wParam) == BN_DOUBLECLICKED)
1589 cfg.ctrlaltkeys = IsDlgButtonChecked (hwnd, IDC_CTRLALTKEYS);
1592 if (HIWORD(wParam) == BN_CLICKED ||
1593 HIWORD(wParam) == BN_DOUBLECLICKED)
1594 cfg.wrap_mode = IsDlgButtonChecked (hwnd, IDC_WRAPMODE);
1597 if (HIWORD(wParam) == BN_CLICKED ||
1598 HIWORD(wParam) == BN_DOUBLECLICKED)
1599 cfg.dec_om = IsDlgButtonChecked (hwnd, IDC_DECOM);
1602 if (HIWORD(wParam) == BN_CLICKED ||
1603 HIWORD(wParam) == BN_DOUBLECLICKED)
1604 cfg.lfhascr = IsDlgButtonChecked (hwnd, IDC_LFHASCR);
1607 if (HIWORD(wParam) == EN_CHANGE)
1608 MyGetDlgItemInt (hwnd, IDC_ROWSEDIT, &cfg.height);
1611 if (HIWORD(wParam) == EN_CHANGE)
1612 MyGetDlgItemInt (hwnd, IDC_COLSEDIT, &cfg.width);
1615 if (HIWORD(wParam) == EN_CHANGE)
1616 MyGetDlgItemInt (hwnd, IDC_SAVEEDIT, &cfg.savelines);
1618 case IDC_CHOOSEFONT:
1619 lf.lfHeight = cfg.fontheight;
1620 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
1621 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
1622 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
1623 lf.lfCharSet = cfg.fontcharset;
1624 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
1625 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
1626 lf.lfQuality = DEFAULT_QUALITY;
1627 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
1628 strncpy (lf.lfFaceName, cfg.font, sizeof(lf.lfFaceName)-1);
1629 lf.lfFaceName[sizeof(lf.lfFaceName)-1] = '\0';
1631 cf.lStructSize = sizeof(cf);
1632 cf.hwndOwner = hwnd;
1634 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
1635 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
1637 if (ChooseFont (&cf)) {
1638 strncpy (cfg.font, lf.lfFaceName, sizeof(cfg.font)-1);
1639 cfg.font[sizeof(cfg.font)-1] = '\0';
1640 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
1641 cfg.fontcharset = lf.lfCharSet;
1642 cfg.fontheight = cf.iPointSize / 10;
1643 fmtfont (fontstatic);
1644 SetDlgItemText (hwnd, IDC_FONTSTATIC, fontstatic);
1647 case IDC_BELL_DISABLED:
1648 case IDC_BELL_DEFAULT:
1649 case IDC_BELL_VISUAL:
1650 if (HIWORD(wParam) == BN_CLICKED ||
1651 HIWORD(wParam) == BN_DOUBLECLICKED) {
1652 if (LOWORD(wParam)==IDC_BELL_DISABLED) cfg.beep = 0;
1653 if (LOWORD(wParam)==IDC_BELL_DEFAULT) cfg.beep = 1;
1654 if (LOWORD(wParam)==IDC_BELL_VISUAL) cfg.beep = 2;
1658 if (HIWORD(wParam) == BN_CLICKED ||
1659 HIWORD(wParam) == BN_DOUBLECLICKED)
1660 cfg.bellovl = IsDlgButtonChecked (hwnd, IDC_BELLOVL);
1663 if (HIWORD(wParam) == EN_CHANGE)
1664 MyGetDlgItemInt (hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
1667 if (HIWORD(wParam) == EN_CHANGE)
1668 MyGetDlgItemInt (hwnd, IDC_BELLOVLT, &cfg.bellovl_t);
1671 if (HIWORD(wParam) == EN_CHANGE)
1672 MyGetDlgItemInt (hwnd, IDC_BELLOVLS, &cfg.bellovl_s);
1675 if (HIWORD(wParam) == BN_CLICKED ||
1676 HIWORD(wParam) == BN_DOUBLECLICKED)
1677 cfg.blinktext = IsDlgButtonChecked (hwnd, IDC_BLINKTEXT);
1680 if (HIWORD(wParam) == BN_CLICKED ||
1681 HIWORD(wParam) == BN_DOUBLECLICKED)
1682 cfg.bce = IsDlgButtonChecked (hwnd, IDC_BCE);
1685 if (HIWORD(wParam) == BN_CLICKED ||
1686 HIWORD(wParam) == BN_DOUBLECLICKED)
1687 cfg.win_name_always = IsDlgButtonChecked (hwnd, IDC_WINNAME);
1690 if (HIWORD(wParam) == BN_CLICKED ||
1691 HIWORD(wParam) == BN_DOUBLECLICKED)
1692 cfg.hide_mouseptr = IsDlgButtonChecked (hwnd, IDC_HIDEMOUSE);
1695 if (HIWORD(wParam) == BN_CLICKED ||
1696 HIWORD(wParam) == BN_DOUBLECLICKED)
1697 cfg.cursor_type = 0;
1700 if (HIWORD(wParam) == BN_CLICKED ||
1701 HIWORD(wParam) == BN_DOUBLECLICKED)
1702 cfg.cursor_type = 1;
1705 if (HIWORD(wParam) == BN_CLICKED ||
1706 HIWORD(wParam) == BN_DOUBLECLICKED)
1707 cfg.cursor_type = 2;
1710 if (HIWORD(wParam) == BN_CLICKED ||
1711 HIWORD(wParam) == BN_DOUBLECLICKED)
1712 cfg.blink_cur = IsDlgButtonChecked (hwnd, IDC_BLINKCUR);
1715 if (HIWORD(wParam) == BN_CLICKED ||
1716 HIWORD(wParam) == BN_DOUBLECLICKED)
1717 cfg.scrollbar = IsDlgButtonChecked (hwnd, IDC_SCROLLBAR);
1720 if (HIWORD(wParam) == BN_CLICKED ||
1721 HIWORD(wParam) == BN_DOUBLECLICKED)
1722 cfg.locksize = IsDlgButtonChecked (hwnd, IDC_LOCKSIZE);
1725 if (HIWORD(wParam) == EN_CHANGE)
1726 GetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle,
1727 sizeof(cfg.wintitle)-1);
1732 if (HIWORD(wParam) == BN_CLICKED ||
1733 HIWORD(wParam) == BN_DOUBLECLICKED) {
1734 cfg.close_on_exit = IsDlgButtonChecked (hwnd, IDC_COEALWAYS) ? COE_ALWAYS :
1735 IsDlgButtonChecked (hwnd, IDC_COENEVER) ? COE_NEVER :
1740 if (HIWORD(wParam) == BN_CLICKED ||
1741 HIWORD(wParam) == BN_DOUBLECLICKED)
1742 cfg.warn_on_close = IsDlgButtonChecked (hwnd, IDC_CLOSEWARN);
1745 if (HIWORD(wParam) == EN_CHANGE)
1746 GetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype,
1747 sizeof(cfg.termtype)-1);
1750 if (HIWORD(wParam) == EN_CHANGE)
1751 GetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename,
1752 sizeof(cfg.logfilename)-1);
1755 memset(&of, 0, sizeof(of));
1756 #ifdef OPENFILENAME_SIZE_VERSION_400
1757 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
1759 of.lStructSize = sizeof(of);
1761 of.hwndOwner = hwnd;
1762 of.lpstrFilter = "All Files\0*\0\0\0";
1763 of.lpstrCustomFilter = NULL;
1764 of.nFilterIndex = 1;
1765 of.lpstrFile = filename; strcpy(filename, cfg.logfilename);
1766 of.nMaxFile = sizeof(filename);
1767 of.lpstrFileTitle = NULL;
1768 of.lpstrInitialDir = NULL;
1769 of.lpstrTitle = "Select session log file";
1771 if (GetSaveFileName(&of)) {
1772 strcpy(cfg.logfilename, filename);
1773 SetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename);
1777 case IDC_LSTATASCII:
1779 if (HIWORD(wParam) == BN_CLICKED ||
1780 HIWORD(wParam) == BN_DOUBLECLICKED) {
1781 if (IsDlgButtonChecked (hwnd, IDC_LSTATOFF)) cfg.logtype = 0;
1782 if (IsDlgButtonChecked (hwnd, IDC_LSTATASCII)) cfg.logtype = 1;
1783 if (IsDlgButtonChecked (hwnd, IDC_LSTATRAW)) cfg.logtype = 2;
1788 if (HIWORD(wParam) == EN_CHANGE)
1789 GetDlgItemText (hwnd, LOWORD(wParam), cfg.termspeed,
1790 sizeof(cfg.termspeed)-1);
1793 if (HIWORD(wParam) == EN_CHANGE)
1794 GetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username,
1795 sizeof(cfg.username)-1);
1797 case IDC_RLLUSEREDIT:
1798 if (HIWORD(wParam) == EN_CHANGE)
1799 GetDlgItemText (hwnd, IDC_RLLUSEREDIT, cfg.localusername,
1800 sizeof(cfg.localusername)-1);
1804 cfg.rfc_environ = IsDlgButtonChecked (hwnd, IDC_EMRFC);
1807 if (HIWORD(wParam) == BN_CLICKED ||
1808 HIWORD(wParam) == BN_DOUBLECLICKED) {
1809 char str[sizeof(cfg.environmt)];
1811 GetDlgItemText (hwnd, IDC_VAREDIT, str, sizeof(str)-1);
1816 p = str + strlen(str);
1818 GetDlgItemText (hwnd, IDC_VALEDIT, p, sizeof(str)-1-(p-str));
1828 if ((p-cfg.environmt) + strlen(str) + 2 < sizeof(cfg.environmt)) {
1830 p[strlen(str)+1] = '\0';
1831 SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_ADDSTRING,
1833 SetDlgItemText (hwnd, IDC_VAREDIT, "");
1834 SetDlgItemText (hwnd, IDC_VALEDIT, "");
1836 MessageBox(hwnd, "Environment too big", "PuTTY Error",
1837 MB_OK | MB_ICONERROR);
1842 if (HIWORD(wParam) != BN_CLICKED &&
1843 HIWORD(wParam) != BN_DOUBLECLICKED)
1845 i = SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_GETCURSEL, 0, 0);
1851 SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_DELETESTRING,
1876 if (HIWORD(wParam) == BN_CLICKED ||
1877 HIWORD(wParam) == BN_DOUBLECLICKED)
1878 cfg.nopty = IsDlgButtonChecked (hwnd, IDC_NOPTY);
1881 if (HIWORD(wParam) == BN_CLICKED ||
1882 HIWORD(wParam) == BN_DOUBLECLICKED)
1883 cfg.compression = IsDlgButtonChecked (hwnd, IDC_COMPRESS);
1886 if (HIWORD(wParam) == BN_CLICKED ||
1887 HIWORD(wParam) == BN_DOUBLECLICKED)
1888 cfg.buggymac = IsDlgButtonChecked (hwnd, IDC_BUGGYMAC);
1891 if (HIWORD(wParam) == BN_CLICKED ||
1892 HIWORD(wParam) == BN_DOUBLECLICKED)
1893 cfg.agentfwd = IsDlgButtonChecked (hwnd, IDC_AGENTFWD);
1895 case IDC_CIPHER3DES:
1896 case IDC_CIPHERBLOWF:
1899 if (HIWORD(wParam) == BN_CLICKED ||
1900 HIWORD(wParam) == BN_DOUBLECLICKED) {
1901 if (IsDlgButtonChecked (hwnd, IDC_CIPHER3DES))
1902 cfg.cipher = CIPHER_3DES;
1903 else if (IsDlgButtonChecked (hwnd, IDC_CIPHERBLOWF))
1904 cfg.cipher = CIPHER_BLOWFISH;
1905 else if (IsDlgButtonChecked (hwnd, IDC_CIPHERDES))
1906 cfg.cipher = CIPHER_DES;
1907 else if (IsDlgButtonChecked (hwnd, IDC_CIPHERAES))
1908 cfg.cipher = CIPHER_AES;
1913 if (HIWORD(wParam) == BN_CLICKED ||
1914 HIWORD(wParam) == BN_DOUBLECLICKED) {
1915 if (IsDlgButtonChecked (hwnd, IDC_SSHPROT1))
1917 else if (IsDlgButtonChecked (hwnd, IDC_SSHPROT2))
1922 if (HIWORD(wParam) == BN_CLICKED ||
1923 HIWORD(wParam) == BN_DOUBLECLICKED)
1924 cfg.try_tis_auth = IsDlgButtonChecked (hwnd, IDC_AUTHTIS);
1927 if (HIWORD(wParam) == EN_CHANGE)
1928 GetDlgItemText (hwnd, IDC_PKEDIT, cfg.keyfile,
1929 sizeof(cfg.keyfile)-1);
1932 if (HIWORD(wParam) == EN_CHANGE)
1933 GetDlgItemText (hwnd, IDC_CMDEDIT, cfg.remote_cmd,
1934 sizeof(cfg.remote_cmd)-1);
1937 memset(&of, 0, sizeof(of));
1938 #ifdef OPENFILENAME_SIZE_VERSION_400
1939 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
1941 of.lStructSize = sizeof(of);
1943 of.hwndOwner = hwnd;
1944 of.lpstrFilter = "All Files\0*\0\0\0";
1945 of.lpstrCustomFilter = NULL;
1946 of.nFilterIndex = 1;
1947 of.lpstrFile = filename; strcpy(filename, cfg.keyfile);
1948 of.nMaxFile = sizeof(filename);
1949 of.lpstrFileTitle = NULL;
1950 of.lpstrInitialDir = NULL;
1951 of.lpstrTitle = "Select Public Key File";
1953 if (GetOpenFileName(&of)) {
1954 strcpy(cfg.keyfile, filename);
1955 SetDlgItemText (hwnd, IDC_PKEDIT, cfg.keyfile);
1959 cfg.rawcnp = IsDlgButtonChecked (hwnd, IDC_RAWCNP);
1962 cfg.mouse_is_xterm = IsDlgButtonChecked (hwnd, IDC_MBXTERM);
1968 int n = GetDlgItemInt (hwnd, IDC_CCEDIT, &ok, FALSE);
1973 for (i=0; i<256; i++)
1974 if (SendDlgItemMessage (hwnd, IDC_CCLIST, LB_GETSEL,
1977 cfg.wordness[i] = n;
1978 SendDlgItemMessage (hwnd, IDC_CCLIST,
1979 LB_DELETESTRING, i, 0);
1980 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
1981 (i>=0x21 && i != 0x7F) ? i : ' ',
1983 SendDlgItemMessage (hwnd, IDC_CCLIST,
1990 case IDC_BOLDCOLOUR:
1991 if (HIWORD(wParam) == BN_CLICKED ||
1992 HIWORD(wParam) == BN_DOUBLECLICKED) {
1994 cfg.bold_colour = IsDlgButtonChecked (hwnd, IDC_BOLDCOLOUR);
1995 n = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
1996 if (n != 12+10*cfg.bold_colour) {
1998 SendDlgItemMessage (hwnd, IDC_COLOURLIST,
1999 LB_DELETESTRING, i, 0);
2000 for (i=0; i<22; i++)
2001 if (cfg.bold_colour || permcolour[i])
2002 SendDlgItemMessage (hwnd, IDC_COLOURLIST,
2004 (LPARAM) colours[i]);
2009 if (HIWORD(wParam) == BN_CLICKED ||
2010 HIWORD(wParam) == BN_DOUBLECLICKED)
2011 cfg.try_palette = IsDlgButtonChecked (hwnd, IDC_PALETTE);
2013 case IDC_COLOURLIST:
2014 if (HIWORD(wParam) == LBN_DBLCLK ||
2015 HIWORD(wParam) == LBN_SELCHANGE) {
2016 int i = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCURSEL,
2018 if (!cfg.bold_colour)
2019 i = (i < 3 ? i*2 : i == 3 ? 5 : i*2-2);
2020 SetDlgItemInt (hwnd, IDC_RVALUE, cfg.colours[i][0], FALSE);
2021 SetDlgItemInt (hwnd, IDC_GVALUE, cfg.colours[i][1], FALSE);
2022 SetDlgItemInt (hwnd, IDC_BVALUE, cfg.colours[i][2], FALSE);
2026 if (HIWORD(wParam) == BN_CLICKED ||
2027 HIWORD(wParam) == BN_DOUBLECLICKED) {
2028 static CHOOSECOLOR cc;
2029 static DWORD custom[16] = {0}; /* zero initialisers */
2030 int i = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCURSEL,
2032 if (!cfg.bold_colour)
2033 i = (i < 3 ? i*2 : i == 3 ? 5 : i*2-2);
2034 cc.lStructSize = sizeof(cc);
2035 cc.hwndOwner = hwnd;
2036 cc.hInstance = (HWND)hinst;
2037 cc.lpCustColors = custom;
2038 cc.rgbResult = RGB (cfg.colours[i][0], cfg.colours[i][1],
2040 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
2041 if (ChooseColor(&cc)) {
2043 (unsigned char) (cc.rgbResult & 0xFF);
2045 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
2047 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
2048 SetDlgItemInt (hwnd, IDC_RVALUE, cfg.colours[i][0],
2050 SetDlgItemInt (hwnd, IDC_GVALUE, cfg.colours[i][1],
2052 SetDlgItemInt (hwnd, IDC_BVALUE, cfg.colours[i][2],
2058 case IDC_KOI8WIN1251:
2059 case IDC_88592WIN1250:
2060 case IDC_88592CP852:
2061 cfg.xlat_enablekoiwin =
2062 IsDlgButtonChecked (hwnd, IDC_KOI8WIN1251);
2063 cfg.xlat_88592w1250 =
2064 IsDlgButtonChecked (hwnd, IDC_88592WIN1250);
2065 cfg.xlat_88592cp852 =
2066 IsDlgButtonChecked (hwnd, IDC_88592CP852);
2068 case IDC_CAPSLOCKCYR:
2069 if (HIWORD(wParam) == BN_CLICKED ||
2070 HIWORD(wParam) == BN_DOUBLECLICKED) {
2071 cfg.xlat_capslockcyr =
2072 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
2075 case IDC_VTXWINDOWS:
2080 (IsDlgButtonChecked (hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS :
2081 IsDlgButtonChecked (hwnd, IDC_VTOEMANSI) ? VT_OEMANSI :
2082 IsDlgButtonChecked (hwnd, IDC_VTOEMONLY) ? VT_OEMONLY :
2085 case IDC_X11_FORWARD:
2086 if (HIWORD(wParam) == BN_CLICKED ||
2087 HIWORD(wParam) == BN_DOUBLECLICKED)
2088 cfg.x11_forward = IsDlgButtonChecked (hwnd, IDC_X11_FORWARD);
2090 case IDC_X11_DISPLAY:
2091 if (HIWORD(wParam) == EN_CHANGE)
2092 GetDlgItemText (hwnd, IDC_X11_DISPLAY, cfg.x11_display,
2093 sizeof(cfg.x11_display)-1);
2098 EndDialog (hwnd, 0);
2101 /* Grrr Explorer will maximize Dialogs! */
2103 if (wParam == SIZE_MAXIMIZED)
2110 static int CALLBACK MainDlgProc (HWND hwnd, UINT msg,
2111 WPARAM wParam, LPARAM lParam) {
2112 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
2114 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
2115 EnableWindow(hwnd, 0);
2116 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
2117 GetParent(hwnd), AboutProc);
2118 EnableWindow(hwnd, 1);
2119 SetActiveWindow(hwnd);
2121 return GenericMainDlgProc (hwnd, msg, wParam, lParam, 0);
2124 static int CALLBACK ReconfDlgProc (HWND hwnd, UINT msg,
2125 WPARAM wParam, LPARAM lParam) {
2126 return GenericMainDlgProc (hwnd, msg, wParam, lParam, 1);
2129 void defuse_showwindow(void) {
2131 * Work around the fact that the app's first call to ShowWindow
2132 * will ignore the default in favour of the shell-provided
2137 hwnd = CreateDialog (hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
2139 ShowWindow(hwnd, SW_HIDE);
2140 DestroyWindow(hwnd);
2144 int do_config (void) {
2148 savedsession[0] = '\0';
2149 ret = DialogBox (hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
2150 get_sesslist(FALSE);
2155 int do_reconfig (HWND hwnd) {
2159 backup_cfg = cfg; /* structure copy */
2160 ret = DialogBox (hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
2162 cfg = backup_cfg; /* structure copy */
2167 void logevent (char *string) {
2171 if (nevents >= negsize) {
2173 events = srealloc (events, negsize * sizeof(*events));
2177 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t", localtime(&t));
2179 events[nevents] = smalloc(strlen(timebuf)+strlen(string)+1);
2180 strcpy(events[nevents], timebuf);
2181 strcat(events[nevents], string);
2184 SendDlgItemMessage (logbox, IDN_LIST, LB_ADDSTRING,
2185 0, (LPARAM)events[nevents]);
2186 count = SendDlgItemMessage (logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
2187 SendDlgItemMessage (logbox, IDN_LIST, LB_SETTOPINDEX, count-1, 0);
2192 void showeventlog (HWND hwnd) {
2194 logbox = CreateDialog (hinst, MAKEINTRESOURCE(IDD_LOGBOX),
2196 ShowWindow (logbox, SW_SHOWNORMAL);
2198 SetActiveWindow(logbox);
2201 void showabout (HWND hwnd) {
2202 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),hwnd, AboutProc);
2205 void verify_ssh_host_key(char *host, int port, char *keytype,
2206 char *keystr, char *fingerprint) {
2209 static const char absentmsg[] =
2210 "The server's host key is not cached in the registry. You\n"
2211 "have no guarantee that the server is the computer you\n"
2213 "The server's key fingerprint is:\n"
2215 "If you trust this host, hit Yes to add the key to\n"
2216 "PuTTY's cache and carry on connecting.\n"
2217 "If you do not trust this host, hit No to abandon the\n"
2220 static const char wrongmsg[] =
2221 "WARNING - POTENTIAL SECURITY BREACH!\n"
2223 "The server's host key does not match the one PuTTY has\n"
2224 "cached in the registry. This means that either the\n"
2225 "server administrator has changed the host key, or you\n"
2226 "have actually connected to another computer pretending\n"
2227 "to be the server.\n"
2228 "The new key fingerprint is:\n"
2230 "If you were expecting this change and trust the new key,\n"
2231 "hit Yes to update PuTTY's cache and continue connecting.\n"
2232 "If you want to carry on connecting but without updating\n"
2233 "the cache, hit No.\n"
2234 "If you want to abandon the connection completely, hit\n"
2235 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2238 static const char mbtitle[] = "PuTTY Security Alert";
2241 char message[160+ /* sensible fingerprint max size */
2242 (sizeof(absentmsg) > sizeof(wrongmsg) ?
2243 sizeof(absentmsg) : sizeof(wrongmsg))];
2246 * Verify the key against the registry.
2248 ret = verify_host_key(host, port, keytype, keystr);
2250 if (ret == 0) /* success - key matched OK */
2252 if (ret == 2) { /* key was different */
2254 sprintf(message, wrongmsg, fingerprint);
2255 mbret = MessageBox(NULL, message, mbtitle,
2256 MB_ICONWARNING | MB_YESNOCANCEL);
2258 store_host_key(host, port, keytype, keystr);
2259 if (mbret == IDCANCEL)
2262 if (ret == 1) { /* key was absent */
2264 sprintf(message, absentmsg, fingerprint);
2265 mbret = MessageBox(NULL, message, mbtitle,
2266 MB_ICONWARNING | MB_YESNO);
2269 store_host_key(host, port, keytype, keystr);
2274 * Ask whether to wipe a session log file before writing to it.
2275 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2277 int askappend(char *filename) {
2278 static const char mbtitle[] = "PuTTY Log to File";
2279 static const char msgtemplate[] =
2280 "The session log file \"%.*s\" already exists.\n"
2281 "You can overwrite it with a new session log,\n"
2282 "append your session log to the end of it,\n"
2283 "or disable session logging for this session.\n"
2284 "Hit Yes to wipe the file, No to append to it,\n"
2285 "or Cancel to disable logging.";
2286 char message[sizeof(msgtemplate) + FILENAME_MAX];
2288 sprintf(message, msgtemplate, FILENAME_MAX, filename);
2290 mbret = MessageBox(NULL, message, mbtitle,
2291 MB_ICONQUESTION | MB_YESNOCANCEL);
2294 else if (mbret == IDNO)