+ of.hwndOwner = hwnd;
+ of.lpstrFilter = "PuTTY Private Key Files (*.ppk)\0*.PPK\0"
+ "AllFiles\0*\0\0\0";
+ of.lpstrCustomFilter = NULL;
+ of.nFilterIndex = 1;
+ of.lpstrFile = filename;
+ strcpy(filename, cfg.keyfile);
+ of.nMaxFile = sizeof(filename);
+ of.lpstrFileTitle = NULL;
+ of.lpstrInitialDir = NULL;
+ of.lpstrTitle = "Select Private Key File";
+ of.Flags = 0;
+ if (GetOpenFileName(&of)) {
+ strcpy(cfg.keyfile, filename);
+ SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
+ }
+ break;
+ case IDC_RAWCNP:
+ cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
+ break;
+ case IDC_RTFPASTE:
+ cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
+ break;
+ case IDC_MBWINDOWS:
+ case IDC_MBXTERM:
+ cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
+ break;
+ case IDC_SELTYPELEX:
+ case IDC_SELTYPERECT:
+ cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
+ break;
+ case IDC_MOUSEOVERRIDE:
+ cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
+ break;
+ case IDC_CCSET:
+ {
+ BOOL ok;
+ int i;
+ int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
+
+ if (!ok)
+ MessageBeep(0);
+ else {
+ for (i = 0; i < 128; i++)
+ if (SendDlgItemMessage
+ (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
+ char str[100];
+ cfg.wordness[i] = n;
+ SendDlgItemMessage(hwnd, IDC_CCLIST,
+ LB_DELETESTRING, i, 0);
+ sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
+ (i >= 0x21 && i != 0x7F) ? i : ' ',
+ cfg.wordness[i]);
+ SendDlgItemMessage(hwnd, IDC_CCLIST,
+ LB_INSERTSTRING, i,
+ (LPARAM) str);
+ }
+ }
+ }
+ break;
+ case IDC_BOLDCOLOUR:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED) {
+ int n, i;
+ cfg.bold_colour =
+ IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
+ SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
+ FALSE, 0);
+ n =
+ SendDlgItemMessage(hwnd, IDC_COLOURLIST,
+ LB_GETCOUNT, 0, 0);
+ if (n != 12 + 10 * cfg.bold_colour) {
+ for (i = n; i-- > 0;)
+ SendDlgItemMessage(hwnd, IDC_COLOURLIST,
+ LB_DELETESTRING, i, 0);
+ for (i = 0; i < 22; i++)
+ if (cfg.bold_colour || permcolour[i])
+ SendDlgItemMessage(hwnd, IDC_COLOURLIST,
+ LB_ADDSTRING, 0,
+ (LPARAM) colours[i]);
+ }
+ SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
+ TRUE, 0);
+ InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
+ TRUE);
+ }
+ break;
+ case IDC_PALETTE:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED)
+ cfg.try_palette =
+ IsDlgButtonChecked(hwnd, IDC_PALETTE);
+ break;
+ case IDC_COLOURLIST:
+ if (HIWORD(wParam) == LBN_DBLCLK ||
+ HIWORD(wParam) == LBN_SELCHANGE) {
+ int i =
+ SendDlgItemMessage(hwnd, IDC_COLOURLIST,
+ LB_GETCURSEL,
+ 0, 0);
+ if (!cfg.bold_colour)
+ i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
+ SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
+ FALSE);
+ SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
+ FALSE);
+ SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
+ FALSE);
+ }
+ break;
+ case IDC_CHANGE:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED) {
+ static CHOOSECOLOR cc;
+ static DWORD custom[16] = { 0 }; /* zero initialisers */
+ int i =
+ SendDlgItemMessage(hwnd, IDC_COLOURLIST,
+ LB_GETCURSEL,
+ 0, 0);
+ if (!cfg.bold_colour)
+ i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
+ cc.lStructSize = sizeof(cc);
+ cc.hwndOwner = hwnd;
+ cc.hInstance = (HWND) hinst;
+ cc.lpCustColors = custom;
+ cc.rgbResult =
+ RGB(cfg.colours[i][0], cfg.colours[i][1],
+ cfg.colours[i][2]);
+ cc.Flags = CC_FULLOPEN | CC_RGBINIT;
+ if (ChooseColor(&cc)) {
+ cfg.colours[i][0] =
+ (unsigned char) (cc.rgbResult & 0xFF);
+ cfg.colours[i][1] =
+ (unsigned char) (cc.rgbResult >> 8) & 0xFF;
+ cfg.colours[i][2] =
+ (unsigned char) (cc.rgbResult >> 16) & 0xFF;
+ SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
+ FALSE);
+ SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
+ FALSE);
+ SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
+ FALSE);
+ }
+ }
+ break;
+ case IDC_CODEPAGE:
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
+ CB_GETCURSEL, 0, 0);
+ SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
+ index, (LPARAM)cfg.line_codepage);
+ } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
+ GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
+ sizeof(cfg.line_codepage) - 1);
+ } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
+ strcpy(cfg.line_codepage,
+ cp_name(decode_codepage(cfg.line_codepage)));
+ SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
+ }
+ break;
+ case IDC_PRINTER:
+ if (HIWORD(wParam) == CBN_SELCHANGE) {
+ int index = SendDlgItemMessage(hwnd, IDC_PRINTER,
+ CB_GETCURSEL, 0, 0);
+ SendDlgItemMessage(hwnd, IDC_PRINTER, CB_GETLBTEXT,
+ index, (LPARAM)cfg.printer);
+ } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
+ GetDlgItemText(hwnd, IDC_PRINTER, cfg.printer,
+ sizeof(cfg.printer) - 1);
+ }
+ if (!strcmp(cfg.printer, PRINTER_DISABLED_STRING))
+ *cfg.printer = '\0';
+ break;
+ case IDC_CAPSLOCKCYR:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED) {
+ cfg.xlat_capslockcyr =
+ IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
+ }
+ break;
+ case IDC_VTXWINDOWS:
+ case IDC_VTOEMANSI:
+ case IDC_VTOEMONLY:
+ case IDC_VTPOORMAN:
+ case IDC_VTUNICODE:
+ cfg.vtmode =
+ (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
+ : IsDlgButtonChecked(hwnd,
+ IDC_VTOEMANSI) ? VT_OEMANSI :
+ IsDlgButtonChecked(hwnd,
+ IDC_VTOEMONLY) ? VT_OEMONLY :
+ IsDlgButtonChecked(hwnd,
+ IDC_VTUNICODE) ? VT_UNICODE :
+ VT_POORMAN);
+ break;
+ case IDC_X11_FORWARD:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED)
+ cfg.x11_forward =
+ IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
+ break;
+ case IDC_LPORT_ALL:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED)
+ cfg.lport_acceptall =
+ IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
+ break;
+ case IDC_RPORT_ALL:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED)
+ cfg.rport_acceptall =
+ IsDlgButtonChecked(hwnd, IDC_RPORT_ALL);
+ break;
+ case IDC_X11_DISPLAY:
+ if (HIWORD(wParam) == EN_CHANGE)
+ GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
+ sizeof(cfg.x11_display) - 1);
+ break;
+ case IDC_X11MIT:
+ case IDC_X11XDM:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED) {
+ if (IsDlgButtonChecked(hwnd, IDC_X11MIT))
+ cfg.x11_auth = X11_MIT;
+ else if (IsDlgButtonChecked(hwnd, IDC_X11XDM))
+ cfg.x11_auth = X11_XDM;
+ }
+ break;
+ case IDC_PFWDADD:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED) {
+ char str[sizeof(cfg.portfwd)];
+ char *p;
+ if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
+ str[0] = 'L';
+ else
+ str[0] = 'R';
+ GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
+ sizeof(str) - 2);
+ if (!str[1]) {
+ MessageBox(hwnd,
+ "You need to specify a source port number",
+ "PuTTY Error", MB_OK | MB_ICONERROR);
+ break;
+ }
+ p = str + strlen(str);
+ *p++ = '\t';
+ GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
+ sizeof(str) - 1 - (p - str));
+ if (!*p || !strchr(p, ':')) {
+ MessageBox(hwnd,
+ "You need to specify a destination address\n"
+ "in the form \"host.name:port\"",
+ "PuTTY Error", MB_OK | MB_ICONERROR);
+ break;
+ }
+ p = cfg.portfwd;
+ while (*p) {
+ while (*p)
+ p++;
+ p++;
+ }
+ if ((p - cfg.portfwd) + strlen(str) + 2 <
+ sizeof(cfg.portfwd)) {
+ strcpy(p, str);
+ p[strlen(str) + 1] = '\0';
+ SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
+ 0, (LPARAM) str);
+ SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
+ SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
+ } else {
+ MessageBox(hwnd, "Too many forwardings",
+ "PuTTY Error", MB_OK | MB_ICONERROR);
+ }
+ }
+ break;
+ case IDC_PFWDREMOVE:
+ if (HIWORD(wParam) != BN_CLICKED &&
+ HIWORD(wParam) != BN_DOUBLECLICKED) break;
+ i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
+ LB_GETCURSEL, 0, 0);
+ if (i == LB_ERR)
+ MessageBeep(0);