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,
337 appearancepanelstart,
338 IDC_TITLE_APPEARANCE,
356 connectionpanelstart,
357 IDC_TITLE_CONNECTION,
455 translationpanelstart,
456 IDC_TITLE_TRANSLATION,
457 IDC_BOX_TRANSLATION1,
458 IDC_BOX_TRANSLATION2,
459 IDC_BOX_TRANSLATION3,
484 static const char *const colours[] = {
485 "Default Foreground", "Default Bold Foreground",
486 "Default Background", "Default Bold Background",
487 "Cursor Text", "Cursor Colour",
488 "ANSI Black", "ANSI Black Bold",
489 "ANSI Red", "ANSI Red Bold",
490 "ANSI Green", "ANSI Green Bold",
491 "ANSI Yellow", "ANSI Yellow Bold",
492 "ANSI Blue", "ANSI Blue Bold",
493 "ANSI Magenta", "ANSI Magenta Bold",
494 "ANSI Cyan", "ANSI Cyan Bold",
495 "ANSI White", "ANSI White Bold"
497 static const int permcolour[] = {
498 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
499 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
500 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
503 static void fmtfont (char *buf) {
504 sprintf (buf, "Font: %s, ", cfg.font);
506 strcat(buf, "bold, ");
507 if (cfg.fontheight == 0)
508 strcat (buf, "default height");
510 sprintf (buf+strlen(buf), "%d-point",
511 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
514 static void init_dlg_ctrls(HWND hwnd) {
516 char fontstatic[256];
518 SetDlgItemText (hwnd, IDC_HOST, cfg.host);
519 SetDlgItemText (hwnd, IDC_SESSEDIT, savedsession);
522 n = SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
524 SendDlgItemMessage (hwnd, IDC_SESSLIST,
525 LB_DELETESTRING, i, 0);
526 for (i = 0; i < nsessions; i++)
527 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_ADDSTRING,
528 0, (LPARAM) (sessions[i]));
530 SetDlgItemInt (hwnd, IDC_PORT, cfg.port, FALSE);
531 CheckRadioButton (hwnd, IDC_PROTRAW, IDC_PROTSSH,
532 cfg.protocol==PROT_SSH ? IDC_PROTSSH :
533 cfg.protocol==PROT_TELNET ? IDC_PROTTELNET :
534 cfg.protocol==PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW );
535 SetDlgItemInt (hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
537 CheckRadioButton (hwnd, IDC_DEL008, IDC_DEL127,
538 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
539 CheckRadioButton (hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
540 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
541 CheckRadioButton (hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
542 cfg.funky_type == 0 ? IDC_FUNCTILDE :
543 cfg.funky_type == 1 ? IDC_FUNCLINUX :
544 cfg.funky_type == 2 ? IDC_FUNCXTERM :
545 cfg.funky_type == 3 ? IDC_FUNCVT400 :
546 cfg.funky_type == 4 ? IDC_FUNCVT100P :
547 cfg.funky_type == 5 ? IDC_FUNCSCO :
549 CheckDlgButton (hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
550 CheckDlgButton (hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
551 CheckRadioButton (hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
552 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
553 CheckRadioButton (hwnd, IDC_KPNORMAL, IDC_KPNH,
554 cfg.nethack_keypad ? IDC_KPNH :
555 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
556 CheckDlgButton (hwnd, IDC_ALTF4, cfg.alt_f4);
557 CheckDlgButton (hwnd, IDC_ALTSPACE, cfg.alt_space);
558 CheckDlgButton (hwnd, IDC_ALTONLY, cfg.alt_only);
559 CheckDlgButton (hwnd, IDC_COMPOSEKEY, cfg.compose_key);
560 CheckDlgButton (hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
561 CheckRadioButton (hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
562 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND:
563 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
564 CheckRadioButton (hwnd, IDC_EDITBACKEND, IDC_EDITNO,
565 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND:
566 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
567 SetDlgItemText (hwnd, IDC_ANSWEREDIT, cfg.answerback);
568 CheckDlgButton (hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
569 CheckDlgButton (hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
570 CheckDlgButton (hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
572 CheckDlgButton (hwnd, IDC_WRAPMODE, cfg.wrap_mode);
573 CheckDlgButton (hwnd, IDC_DECOM, cfg.dec_om);
574 CheckDlgButton (hwnd, IDC_LFHASCR, cfg.lfhascr);
575 SetDlgItemInt (hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
576 SetDlgItemInt (hwnd, IDC_COLSEDIT, cfg.width, FALSE);
577 SetDlgItemInt (hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
578 fmtfont (fontstatic);
579 SetDlgItemText (hwnd, IDC_FONTSTATIC, fontstatic);
580 CheckRadioButton (hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
581 cfg.beep==BELL_DISABLED ? IDC_BELL_DISABLED :
582 cfg.beep==BELL_DEFAULT ? IDC_BELL_DEFAULT :
583 cfg.beep==BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
584 cfg.beep==BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
585 SetDlgItemText (hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
586 CheckDlgButton (hwnd, IDC_BELLOVL, cfg.bellovl);
587 SetDlgItemInt (hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
588 SetDlgItemInt (hwnd, IDC_BELLOVLT, cfg.bellovl_t, FALSE);
589 SetDlgItemInt (hwnd, IDC_BELLOVLS, cfg.bellovl_s, FALSE);
591 CheckDlgButton (hwnd, IDC_BCE, cfg.bce);
592 CheckDlgButton (hwnd, IDC_BLINKTEXT, cfg.blinktext);
594 SetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle);
595 CheckDlgButton (hwnd, IDC_WINNAME, cfg.win_name_always);
596 CheckDlgButton (hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
597 CheckRadioButton (hwnd, IDC_CURBLOCK, IDC_CURVERT,
598 cfg.cursor_type==0 ? IDC_CURBLOCK :
599 cfg.cursor_type==1 ? IDC_CURUNDER : IDC_CURVERT);
600 CheckDlgButton (hwnd, IDC_BLINKCUR, cfg.blink_cur);
601 CheckDlgButton (hwnd, IDC_SCROLLBAR, cfg.scrollbar);
602 CheckDlgButton (hwnd, IDC_LOCKSIZE, cfg.locksize);
603 CheckRadioButton (hwnd, IDC_COEALWAYS, IDC_COENORMAL,
604 cfg.close_on_exit==COE_NORMAL ? IDC_COENORMAL :
605 cfg.close_on_exit==COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
606 CheckDlgButton (hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
608 SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype);
609 SetDlgItemText (hwnd, IDC_TSEDIT, cfg.termspeed);
610 SetDlgItemText (hwnd, IDC_R_TSEDIT, cfg.termspeed);
611 SetDlgItemText (hwnd, IDC_RLLUSEREDIT, cfg.localusername);
612 SetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username);
613 SetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename);
614 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATRAW,
615 cfg.logtype == 0 ? IDC_LSTATOFF :
616 cfg.logtype == 1 ? IDC_LSTATASCII :
618 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
619 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
620 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
623 char *p = cfg.environmt;
625 SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
630 CheckRadioButton (hwnd, IDC_EMBSD, IDC_EMRFC,
631 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
633 SetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype);
634 SetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username);
635 CheckDlgButton (hwnd, IDC_NOPTY, cfg.nopty);
636 CheckDlgButton (hwnd, IDC_COMPRESS, cfg.compression);
637 CheckDlgButton (hwnd, IDC_BUGGYMAC, cfg.buggymac);
638 CheckDlgButton (hwnd, IDC_AGENTFWD, cfg.agentfwd);
639 CheckRadioButton (hwnd, IDC_CIPHER3DES, IDC_CIPHERAES,
640 cfg.cipher == CIPHER_BLOWFISH ? IDC_CIPHERBLOWF :
641 cfg.cipher == CIPHER_DES ? IDC_CIPHERDES :
642 cfg.cipher == CIPHER_AES ? IDC_CIPHERAES :
644 CheckRadioButton (hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
645 cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
646 CheckDlgButton (hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
647 SetDlgItemText (hwnd, IDC_PKEDIT, cfg.keyfile);
648 SetDlgItemText (hwnd, IDC_CMDEDIT, cfg.remote_cmd);
650 CheckRadioButton (hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
651 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
652 CheckDlgButton (hwnd, IDC_RAWCNP, cfg.rawcnp);
654 static int tabs[4] = {25, 61, 96, 128};
655 SendDlgItemMessage (hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
658 for (i=0; i<256; i++) {
660 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
661 (i>=0x21 && i != 0x7F) ? i : ' ',
663 SendDlgItemMessage (hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
667 CheckDlgButton (hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
668 CheckDlgButton (hwnd, IDC_PALETTE, cfg.try_palette);
671 n = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
673 SendDlgItemMessage (hwnd, IDC_COLOURLIST,
674 LB_DELETESTRING, i, 0);
676 if (cfg.bold_colour || permcolour[i])
677 SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
678 (LPARAM) colours[i]);
680 SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
681 SetDlgItemInt (hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
682 SetDlgItemInt (hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
683 SetDlgItemInt (hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
685 CheckRadioButton (hwnd, IDC_NOXLAT, IDC_88592CP852,
686 cfg.xlat_88592w1250 ? IDC_88592WIN1250 :
687 cfg.xlat_88592cp852 ? IDC_88592CP852 :
688 cfg.xlat_enablekoiwin ? IDC_KOI8WIN1251 :
690 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
691 CheckRadioButton (hwnd, IDC_VTXWINDOWS, IDC_VTPOORMAN,
692 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
693 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
694 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
697 CheckDlgButton (hwnd, IDC_X11_FORWARD, cfg.x11_forward);
698 SetDlgItemText (hwnd, IDC_X11_DISPLAY, cfg.x11_display);
701 struct treeview_faff {
706 static HTREEITEM treeview_insert(struct treeview_faff *faff,
707 int level, char *text) {
711 ins.hParent = (level > 0 ? faff->lastat[level-1] : TVI_ROOT);
712 ins.hInsertAfter = faff->lastat[level];
713 #if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
714 #define INSITEM DUMMYUNIONNAME.item
718 ins.INSITEM.mask = TVIF_TEXT;
719 ins.INSITEM.pszText = text;
720 newitem = TreeView_InsertItem(faff->treeview, &ins);
722 TreeView_Expand(faff->treeview, faff->lastat[level-1], TVE_EXPAND);
723 faff->lastat[level] = newitem;
724 for (i = level+1; i < 4; i++) faff->lastat[i] = NULL;
729 * Create the panelfuls of controls in the configuration box.
731 static void create_controls(HWND hwnd, int dlgtype, int panel) {
732 if (panel == sessionpanelstart) {
733 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
735 ctlposinit(&cp, hwnd, 80, 3, 13);
736 bartitle(&cp, "Basic options for your PuTTY session",
739 beginbox(&cp, "Specify your connection by host name",
742 "Host &Name", IDC_HOSTSTATIC, IDC_HOST, 75,
743 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
744 if (backends[3].backend == NULL) {
745 /* this is PuTTYtel, so only three protocols available */
746 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
748 "&Telnet", IDC_PROTTELNET,
749 "Rlog&in", IDC_PROTRLOGIN, NULL);
751 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
753 "&Telnet", IDC_PROTTELNET,
754 "Rlog&in", IDC_PROTRLOGIN,
763 beginbox(&cp, "Load, save or delete a stored session",
765 sesssaver(&cp, "Sav&ed Sessions",
766 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
767 "&Load", IDC_SESSLOAD,
768 "&Save", IDC_SESSSAVE,
769 "&Delete", IDC_SESSDEL, NULL);
772 beginbox(&cp, NULL, IDC_BOX_SESSION3);
773 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
774 "Always", IDC_COEALWAYS,
775 "Never", IDC_COENEVER,
776 "Only on clean exit", IDC_COENORMAL, NULL);
780 if (panel == loggingpanelstart) {
781 /* The Logging panel. Accelerators used: [acgo] tplfwes */
783 ctlposinit(&cp, hwnd, 80, 3, 13);
784 bartitle(&cp, "Options controlling session logging",
786 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
788 "Session logging:", IDC_LSTATSTATIC,
789 "Logging &turned off completely", IDC_LSTATOFF,
790 "Log &printable output only", IDC_LSTATASCII,
791 "&Log all session output", IDC_LSTATRAW, NULL);
792 editbutton(&cp, "Log &file name:",
793 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
796 "What to do if the log file already &exists:", IDC_LSTATXIST,
797 "Always overwrite it", IDC_LSTATXOVR,
798 "Always append to the end of it", IDC_LSTATXAPN,
799 "Ask the user every time", IDC_LSTATXASK, NULL);
803 if (panel == terminalpanelstart) {
804 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
806 ctlposinit(&cp, hwnd, 80, 3, 13);
807 bartitle(&cp, "Options controlling the terminal emulation",
809 beginbox(&cp, "Set various terminal options",
811 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
812 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
813 checkbox(&cp, "Implicit CR in every &LF", IDC_LFHASCR);
814 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
815 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
817 "An&swerback to ^E:", IDC_ANSWERBACK,
818 IDC_ANSWEREDIT, 100, NULL);
821 beginbox(&cp, "Line discipline options",
823 radioline(&cp, "Local ec&ho:", IDC_ECHOSTATIC, 3,
824 "Auto", IDC_ECHOBACKEND,
825 "Force on", IDC_ECHOYES,
826 "Force off", IDC_ECHONO, NULL);
827 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
828 "Auto", IDC_EDITBACKEND,
829 "Force on", IDC_EDITYES,
830 "Force off", IDC_EDITNO, NULL);
834 if (panel == bellpanelstart) {
835 /* The Bell panel. Accelerators used: [acgo] bdsm wt */
837 ctlposinit(&cp, hwnd, 80, 3, 13);
838 bartitle(&cp, "Options controlling the terminal bell",
840 beginbox(&cp, "Set the style of bell",
843 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
844 "None (bell disabled)", IDC_BELL_DISABLED,
845 "Play Windows Default Sound", IDC_BELL_DEFAULT,
846 "Play a custom sound file", IDC_BELL_WAVEFILE,
847 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
848 editbutton(&cp, "Custom sound file to play as a bell:",
849 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
850 "Bro&wse...", IDC_BELL_WAVEBROWSE);
852 beginbox(&cp, "Control the bell overload behaviour",
854 checkbox(&cp, "Bell is temporarily &disabled when over-used",
856 staticedit(&cp, "Over-use means this &many bells...",
857 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
858 staticedit(&cp, "... in &this many seconds",
859 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
860 statictext(&cp, "The bell is re-enabled after a few seconds of silence.",
862 staticedit(&cp, "Seconds of &silence required",
863 IDC_BELLOVLSSTATIC, IDC_BELLOVLS, 20);
867 if (panel == keyboardpanelstart) {
868 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
870 ctlposinit(&cp, hwnd, 80, 3, 13);
872 bartitle(&cp, "Options controlling the effects of keys",
875 beginbox(&cp, "Change the sequences sent by:",
877 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
878 "Control-H", IDC_DEL008,
879 "Control-? (127)", IDC_DEL127, NULL);
880 radioline(&cp, "The &Home and End keys", IDC_HOMESTATIC, 2,
881 "Standard", IDC_HOMETILDE,
882 "rxvt", IDC_HOMERXVT, NULL);
883 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
884 "ESC[n~", IDC_FUNCTILDE,
885 "Linux", IDC_FUNCLINUX,
886 "Xterm R6", IDC_FUNCXTERM,
887 "VT400", IDC_FUNCVT400,
888 "VT100+", IDC_FUNCVT100P,
889 "SCO", IDC_FUNCSCO, NULL);
891 beginbox(&cp, "Application keypad settings:",
894 "Application c&ursor keys totally disabled",
896 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
897 "Normal", IDC_CURNORMAL,
898 "Application", IDC_CURAPPLIC, NULL);
900 "Application ke&ypad keys totally disabled",
902 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC, 3,
903 "Normal", IDC_KPNORMAL,
904 "Application", IDC_KPAPPLIC,
905 "NetHack", IDC_KPNH, NULL);
907 beginbox(&cp, "Enable extra keyboard features:",
909 checkbox(&cp, "AltGr ac&ts as Compose key",
911 checkbox(&cp, "Control-Alt is &different from AltGr",
916 if (panel == windowpanelstart) {
917 /* The Window panel. Accelerators used: [acgo] rmz sdkp w4ylt */
919 ctlposinit(&cp, hwnd, 80, 3, 13);
920 bartitle(&cp, "Options controlling PuTTY's window",
922 beginbox(&cp, "Set the size of the window",
925 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
926 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50,
928 checkbox(&cp, "Lock window size against resi&zing", IDC_LOCKSIZE);
930 beginbox(&cp, "Control the scrollback in the window",
932 staticedit(&cp, "Lines of &scrollback",
933 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
934 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
935 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
936 checkbox(&cp, "Reset scrollback on dis&play activity",
939 beginbox(&cp, NULL, IDC_BOX_WINDOW3);
940 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
941 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
942 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
943 checkbox(&cp, "System menu appears on A< alone", IDC_ALTONLY);
944 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
948 if (panel == appearancepanelstart) {
949 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p */
951 ctlposinit(&cp, hwnd, 80, 3, 13);
952 bartitle(&cp, "Options controlling PuTTY's appearance",
953 IDC_TITLE_APPEARANCE);
954 beginbox(&cp, "Adjust the use of the cursor",
955 IDC_BOX_APPEARANCE1);
956 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
957 "B&lock", IDC_CURBLOCK,
958 "&Underline", IDC_CURUNDER,
959 "&Vertical line", IDC_CURVERT,
961 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
963 beginbox(&cp, "Set the font used in the terminal window",
964 IDC_BOX_APPEARANCE2);
965 staticbtn(&cp, "", IDC_FONTSTATIC, "C&hange...", IDC_CHOOSEFONT);
967 beginbox(&cp, "Adjust the use of the window title",
968 IDC_BOX_APPEARANCE3);
970 "Window &title:", IDC_WINTITLE,
971 IDC_WINEDIT, 100, NULL);
972 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
974 beginbox(&cp, "Adjust the use of the mouse pointer",
975 IDC_BOX_APPEARANCE4);
976 checkbox(&cp, "Hide mouse &pointer when typing in window",
981 if (panel == translationpanelstart) {
982 /* The Translation panel. Accelerators used: [acgo] xbep t s */
984 ctlposinit(&cp, hwnd, 80, 3, 13);
985 bartitle(&cp, "Options controlling character set translation",
986 IDC_TITLE_TRANSLATION);
987 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
988 IDC_BOX_TRANSLATION1);
990 "Handling of line drawing characters:", IDC_VTSTATIC,
991 "Font has &XWindows encoding", IDC_VTXWINDOWS,
992 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
993 "Use font in O&EM mode only", IDC_VTOEMONLY,
994 "&Poor man's line drawing (""+"", ""-"" and ""|"")",
995 IDC_VTPOORMAN, NULL);
997 beginbox(&cp, "Enable character set translation on received data",
998 IDC_BOX_TRANSLATION2);
1000 "Character set &translation:", IDC_XLATSTATIC,
1002 "KOI8 / Win-1251", IDC_KOI8WIN1251,
1003 "ISO-8859-2 / Win-1250", IDC_88592WIN1250,
1004 "ISO-8859-2 / CP852", IDC_88592CP852, NULL);
1006 beginbox(&cp, "Enable character set translation on input data",
1007 IDC_BOX_TRANSLATION3);
1008 checkbox(&cp, "CAP&S LOCK acts as cyrillic switch",
1013 if (panel == selectionpanelstart) {
1014 /* The Selection panel. Accelerators used: [acgo] d wx hst */
1016 ctlposinit(&cp, hwnd, 80, 3, 13);
1017 bartitle(&cp, "Options controlling copy and paste",
1018 IDC_TITLE_SELECTION);
1019 beginbox(&cp, "Translation of pasted characters",
1020 IDC_BOX_SELECTION1);
1021 checkbox(&cp, "&Don't translate line drawing chars into +, - and |",
1024 beginbox(&cp, "Control which mouse button does which thing",
1025 IDC_BOX_SELECTION2);
1026 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1027 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1028 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1031 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1032 IDC_BOX_SELECTION3);
1033 charclass(&cp, "C&haracter classes:", IDC_CCSTATIC, IDC_CCLIST,
1034 "&Set", IDC_CCSET, IDC_CCEDIT,
1035 "&to class", IDC_CCSTATIC2);
1039 if (panel == colourspanelstart) {
1040 /* The Colours panel. Accelerators used: [acgo] blum */
1042 ctlposinit(&cp, hwnd, 80, 3, 13);
1043 bartitle(&cp, "Options controlling use of colours",
1045 beginbox(&cp, "General options for colour usage",
1047 checkbox(&cp, "&Bolded text is a different colour", IDC_BOLDCOLOUR);
1048 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1050 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1052 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1053 IDC_COLOURSTATIC, IDC_COLOURLIST,
1054 "&Modify...", IDC_CHANGE,
1055 "Red:", IDC_RSTATIC, IDC_RVALUE,
1056 "Green:", IDC_GSTATIC, IDC_GVALUE,
1057 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1061 if (panel == connectionpanelstart) {
1062 /* The Connection panel. Accelerators used: [acgo] tuk */
1064 ctlposinit(&cp, hwnd, 80, 3, 13);
1065 bartitle(&cp, "Options controlling the connection", IDC_TITLE_CONNECTION);
1067 beginbox(&cp, "Data to send to the server",
1068 IDC_BOX_CONNECTION1);
1069 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC, IDC_TTEDIT, 50);
1070 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC, IDC_LOGEDIT, 50);
1073 beginbox(&cp, "Sending of null packets to keep session active",
1074 IDC_BOX_CONNECTION2);
1075 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1076 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1080 if (panel == telnetpanelstart) {
1081 /* The Telnet panel. Accelerators used: [acgo] svldr bf */
1083 ctlposinit(&cp, hwnd, 80, 3, 13);
1085 bartitle(&cp, "Options controlling Telnet connections", IDC_TITLE_TELNET);
1086 beginbox(&cp, "Data to send to the server",
1088 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC, IDC_TSEDIT, 50);
1089 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1090 "&Variable", IDC_VARSTATIC, IDC_VAREDIT,
1091 "Va&lue", IDC_VALSTATIC, IDC_VALEDIT,
1093 "A&dd", IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1095 beginbox(&cp, "Telnet protocol adjustments",
1097 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:", IDC_EMSTATIC, 2,
1098 "&BSD (commonplace)", IDC_EMBSD,
1099 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
1104 if (panel == rloginpanelstart) {
1105 /* The Rlogin panel. Accelerators used: [acgo] sl */
1107 ctlposinit(&cp, hwnd, 80, 3, 13);
1109 bartitle(&cp, "Options controlling Rlogin connections", IDC_TITLE_RLOGIN);
1110 beginbox(&cp, "Data to send to the server",
1112 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC, IDC_R_TSEDIT, 50);
1113 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC, IDC_RLLUSEREDIT, 50);
1118 if (panel == sshpanelstart) {
1119 /* The SSH panel. Accelerators used: [acgo] rmfkw pe123bds i */
1121 ctlposinit(&cp, hwnd, 80, 3, 13);
1123 bartitle(&cp, "Options controlling SSH connections", IDC_TITLE_SSH);
1124 beginbox(&cp, "Data to send to the server",
1127 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1130 beginbox(&cp, "Authentication options",
1132 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication",
1134 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
1135 editbutton(&cp, "Private &key file for authentication:",
1136 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...", IDC_PKBUTTON);
1138 beginbox(&cp, "Protocol options",
1140 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1141 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1142 radioline(&cp, "Preferred SSH protocol version:",
1143 IDC_SSHPROTSTATIC, 2,
1144 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL);
1145 radioline(&cp, "Preferred encryption algorithm:", IDC_CIPHERSTATIC, 4,
1146 "&3DES", IDC_CIPHER3DES,
1147 "&Blowfish", IDC_CIPHERBLOWF,
1148 "&DES", IDC_CIPHERDES,
1149 "AE&S", IDC_CIPHERAES,
1151 checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1157 if (panel == tunnelspanelstart) {
1158 /* The Tunnels panel. Accelerators used: [acgo] ex */
1160 ctlposinit(&cp, hwnd, 80, 3, 13);
1162 bartitle(&cp, "Options controlling SSH tunnelling",
1164 beginbox(&cp, "X11 forwarding options",
1166 checkbox(&cp, "&Enable X11 forwarding",
1168 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
1169 IDC_X11_DISPLAY, 50, NULL);
1176 * This function is the configuration box.
1178 static int GenericMainDlgProc (HWND hwnd, UINT msg,
1179 WPARAM wParam, LPARAM lParam,
1182 struct treeview_faff tvfaff;
1185 char filename[sizeof(cfg.keyfile)];
1188 char fontstatic[256];
1190 struct servent * service;
1196 SetWindowLong(hwnd, GWL_USERDATA, 0);
1198 * Centre the window.
1200 { /* centre the window */
1203 hw = GetDesktopWindow();
1204 if (GetWindowRect (hw, &rs) && GetWindowRect (hwnd, &rd))
1205 MoveWindow (hwnd, (rs.right + rs.left + rd.left - rd.right)/2,
1206 (rs.bottom + rs.top + rd.top - rd.bottom)/2,
1207 rd.right-rd.left, rd.bottom-rd.top, TRUE);
1211 * Create the tree view.
1218 r.left = 3; r.right = r.left + 75;
1219 r.top = 3; r.bottom = r.top + 10;
1220 MapDialogRect(hwnd, &r);
1221 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
1222 WS_CHILD | WS_VISIBLE,
1224 r.right-r.left, r.bottom-r.top,
1225 hwnd, (HMENU)IDCX_TVSTATIC, hinst, NULL);
1226 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1227 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1229 r.left = 3; r.right = r.left + 75;
1230 r.top = 13; r.bottom = r.top + 206;
1231 MapDialogRect(hwnd, &r);
1232 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
1233 WS_CHILD | WS_VISIBLE |
1234 WS_TABSTOP | TVS_HASLINES |
1235 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS |
1236 TVS_LINESATROOT | TVS_SHOWSELALWAYS,
1238 r.right-r.left, r.bottom-r.top,
1239 hwnd, (HMENU)IDCX_TREEVIEW, hinst, NULL);
1240 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1241 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1242 tvfaff.treeview = treeview;
1243 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
1247 * Set up the tree view contents.
1249 hsession = treeview_insert(&tvfaff, 0, "Session");
1250 treeview_insert(&tvfaff, 1, "Logging");
1251 treeview_insert(&tvfaff, 0, "Terminal");
1252 treeview_insert(&tvfaff, 1, "Keyboard");
1253 treeview_insert(&tvfaff, 1, "Bell");
1254 treeview_insert(&tvfaff, 0, "Window");
1255 treeview_insert(&tvfaff, 1, "Appearance");
1256 treeview_insert(&tvfaff, 1, "Translation");
1257 treeview_insert(&tvfaff, 1, "Selection");
1258 treeview_insert(&tvfaff, 1, "Colours");
1259 treeview_insert(&tvfaff, 0, "Connection");
1261 treeview_insert(&tvfaff, 1, "Telnet");
1262 treeview_insert(&tvfaff, 1, "Rlogin");
1263 if (backends[3].backend != NULL) {
1264 treeview_insert(&tvfaff, 1, "SSH");
1265 treeview_insert(&tvfaff, 2, "Tunnels");
1270 * Put the treeview selection on to the Session panel. This
1271 * should also cause creation of the relevant controls.
1273 TreeView_SelectItem(treeview, hsession);
1276 * Set focus into the first available control.
1280 ctl = GetDlgItem(hwnd, IDC_HOST);
1281 if (!ctl) ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
1285 SetWindowLong(hwnd, GWL_USERDATA, 1);
1289 * Button release should trigger WM_OK if there was a
1290 * previous double click on the session list.
1294 SendMessage (hwnd, WM_COMMAND, IDOK, 0);
1297 if (LOWORD(wParam) == IDCX_TREEVIEW &&
1298 ((LPNMHDR)lParam)->code == TVN_SELCHANGED) {
1299 HTREEITEM i = TreeView_GetSelection(((LPNMHDR)lParam)->hwndFrom);
1304 item.pszText = buffer;
1305 item.cchTextMax = sizeof(buffer);
1306 item.mask = TVIF_TEXT;
1307 TreeView_GetItem(((LPNMHDR)lParam)->hwndFrom, &item);
1308 for (j = controlstartvalue; j < controlendvalue; j++) {
1309 HWND item = GetDlgItem(hwnd, j);
1311 DestroyWindow(item);
1313 if (!strcmp(buffer, "Session"))
1314 create_controls(hwnd, dlgtype, sessionpanelstart);
1315 if (!strcmp(buffer, "Logging"))
1316 create_controls(hwnd, dlgtype, loggingpanelstart);
1317 if (!strcmp(buffer, "Keyboard"))
1318 create_controls(hwnd, dlgtype, keyboardpanelstart);
1319 if (!strcmp(buffer, "Terminal"))
1320 create_controls(hwnd, dlgtype, terminalpanelstart);
1321 if (!strcmp(buffer, "Bell"))
1322 create_controls(hwnd, dlgtype, bellpanelstart);
1323 if (!strcmp(buffer, "Window"))
1324 create_controls(hwnd, dlgtype, windowpanelstart);
1325 if (!strcmp(buffer, "Appearance"))
1326 create_controls(hwnd, dlgtype, appearancepanelstart);
1327 if (!strcmp(buffer, "Tunnels"))
1328 create_controls(hwnd, dlgtype, tunnelspanelstart);
1329 if (!strcmp(buffer, "Connection"))
1330 create_controls(hwnd, dlgtype, connectionpanelstart);
1331 if (!strcmp(buffer, "Telnet"))
1332 create_controls(hwnd, dlgtype, telnetpanelstart);
1333 if (!strcmp(buffer, "Rlogin"))
1334 create_controls(hwnd, dlgtype, rloginpanelstart);
1335 if (!strcmp(buffer, "SSH"))
1336 create_controls(hwnd, dlgtype, sshpanelstart);
1337 if (!strcmp(buffer, "Selection"))
1338 create_controls(hwnd, dlgtype, selectionpanelstart);
1339 if (!strcmp(buffer, "Colours"))
1340 create_controls(hwnd, dlgtype, colourspanelstart);
1341 if (!strcmp(buffer, "Translation"))
1342 create_controls(hwnd, dlgtype, translationpanelstart);
1344 init_dlg_ctrls(hwnd);
1346 SetFocus (((LPNMHDR)lParam)->hwndFrom); /* ensure focus stays */
1352 * Only process WM_COMMAND once the dialog is fully formed.
1354 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
1357 EndDialog (hwnd, 1);
1362 EndDialog (hwnd, 0);
1364 case IDC_PROTTELNET:
1365 case IDC_PROTRLOGIN:
1368 if (HIWORD(wParam) == BN_CLICKED ||
1369 HIWORD(wParam) == BN_DOUBLECLICKED) {
1370 int i = IsDlgButtonChecked (hwnd, IDC_PROTSSH);
1371 int j = IsDlgButtonChecked (hwnd, IDC_PROTTELNET);
1372 int k = IsDlgButtonChecked (hwnd, IDC_PROTRLOGIN);
1373 cfg.protocol = i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN : PROT_RAW ;
1374 if ((cfg.protocol == PROT_SSH && cfg.port != 22) ||
1375 (cfg.protocol == PROT_TELNET && cfg.port != 23) ||
1376 (cfg.protocol == PROT_RLOGIN && cfg.port != 513)) {
1377 cfg.port = i ? 22 : j ? 23 : 513;
1378 SetDlgItemInt (hwnd, IDC_PORT, cfg.port, FALSE);
1383 if (HIWORD(wParam) == EN_CHANGE)
1384 GetDlgItemText (hwnd, IDC_HOST, cfg.host,
1385 sizeof(cfg.host)-1);
1388 if (HIWORD(wParam) == EN_CHANGE) {
1389 GetDlgItemText (hwnd, IDC_PORT, portname, 31);
1390 if (isdigit(portname[0]))
1391 MyGetDlgItemInt (hwnd, IDC_PORT, &cfg.port);
1393 service = getservbyname(portname, NULL);
1394 if (service) cfg.port = ntohs(service->s_port);
1400 if (HIWORD(wParam) == EN_CHANGE) {
1401 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_SETCURSEL,
1403 GetDlgItemText (hwnd, IDC_SESSEDIT,
1404 savedsession, sizeof(savedsession)-1);
1405 savedsession[sizeof(savedsession)-1] = '\0';
1409 if (HIWORD(wParam) == BN_CLICKED ||
1410 HIWORD(wParam) == BN_DOUBLECLICKED) {
1415 GetDlgItemText (hwnd, IDC_SESSEDIT, str, sizeof(str)-1);
1417 int n = SendDlgItemMessage (hwnd, IDC_SESSLIST,
1418 LB_GETCURSEL, 0, 0);
1423 strcpy (str, sessions[n]);
1425 save_settings (str, !!strcmp(str, "Default Settings"), &cfg);
1426 get_sesslist (FALSE);
1427 get_sesslist (TRUE);
1428 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_RESETCONTENT,
1430 for (i = 0; i < nsessions; i++)
1431 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_ADDSTRING,
1432 0, (LPARAM) (sessions[i]));
1433 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_SETCURSEL,
1439 if (LOWORD(wParam) == IDC_SESSLOAD &&
1440 HIWORD(wParam) != BN_CLICKED &&
1441 HIWORD(wParam) != BN_DOUBLECLICKED)
1443 if (LOWORD(wParam) == IDC_SESSLIST &&
1444 HIWORD(wParam) != LBN_DBLCLK)
1447 int n = SendDlgItemMessage (hwnd, IDC_SESSLIST,
1448 LB_GETCURSEL, 0, 0);
1454 isdef = !strcmp(sessions[n], "Default Settings");
1455 load_settings (sessions[n], !isdef, &cfg);
1456 init_dlg_ctrls(hwnd);
1458 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
1460 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
1462 if (LOWORD(wParam) == IDC_SESSLIST) {
1464 * A double-click on a saved session should
1465 * actually start the session, not just load it.
1466 * Unless it's Default Settings or some other
1467 * host-less set of saved settings.
1476 if (HIWORD(wParam) == BN_CLICKED ||
1477 HIWORD(wParam) == BN_DOUBLECLICKED) {
1478 int n = SendDlgItemMessage (hwnd, IDC_SESSLIST,
1479 LB_GETCURSEL, 0, 0);
1480 if (n == LB_ERR || n == 0) {
1484 del_settings(sessions[n]);
1485 get_sesslist (FALSE);
1486 get_sesslist (TRUE);
1487 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_RESETCONTENT,
1489 for (i = 0; i < nsessions; i++)
1490 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_ADDSTRING,
1491 0, (LPARAM) (sessions[i]));
1492 SendDlgItemMessage (hwnd, IDC_SESSLIST, LB_SETCURSEL,
1496 if (HIWORD(wParam) == EN_CHANGE)
1497 MyGetDlgItemInt (hwnd, IDC_PINGEDIT, &cfg.ping_interval);
1501 if (HIWORD(wParam) == BN_CLICKED ||
1502 HIWORD(wParam) == BN_DOUBLECLICKED)
1503 cfg.bksp_is_delete = IsDlgButtonChecked (hwnd, IDC_DEL127);
1507 if (HIWORD(wParam) == BN_CLICKED ||
1508 HIWORD(wParam) == BN_DOUBLECLICKED)
1509 cfg.rxvt_homeend = IsDlgButtonChecked (hwnd, IDC_HOMERXVT);
1515 case IDC_FUNCVT100P:
1517 if (HIWORD(wParam) == BN_CLICKED ||
1518 HIWORD(wParam) == BN_DOUBLECLICKED)
1519 switch (LOWORD(wParam)) {
1520 case IDC_FUNCTILDE: cfg.funky_type = 0; break;
1521 case IDC_FUNCLINUX: cfg.funky_type = 1; break;
1522 case IDC_FUNCXTERM: cfg.funky_type = 2; break;
1523 case IDC_FUNCVT400: cfg.funky_type = 3; break;
1524 case IDC_FUNCVT100P: cfg.funky_type = 4; break;
1525 case IDC_FUNCSCO: cfg.funky_type = 5; break;
1530 if (HIWORD(wParam) == BN_CLICKED ||
1531 HIWORD(wParam) == BN_DOUBLECLICKED) {
1532 cfg.app_keypad = IsDlgButtonChecked (hwnd, IDC_KPAPPLIC);
1533 cfg.nethack_keypad = FALSE;
1537 if (HIWORD(wParam) == BN_CLICKED ||
1538 HIWORD(wParam) == BN_DOUBLECLICKED) {
1539 cfg.app_keypad = FALSE;
1540 cfg.nethack_keypad = TRUE;
1545 if (HIWORD(wParam) == BN_CLICKED ||
1546 HIWORD(wParam) == BN_DOUBLECLICKED)
1547 cfg.app_cursor = IsDlgButtonChecked (hwnd, IDC_CURAPPLIC);
1550 if (HIWORD(wParam) == BN_CLICKED ||
1551 HIWORD(wParam) == BN_DOUBLECLICKED)
1552 cfg.no_applic_c = IsDlgButtonChecked (hwnd, IDC_NOAPPLICC);
1555 if (HIWORD(wParam) == BN_CLICKED ||
1556 HIWORD(wParam) == BN_DOUBLECLICKED)
1557 cfg.no_applic_k = IsDlgButtonChecked (hwnd, IDC_NOAPPLICK);
1560 if (HIWORD(wParam) == BN_CLICKED ||
1561 HIWORD(wParam) == BN_DOUBLECLICKED)
1562 cfg.alt_f4 = IsDlgButtonChecked (hwnd, IDC_ALTF4);
1565 if (HIWORD(wParam) == BN_CLICKED ||
1566 HIWORD(wParam) == BN_DOUBLECLICKED)
1567 cfg.alt_space = IsDlgButtonChecked (hwnd, IDC_ALTSPACE);
1570 if (HIWORD(wParam) == BN_CLICKED ||
1571 HIWORD(wParam) == BN_DOUBLECLICKED)
1572 cfg.alt_only = IsDlgButtonChecked (hwnd, IDC_ALTONLY);
1574 case IDC_ECHOBACKEND:
1577 if (HIWORD(wParam) == BN_CLICKED ||
1578 HIWORD(wParam) == BN_DOUBLECLICKED) {
1579 if (LOWORD(wParam)==IDC_ECHOBACKEND) cfg.localecho=LD_BACKEND;
1580 if (LOWORD(wParam)==IDC_ECHOYES) cfg.localecho=LD_YES;
1581 if (LOWORD(wParam)==IDC_ECHONO) cfg.localecho=LD_NO;
1584 case IDC_EDITBACKEND:
1587 if (HIWORD(wParam) == BN_CLICKED ||
1588 HIWORD(wParam) == BN_DOUBLECLICKED) {
1589 if (LOWORD(wParam)==IDC_EDITBACKEND) cfg.localedit=LD_BACKEND;
1590 if (LOWORD(wParam)==IDC_EDITYES) cfg.localedit=LD_YES;
1591 if (LOWORD(wParam)==IDC_EDITNO) cfg.localedit=LD_NO;
1594 case IDC_ANSWEREDIT:
1595 if (HIWORD(wParam) == EN_CHANGE)
1596 GetDlgItemText (hwnd, IDC_ANSWEREDIT, cfg.answerback,
1597 sizeof(cfg.answerback)-1);
1599 case IDC_ALWAYSONTOP:
1600 if (HIWORD(wParam) == BN_CLICKED ||
1601 HIWORD(wParam) == BN_DOUBLECLICKED)
1602 cfg.alwaysontop = IsDlgButtonChecked (hwnd, IDC_ALWAYSONTOP);
1605 if (HIWORD(wParam) == BN_CLICKED ||
1606 HIWORD(wParam) == BN_DOUBLECLICKED)
1607 cfg.scroll_on_key = IsDlgButtonChecked (hwnd, IDC_SCROLLKEY);
1609 case IDC_SCROLLDISP:
1610 if (HIWORD(wParam) == BN_CLICKED ||
1611 HIWORD(wParam) == BN_DOUBLECLICKED)
1612 cfg.scroll_on_disp = IsDlgButtonChecked (hwnd, IDC_SCROLLDISP);
1614 case IDC_COMPOSEKEY:
1615 if (HIWORD(wParam) == BN_CLICKED ||
1616 HIWORD(wParam) == BN_DOUBLECLICKED)
1617 cfg.compose_key = IsDlgButtonChecked (hwnd, IDC_COMPOSEKEY);
1619 case IDC_CTRLALTKEYS:
1620 if (HIWORD(wParam) == BN_CLICKED ||
1621 HIWORD(wParam) == BN_DOUBLECLICKED)
1622 cfg.ctrlaltkeys = IsDlgButtonChecked (hwnd, IDC_CTRLALTKEYS);
1625 if (HIWORD(wParam) == BN_CLICKED ||
1626 HIWORD(wParam) == BN_DOUBLECLICKED)
1627 cfg.wrap_mode = IsDlgButtonChecked (hwnd, IDC_WRAPMODE);
1630 if (HIWORD(wParam) == BN_CLICKED ||
1631 HIWORD(wParam) == BN_DOUBLECLICKED)
1632 cfg.dec_om = IsDlgButtonChecked (hwnd, IDC_DECOM);
1635 if (HIWORD(wParam) == BN_CLICKED ||
1636 HIWORD(wParam) == BN_DOUBLECLICKED)
1637 cfg.lfhascr = IsDlgButtonChecked (hwnd, IDC_LFHASCR);
1640 if (HIWORD(wParam) == EN_CHANGE)
1641 MyGetDlgItemInt (hwnd, IDC_ROWSEDIT, &cfg.height);
1644 if (HIWORD(wParam) == EN_CHANGE)
1645 MyGetDlgItemInt (hwnd, IDC_COLSEDIT, &cfg.width);
1648 if (HIWORD(wParam) == EN_CHANGE)
1649 MyGetDlgItemInt (hwnd, IDC_SAVEEDIT, &cfg.savelines);
1651 case IDC_CHOOSEFONT:
1652 lf.lfHeight = cfg.fontheight;
1653 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
1654 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
1655 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
1656 lf.lfCharSet = cfg.fontcharset;
1657 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
1658 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
1659 lf.lfQuality = DEFAULT_QUALITY;
1660 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
1661 strncpy (lf.lfFaceName, cfg.font, sizeof(lf.lfFaceName)-1);
1662 lf.lfFaceName[sizeof(lf.lfFaceName)-1] = '\0';
1664 cf.lStructSize = sizeof(cf);
1665 cf.hwndOwner = hwnd;
1667 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
1668 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
1670 if (ChooseFont (&cf)) {
1671 strncpy (cfg.font, lf.lfFaceName, sizeof(cfg.font)-1);
1672 cfg.font[sizeof(cfg.font)-1] = '\0';
1673 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
1674 cfg.fontcharset = lf.lfCharSet;
1675 cfg.fontheight = cf.iPointSize / 10;
1676 fmtfont (fontstatic);
1677 SetDlgItemText (hwnd, IDC_FONTSTATIC, fontstatic);
1680 case IDC_BELL_DISABLED:
1681 case IDC_BELL_DEFAULT:
1682 case IDC_BELL_WAVEFILE:
1683 case IDC_BELL_VISUAL:
1684 if (HIWORD(wParam) == BN_CLICKED ||
1685 HIWORD(wParam) == BN_DOUBLECLICKED) {
1686 if (LOWORD(wParam)==IDC_BELL_DISABLED) cfg.beep = BELL_DISABLED;
1687 if (LOWORD(wParam)==IDC_BELL_DEFAULT) cfg.beep = BELL_DEFAULT;
1688 if (LOWORD(wParam)==IDC_BELL_WAVEFILE) cfg.beep = BELL_WAVEFILE;
1689 if (LOWORD(wParam)==IDC_BELL_VISUAL) cfg.beep = BELL_VISUAL;
1692 case IDC_BELL_WAVEBROWSE:
1693 memset(&of, 0, sizeof(of));
1694 #ifdef OPENFILENAME_SIZE_VERSION_400
1695 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
1697 of.lStructSize = sizeof(of);
1699 of.hwndOwner = hwnd;
1700 of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
1701 of.lpstrCustomFilter = NULL;
1702 of.nFilterIndex = 1;
1703 of.lpstrFile = filename; strcpy(filename, cfg.bell_wavefile);
1704 of.nMaxFile = sizeof(filename);
1705 of.lpstrFileTitle = NULL;
1706 of.lpstrInitialDir = NULL;
1707 of.lpstrTitle = "Select Bell Sound File";
1709 if (GetOpenFileName(&of)) {
1710 strcpy(cfg.bell_wavefile, filename);
1711 SetDlgItemText (hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
1714 case IDC_BELL_WAVEEDIT:
1715 if (HIWORD(wParam) == EN_CHANGE)
1716 GetDlgItemText (hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile,
1717 sizeof(cfg.bell_wavefile)-1);
1720 if (HIWORD(wParam) == BN_CLICKED ||
1721 HIWORD(wParam) == BN_DOUBLECLICKED)
1722 cfg.bellovl = IsDlgButtonChecked (hwnd, IDC_BELLOVL);
1725 if (HIWORD(wParam) == EN_CHANGE)
1726 MyGetDlgItemInt (hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
1729 if (HIWORD(wParam) == EN_CHANGE)
1730 MyGetDlgItemInt (hwnd, IDC_BELLOVLT, &cfg.bellovl_t);
1733 if (HIWORD(wParam) == EN_CHANGE)
1734 MyGetDlgItemInt (hwnd, IDC_BELLOVLS, &cfg.bellovl_s);
1737 if (HIWORD(wParam) == BN_CLICKED ||
1738 HIWORD(wParam) == BN_DOUBLECLICKED)
1739 cfg.blinktext = IsDlgButtonChecked (hwnd, IDC_BLINKTEXT);
1742 if (HIWORD(wParam) == BN_CLICKED ||
1743 HIWORD(wParam) == BN_DOUBLECLICKED)
1744 cfg.bce = IsDlgButtonChecked (hwnd, IDC_BCE);
1747 if (HIWORD(wParam) == BN_CLICKED ||
1748 HIWORD(wParam) == BN_DOUBLECLICKED)
1749 cfg.win_name_always = IsDlgButtonChecked (hwnd, IDC_WINNAME);
1752 if (HIWORD(wParam) == BN_CLICKED ||
1753 HIWORD(wParam) == BN_DOUBLECLICKED)
1754 cfg.hide_mouseptr = IsDlgButtonChecked (hwnd, IDC_HIDEMOUSE);
1757 if (HIWORD(wParam) == BN_CLICKED ||
1758 HIWORD(wParam) == BN_DOUBLECLICKED)
1759 cfg.cursor_type = 0;
1762 if (HIWORD(wParam) == BN_CLICKED ||
1763 HIWORD(wParam) == BN_DOUBLECLICKED)
1764 cfg.cursor_type = 1;
1767 if (HIWORD(wParam) == BN_CLICKED ||
1768 HIWORD(wParam) == BN_DOUBLECLICKED)
1769 cfg.cursor_type = 2;
1772 if (HIWORD(wParam) == BN_CLICKED ||
1773 HIWORD(wParam) == BN_DOUBLECLICKED)
1774 cfg.blink_cur = IsDlgButtonChecked (hwnd, IDC_BLINKCUR);
1777 if (HIWORD(wParam) == BN_CLICKED ||
1778 HIWORD(wParam) == BN_DOUBLECLICKED)
1779 cfg.scrollbar = IsDlgButtonChecked (hwnd, IDC_SCROLLBAR);
1782 if (HIWORD(wParam) == BN_CLICKED ||
1783 HIWORD(wParam) == BN_DOUBLECLICKED)
1784 cfg.locksize = IsDlgButtonChecked (hwnd, IDC_LOCKSIZE);
1787 if (HIWORD(wParam) == EN_CHANGE)
1788 GetDlgItemText (hwnd, IDC_WINEDIT, cfg.wintitle,
1789 sizeof(cfg.wintitle)-1);
1794 if (HIWORD(wParam) == BN_CLICKED ||
1795 HIWORD(wParam) == BN_DOUBLECLICKED) {
1796 cfg.close_on_exit = IsDlgButtonChecked (hwnd, IDC_COEALWAYS) ? COE_ALWAYS :
1797 IsDlgButtonChecked (hwnd, IDC_COENEVER) ? COE_NEVER :
1802 if (HIWORD(wParam) == BN_CLICKED ||
1803 HIWORD(wParam) == BN_DOUBLECLICKED)
1804 cfg.warn_on_close = IsDlgButtonChecked (hwnd, IDC_CLOSEWARN);
1807 if (HIWORD(wParam) == EN_CHANGE)
1808 GetDlgItemText (hwnd, IDC_TTEDIT, cfg.termtype,
1809 sizeof(cfg.termtype)-1);
1812 if (HIWORD(wParam) == EN_CHANGE)
1813 GetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename,
1814 sizeof(cfg.logfilename)-1);
1817 memset(&of, 0, sizeof(of));
1818 #ifdef OPENFILENAME_SIZE_VERSION_400
1819 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
1821 of.lStructSize = sizeof(of);
1823 of.hwndOwner = hwnd;
1824 of.lpstrFilter = "All Files\0*\0\0\0";
1825 of.lpstrCustomFilter = NULL;
1826 of.nFilterIndex = 1;
1827 of.lpstrFile = filename; strcpy(filename, cfg.logfilename);
1828 of.nMaxFile = sizeof(filename);
1829 of.lpstrFileTitle = NULL;
1830 of.lpstrInitialDir = NULL;
1831 of.lpstrTitle = "Select session log file";
1833 if (GetSaveFileName(&of)) {
1834 strcpy(cfg.logfilename, filename);
1835 SetDlgItemText (hwnd, IDC_LGFEDIT, cfg.logfilename);
1839 case IDC_LSTATASCII:
1841 if (HIWORD(wParam) == BN_CLICKED ||
1842 HIWORD(wParam) == BN_DOUBLECLICKED) {
1843 if (IsDlgButtonChecked (hwnd, IDC_LSTATOFF)) cfg.logtype = 0;
1844 if (IsDlgButtonChecked (hwnd, IDC_LSTATASCII)) cfg.logtype = 1;
1845 if (IsDlgButtonChecked (hwnd, IDC_LSTATRAW)) cfg.logtype = 2;
1851 if (HIWORD(wParam) == BN_CLICKED ||
1852 HIWORD(wParam) == BN_DOUBLECLICKED) {
1853 if (IsDlgButtonChecked (hwnd, IDC_LSTATXASK)) cfg.logxfovr = LGXF_ASK;
1854 if (IsDlgButtonChecked (hwnd, IDC_LSTATXAPN)) cfg.logxfovr = LGXF_APN;
1855 if (IsDlgButtonChecked (hwnd, IDC_LSTATXOVR)) cfg.logxfovr = LGXF_OVR;
1860 if (HIWORD(wParam) == EN_CHANGE)
1861 GetDlgItemText (hwnd, LOWORD(wParam), cfg.termspeed,
1862 sizeof(cfg.termspeed)-1);
1865 if (HIWORD(wParam) == EN_CHANGE)
1866 GetDlgItemText (hwnd, IDC_LOGEDIT, cfg.username,
1867 sizeof(cfg.username)-1);
1869 case IDC_RLLUSEREDIT:
1870 if (HIWORD(wParam) == EN_CHANGE)
1871 GetDlgItemText (hwnd, IDC_RLLUSEREDIT, cfg.localusername,
1872 sizeof(cfg.localusername)-1);
1876 cfg.rfc_environ = IsDlgButtonChecked (hwnd, IDC_EMRFC);
1879 if (HIWORD(wParam) == BN_CLICKED ||
1880 HIWORD(wParam) == BN_DOUBLECLICKED) {
1881 char str[sizeof(cfg.environmt)];
1883 GetDlgItemText (hwnd, IDC_VAREDIT, str, sizeof(str)-1);
1888 p = str + strlen(str);
1890 GetDlgItemText (hwnd, IDC_VALEDIT, p, sizeof(str)-1-(p-str));
1900 if ((p-cfg.environmt) + strlen(str) + 2 < sizeof(cfg.environmt)) {
1902 p[strlen(str)+1] = '\0';
1903 SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_ADDSTRING,
1905 SetDlgItemText (hwnd, IDC_VAREDIT, "");
1906 SetDlgItemText (hwnd, IDC_VALEDIT, "");
1908 MessageBox(hwnd, "Environment too big", "PuTTY Error",
1909 MB_OK | MB_ICONERROR);
1914 if (HIWORD(wParam) != BN_CLICKED &&
1915 HIWORD(wParam) != BN_DOUBLECLICKED)
1917 i = SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_GETCURSEL, 0, 0);
1923 SendDlgItemMessage (hwnd, IDC_ENVLIST, LB_DELETESTRING,
1948 if (HIWORD(wParam) == BN_CLICKED ||
1949 HIWORD(wParam) == BN_DOUBLECLICKED)
1950 cfg.nopty = IsDlgButtonChecked (hwnd, IDC_NOPTY);
1953 if (HIWORD(wParam) == BN_CLICKED ||
1954 HIWORD(wParam) == BN_DOUBLECLICKED)
1955 cfg.compression = IsDlgButtonChecked (hwnd, IDC_COMPRESS);
1958 if (HIWORD(wParam) == BN_CLICKED ||
1959 HIWORD(wParam) == BN_DOUBLECLICKED)
1960 cfg.buggymac = IsDlgButtonChecked (hwnd, IDC_BUGGYMAC);
1963 if (HIWORD(wParam) == BN_CLICKED ||
1964 HIWORD(wParam) == BN_DOUBLECLICKED)
1965 cfg.agentfwd = IsDlgButtonChecked (hwnd, IDC_AGENTFWD);
1967 case IDC_CIPHER3DES:
1968 case IDC_CIPHERBLOWF:
1971 if (HIWORD(wParam) == BN_CLICKED ||
1972 HIWORD(wParam) == BN_DOUBLECLICKED) {
1973 if (IsDlgButtonChecked (hwnd, IDC_CIPHER3DES))
1974 cfg.cipher = CIPHER_3DES;
1975 else if (IsDlgButtonChecked (hwnd, IDC_CIPHERBLOWF))
1976 cfg.cipher = CIPHER_BLOWFISH;
1977 else if (IsDlgButtonChecked (hwnd, IDC_CIPHERDES))
1978 cfg.cipher = CIPHER_DES;
1979 else if (IsDlgButtonChecked (hwnd, IDC_CIPHERAES))
1980 cfg.cipher = CIPHER_AES;
1985 if (HIWORD(wParam) == BN_CLICKED ||
1986 HIWORD(wParam) == BN_DOUBLECLICKED) {
1987 if (IsDlgButtonChecked (hwnd, IDC_SSHPROT1))
1989 else if (IsDlgButtonChecked (hwnd, IDC_SSHPROT2))
1994 if (HIWORD(wParam) == BN_CLICKED ||
1995 HIWORD(wParam) == BN_DOUBLECLICKED)
1996 cfg.try_tis_auth = IsDlgButtonChecked (hwnd, IDC_AUTHTIS);
1999 if (HIWORD(wParam) == EN_CHANGE)
2000 GetDlgItemText (hwnd, IDC_PKEDIT, cfg.keyfile,
2001 sizeof(cfg.keyfile)-1);
2004 if (HIWORD(wParam) == EN_CHANGE)
2005 GetDlgItemText (hwnd, IDC_CMDEDIT, cfg.remote_cmd,
2006 sizeof(cfg.remote_cmd)-1);
2009 memset(&of, 0, sizeof(of));
2010 #ifdef OPENFILENAME_SIZE_VERSION_400
2011 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
2013 of.lStructSize = sizeof(of);
2015 of.hwndOwner = hwnd;
2016 of.lpstrFilter = "All Files\0*\0\0\0";
2017 of.lpstrCustomFilter = NULL;
2018 of.nFilterIndex = 1;
2019 of.lpstrFile = filename; strcpy(filename, cfg.keyfile);
2020 of.nMaxFile = sizeof(filename);
2021 of.lpstrFileTitle = NULL;
2022 of.lpstrInitialDir = NULL;
2023 of.lpstrTitle = "Select Public Key File";
2025 if (GetOpenFileName(&of)) {
2026 strcpy(cfg.keyfile, filename);
2027 SetDlgItemText (hwnd, IDC_PKEDIT, cfg.keyfile);
2031 cfg.rawcnp = IsDlgButtonChecked (hwnd, IDC_RAWCNP);
2034 cfg.mouse_is_xterm = IsDlgButtonChecked (hwnd, IDC_MBXTERM);
2040 int n = GetDlgItemInt (hwnd, IDC_CCEDIT, &ok, FALSE);
2045 for (i=0; i<256; i++)
2046 if (SendDlgItemMessage (hwnd, IDC_CCLIST, LB_GETSEL,
2049 cfg.wordness[i] = n;
2050 SendDlgItemMessage (hwnd, IDC_CCLIST,
2051 LB_DELETESTRING, i, 0);
2052 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
2053 (i>=0x21 && i != 0x7F) ? i : ' ',
2055 SendDlgItemMessage (hwnd, IDC_CCLIST,
2062 case IDC_BOLDCOLOUR:
2063 if (HIWORD(wParam) == BN_CLICKED ||
2064 HIWORD(wParam) == BN_DOUBLECLICKED) {
2066 cfg.bold_colour = IsDlgButtonChecked (hwnd, IDC_BOLDCOLOUR);
2067 n = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
2068 if (n != 12+10*cfg.bold_colour) {
2070 SendDlgItemMessage (hwnd, IDC_COLOURLIST,
2071 LB_DELETESTRING, i, 0);
2072 for (i=0; i<22; i++)
2073 if (cfg.bold_colour || permcolour[i])
2074 SendDlgItemMessage (hwnd, IDC_COLOURLIST,
2076 (LPARAM) colours[i]);
2081 if (HIWORD(wParam) == BN_CLICKED ||
2082 HIWORD(wParam) == BN_DOUBLECLICKED)
2083 cfg.try_palette = IsDlgButtonChecked (hwnd, IDC_PALETTE);
2085 case IDC_COLOURLIST:
2086 if (HIWORD(wParam) == LBN_DBLCLK ||
2087 HIWORD(wParam) == LBN_SELCHANGE) {
2088 int i = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCURSEL,
2090 if (!cfg.bold_colour)
2091 i = (i < 3 ? i*2 : i == 3 ? 5 : i*2-2);
2092 SetDlgItemInt (hwnd, IDC_RVALUE, cfg.colours[i][0], FALSE);
2093 SetDlgItemInt (hwnd, IDC_GVALUE, cfg.colours[i][1], FALSE);
2094 SetDlgItemInt (hwnd, IDC_BVALUE, cfg.colours[i][2], FALSE);
2098 if (HIWORD(wParam) == BN_CLICKED ||
2099 HIWORD(wParam) == BN_DOUBLECLICKED) {
2100 static CHOOSECOLOR cc;
2101 static DWORD custom[16] = {0}; /* zero initialisers */
2102 int i = SendDlgItemMessage (hwnd, IDC_COLOURLIST, LB_GETCURSEL,
2104 if (!cfg.bold_colour)
2105 i = (i < 3 ? i*2 : i == 3 ? 5 : i*2-2);
2106 cc.lStructSize = sizeof(cc);
2107 cc.hwndOwner = hwnd;
2108 cc.hInstance = (HWND)hinst;
2109 cc.lpCustColors = custom;
2110 cc.rgbResult = RGB (cfg.colours[i][0], cfg.colours[i][1],
2112 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
2113 if (ChooseColor(&cc)) {
2115 (unsigned char) (cc.rgbResult & 0xFF);
2117 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
2119 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
2120 SetDlgItemInt (hwnd, IDC_RVALUE, cfg.colours[i][0],
2122 SetDlgItemInt (hwnd, IDC_GVALUE, cfg.colours[i][1],
2124 SetDlgItemInt (hwnd, IDC_BVALUE, cfg.colours[i][2],
2130 case IDC_KOI8WIN1251:
2131 case IDC_88592WIN1250:
2132 case IDC_88592CP852:
2133 cfg.xlat_enablekoiwin =
2134 IsDlgButtonChecked (hwnd, IDC_KOI8WIN1251);
2135 cfg.xlat_88592w1250 =
2136 IsDlgButtonChecked (hwnd, IDC_88592WIN1250);
2137 cfg.xlat_88592cp852 =
2138 IsDlgButtonChecked (hwnd, IDC_88592CP852);
2140 case IDC_CAPSLOCKCYR:
2141 if (HIWORD(wParam) == BN_CLICKED ||
2142 HIWORD(wParam) == BN_DOUBLECLICKED) {
2143 cfg.xlat_capslockcyr =
2144 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
2147 case IDC_VTXWINDOWS:
2152 (IsDlgButtonChecked (hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS :
2153 IsDlgButtonChecked (hwnd, IDC_VTOEMANSI) ? VT_OEMANSI :
2154 IsDlgButtonChecked (hwnd, IDC_VTOEMONLY) ? VT_OEMONLY :
2157 case IDC_X11_FORWARD:
2158 if (HIWORD(wParam) == BN_CLICKED ||
2159 HIWORD(wParam) == BN_DOUBLECLICKED)
2160 cfg.x11_forward = IsDlgButtonChecked (hwnd, IDC_X11_FORWARD);
2162 case IDC_X11_DISPLAY:
2163 if (HIWORD(wParam) == EN_CHANGE)
2164 GetDlgItemText (hwnd, IDC_X11_DISPLAY, cfg.x11_display,
2165 sizeof(cfg.x11_display)-1);
2170 EndDialog (hwnd, 0);
2173 /* Grrr Explorer will maximize Dialogs! */
2175 if (wParam == SIZE_MAXIMIZED)
2182 static int CALLBACK MainDlgProc (HWND hwnd, UINT msg,
2183 WPARAM wParam, LPARAM lParam) {
2184 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
2186 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
2187 EnableWindow(hwnd, 0);
2188 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
2189 GetParent(hwnd), AboutProc);
2190 EnableWindow(hwnd, 1);
2191 SetActiveWindow(hwnd);
2193 return GenericMainDlgProc (hwnd, msg, wParam, lParam, 0);
2196 static int CALLBACK ReconfDlgProc (HWND hwnd, UINT msg,
2197 WPARAM wParam, LPARAM lParam) {
2198 return GenericMainDlgProc (hwnd, msg, wParam, lParam, 1);
2201 void defuse_showwindow(void) {
2203 * Work around the fact that the app's first call to ShowWindow
2204 * will ignore the default in favour of the shell-provided
2209 hwnd = CreateDialog (hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
2211 ShowWindow(hwnd, SW_HIDE);
2212 DestroyWindow(hwnd);
2216 int do_config (void) {
2220 savedsession[0] = '\0';
2221 ret = DialogBox (hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
2222 get_sesslist(FALSE);
2227 int do_reconfig (HWND hwnd) {
2231 backup_cfg = cfg; /* structure copy */
2232 ret = DialogBox (hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
2234 cfg = backup_cfg; /* structure copy */
2239 void logevent (char *string) {
2243 if (nevents >= negsize) {
2245 events = srealloc (events, negsize * sizeof(*events));
2249 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t", localtime(&t));
2251 events[nevents] = smalloc(strlen(timebuf)+strlen(string)+1);
2252 strcpy(events[nevents], timebuf);
2253 strcat(events[nevents], string);
2256 SendDlgItemMessage (logbox, IDN_LIST, LB_ADDSTRING,
2257 0, (LPARAM)events[nevents]);
2258 count = SendDlgItemMessage (logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
2259 SendDlgItemMessage (logbox, IDN_LIST, LB_SETTOPINDEX, count-1, 0);
2264 void showeventlog (HWND hwnd) {
2266 logbox = CreateDialog (hinst, MAKEINTRESOURCE(IDD_LOGBOX),
2268 ShowWindow (logbox, SW_SHOWNORMAL);
2270 SetActiveWindow(logbox);
2273 void showabout (HWND hwnd) {
2274 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),hwnd, AboutProc);
2277 void verify_ssh_host_key(char *host, int port, char *keytype,
2278 char *keystr, char *fingerprint) {
2281 static const char absentmsg[] =
2282 "The server's host key is not cached in the registry. You\n"
2283 "have no guarantee that the server is the computer you\n"
2285 "The server's key fingerprint is:\n"
2287 "If you trust this host, hit Yes to add the key to\n"
2288 "PuTTY's cache and carry on connecting.\n"
2289 "If you do not trust this host, hit No to abandon the\n"
2292 static const char wrongmsg[] =
2293 "WARNING - POTENTIAL SECURITY BREACH!\n"
2295 "The server's host key does not match the one PuTTY has\n"
2296 "cached in the registry. This means that either the\n"
2297 "server administrator has changed the host key, or you\n"
2298 "have actually connected to another computer pretending\n"
2299 "to be the server.\n"
2300 "The new key fingerprint is:\n"
2302 "If you were expecting this change and trust the new key,\n"
2303 "hit Yes to update PuTTY's cache and continue connecting.\n"
2304 "If you want to carry on connecting but without updating\n"
2305 "the cache, hit No.\n"
2306 "If you want to abandon the connection completely, hit\n"
2307 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n"
2310 static const char mbtitle[] = "PuTTY Security Alert";
2313 char message[160+ /* sensible fingerprint max size */
2314 (sizeof(absentmsg) > sizeof(wrongmsg) ?
2315 sizeof(absentmsg) : sizeof(wrongmsg))];
2318 * Verify the key against the registry.
2320 ret = verify_host_key(host, port, keytype, keystr);
2322 if (ret == 0) /* success - key matched OK */
2324 if (ret == 2) { /* key was different */
2326 sprintf(message, wrongmsg, fingerprint);
2327 mbret = MessageBox(NULL, message, mbtitle,
2328 MB_ICONWARNING | MB_YESNOCANCEL);
2330 store_host_key(host, port, keytype, keystr);
2331 if (mbret == IDCANCEL)
2334 if (ret == 1) { /* key was absent */
2336 sprintf(message, absentmsg, fingerprint);
2337 mbret = MessageBox(NULL, message, mbtitle,
2338 MB_ICONWARNING | MB_YESNO);
2341 store_host_key(host, port, keytype, keystr);
2346 * Ask whether to wipe a session log file before writing to it.
2347 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
2349 int askappend(char *filename) {
2350 static const char mbtitle[] = "PuTTY Log to File";
2351 static const char msgtemplate[] =
2352 "The session log file \"%.*s\" already exists.\n"
2353 "You can overwrite it with a new session log,\n"
2354 "append your session log to the end of it,\n"
2355 "or disable session logging for this session.\n"
2356 "Hit Yes to wipe the file, No to append to it,\n"
2357 "or Cancel to disable logging.";
2358 char message[sizeof(msgtemplate) + FILENAME_MAX];
2360 if ( cfg.logxfovr != LGXF_ASK ) {
2361 return ( (cfg.logxfovr==LGXF_OVR) ? 2 : 1);
2363 sprintf(message, msgtemplate, FILENAME_MAX, filename);
2365 mbret = MessageBox(NULL, message, mbtitle,
2366 MB_ICONQUESTION | MB_YESNOCANCEL);
2369 else if (mbret == IDNO)