Remove ghastly hack involving fxp_error_message.
[u/mdw/putty] / windlg.c
CommitLineData
374330e2 1#include <windows.h>
2#include <commctrl.h>
3#include <commdlg.h>
374330e2 4#include <stdio.h>
5#include <stdlib.h>
b6c680d4 6#include <ctype.h>
71346075 7#include <time.h>
374330e2 8
374330e2 9#include "ssh.h"
bea1ef5f 10#include "putty.h"
8c3cd914 11#include "winstuff.h"
374330e2 12#include "win_res.h"
d5859615 13#include "storage.h"
374330e2 14
c5e9c988 15static char **events = NULL;
16static int nevents = 0, negsize = 0;
17
1cd246bb 18static int readytogo;
c8d7378d 19static int sesslist_has_focus;
70133c0e 20static int requested_help;
1cd246bb 21
ca20bfcf 22static struct prefslist cipherlist;
23
3da0b1d2 24void force_normal(HWND hwnd)
c9def1b8 25{
a9422f39 26 static int recurse = 0;
c9def1b8 27
28 WINDOWPLACEMENT wp;
29
32874aea 30 if (recurse)
31 return;
c9def1b8 32 recurse = 1;
33
34 wp.length = sizeof(wp);
32874aea 35 if (GetWindowPlacement(hwnd, &wp) && wp.showCmd == SW_SHOWMAXIMIZED) {
c9def1b8 36 wp.showCmd = SW_SHOWNORMAL;
37 SetWindowPlacement(hwnd, &wp);
38 }
39 recurse = 0;
40}
41
32874aea 42static void MyGetDlgItemInt(HWND hwnd, int id, int *result)
43{
374330e2 44 BOOL ok;
45 int n;
32874aea 46 n = GetDlgItemInt(hwnd, id, &ok, FALSE);
374330e2 47 if (ok)
48 *result = n;
49}
50
32874aea 51static void MyGetDlgItemFlt(HWND hwnd, int id, int *result, int scale)
52{
7f4968e6 53 char text[80];
54 BOOL ok;
32874aea 55 ok = GetDlgItemText(hwnd, id, text, sizeof(text) - 1);
7f4968e6 56 if (ok && text[0])
57 *result = (int) (scale * atof(text));
58}
59
32874aea 60static void MySetDlgItemFlt(HWND hwnd, int id, double value)
61{
7f4968e6 62 char text[80];
63 sprintf(text, "%g", value);
32874aea 64 SetDlgItemText(hwnd, id, text);
7f4968e6 65}
66
32874aea 67static int CALLBACK LogProc(HWND hwnd, UINT msg,
68 WPARAM wParam, LPARAM lParam)
69{
374330e2 70 int i;
71
72 switch (msg) {
73 case WM_INITDIALOG:
32874aea 74 {
75 static int tabs[4] = { 78, 108 };
76 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETTABSTOPS, 2,
77 (LPARAM) tabs);
78 }
79 for (i = 0; i < nevents; i++)
80 SendDlgItemMessage(hwnd, IDN_LIST, LB_ADDSTRING,
81 0, (LPARAM) events[i]);
374330e2 82 return 1;
374330e2 83 case WM_COMMAND:
84 switch (LOWORD(wParam)) {
85 case IDOK:
475eebf9 86 case IDCANCEL:
374330e2 87 logbox = NULL;
32874aea 88 SetActiveWindow(GetParent(hwnd));
89 DestroyWindow(hwnd);
374330e2 90 return 0;
32874aea 91 case IDN_COPY:
989b10e9 92 if (HIWORD(wParam) == BN_CLICKED ||
93 HIWORD(wParam) == BN_DOUBLECLICKED) {
32874aea 94 int selcount;
95 int *selitems;
96 selcount = SendDlgItemMessage(hwnd, IDN_LIST,
97 LB_GETSELCOUNT, 0, 0);
98 if (selcount == 0) { /* don't even try to copy zero items */
99 MessageBeep(0);
100 break;
101 }
102
103 selitems = smalloc(selcount * sizeof(int));
104 if (selitems) {
105 int count = SendDlgItemMessage(hwnd, IDN_LIST,
106 LB_GETSELITEMS,
107 selcount,
108 (LPARAM) selitems);
109 int i;
110 int size;
111 char *clipdata;
112 static unsigned char sel_nl[] = SEL_NL;
113
114 if (count == 0) { /* can't copy zero stuff */
115 MessageBeep(0);
116 break;
117 }
118
119 size = 0;
120 for (i = 0; i < count; i++)
121 size +=
122 strlen(events[selitems[i]]) + sizeof(sel_nl);
123
124 clipdata = smalloc(size);
125 if (clipdata) {
126 char *p = clipdata;
127 for (i = 0; i < count; i++) {
128 char *q = events[selitems[i]];
129 int qlen = strlen(q);
130 memcpy(p, q, qlen);
131 p += qlen;
132 memcpy(p, sel_nl, sizeof(sel_nl));
133 p += sizeof(sel_nl);
134 }
4eeb7d09 135 write_aclip(clipdata, size, TRUE);
32874aea 136 sfree(clipdata);
137 }
138 sfree(selitems);
139
140 for (i = 0; i < nevents; i++)
141 SendDlgItemMessage(hwnd, IDN_LIST, LB_SETSEL,
142 FALSE, i);
143 }
144 }
145 return 0;
374330e2 146 }
147 return 0;
148 case WM_CLOSE:
149 logbox = NULL;
32874aea 150 SetActiveWindow(GetParent(hwnd));
151 DestroyWindow(hwnd);
374330e2 152 return 0;
153 }
154 return 0;
155}
156
32874aea 157static int CALLBACK LicenceProc(HWND hwnd, UINT msg,
158 WPARAM wParam, LPARAM lParam)
159{
d57835ab 160 switch (msg) {
161 case WM_INITDIALOG:
162 return 1;
163 case WM_COMMAND:
164 switch (LOWORD(wParam)) {
165 case IDOK:
97749503 166 EndDialog(hwnd, 1);
d57835ab 167 return 0;
168 }
169 return 0;
170 case WM_CLOSE:
97749503 171 EndDialog(hwnd, 1);
d57835ab 172 return 0;
173 }
174 return 0;
175}
176
32874aea 177static int CALLBACK AboutProc(HWND hwnd, UINT msg,
178 WPARAM wParam, LPARAM lParam)
179{
374330e2 180 switch (msg) {
181 case WM_INITDIALOG:
32874aea 182 SetDlgItemText(hwnd, IDA_VERSION, ver);
374330e2 183 return 1;
374330e2 184 case WM_COMMAND:
185 switch (LOWORD(wParam)) {
186 case IDOK:
32874aea 187 case IDCANCEL:
188 EndDialog(hwnd, TRUE);
374330e2 189 return 0;
190 case IDA_LICENCE:
191 EnableWindow(hwnd, 0);
32874aea 192 DialogBox(hinst, MAKEINTRESOURCE(IDD_LICENCEBOX),
193 NULL, LicenceProc);
374330e2 194 EnableWindow(hwnd, 1);
32874aea 195 SetActiveWindow(hwnd);
374330e2 196 return 0;
defab6b8 197
32874aea 198 case IDA_WEB:
199 /* Load web browser */
200 ShellExecute(hwnd, "open",
201 "http://www.chiark.greenend.org.uk/~sgtatham/putty/",
202 0, 0, SW_SHOWDEFAULT);
203 return 0;
374330e2 204 }
205 return 0;
206 case WM_CLOSE:
32874aea 207 EndDialog(hwnd, TRUE);
374330e2 208 return 0;
209 }
210 return 0;
211}
212
301b66db 213/*
214 * Null dialog procedure.
215 */
32874aea 216static int CALLBACK NullDlgProc(HWND hwnd, UINT msg,
217 WPARAM wParam, LPARAM lParam)
218{
301b66db 219 return 0;
220}
221
c96a8fef 222static char savedsession[2048];
223
32874aea 224enum { IDCX_ABOUT =
225 IDC_ABOUT, IDCX_TVSTATIC, IDCX_TREEVIEW, controlstartvalue,
927d4fc5 226
227 sessionpanelstart,
228 IDC_TITLE_SESSION,
3ac9cd9f 229 IDC_BOX_SESSION1,
230 IDC_BOX_SESSION2,
927d4fc5 231 IDC_BOX_SESSION3,
232 IDC_HOSTSTATIC,
233 IDC_HOST,
234 IDC_PORTSTATIC,
235 IDC_PORT,
236 IDC_PROTSTATIC,
237 IDC_PROTRAW,
238 IDC_PROTTELNET,
c91409da 239 IDC_PROTRLOGIN,
927d4fc5 240 IDC_PROTSSH,
241 IDC_SESSSTATIC,
242 IDC_SESSEDIT,
243 IDC_SESSLIST,
244 IDC_SESSLOAD,
245 IDC_SESSSAVE,
246 IDC_SESSDEL,
247 IDC_CLOSEEXIT,
b41069ff 248 IDC_COEALWAYS,
b41069ff 249 IDC_COENEVER,
1cd48051 250 IDC_COENORMAL,
927d4fc5 251 sessionpanelend,
c96a8fef 252
0965bee0 253 loggingpanelstart,
156686ef 254 IDC_TITLE_LOGGING,
0965bee0 255 IDC_BOX_LOGGING1,
256 IDC_LSTATSTATIC,
257 IDC_LSTATOFF,
258 IDC_LSTATASCII,
259 IDC_LSTATRAW,
260 IDC_LGFSTATIC,
261 IDC_LGFEDIT,
262 IDC_LGFBUTTON,
66ee282a 263 IDC_LGFEXPLAIN,
9f89f96e 264 IDC_LSTATXIST,
265 IDC_LSTATXOVR,
266 IDC_LSTATXAPN,
267 IDC_LSTATXASK,
0965bee0 268 loggingpanelend,
269
c96a8fef 270 keyboardpanelstart,
927d4fc5 271 IDC_TITLE_KEYBOARD,
3ac9cd9f 272 IDC_BOX_KEYBOARD1,
273 IDC_BOX_KEYBOARD2,
274 IDC_BOX_KEYBOARD3,
927d4fc5 275 IDC_DELSTATIC,
276 IDC_DEL008,
277 IDC_DEL127,
278 IDC_HOMESTATIC,
279 IDC_HOMETILDE,
280 IDC_HOMERXVT,
281 IDC_FUNCSTATIC,
282 IDC_FUNCTILDE,
283 IDC_FUNCLINUX,
284 IDC_FUNCXTERM,
285 IDC_FUNCVT400,
f37caa11 286 IDC_FUNCVT100P,
287 IDC_FUNCSCO,
927d4fc5 288 IDC_KPSTATIC,
289 IDC_KPNORMAL,
290 IDC_KPAPPLIC,
291 IDC_KPNH,
b00f8b34 292 IDC_NOAPPLICK,
293 IDC_NOAPPLICC,
927d4fc5 294 IDC_CURSTATIC,
295 IDC_CURNORMAL,
296 IDC_CURAPPLIC,
a094ae43 297 IDC_COMPOSEKEY,
95bbe1ae 298 IDC_CTRLALTKEYS,
c96a8fef 299 keyboardpanelend,
300
301 terminalpanelstart,
927d4fc5 302 IDC_TITLE_TERMINAL,
3ac9cd9f 303 IDC_BOX_TERMINAL1,
304 IDC_BOX_TERMINAL2,
927d4fc5 305 IDC_WRAPMODE,
306 IDC_DECOM,
927d4fc5 307 IDC_LFHASCR,
927d4fc5 308 IDC_BCE,
309 IDC_BLINKTEXT,
e7fbcdd8 310 IDC_ANSWERBACK,
311 IDC_ANSWEREDIT,
0965bee0 312 IDC_ECHOSTATIC,
313 IDC_ECHOBACKEND,
314 IDC_ECHOYES,
315 IDC_ECHONO,
316 IDC_EDITSTATIC,
317 IDC_EDITBACKEND,
318 IDC_EDITYES,
319 IDC_EDITNO,
c96a8fef 320 terminalpanelend,
321
156686ef 322 bellpanelstart,
323 IDC_TITLE_BELL,
324 IDC_BOX_BELL1,
325 IDC_BOX_BELL2,
326 IDC_BELLSTATIC,
327 IDC_BELL_DISABLED,
328 IDC_BELL_DEFAULT,
03169ad0 329 IDC_BELL_WAVEFILE,
156686ef 330 IDC_BELL_VISUAL,
03169ad0 331 IDC_BELL_WAVESTATIC,
332 IDC_BELL_WAVEEDIT,
333 IDC_BELL_WAVEBROWSE,
f8a28d1f 334 IDC_B_IND_STATIC,
335 IDC_B_IND_DISABLED,
336 IDC_B_IND_FLASH,
337 IDC_B_IND_STEADY,
156686ef 338 IDC_BELLOVL,
339 IDC_BELLOVLNSTATIC,
340 IDC_BELLOVLN,
341 IDC_BELLOVLTSTATIC,
342 IDC_BELLOVLT,
343 IDC_BELLOVLEXPLAIN,
344 IDC_BELLOVLSSTATIC,
345 IDC_BELLOVLS,
346 bellpanelend,
347
c96a8fef 348 windowpanelstart,
927d4fc5 349 IDC_TITLE_WINDOW,
3ac9cd9f 350 IDC_BOX_WINDOW1,
351 IDC_BOX_WINDOW2,
4c4f2716 352 IDC_BOX_WINDOW3,
353 IDC_ROWSSTATIC,
354 IDC_ROWSEDIT,
355 IDC_COLSSTATIC,
356 IDC_COLSEDIT,
ad5c93cc 357 IDC_RESIZESTATIC,
358 IDC_RESIZETERM,
359 IDC_RESIZEFONT,
360 IDC_RESIZENONE,
0ed2f48e 361 IDC_RESIZEEITHER,
927d4fc5 362 IDC_SCROLLBAR,
a401e5f3 363 IDC_SCROLLBARFULLSCREEN,
927d4fc5 364 IDC_SAVESTATIC,
365 IDC_SAVEEDIT,
d0cadfcd 366 IDC_SCROLLKEY,
367 IDC_SCROLLDISP,
368 windowpanelend,
369
370 behaviourpanelstart,
371 IDC_TITLE_BEHAVIOUR,
372 IDC_BOX_BEHAVIOUR1,
373 IDC_CLOSEWARN,
927d4fc5 374 IDC_ALTF4,
375 IDC_ALTSPACE,
a094ae43 376 IDC_ALTONLY,
e95edc00 377 IDC_ALWAYSONTOP,
8f57d753 378 IDC_FULLSCREENONALTENTER,
d0cadfcd 379 behaviourpanelend,
c96a8fef 380
4c4f2716 381 appearancepanelstart,
382 IDC_TITLE_APPEARANCE,
3ac9cd9f 383 IDC_BOX_APPEARANCE1,
384 IDC_BOX_APPEARANCE2,
385 IDC_BOX_APPEARANCE3,
386 IDC_BOX_APPEARANCE4,
57d08f2f 387 IDC_BOX_APPEARANCE5,
2d3411e9 388 IDC_CURSORSTATIC,
4e30ff69 389 IDC_CURBLOCK,
390 IDC_CURUNDER,
391 IDC_CURVERT,
4c4f2716 392 IDC_BLINKCUR,
393 IDC_FONTSTATIC,
394 IDC_CHOOSEFONT,
395 IDC_WINTITLE,
396 IDC_WINEDIT,
397 IDC_WINNAME,
554c540d 398 IDC_HIDEMOUSE,
57d08f2f 399 IDC_SUNKENEDGE,
5a73255e 400 IDC_WINBSTATIC,
401 IDC_WINBEDIT,
4c4f2716 402 appearancepanelend,
403
927d4fc5 404 connectionpanelstart,
405 IDC_TITLE_CONNECTION,
3ac9cd9f 406 IDC_BOX_CONNECTION1,
407 IDC_BOX_CONNECTION2,
2184a5d9 408 IDC_BOX_CONNECTION3,
927d4fc5 409 IDC_TTSTATIC,
410 IDC_TTEDIT,
411 IDC_LOGSTATIC,
412 IDC_LOGEDIT,
413 IDC_PINGSTATIC,
414 IDC_PINGEDIT,
2184a5d9 415 IDC_NODELAY,
927d4fc5 416 connectionpanelend,
417
c96a8fef 418 telnetpanelstart,
927d4fc5 419 IDC_TITLE_TELNET,
3ac9cd9f 420 IDC_BOX_TELNET1,
421 IDC_BOX_TELNET2,
927d4fc5 422 IDC_TSSTATIC,
423 IDC_TSEDIT,
424 IDC_ENVSTATIC,
425 IDC_VARSTATIC,
426 IDC_VAREDIT,
427 IDC_VALSTATIC,
428 IDC_VALEDIT,
429 IDC_ENVLIST,
430 IDC_ENVADD,
431 IDC_ENVREMOVE,
432 IDC_EMSTATIC,
433 IDC_EMBSD,
434 IDC_EMRFC,
8faa456c 435 IDC_ACTSTATIC,
436 IDC_TPASSIVE,
437 IDC_TACTIVE,
70133c0e 438 IDC_TELNETKEY,
c96a8fef 439 telnetpanelend,
440
c91409da 441 rloginpanelstart,
442 IDC_TITLE_RLOGIN,
3ac9cd9f 443 IDC_BOX_RLOGIN1,
444 IDC_BOX_RLOGIN2,
c91409da 445 IDC_R_TSSTATIC,
446 IDC_R_TSEDIT,
447 IDC_RLLUSERSTATIC,
448 IDC_RLLUSEREDIT,
449 rloginpanelend,
450
c96a8fef 451 sshpanelstart,
927d4fc5 452 IDC_TITLE_SSH,
3ac9cd9f 453 IDC_BOX_SSH1,
454 IDC_BOX_SSH2,
455 IDC_BOX_SSH3,
927d4fc5 456 IDC_NOPTY,
ca20bfcf 457 IDC_BOX_SSHCIPHER,
458 IDC_CIPHERSTATIC2,
459 IDC_CIPHERLIST,
460 IDC_CIPHERUP,
461 IDC_CIPHERDN,
7591b9ff 462 IDC_BUGGYMAC,
cb4d4768 463 IDC_SSH2DES,
927d4fc5 464 IDC_SSHPROTSTATIC,
465 IDC_SSHPROT1,
466 IDC_SSHPROT2,
927d4fc5 467 IDC_CMDSTATIC,
468 IDC_CMDEDIT,
4ba9b64b 469 IDC_COMPRESS,
c96a8fef 470 sshpanelend,
471
ca20bfcf 472 sshauthpanelstart,
473 IDC_TITLE_SSHAUTH,
474 IDC_BOX_SSHAUTH1,
475 IDC_BOX_SSHAUTH2,
476 IDC_PKSTATIC,
477 IDC_PKEDIT,
478 IDC_PKBUTTON,
479 IDC_AGENTFWD,
5bb641e1 480 IDC_CHANGEUSER,
ca20bfcf 481 IDC_AUTHTIS,
f091e308 482 IDC_AUTHKI,
ca20bfcf 483 sshauthpanelend,
484
c96a8fef 485 selectionpanelstart,
927d4fc5 486 IDC_TITLE_SELECTION,
3ac9cd9f 487 IDC_BOX_SELECTION1,
488 IDC_BOX_SELECTION2,
d3a22f79 489 IDC_BOX_SELECTION3,
927d4fc5 490 IDC_MBSTATIC,
491 IDC_MBWINDOWS,
492 IDC_MBXTERM,
b90840c3 493 IDC_MOUSEOVERRIDE,
6908fed7 494 IDC_SELTYPESTATIC,
495 IDC_SELTYPELEX,
496 IDC_SELTYPERECT,
927d4fc5 497 IDC_CCSTATIC,
498 IDC_CCLIST,
499 IDC_CCSET,
500 IDC_CCSTATIC2,
501 IDC_CCEDIT,
d3a22f79 502 IDC_RAWCNP,
a7419ea4 503 IDC_RTFPASTE,
c96a8fef 504 selectionpanelend,
505
506 colourspanelstart,
927d4fc5 507 IDC_TITLE_COLOURS,
3ac9cd9f 508 IDC_BOX_COLOURS1,
509 IDC_BOX_COLOURS2,
927d4fc5 510 IDC_BOLDCOLOUR,
511 IDC_PALETTE,
5055f918 512 IDC_COLOURSTATIC,
513 IDC_COLOURLIST,
927d4fc5 514 IDC_RSTATIC,
515 IDC_GSTATIC,
516 IDC_BSTATIC,
517 IDC_RVALUE,
518 IDC_GVALUE,
519 IDC_BVALUE,
520 IDC_CHANGE,
c96a8fef 521 colourspanelend,
522
523 translationpanelstart,
927d4fc5 524 IDC_TITLE_TRANSLATION,
3ac9cd9f 525 IDC_BOX_TRANSLATION1,
526 IDC_BOX_TRANSLATION2,
a9c02454 527 IDC_BOX_TRANSLATION3,
4eeb7d09 528 IDC_CODEPAGESTATIC,
529 IDC_CODEPAGE,
a9c02454 530 IDC_CAPSLOCKCYR,
927d4fc5 531 IDC_VTSTATIC,
532 IDC_VTXWINDOWS,
533 IDC_VTOEMANSI,
534 IDC_VTOEMONLY,
535 IDC_VTPOORMAN,
4eeb7d09 536 IDC_VTUNICODE,
c96a8fef 537 translationpanelend,
538
9c964e85 539 tunnelspanelstart,
e6ace450 540 IDC_TITLE_TUNNELS,
d74d141c 541 IDC_BOX_TUNNELS1,
542 IDC_BOX_TUNNELS2,
9c964e85 543 IDC_X11_FORWARD,
544 IDC_X11_DISPSTATIC,
545 IDC_X11_DISPLAY,
d74d141c 546 IDC_LPORT_ALL,
547 IDC_PFWDSTATIC,
548 IDC_PFWDSTATIC2,
549 IDC_PFWDREMOVE,
550 IDC_PFWDLIST,
551 IDC_PFWDADD,
552 IDC_SPORTSTATIC,
553 IDC_SPORTEDIT,
554 IDC_DPORTSTATIC,
555 IDC_DPORTEDIT,
556 IDC_PFWDLOCAL,
557 IDC_PFWDREMOTE,
558
9c964e85 559 tunnelspanelend,
560
c96a8fef 561 controlendvalue
562};
563
564static const char *const colours[] = {
565 "Default Foreground", "Default Bold Foreground",
566 "Default Background", "Default Bold Background",
567 "Cursor Text", "Cursor Colour",
568 "ANSI Black", "ANSI Black Bold",
569 "ANSI Red", "ANSI Red Bold",
570 "ANSI Green", "ANSI Green Bold",
571 "ANSI Yellow", "ANSI Yellow Bold",
572 "ANSI Blue", "ANSI Blue Bold",
573 "ANSI Magenta", "ANSI Magenta Bold",
574 "ANSI Cyan", "ANSI Cyan Bold",
575 "ANSI White", "ANSI White Bold"
576};
577static const int permcolour[] = {
578 TRUE, FALSE, TRUE, FALSE, TRUE, TRUE,
579 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE,
580 TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE
581};
582
32874aea 583static void fmtfont(char *buf)
584{
585 sprintf(buf, "Font: %s, ", cfg.font);
c96a8fef 586 if (cfg.fontisbold)
587 strcat(buf, "bold, ");
588 if (cfg.fontheight == 0)
32874aea 589 strcat(buf, "default height");
c96a8fef 590 else
32874aea 591 sprintf(buf + strlen(buf), "%d-point",
592 (cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
c96a8fef 593}
594
70133c0e 595char *help_context_cmd(int id)
596{
597 switch (id) {
598 case IDC_HOSTSTATIC:
599 case IDC_HOST:
600 case IDC_PORTSTATIC:
601 case IDC_PORT:
602 case IDC_PROTSTATIC:
603 case IDC_PROTRAW:
604 case IDC_PROTTELNET:
605 case IDC_PROTRLOGIN:
606 case IDC_PROTSSH:
607 return "JI(`',`session.hostname')";
608 case IDC_SESSSTATIC:
609 case IDC_SESSEDIT:
610 case IDC_SESSLIST:
611 case IDC_SESSLOAD:
612 case IDC_SESSSAVE:
613 case IDC_SESSDEL:
614 return "JI(`',`session.saved')";
615 case IDC_CLOSEEXIT:
616 case IDC_COEALWAYS:
617 case IDC_COENEVER:
618 case IDC_COENORMAL:
619 return "JI(`',`session.coe')";
620 case IDC_LSTATSTATIC:
621 case IDC_LSTATOFF:
622 case IDC_LSTATASCII:
623 case IDC_LSTATRAW:
624 return "JI(`',`logging.main')";
625 case IDC_LGFSTATIC:
626 case IDC_LGFEDIT:
627 case IDC_LGFBUTTON:
628 case IDC_LGFEXPLAIN:
629 return "JI(`',`logging.filename')";
630 case IDC_LSTATXIST:
631 case IDC_LSTATXOVR:
632 case IDC_LSTATXAPN:
633 case IDC_LSTATXASK:
634 return "JI(`',`logging.exists')";
635
636 case IDC_DELSTATIC:
637 case IDC_DEL008:
638 case IDC_DEL127:
639 return "JI(`',`keyboard.backspace')";
640 case IDC_HOMESTATIC:
641 case IDC_HOMETILDE:
642 case IDC_HOMERXVT:
643 return "JI(`',`keyboard.homeend')";
644 case IDC_FUNCSTATIC:
645 case IDC_FUNCTILDE:
646 case IDC_FUNCLINUX:
647 case IDC_FUNCXTERM:
648 case IDC_FUNCVT400:
649 case IDC_FUNCVT100P:
650 case IDC_FUNCSCO:
651 return "JI(`',`keyboard.funkeys')";
652 case IDC_KPSTATIC:
653 case IDC_KPNORMAL:
654 case IDC_KPAPPLIC:
655 case IDC_NOAPPLICK:
656 return "JI(`',`keyboard.appkeypad')";
657 case IDC_NOAPPLICC:
658 case IDC_CURSTATIC:
659 case IDC_CURNORMAL:
660 case IDC_CURAPPLIC:
661 return "JI(`',`keyboard.appcursor')";
662 case IDC_KPNH:
663 return "JI(`',`keyboard.nethack')";
664 case IDC_COMPOSEKEY:
665 return "JI(`',`keyboard.compose')";
666 case IDC_CTRLALTKEYS:
667 return "JI(`',`keyboard.ctrlalt')";
668
669 case IDC_WRAPMODE:
670 return "JI(`',`terminal.autowrap')";
671 case IDC_DECOM:
672 return "JI(`',`terminal.decom')";
673 case IDC_LFHASCR:
674 return "JI(`',`terminal.lfhascr')";
675 case IDC_BCE:
676 return "JI(`',`terminal.bce')";
677 case IDC_BLINKTEXT:
678 return "JI(`',`terminal.blink')";
679 case IDC_ANSWERBACK:
680 case IDC_ANSWEREDIT:
681 return "JI(`',`terminal.answerback')";
682 case IDC_ECHOSTATIC:
683 case IDC_ECHOBACKEND:
684 case IDC_ECHOYES:
685 case IDC_ECHONO:
686 return "JI(`',`terminal.localecho')";
687 case IDC_EDITSTATIC:
688 case IDC_EDITBACKEND:
689 case IDC_EDITYES:
690 case IDC_EDITNO:
691 return "JI(`',`terminal.localedit')";
692
693 case IDC_BELLSTATIC:
694 case IDC_BELL_DISABLED:
695 case IDC_BELL_DEFAULT:
696 case IDC_BELL_WAVEFILE:
697 case IDC_BELL_VISUAL:
698 case IDC_BELL_WAVESTATIC:
699 case IDC_BELL_WAVEEDIT:
700 case IDC_BELL_WAVEBROWSE:
701 return "JI(`',`bell.style')";
702 case IDC_B_IND_STATIC:
703 case IDC_B_IND_DISABLED:
704 case IDC_B_IND_FLASH:
705 case IDC_B_IND_STEADY:
706 return "JI(`',`bell.taskbar')";
707 case IDC_BELLOVL:
708 case IDC_BELLOVLNSTATIC:
709 case IDC_BELLOVLN:
710 case IDC_BELLOVLTSTATIC:
711 case IDC_BELLOVLT:
712 case IDC_BELLOVLEXPLAIN:
713 case IDC_BELLOVLSSTATIC:
714 case IDC_BELLOVLS:
715 return "JI(`',`bell.overload')";
716
717 case IDC_ROWSSTATIC:
718 case IDC_ROWSEDIT:
719 case IDC_COLSSTATIC:
720 case IDC_COLSEDIT:
721 return "JI(`',`window.size')";
722 case IDC_RESIZESTATIC:
723 case IDC_RESIZETERM:
724 case IDC_RESIZEFONT:
725 case IDC_RESIZENONE:
726 case IDC_RESIZEEITHER:
727 return "JI(`',`window.resize')";
728 case IDC_SCROLLBAR:
729 case IDC_SCROLLBARFULLSCREEN:
730 case IDC_SAVESTATIC:
731 case IDC_SAVEEDIT:
732 case IDC_SCROLLKEY:
733 case IDC_SCROLLDISP:
734 return "JI(`',`window.scrollback')";
735
736 case IDC_CLOSEWARN:
737 return "JI(`',`behaviour.closewarn')";
738 case IDC_ALTF4:
739 return "JI(`',`behaviour.altf4')";
740 case IDC_ALTSPACE:
741 return "JI(`',`behaviour.altspace')";
742 case IDC_ALTONLY:
743 return "JI(`',`behaviour.altonly')";
744 case IDC_ALWAYSONTOP:
745 return "JI(`',`behaviour.alwaysontop')";
746 case IDC_FULLSCREENONALTENTER:
747 return "JI(`',`behaviour.altenter')";
748
749 case IDC_CURSORSTATIC:
750 case IDC_CURBLOCK:
751 case IDC_CURUNDER:
752 case IDC_CURVERT:
753 case IDC_BLINKCUR:
754 return "JI(`',`appearance.cursor')";
755 case IDC_FONTSTATIC:
756 case IDC_CHOOSEFONT:
757 return "JI(`',`appearance.font')";
758 case IDC_WINTITLE:
759 case IDC_WINEDIT:
760 case IDC_WINNAME:
761 return "JI(`',`appearance.title')";
762 case IDC_HIDEMOUSE:
763 return "JI(`',`appearance.hidemouse')";
764 case IDC_SUNKENEDGE:
765 case IDC_WINBSTATIC:
766 case IDC_WINBEDIT:
767 return "JI(`',`appearance.border')";
768
769 case IDC_TTSTATIC:
770 case IDC_TTEDIT:
771 return "JI(`',`connection.termtype')";
772 case IDC_LOGSTATIC:
773 case IDC_LOGEDIT:
774 return "JI(`',`connection.username')";
775 case IDC_PINGSTATIC:
776 case IDC_PINGEDIT:
777 return "JI(`',`connection.keepalive')";
778 case IDC_NODELAY:
779 return "JI(`',`connection.nodelay')";
780
781 case IDC_TSSTATIC:
782 case IDC_TSEDIT:
783 return "JI(`',`telnet.termspeed')";
784 case IDC_ENVSTATIC:
785 case IDC_VARSTATIC:
786 case IDC_VAREDIT:
787 case IDC_VALSTATIC:
788 case IDC_VALEDIT:
789 case IDC_ENVLIST:
790 case IDC_ENVADD:
791 case IDC_ENVREMOVE:
792 return "JI(`',`telnet.environ')";
793 case IDC_EMSTATIC:
794 case IDC_EMBSD:
795 case IDC_EMRFC:
796 return "JI(`',`telnet.oldenviron')";
797 case IDC_ACTSTATIC:
798 case IDC_TPASSIVE:
799 case IDC_TACTIVE:
800 return "JI(`',`telnet.passive')";
801 case IDC_TELNETKEY:
802 return "JI(`',`telnet.specialkeys')";
803
804 case IDC_R_TSSTATIC:
805 case IDC_R_TSEDIT:
806 return "JI(`',`rlogin.termspeed')";
807 case IDC_RLLUSERSTATIC:
808 case IDC_RLLUSEREDIT:
809 return "JI(`',`rlogin.localuser')";
810
811 case IDC_NOPTY:
812 return "JI(`',`ssh.nopty')";
813 case IDC_CIPHERSTATIC2:
814 case IDC_CIPHERLIST:
815 case IDC_CIPHERUP:
816 case IDC_CIPHERDN:
817 case IDC_SSH2DES:
818 return "JI(`',`ssh.ciphers')";
819 case IDC_BUGGYMAC:
820 return "JI(`',`ssh.buggymac')";
821 case IDC_SSHPROTSTATIC:
822 case IDC_SSHPROT1:
823 case IDC_SSHPROT2:
824 return "JI(`',`ssh.protocol')";
825 case IDC_CMDSTATIC:
826 case IDC_CMDEDIT:
827 return "JI(`',`ssh.command')";
828 case IDC_COMPRESS:
829 return "JI(`',`ssh.compress')";
830
831 case IDC_PKSTATIC:
832 case IDC_PKEDIT:
833 case IDC_PKBUTTON:
834 return "JI(`',`ssh.auth.privkey')";
835 case IDC_AGENTFWD:
836 return "JI(`',`ssh.auth.agentfwd')";
5bb641e1 837 case IDC_CHANGEUSER:
838 return "JI(`',`ssh.auth.changeuser')";
70133c0e 839 case IDC_AUTHTIS:
840 return "JI(`',`ssh.auth.tis')";
841 case IDC_AUTHKI:
842 return "JI(`',`ssh.auth.ki')";
843
844 case IDC_MBSTATIC:
845 case IDC_MBWINDOWS:
846 case IDC_MBXTERM:
847 return "JI(`',`selection.buttons')";
848 case IDC_MOUSEOVERRIDE:
849 return "JI(`',`selection.shiftdrag')";
850 case IDC_SELTYPESTATIC:
851 case IDC_SELTYPELEX:
852 case IDC_SELTYPERECT:
853 return "JI(`',`selection.rect')";
854 case IDC_CCSTATIC:
855 case IDC_CCLIST:
856 case IDC_CCSET:
857 case IDC_CCSTATIC2:
858 case IDC_CCEDIT:
859 return "JI(`',`selection.charclasses')";
860 case IDC_RAWCNP:
861 return "JI(`',`selection.linedraw')";
862 case IDC_RTFPASTE:
863 return "JI(`',`selection.rtf')";
864
865 case IDC_BOLDCOLOUR:
866 return "JI(`',`colours.bold')";
867 case IDC_PALETTE:
868 return "JI(`',`colours.logpal')";
869 case IDC_COLOURSTATIC:
870 case IDC_COLOURLIST:
871 case IDC_RSTATIC:
872 case IDC_GSTATIC:
873 case IDC_BSTATIC:
874 case IDC_RVALUE:
875 case IDC_GVALUE:
876 case IDC_BVALUE:
877 case IDC_CHANGE:
878 return "JI(`',`colours.config')";
879
880 case IDC_CODEPAGESTATIC:
881 case IDC_CODEPAGE:
882 return "JI(`',`translation.codepage')";
883 case IDC_CAPSLOCKCYR:
884 return "JI(`',`translation.cyrillic')";
885 case IDC_VTSTATIC:
886 case IDC_VTXWINDOWS:
887 case IDC_VTOEMANSI:
888 case IDC_VTOEMONLY:
889 case IDC_VTPOORMAN:
890 case IDC_VTUNICODE:
891 return "JI(`',`translation.linedraw')";
892
893 case IDC_X11_FORWARD:
894 case IDC_X11_DISPSTATIC:
895 case IDC_X11_DISPLAY:
896 return "JI(`',`ssh.tunnels.x11')";
897 case IDC_LPORT_ALL:
898 case IDC_PFWDSTATIC:
899 case IDC_PFWDSTATIC2:
900 case IDC_PFWDREMOVE:
901 case IDC_PFWDLIST:
902 case IDC_PFWDADD:
903 case IDC_SPORTSTATIC:
904 case IDC_SPORTEDIT:
905 case IDC_DPORTSTATIC:
906 case IDC_DPORTEDIT:
907 case IDC_PFWDLOCAL:
908 case IDC_PFWDREMOTE:
909 return "JI(`',`ssh.tunnels.portfwd')";
910
911 default:
912 return NULL;
913 }
914}
915
c8d7378d 916/* 2nd arg: NZ => don't redraw session list (use when loading
917 * a new session) */
918static void init_dlg_ctrls(HWND hwnd, int keepsess)
32874aea 919{
c96a8fef 920 int i;
921 char fontstatic[256];
922
32874aea 923 SetDlgItemText(hwnd, IDC_HOST, cfg.host);
924 SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
c8d7378d 925 if (!keepsess) {
3ac9cd9f 926 int i, n;
32874aea 927 n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
928 for (i = n; i-- > 0;)
929 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_DELETESTRING, i, 0);
930 for (i = 0; i < nsessions; i++)
931 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_ADDSTRING,
932 0, (LPARAM) (sessions[i]));
3ac9cd9f 933 }
32874aea 934 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
935 CheckRadioButton(hwnd, IDC_PROTRAW, IDC_PROTSSH,
936 cfg.protocol == PROT_SSH ? IDC_PROTSSH :
937 cfg.protocol == PROT_TELNET ? IDC_PROTTELNET :
938 cfg.protocol ==
939 PROT_RLOGIN ? IDC_PROTRLOGIN : IDC_PROTRAW);
940 SetDlgItemInt(hwnd, IDC_PINGEDIT, cfg.ping_interval, FALSE);
2184a5d9 941 CheckDlgButton(hwnd, IDC_NODELAY, cfg.tcp_nodelay);
32874aea 942
943 CheckRadioButton(hwnd, IDC_DEL008, IDC_DEL127,
944 cfg.bksp_is_delete ? IDC_DEL127 : IDC_DEL008);
945 CheckRadioButton(hwnd, IDC_HOMETILDE, IDC_HOMERXVT,
946 cfg.rxvt_homeend ? IDC_HOMERXVT : IDC_HOMETILDE);
947 CheckRadioButton(hwnd, IDC_FUNCTILDE, IDC_FUNCSCO,
948 cfg.funky_type == 0 ? IDC_FUNCTILDE :
949 cfg.funky_type == 1 ? IDC_FUNCLINUX :
950 cfg.funky_type == 2 ? IDC_FUNCXTERM :
951 cfg.funky_type == 3 ? IDC_FUNCVT400 :
952 cfg.funky_type == 4 ? IDC_FUNCVT100P :
953 cfg.funky_type == 5 ? IDC_FUNCSCO : IDC_FUNCTILDE);
954 CheckDlgButton(hwnd, IDC_NOAPPLICC, cfg.no_applic_c);
955 CheckDlgButton(hwnd, IDC_NOAPPLICK, cfg.no_applic_k);
956 CheckRadioButton(hwnd, IDC_CURNORMAL, IDC_CURAPPLIC,
957 cfg.app_cursor ? IDC_CURAPPLIC : IDC_CURNORMAL);
958 CheckRadioButton(hwnd, IDC_KPNORMAL, IDC_KPNH,
959 cfg.nethack_keypad ? IDC_KPNH :
960 cfg.app_keypad ? IDC_KPAPPLIC : IDC_KPNORMAL);
961 CheckDlgButton(hwnd, IDC_ALTF4, cfg.alt_f4);
962 CheckDlgButton(hwnd, IDC_ALTSPACE, cfg.alt_space);
963 CheckDlgButton(hwnd, IDC_ALTONLY, cfg.alt_only);
964 CheckDlgButton(hwnd, IDC_COMPOSEKEY, cfg.compose_key);
965 CheckDlgButton(hwnd, IDC_CTRLALTKEYS, cfg.ctrlaltkeys);
a5f3e637 966 CheckDlgButton(hwnd, IDC_TELNETKEY, cfg.telnet_keyboard);
32874aea 967 CheckRadioButton(hwnd, IDC_ECHOBACKEND, IDC_ECHONO,
968 cfg.localecho == LD_BACKEND ? IDC_ECHOBACKEND :
969 cfg.localecho == LD_YES ? IDC_ECHOYES : IDC_ECHONO);
970 CheckRadioButton(hwnd, IDC_EDITBACKEND, IDC_EDITNO,
971 cfg.localedit == LD_BACKEND ? IDC_EDITBACKEND :
972 cfg.localedit == LD_YES ? IDC_EDITYES : IDC_EDITNO);
973 SetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback);
974 CheckDlgButton(hwnd, IDC_ALWAYSONTOP, cfg.alwaysontop);
8f57d753 975 CheckDlgButton(hwnd, IDC_FULLSCREENONALTENTER, cfg.fullscreenonaltenter);
32874aea 976 CheckDlgButton(hwnd, IDC_SCROLLKEY, cfg.scroll_on_key);
977 CheckDlgButton(hwnd, IDC_SCROLLDISP, cfg.scroll_on_disp);
978
979 CheckDlgButton(hwnd, IDC_WRAPMODE, cfg.wrap_mode);
980 CheckDlgButton(hwnd, IDC_DECOM, cfg.dec_om);
981 CheckDlgButton(hwnd, IDC_LFHASCR, cfg.lfhascr);
982 SetDlgItemInt(hwnd, IDC_ROWSEDIT, cfg.height, FALSE);
983 SetDlgItemInt(hwnd, IDC_COLSEDIT, cfg.width, FALSE);
984 SetDlgItemInt(hwnd, IDC_SAVEEDIT, cfg.savelines, FALSE);
985 fmtfont(fontstatic);
986 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
987 CheckRadioButton(hwnd, IDC_BELL_DISABLED, IDC_BELL_VISUAL,
988 cfg.beep == BELL_DISABLED ? IDC_BELL_DISABLED :
989 cfg.beep == BELL_DEFAULT ? IDC_BELL_DEFAULT :
990 cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
991 cfg.beep ==
992 BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
f8a28d1f 993 CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
994 cfg.beep_ind ==
995 B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
996 B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
997 B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
32874aea 998 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
999 CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
1000 SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
1001 MySetDlgItemFlt(hwnd, IDC_BELLOVLT, cfg.bellovl_t / 1000.0);
1002 MySetDlgItemFlt(hwnd, IDC_BELLOVLS, cfg.bellovl_s / 1000.0);
1003
1004 CheckDlgButton(hwnd, IDC_BCE, cfg.bce);
1005 CheckDlgButton(hwnd, IDC_BLINKTEXT, cfg.blinktext);
1006
1007 SetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle);
1008 CheckDlgButton(hwnd, IDC_WINNAME, cfg.win_name_always);
1009 CheckDlgButton(hwnd, IDC_HIDEMOUSE, cfg.hide_mouseptr);
1010 CheckDlgButton(hwnd, IDC_SUNKENEDGE, cfg.sunken_edge);
5a73255e 1011 SetDlgItemInt(hwnd, IDC_WINBEDIT, cfg.window_border, FALSE);
32874aea 1012 CheckRadioButton(hwnd, IDC_CURBLOCK, IDC_CURVERT,
1013 cfg.cursor_type == 0 ? IDC_CURBLOCK :
1014 cfg.cursor_type == 1 ? IDC_CURUNDER : IDC_CURVERT);
1015 CheckDlgButton(hwnd, IDC_BLINKCUR, cfg.blink_cur);
1016 CheckDlgButton(hwnd, IDC_SCROLLBAR, cfg.scrollbar);
a401e5f3 1017 CheckDlgButton(hwnd, IDC_SCROLLBARFULLSCREEN, cfg.scrollbar_in_fullscreen);
0ed2f48e 1018 CheckRadioButton(hwnd, IDC_RESIZETERM, IDC_RESIZEEITHER,
ad5c93cc 1019 cfg.resize_action == RESIZE_TERM ? IDC_RESIZETERM :
1020 cfg.resize_action == RESIZE_FONT ? IDC_RESIZEFONT :
0ed2f48e 1021 cfg.resize_action == RESIZE_EITHER ? IDC_RESIZEEITHER :
ad5c93cc 1022 IDC_RESIZENONE);
32874aea 1023 CheckRadioButton(hwnd, IDC_COEALWAYS, IDC_COENORMAL,
1024 cfg.close_on_exit == COE_NORMAL ? IDC_COENORMAL :
1025 cfg.close_on_exit ==
1026 COE_NEVER ? IDC_COENEVER : IDC_COEALWAYS);
1027 CheckDlgButton(hwnd, IDC_CLOSEWARN, cfg.warn_on_close);
1028
1029 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1030 SetDlgItemText(hwnd, IDC_TSEDIT, cfg.termspeed);
1031 SetDlgItemText(hwnd, IDC_R_TSEDIT, cfg.termspeed);
1032 SetDlgItemText(hwnd, IDC_RLLUSEREDIT, cfg.localusername);
1033 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1034 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
e1c8e0ed 1035 CheckRadioButton(hwnd, IDC_LSTATOFF, IDC_LSTATRAW,
1036 cfg.logtype == 0 ? IDC_LSTATOFF :
32874aea 1037 cfg.logtype == 1 ? IDC_LSTATASCII : IDC_LSTATRAW);
9f89f96e 1038 CheckRadioButton(hwnd, IDC_LSTATXOVR, IDC_LSTATXASK,
1039 cfg.logxfovr == LGXF_OVR ? IDC_LSTATXOVR :
1040 cfg.logxfovr == LGXF_ASK ? IDC_LSTATXASK :
1041 IDC_LSTATXAPN);
c96a8fef 1042 {
1043 char *p = cfg.environmt;
1cb2aa45 1044 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
c96a8fef 1045 while (*p) {
32874aea 1046 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
1047 (LPARAM) p);
1048 p += strlen(p) + 1;
c96a8fef 1049 }
d74d141c 1050 p = cfg.portfwd;
1051 while (*p) {
1052 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING, 0,
1053 (LPARAM) p);
1054 p += strlen(p) + 1;
1055 }
374330e2 1056 }
32874aea 1057 CheckRadioButton(hwnd, IDC_EMBSD, IDC_EMRFC,
1058 cfg.rfc_environ ? IDC_EMRFC : IDC_EMBSD);
8faa456c 1059 CheckRadioButton(hwnd, IDC_TPASSIVE, IDC_TACTIVE,
1060 cfg.passive_telnet ? IDC_TPASSIVE : IDC_TACTIVE);
32874aea 1061
1062 SetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype);
1063 SetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username);
1064 CheckDlgButton(hwnd, IDC_NOPTY, cfg.nopty);
1065 CheckDlgButton(hwnd, IDC_COMPRESS, cfg.compression);
1066 CheckDlgButton(hwnd, IDC_BUGGYMAC, cfg.buggymac);
cb4d4768 1067 CheckDlgButton(hwnd, IDC_SSH2DES, cfg.ssh2_des_cbc);
32874aea 1068 CheckDlgButton(hwnd, IDC_AGENTFWD, cfg.agentfwd);
5bb641e1 1069 CheckDlgButton(hwnd, IDC_CHANGEUSER, cfg.change_username);
32874aea 1070 CheckRadioButton(hwnd, IDC_SSHPROT1, IDC_SSHPROT2,
1071 cfg.sshprot == 1 ? IDC_SSHPROT1 : IDC_SSHPROT2);
1072 CheckDlgButton(hwnd, IDC_AUTHTIS, cfg.try_tis_auth);
f091e308 1073 CheckDlgButton(hwnd, IDC_AUTHKI, cfg.try_ki_auth);
32874aea 1074 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
1075 SetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd);
1076
ca20bfcf 1077 {
1078 int i;
1079 static const struct { char *s; int c; } ciphers[] = {
1080 { "3DES", CIPHER_3DES },
1081 { "Blowfish", CIPHER_BLOWFISH },
7f1ae1d2 1082 { "DES", CIPHER_DES },
ca20bfcf 1083 { "AES (SSH 2 only)", CIPHER_AES },
1084 { "-- warn below here --", CIPHER_WARN }
1085 };
1086
1087 /* Set up the "selected ciphers" box. */
1088 /* (cipherlist assumed to contain all ciphers) */
1089 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_RESETCONTENT, 0, 0);
1090 for (i = 0; i < CIPHER_MAX; i++) {
1091 int c = cfg.ssh_cipherlist[i];
1092 int j, pos;
1093 char *cstr = NULL;
1094 for (j = 0; j < (sizeof ciphers) / (sizeof ciphers[0]); j++) {
1095 if (ciphers[j].c == c) {
1096 cstr = ciphers[j].s;
1097 break;
1098 }
1099 }
1100 pos = SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_ADDSTRING,
1101 0, (LPARAM) cstr);
1102 SendDlgItemMessage(hwnd, IDC_CIPHERLIST, LB_SETITEMDATA,
1103 pos, (LPARAM) c);
1104 }
ca20bfcf 1105
1106 }
1107
32874aea 1108 CheckRadioButton(hwnd, IDC_MBWINDOWS, IDC_MBXTERM,
1109 cfg.mouse_is_xterm ? IDC_MBXTERM : IDC_MBWINDOWS);
6908fed7 1110 CheckRadioButton(hwnd, IDC_SELTYPELEX, IDC_SELTYPERECT,
1111 cfg.rect_select == 0 ? IDC_SELTYPELEX : IDC_SELTYPERECT);
b90840c3 1112 CheckDlgButton(hwnd, IDC_MOUSEOVERRIDE, cfg.mouse_override);
32874aea 1113 CheckDlgButton(hwnd, IDC_RAWCNP, cfg.rawcnp);
a7419ea4 1114 CheckDlgButton(hwnd, IDC_RTFPASTE, cfg.rtf_paste);
c96a8fef 1115 {
32874aea 1116 static int tabs[4] = { 25, 61, 96, 128 };
1117 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_SETTABSTOPS, 4,
1118 (LPARAM) tabs);
c96a8fef 1119 }
4eeb7d09 1120 for (i = 0; i < 128; i++) {
c96a8fef 1121 char str[100];
1122 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
32874aea 1123 (i >= 0x21 && i != 0x7F) ? i : ' ', cfg.wordness[i]);
1124 SendDlgItemMessage(hwnd, IDC_CCLIST, LB_ADDSTRING, 0,
1125 (LPARAM) str);
c96a8fef 1126 }
1127
32874aea 1128 CheckDlgButton(hwnd, IDC_BOLDCOLOUR, cfg.bold_colour);
1129 CheckDlgButton(hwnd, IDC_PALETTE, cfg.try_palette);
c96a8fef 1130 {
2ceb950f 1131 int i, n;
32874aea 1132 n = SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_GETCOUNT, 0, 0);
1133 for (i = n; i-- > 0;)
1134 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
1135 LB_DELETESTRING, i, 0);
1136 for (i = 0; i < 22; i++)
c96a8fef 1137 if (cfg.bold_colour || permcolour[i])
32874aea 1138 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_ADDSTRING, 0,
1139 (LPARAM) colours[i]);
c96a8fef 1140 }
32874aea 1141 SendDlgItemMessage(hwnd, IDC_COLOURLIST, LB_SETCURSEL, 0, 0);
1142 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[0][0], FALSE);
1143 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[0][1], FALSE);
1144 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[0][2], FALSE);
1145
875b193f 1146 {
1147 int i;
1148 char *cp;
b8ae1f0f 1149 strcpy(cfg.line_codepage, cp_name(decode_codepage(cfg.line_codepage)));
875b193f 1150 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_RESETCONTENT, 0, 0);
a9c02454 1151 CheckDlgButton (hwnd, IDC_CAPSLOCKCYR, cfg.xlat_capslockcyr);
875b193f 1152 for (i = 0; (cp = cp_enumerate(i)) != NULL; i++) {
1153 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_ADDSTRING,
1154 0, (LPARAM) cp);
875b193f 1155 }
b8ae1f0f 1156 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
875b193f 1157 }
1158
4eeb7d09 1159 CheckRadioButton(hwnd, IDC_VTXWINDOWS, IDC_VTUNICODE,
32874aea 1160 cfg.vtmode == VT_XWINDOWS ? IDC_VTXWINDOWS :
1161 cfg.vtmode == VT_OEMANSI ? IDC_VTOEMANSI :
1162 cfg.vtmode == VT_OEMONLY ? IDC_VTOEMONLY :
4eeb7d09 1163 cfg.vtmode == VT_UNICODE ? IDC_VTUNICODE :
32874aea 1164 IDC_VTPOORMAN);
1165
1166 CheckDlgButton(hwnd, IDC_X11_FORWARD, cfg.x11_forward);
1167 SetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display);
d74d141c 1168
1169 CheckDlgButton(hwnd, IDC_LPORT_ALL, cfg.lport_acceptall);
1170 CheckRadioButton(hwnd, IDC_PFWDLOCAL, IDC_PFWDREMOTE, IDC_PFWDLOCAL);
374330e2 1171}
1172
927d4fc5 1173struct treeview_faff {
1174 HWND treeview;
1175 HTREEITEM lastat[4];
1176};
1177
1178static HTREEITEM treeview_insert(struct treeview_faff *faff,
32874aea 1179 int level, char *text)
1180{
927d4fc5 1181 TVINSERTSTRUCT ins;
1182 int i;
1183 HTREEITEM newitem;
32874aea 1184 ins.hParent = (level > 0 ? faff->lastat[level - 1] : TVI_ROOT);
927d4fc5 1185 ins.hInsertAfter = faff->lastat[level];
06a03685 1186#if _WIN32_IE >= 0x0400 && defined NONAMELESSUNION
1187#define INSITEM DUMMYUNIONNAME.item
1188#else
1189#define INSITEM item
1190#endif
1191 ins.INSITEM.mask = TVIF_TEXT;
1192 ins.INSITEM.pszText = text;
927d4fc5 1193 newitem = TreeView_InsertItem(faff->treeview, &ins);
1194 if (level > 0)
32874aea 1195 TreeView_Expand(faff->treeview, faff->lastat[level - 1],
1196 TVE_EXPAND);
927d4fc5 1197 faff->lastat[level] = newitem;
32874aea 1198 for (i = level + 1; i < 4; i++)
1199 faff->lastat[i] = NULL;
927d4fc5 1200 return newitem;
1201}
1202
c96a8fef 1203/*
3ac9cd9f 1204 * Create the panelfuls of controls in the configuration box.
1205 */
32874aea 1206static void create_controls(HWND hwnd, int dlgtype, int panel)
1207{
3ac9cd9f 1208 if (panel == sessionpanelstart) {
b41069ff 1209 /* The Session panel. Accelerators used: [acgo] nprtih elsd w */
32874aea 1210 struct ctlpos cp;
1211 ctlposinit(&cp, hwnd, 80, 3, 13);
1212 bartitle(&cp, "Basic options for your PuTTY session",
1213 IDC_TITLE_SESSION);
1214 if (dlgtype == 0) {
42ff6345 1215 beginbox(&cp, "Specify your connection by host name or IP address",
32874aea 1216 IDC_BOX_SESSION1);
1217 multiedit(&cp,
42ff6345 1218 "Host &Name (or IP address)",
1219 IDC_HOSTSTATIC, IDC_HOST, 75,
32874aea 1220 "&Port", IDC_PORTSTATIC, IDC_PORT, 25, NULL);
1221 if (backends[3].backend == NULL) {
1222 /* this is PuTTYtel, so only three protocols available */
4eeb7d09 1223 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 3,
32874aea 1224 "&Raw", IDC_PROTRAW,
1225 "&Telnet", IDC_PROTTELNET,
1226 "Rlog&in", IDC_PROTRLOGIN, NULL);
1227 } else {
1228 radioline(&cp, "Protocol:", IDC_PROTSTATIC, 4,
1229 "&Raw", IDC_PROTRAW,
1230 "&Telnet", IDC_PROTTELNET,
1231 "Rlog&in", IDC_PROTRLOGIN,
3ac9cd9f 1232#ifdef FWHACK
32874aea 1233 "SS&H/hack",
3ac9cd9f 1234#else
32874aea 1235 "SS&H",
3ac9cd9f 1236#endif
32874aea 1237 IDC_PROTSSH, NULL);
1238 }
1239 endbox(&cp);
1240 beginbox(&cp, "Load, save or delete a stored session",
1241 IDC_BOX_SESSION2);
1242 sesssaver(&cp, "Sav&ed Sessions",
1243 IDC_SESSSTATIC, IDC_SESSEDIT, IDC_SESSLIST,
1244 "&Load", IDC_SESSLOAD,
1245 "&Save", IDC_SESSSAVE, "&Delete", IDC_SESSDEL, NULL);
1246 endbox(&cp);
1247 }
1248 beginbox(&cp, NULL, IDC_BOX_SESSION3);
1249 radioline(&cp, "Close &window on exit:", IDC_CLOSEEXIT, 4,
1250 "Always", IDC_COEALWAYS,
1251 "Never", IDC_COENEVER,
1252 "Only on clean exit", IDC_COENORMAL, NULL);
1253 endbox(&cp);
3ac9cd9f 1254 }
1255
0965bee0 1256 if (panel == loggingpanelstart) {
32874aea 1257 /* The Logging panel. Accelerators used: [acgo] tplfwe */
1258 struct ctlpos cp;
1259 ctlposinit(&cp, hwnd, 80, 3, 13);
1260 bartitle(&cp, "Options controlling session logging",
1261 IDC_TITLE_LOGGING);
1262 beginbox(&cp, NULL, IDC_BOX_LOGGING1);
1263 radiobig(&cp,
1264 "Session logging:", IDC_LSTATSTATIC,
1265 "Logging &turned off completely", IDC_LSTATOFF,
1266 "Log &printable output only", IDC_LSTATASCII,
1267 "&Log all session output", IDC_LSTATRAW, NULL);
1268 editbutton(&cp, "Log &file name:",
1269 IDC_LGFSTATIC, IDC_LGFEDIT, "Bro&wse...",
1270 IDC_LGFBUTTON);
66ee282a 1271 statictext(&cp, "(Log file name can contain &&Y, &&M, &&D for date,"
1272 " &&T for time, and &&H for host name)", 2, IDC_LGFEXPLAIN);
32874aea 1273 radiobig(&cp,
1274 "What to do if the log file already &exists:",
1275 IDC_LSTATXIST, "Always overwrite it", IDC_LSTATXOVR,
1276 "Always append to the end of it", IDC_LSTATXAPN,
1277 "Ask the user every time", IDC_LSTATXASK, NULL);
1278 endbox(&cp);
0965bee0 1279 }
1280
3ac9cd9f 1281 if (panel == terminalpanelstart) {
32874aea 1282 /* The Terminal panel. Accelerators used: [acgo] wdlen hts */
1283 struct ctlpos cp;
1284 ctlposinit(&cp, hwnd, 80, 3, 13);
1285 bartitle(&cp, "Options controlling the terminal emulation",
1286 IDC_TITLE_TERMINAL);
1287 beginbox(&cp, "Set various terminal options", IDC_BOX_TERMINAL1);
1288 checkbox(&cp, "Auto &wrap mode initially on", IDC_WRAPMODE);
1289 checkbox(&cp, "&DEC Origin Mode initially on", IDC_DECOM);
1290 checkbox(&cp, "Implicit CR in every &LF", IDC_LFHASCR);
1291 checkbox(&cp, "Use background colour to &erase screen", IDC_BCE);
1292 checkbox(&cp, "Enable bli&nking text", IDC_BLINKTEXT);
1293 multiedit(&cp,
1294 "An&swerback to ^E:", IDC_ANSWERBACK,
1295 IDC_ANSWEREDIT, 100, NULL);
1296 endbox(&cp);
1297
1298 beginbox(&cp, "Line discipline options", IDC_BOX_TERMINAL2);
1299 radioline(&cp, "Local ec&ho:", IDC_ECHOSTATIC, 3,
1300 "Auto", IDC_ECHOBACKEND,
1301 "Force on", IDC_ECHOYES, "Force off", IDC_ECHONO, NULL);
1302 radioline(&cp, "Local line edi&ting:", IDC_EDITSTATIC, 3,
1303 "Auto", IDC_EDITBACKEND,
1304 "Force on", IDC_EDITYES, "Force off", IDC_EDITNO, NULL);
1305 endbox(&cp);
3ac9cd9f 1306 }
1307
156686ef 1308 if (panel == bellpanelstart) {
f8a28d1f 1309 /* The Bell panel. Accelerators used: [acgo] bdsm wit */
32874aea 1310 struct ctlpos cp;
1311 ctlposinit(&cp, hwnd, 80, 3, 13);
1312 bartitle(&cp, "Options controlling the terminal bell",
1313 IDC_TITLE_BELL);
1314 beginbox(&cp, "Set the style of bell", IDC_BOX_BELL1);
1315 radiobig(&cp,
1316 "Action to happen when a &bell occurs:", IDC_BELLSTATIC,
1317 "None (bell disabled)", IDC_BELL_DISABLED,
1318 "Play Windows Default Sound", IDC_BELL_DEFAULT,
1319 "Play a custom sound file", IDC_BELL_WAVEFILE,
1320 "Visual bell (flash window)", IDC_BELL_VISUAL, NULL);
03169ad0 1321 editbutton(&cp, "Custom sound file to play as a bell:",
1322 IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
1323 "Bro&wse...", IDC_BELL_WAVEBROWSE);
f8a28d1f 1324 radioline(&cp, "Taskbar/caption &indication on bell:",
1325 IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
1326 "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
1327 NULL);
32874aea 1328 endbox(&cp);
156686ef 1329 beginbox(&cp, "Control the bell overload behaviour",
1330 IDC_BOX_BELL2);
1331 checkbox(&cp, "Bell is temporarily &disabled when over-used",
1332 IDC_BELLOVL);
1333 staticedit(&cp, "Over-use means this &many bells...",
1334 IDC_BELLOVLNSTATIC, IDC_BELLOVLN, 20);
9f89f96e 1335 staticedit(&cp, "... in &this many seconds",
156686ef 1336 IDC_BELLOVLTSTATIC, IDC_BELLOVLT, 20);
32874aea 1337 statictext(&cp,
1338 "The bell is re-enabled after a few seconds of silence.",
66ee282a 1339 1, IDC_BELLOVLEXPLAIN);
32874aea 1340 staticedit(&cp, "Seconds of &silence required", IDC_BELLOVLSSTATIC,
1341 IDC_BELLOVLS, 20);
1342 endbox(&cp);
156686ef 1343 }
1344
3ac9cd9f 1345 if (panel == keyboardpanelstart) {
32874aea 1346 /* The Keyboard panel. Accelerators used: [acgo] bhf ruyntd */
1347 struct ctlpos cp;
1348 ctlposinit(&cp, hwnd, 80, 3, 13);
d0cadfcd 1349 bartitle(&cp, "Options controlling the effects of keys",
1350 IDC_TITLE_KEYBOARD);
32874aea 1351 beginbox(&cp, "Change the sequences sent by:", IDC_BOX_KEYBOARD1);
1352 radioline(&cp, "The &Backspace key", IDC_DELSTATIC, 2,
1353 "Control-H", IDC_DEL008,
1354 "Control-? (127)", IDC_DEL127, NULL);
1355 radioline(&cp, "The &Home and End keys", IDC_HOMESTATIC, 2,
1356 "Standard", IDC_HOMETILDE, "rxvt", IDC_HOMERXVT, NULL);
1357 radioline(&cp, "The &Function keys and keypad", IDC_FUNCSTATIC, 3,
1358 "ESC[n~", IDC_FUNCTILDE,
1359 "Linux", IDC_FUNCLINUX,
1360 "Xterm R6", IDC_FUNCXTERM,
f37caa11 1361 "VT400", IDC_FUNCVT400,
32874aea 1362 "VT100+", IDC_FUNCVT100P, "SCO", IDC_FUNCSCO, NULL);
1363 endbox(&cp);
1364 beginbox(&cp, "Application keypad settings:", IDC_BOX_KEYBOARD2);
1365 checkbox(&cp,
1366 "Application c&ursor keys totally disabled",
1367 IDC_NOAPPLICC);
1368 radioline(&cp, "Initial state of cu&rsor keys:", IDC_CURSTATIC, 2,
1369 "Normal", IDC_CURNORMAL,
1370 "Application", IDC_CURAPPLIC, NULL);
1371 checkbox(&cp,
1372 "Application ke&ypad keys totally disabled",
1373 IDC_NOAPPLICK);
1374 radioline(&cp, "Initial state of &numeric keypad:", IDC_KPSTATIC,
1375 3, "Normal", IDC_KPNORMAL, "Application", IDC_KPAPPLIC,
1376 "NetHack", IDC_KPNH, NULL);
1377 endbox(&cp);
1378 beginbox(&cp, "Enable extra keyboard features:",
1379 IDC_BOX_KEYBOARD3);
1380 checkbox(&cp, "AltGr ac&ts as Compose key", IDC_COMPOSEKEY);
1381 checkbox(&cp, "Control-Alt is &different from AltGr",
1382 IDC_CTRLALTKEYS);
1383 endbox(&cp);
3ac9cd9f 1384 }
1385
1386 if (panel == windowpanelstart) {
d0cadfcd 1387 /* The Window panel. Accelerators used: [acgo] rmz sdikp */
32874aea 1388 struct ctlpos cp;
1389 ctlposinit(&cp, hwnd, 80, 3, 13);
1390 bartitle(&cp, "Options controlling PuTTY's window",
1391 IDC_TITLE_WINDOW);
1392 beginbox(&cp, "Set the size of the window", IDC_BOX_WINDOW1);
1393 multiedit(&cp,
1394 "&Rows", IDC_ROWSSTATIC, IDC_ROWSEDIT, 50,
1395 "Colu&mns", IDC_COLSSTATIC, IDC_COLSEDIT, 50, NULL);
d0cadfcd 1396 radiobig(&cp, "When window is resi&zed:", IDC_RESIZESTATIC,
1397 "Change the number of rows and columns", IDC_RESIZETERM,
1398 "Change the size of the font", IDC_RESIZEFONT,
1399 "Change font size only when maximised", IDC_RESIZEEITHER,
1400 "Forbid resizing completely", IDC_RESIZENONE, NULL);
32874aea 1401 endbox(&cp);
1402 beginbox(&cp, "Control the scrollback in the window",
1403 IDC_BOX_WINDOW2);
1404 staticedit(&cp, "Lines of &scrollback",
1405 IDC_SAVESTATIC, IDC_SAVEEDIT, 50);
1406 checkbox(&cp, "&Display scrollbar", IDC_SCROLLBAR);
a401e5f3 1407 checkbox(&cp, "D&isplay scrollbar in full screen mode", IDC_SCROLLBARFULLSCREEN);
32874aea 1408 checkbox(&cp, "Reset scrollback on &keypress", IDC_SCROLLKEY);
1409 checkbox(&cp, "Reset scrollback on dis&play activity",
1410 IDC_SCROLLDISP);
1411 endbox(&cp);
3ac9cd9f 1412 }
1413
1414 if (panel == appearancepanelstart) {
32874aea 1415 /* The Appearance panel. Accelerators used: [acgo] luvb h ti p s */
1416 struct ctlpos cp;
1417 ctlposinit(&cp, hwnd, 80, 3, 13);
d0cadfcd 1418 bartitle(&cp, "Configure the appearance of PuTTY's window",
1419 IDC_TITLE_APPEARANCE);
32874aea 1420 beginbox(&cp, "Adjust the use of the cursor", IDC_BOX_APPEARANCE1);
1421 radioline(&cp, "Cursor appearance:", IDC_CURSORSTATIC, 3,
1422 "B&lock", IDC_CURBLOCK,
1423 "&Underline", IDC_CURUNDER,
1424 "&Vertical line", IDC_CURVERT, NULL);
1425 checkbox(&cp, "Cursor &blinks", IDC_BLINKCUR);
1426 endbox(&cp);
1427 beginbox(&cp, "Set the font used in the terminal window",
1428 IDC_BOX_APPEARANCE2);
1429 staticbtn(&cp, "", IDC_FONTSTATIC, "C&hange...", IDC_CHOOSEFONT);
1430 endbox(&cp);
1431 beginbox(&cp, "Adjust the use of the window title",
1432 IDC_BOX_APPEARANCE3);
1433 multiedit(&cp,
1434 "Window &title:", IDC_WINTITLE, IDC_WINEDIT, 100, NULL);
1435 checkbox(&cp, "Avoid ever using &icon title", IDC_WINNAME);
1436 endbox(&cp);
1437 beginbox(&cp, "Adjust the use of the mouse pointer",
1438 IDC_BOX_APPEARANCE4);
1439 checkbox(&cp, "Hide mouse &pointer when typing in window",
1440 IDC_HIDEMOUSE);
1441 endbox(&cp);
1442 beginbox(&cp, "Adjust the window border", IDC_BOX_APPEARANCE5);
1443 checkbox(&cp, "&Sunken-edge border (slightly thicker)",
1444 IDC_SUNKENEDGE);
5a73255e 1445 staticedit(&cp, "Gap between text and window edge",
1446 IDC_WINBSTATIC, IDC_WINBEDIT, 20);
32874aea 1447 endbox(&cp);
3ac9cd9f 1448 }
1449
d0cadfcd 1450 if (panel == behaviourpanelstart) {
1451 /* The Behaviour panel. Accelerators used: [acgo] w4yltf */
1452 struct ctlpos cp;
1453 ctlposinit(&cp, hwnd, 80, 3, 13);
1454 bartitle(&cp, "Configure the behaviour of PuTTY's window",
1455 IDC_TITLE_WINDOW);
1456 beginbox(&cp, NULL, IDC_BOX_BEHAVIOUR1);
1457 checkbox(&cp, "&Warn before closing window", IDC_CLOSEWARN);
1458 checkbox(&cp, "Window closes on ALT-F&4", IDC_ALTF4);
1459 checkbox(&cp, "S&ystem menu appears on ALT-Space", IDC_ALTSPACE);
1460 checkbox(&cp, "System menu appears on A&LT alone", IDC_ALTONLY);
1461 checkbox(&cp, "Ensure window is always on &top", IDC_ALWAYSONTOP);
1462 checkbox(&cp, "&Full screen on Alt-Enter", IDC_FULLSCREENONALTENTER);
1463 endbox(&cp);
1464 }
1465
3ac9cd9f 1466 if (panel == translationpanelstart) {
a9c02454 1467 /* The Translation panel. Accelerators used: [acgo] rxbepus */
32874aea 1468 struct ctlpos cp;
1469 ctlposinit(&cp, hwnd, 80, 3, 13);
1470 bartitle(&cp, "Options controlling character set translation",
1471 IDC_TITLE_TRANSLATION);
b682f470 1472 beginbox(&cp, "Character set translation on received data",
a9c02454 1473 IDC_BOX_TRANSLATION1);
8f57d753 1474 combobox(&cp, "&Received data assumed to be in which character set:",
b682f470 1475 IDC_CODEPAGESTATIC, IDC_CODEPAGE);
1476 endbox(&cp);
a9c02454 1477 beginbox(&cp, "Enable character set translation on input data",
1478 IDC_BOX_TRANSLATION2);
acb796a2 1479 checkbox(&cp, "Cap&s Lock acts as Cyrillic switch",
a9c02454 1480 IDC_CAPSLOCKCYR);
1481 endbox(&cp);
32874aea 1482 beginbox(&cp, "Adjust how PuTTY displays line drawing characters",
a9c02454 1483 IDC_BOX_TRANSLATION3);
32874aea 1484 radiobig(&cp,
1485 "Handling of line drawing characters:", IDC_VTSTATIC,
1486 "Font has &XWindows encoding", IDC_VTXWINDOWS,
1487 "Use font in &both ANSI and OEM modes", IDC_VTOEMANSI,
1488 "Use font in O&EM mode only", IDC_VTOEMONLY,
1489 "&Poor man's line drawing (" "+" ", " "-" " and " "|" ")",
4eeb7d09 1490 IDC_VTPOORMAN, "&Unicode mode", IDC_VTUNICODE, NULL);
32874aea 1491 endbox(&cp);
3ac9cd9f 1492 }
1493
1494 if (panel == selectionpanelstart) {
a7419ea4 1495 /* The Selection panel. Accelerators used: [acgo] df wxp hst nr */
32874aea 1496 struct ctlpos cp;
1497 ctlposinit(&cp, hwnd, 80, 3, 13);
1498 bartitle(&cp, "Options controlling copy and paste",
1499 IDC_TITLE_SELECTION);
1500 beginbox(&cp, "Translation of pasted characters",
1501 IDC_BOX_SELECTION1);
1502 checkbox(&cp,
1503 "&Don't translate line drawing chars into +, - and |",
1504 IDC_RAWCNP);
a7419ea4 1505 checkbox(&cp,
1506 "Paste to clipboard in RT&F as well as plain text",
1507 IDC_RTFPASTE);
32874aea 1508 endbox(&cp);
1509 beginbox(&cp, "Control which mouse button does which thing",
1510 IDC_BOX_SELECTION2);
1511 radiobig(&cp, "Action of mouse buttons:", IDC_MBSTATIC,
1512 "&Windows (Right pastes, Middle extends)", IDC_MBWINDOWS,
1513 "&xterm (Right extends, Middle pastes)", IDC_MBXTERM,
1514 NULL);
b90840c3 1515 checkbox(&cp,
1516 "Shift overrides a&pplication's use of mouse",
1517 IDC_MOUSEOVERRIDE);
6908fed7 1518 radioline(&cp,
1519 "Default selection mode (Alt+drag does the other one):",
1520 IDC_SELTYPESTATIC, 2,
1521 "&Normal", IDC_SELTYPELEX,
1522 "&Rectangular block", IDC_SELTYPERECT, NULL);
32874aea 1523 endbox(&cp);
1524 beginbox(&cp, "Control the select-one-word-at-a-time mode",
1525 IDC_BOX_SELECTION3);
1526 charclass(&cp, "C&haracter classes:", IDC_CCSTATIC, IDC_CCLIST,
1527 "&Set", IDC_CCSET, IDC_CCEDIT,
1528 "&to class", IDC_CCSTATIC2);
1529 endbox(&cp);
3ac9cd9f 1530 }
1531
1532 if (panel == colourspanelstart) {
32874aea 1533 /* The Colours panel. Accelerators used: [acgo] blum */
1534 struct ctlpos cp;
1535 ctlposinit(&cp, hwnd, 80, 3, 13);
1536 bartitle(&cp, "Options controlling use of colours",
1537 IDC_TITLE_COLOURS);
1538 beginbox(&cp, "General options for colour usage",
1539 IDC_BOX_COLOURS1);
1540 checkbox(&cp, "&Bolded text is a different colour",
1541 IDC_BOLDCOLOUR);
1542 checkbox(&cp, "Attempt to use &logical palettes", IDC_PALETTE);
1543 endbox(&cp);
1544 beginbox(&cp, "Adjust the precise colours PuTTY displays",
1545 IDC_BOX_COLOURS2);
1546 colouredit(&cp, "Select a colo&ur and then click to modify it:",
1547 IDC_COLOURSTATIC, IDC_COLOURLIST,
1548 "&Modify...", IDC_CHANGE,
1549 "Red:", IDC_RSTATIC, IDC_RVALUE,
1550 "Green:", IDC_GSTATIC, IDC_GVALUE,
1551 "Blue:", IDC_BSTATIC, IDC_BVALUE, NULL);
1552 endbox(&cp);
3ac9cd9f 1553 }
1554
1555 if (panel == connectionpanelstart) {
2184a5d9 1556 /* The Connection panel. Accelerators used: [acgo] tukn */
32874aea 1557 struct ctlpos cp;
1558 ctlposinit(&cp, hwnd, 80, 3, 13);
1559 bartitle(&cp, "Options controlling the connection",
1560 IDC_TITLE_CONNECTION);
1561 if (dlgtype == 0) {
1562 beginbox(&cp, "Data to send to the server",
1563 IDC_BOX_CONNECTION1);
1564 staticedit(&cp, "Terminal-&type string", IDC_TTSTATIC,
1565 IDC_TTEDIT, 50);
1566 staticedit(&cp, "Auto-login &username", IDC_LOGSTATIC,
1567 IDC_LOGEDIT, 50);
1568 endbox(&cp);
a5f3e637 1569 } else {
1570 beginbox(&cp, "Adjust telnet session.", IDC_BOX_CONNECTION1);
1571 checkbox(&cp, "Keyboard sends telnet Backspace and Interrupt",
1572 IDC_TELNETKEY);
1573 endbox(&cp);
32874aea 1574 }
1575 beginbox(&cp, "Sending of null packets to keep session active",
1576 IDC_BOX_CONNECTION2);
1577 staticedit(&cp, "Seconds between &keepalives (0 to turn off)",
1578 IDC_PINGSTATIC, IDC_PINGEDIT, 20);
1579 endbox(&cp);
2184a5d9 1580 if (dlgtype == 0) {
1581 beginbox(&cp, "Low-level TCP connection options",
1582 IDC_BOX_CONNECTION3);
1583 checkbox(&cp, "Disable &Nagle's algorithm (TCP_NODELAY option)",
1584 IDC_NODELAY);
1585 endbox(&cp);
1586 }
3ac9cd9f 1587 }
1588
1589 if (panel == telnetpanelstart) {
a5f3e637 1590 /* The Telnet panel. Accelerators used: [acgo] svldr bftk */
32874aea 1591 struct ctlpos cp;
1592 ctlposinit(&cp, hwnd, 80, 3, 13);
1593 if (dlgtype == 0) {
1594 bartitle(&cp, "Options controlling Telnet connections",
1595 IDC_TITLE_TELNET);
1596 beginbox(&cp, "Data to send to the server", IDC_BOX_TELNET1);
1597 staticedit(&cp, "Terminal-&speed string", IDC_TSSTATIC,
1598 IDC_TSEDIT, 50);
1599 envsetter(&cp, "Environment variables:", IDC_ENVSTATIC,
1600 "&Variable", IDC_VARSTATIC, IDC_VAREDIT, "Va&lue",
1601 IDC_VALSTATIC, IDC_VALEDIT, IDC_ENVLIST, "A&dd",
1602 IDC_ENVADD, "&Remove", IDC_ENVREMOVE);
1603 endbox(&cp);
1604 beginbox(&cp, "Telnet protocol adjustments", IDC_BOX_TELNET2);
1605 radioline(&cp, "Handling of OLD_ENVIRON ambiguity:",
1606 IDC_EMSTATIC, 2, "&BSD (commonplace)", IDC_EMBSD,
1607 "R&FC 1408 (unusual)", IDC_EMRFC, NULL);
8faa456c 1608 radioline(&cp, "&Telnet negotiation mode:", IDC_ACTSTATIC, 2,
1609 "Passive", IDC_TPASSIVE, "Active",
1610 IDC_TACTIVE, NULL);
a5f3e637 1611 checkbox(&cp, "&Keyboard sends telnet Backspace and Interrupt",
1612 IDC_TELNETKEY);
32874aea 1613 endbox(&cp);
1614 }
3ac9cd9f 1615 }
1616
1617 if (panel == rloginpanelstart) {
32874aea 1618 /* The Rlogin panel. Accelerators used: [acgo] sl */
1619 struct ctlpos cp;
1620 ctlposinit(&cp, hwnd, 80, 3, 13);
1621 if (dlgtype == 0) {
1622 bartitle(&cp, "Options controlling Rlogin connections",
1623 IDC_TITLE_RLOGIN);
1624 beginbox(&cp, "Data to send to the server", IDC_BOX_RLOGIN1);
1625 staticedit(&cp, "Terminal-&speed string", IDC_R_TSSTATIC,
1626 IDC_R_TSEDIT, 50);
1627 staticedit(&cp, "&Local username:", IDC_RLLUSERSTATIC,
1628 IDC_RLLUSEREDIT, 50);
1629 endbox(&cp);
1630 }
3ac9cd9f 1631 }
1632
1633 if (panel == sshpanelstart) {
cb4d4768 1634 /* The SSH panel. Accelerators used: [acgo] r pe12i sd */
32874aea 1635 struct ctlpos cp;
1636 ctlposinit(&cp, hwnd, 80, 3, 13);
1637 if (dlgtype == 0) {
1638 bartitle(&cp, "Options controlling SSH connections",
1639 IDC_TITLE_SSH);
1640 beginbox(&cp, "Data to send to the server", IDC_BOX_SSH1);
1641 multiedit(&cp,
1642 "&Remote command:", IDC_CMDSTATIC, IDC_CMDEDIT, 100,
1643 NULL);
1644 endbox(&cp);
ca20bfcf 1645 beginbox(&cp, "Protocol options", IDC_BOX_SSH2);
32874aea 1646 checkbox(&cp, "Don't allocate a &pseudo-terminal", IDC_NOPTY);
1647 checkbox(&cp, "Enable compr&ession", IDC_COMPRESS);
1648 radioline(&cp, "Preferred SSH protocol version:",
1649 IDC_SSHPROTSTATIC, 2,
1650 "&1", IDC_SSHPROT1, "&2", IDC_SSHPROT2, NULL);
32874aea 1651 checkbox(&cp, "&Imitate SSH 2 MAC bug in commercial <= v2.3.x",
1652 IDC_BUGGYMAC);
1653 endbox(&cp);
ca20bfcf 1654 beginbox(&cp, "Encryption options", IDC_BOX_SSH3);
1655 prefslist(&cipherlist, &cp, "Encryption cipher &selection policy:",
1656 IDC_CIPHERSTATIC2, IDC_CIPHERLIST, IDC_CIPHERUP,
1657 IDC_CIPHERDN);
cb4d4768 1658 checkbox(&cp, "Enable non-standard use of single-&DES in SSH 2",
1659 IDC_SSH2DES);
ca20bfcf 1660 endbox(&cp);
1661 }
1662 }
1663
1664 if (panel == sshauthpanelstart) {
f091e308 1665 /* The SSH authentication panel. Accelerators used: [acgo] m fkiw */
ca20bfcf 1666 struct ctlpos cp;
1667 ctlposinit(&cp, hwnd, 80, 3, 13);
1668 if (dlgtype == 0) {
1669 bartitle(&cp, "Options controlling SSH authentication",
1670 IDC_TITLE_SSHAUTH);
1671 beginbox(&cp, "Authentication methods",
1672 IDC_BOX_SSHAUTH1);
f091e308 1673 checkbox(&cp, "Atte&mpt TIS or CryptoCard authentication (SSH1)",
ca20bfcf 1674 IDC_AUTHTIS);
f091e308 1675 checkbox(&cp, "Attempt \"keyboard-&interactive\" authentication"
1676 " (SSH2)", IDC_AUTHKI);
ca20bfcf 1677 endbox(&cp);
1678 beginbox(&cp, "Authentication parameters",
1679 IDC_BOX_SSHAUTH2);
1680 checkbox(&cp, "Allow agent &forwarding", IDC_AGENTFWD);
5bb641e1 1681 checkbox(&cp, "Allow attempted changes of &username in SSH2",
1682 IDC_CHANGEUSER);
ca20bfcf 1683 editbutton(&cp, "Private &key file for authentication:",
1684 IDC_PKSTATIC, IDC_PKEDIT, "Bro&wse...",
1685 IDC_PKBUTTON);
1686 endbox(&cp);
32874aea 1687 }
3ac9cd9f 1688 }
1689
1690 if (panel == tunnelspanelstart) {
d74d141c 1691 /* The Tunnels panel. Accelerators used: [acgo] deilmrstx */
32874aea 1692 struct ctlpos cp;
1693 ctlposinit(&cp, hwnd, 80, 3, 13);
1694 if (dlgtype == 0) {
1695 bartitle(&cp, "Options controlling SSH tunnelling",
1696 IDC_TITLE_TUNNELS);
d74d141c 1697 beginbox(&cp, "X11 forwarding", IDC_BOX_TUNNELS1);
32874aea 1698 checkbox(&cp, "&Enable X11 forwarding", IDC_X11_FORWARD);
1699 multiedit(&cp, "&X display location", IDC_X11_DISPSTATIC,
1700 IDC_X11_DISPLAY, 50, NULL);
1701 endbox(&cp);
d74d141c 1702 beginbox(&cp, "Port forwarding", IDC_BOX_TUNNELS2);
1703 checkbox(&cp, "Local ports accept connections from o&ther hosts", IDC_LPORT_ALL);
1704 staticbtn(&cp, "Forwarded ports:", IDC_PFWDSTATIC,
1705 "&Remove", IDC_PFWDREMOVE);
1706 fwdsetter(&cp, IDC_PFWDLIST,
1707 "Add new forwarded port:", IDC_PFWDSTATIC2,
1708 "&Source port", IDC_SPORTSTATIC, IDC_SPORTEDIT,
1709 "Dest&ination", IDC_DPORTSTATIC, IDC_DPORTEDIT,
1710 "A&dd", IDC_PFWDADD);
1711 bareradioline(&cp, 2,
1712 "&Local", IDC_PFWDLOCAL, "Re&mote", IDC_PFWDREMOTE, NULL);
1713 endbox(&cp);
1714
32874aea 1715 }
3ac9cd9f 1716 }
1717}
1718
c8d7378d 1719/*
1720 * Helper function to load the session selected in SESSLIST
1721 * if any, as this is done in more than one place in
1722 * GenericMainDlgProc(). 0 => failure.
1723 */
1724static int load_selected_session(HWND hwnd)
1725{
1726 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
1727 LB_GETCURSEL, 0, 0);
1728 int isdef;
1729 if (n == LB_ERR) {
1730 MessageBeep(0);
1731 return 0;
1732 }
1733 isdef = !strcmp(sessions[n], "Default Settings");
1734 load_settings(sessions[n], !isdef, &cfg);
1735 init_dlg_ctrls(hwnd, TRUE);
1736 if (!isdef)
1737 SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
1738 else
1739 SetDlgItemText(hwnd, IDC_SESSEDIT, "");
1740 /* Restore the selection, which will have been clobbered by
1741 * SESSEDIT handling. */
1742 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
1743 return 1;
1744}
1745
3ac9cd9f 1746/*
1747 * This function is the configuration box.
c96a8fef 1748 */
32874aea 1749static int GenericMainDlgProc(HWND hwnd, UINT msg,
1750 WPARAM wParam, LPARAM lParam, int dlgtype)
1751{
927d4fc5 1752 HWND hw, treeview;
1753 struct treeview_faff tvfaff;
1754 HTREEITEM hsession;
c96a8fef 1755 OPENFILENAME of;
1756 char filename[sizeof(cfg.keyfile)];
1757 CHOOSEFONT cf;
1758 LOGFONT lf;
1759 char fontstatic[256];
b278b14a 1760 char portname[32];
32874aea 1761 struct servent *service;
374330e2 1762 int i;
ca20bfcf 1763 static UINT draglistmsg = WM_NULL;
374330e2 1764
1765 switch (msg) {
1766 case WM_INITDIALOG:
a094ae43 1767 readytogo = 0;
c96a8fef 1768 SetWindowLong(hwnd, GWL_USERDATA, 0);
70133c0e 1769 if (help_path)
1770 SetWindowLong(hwnd, GWL_EXSTYLE,
1771 GetWindowLong(hwnd, GWL_EXSTYLE) | WS_EX_CONTEXTHELP);
1772 else {
1773 HWND item = GetDlgItem(hwnd, IDC_HELPBTN);
1774 if (item)
1775 DestroyWindow(item);
1776 }
1777 requested_help = FALSE;
648947d4 1778 SendMessage(hwnd, WM_SETICON, (WPARAM) ICON_BIG,
1779 (LPARAM) LoadIcon(hinst, MAKEINTRESOURCE(IDI_CFGICON)));
c96a8fef 1780 /*
1781 * Centre the window.
1782 */
1783 { /* centre the window */
1784 RECT rs, rd;
1785
1786 hw = GetDesktopWindow();
32874aea 1787 if (GetWindowRect(hw, &rs) && GetWindowRect(hwnd, &rd))
1788 MoveWindow(hwnd,
1789 (rs.right + rs.left + rd.left - rd.right) / 2,
1790 (rs.bottom + rs.top + rd.top - rd.bottom) / 2,
1791 rd.right - rd.left, rd.bottom - rd.top, TRUE);
c96a8fef 1792 }
1793
1794 /*
927d4fc5 1795 * Create the tree view.
c96a8fef 1796 */
32874aea 1797 {
1798 RECT r;
c96a8fef 1799 WPARAM font;
32874aea 1800 HWND tvstatic;
1801
1802 r.left = 3;
1803 r.right = r.left + 75;
1804 r.top = 3;
1805 r.bottom = r.top + 10;
1806 MapDialogRect(hwnd, &r);
1807 tvstatic = CreateWindowEx(0, "STATIC", "Cate&gory:",
1808 WS_CHILD | WS_VISIBLE,
1809 r.left, r.top,
1810 r.right - r.left, r.bottom - r.top,
1811 hwnd, (HMENU) IDCX_TVSTATIC, hinst,
1812 NULL);
c96a8fef 1813 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
927d4fc5 1814 SendMessage(tvstatic, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
1815
32874aea 1816 r.left = 3;
1817 r.right = r.left + 75;
1818 r.top = 13;
a401e5f3 1819 r.bottom = r.top + 219;
32874aea 1820 MapDialogRect(hwnd, &r);
1821 treeview = CreateWindowEx(WS_EX_CLIENTEDGE, WC_TREEVIEW, "",
1822 WS_CHILD | WS_VISIBLE |
1823 WS_TABSTOP | TVS_HASLINES |
1824 TVS_DISABLEDRAGDROP | TVS_HASBUTTONS
1825 | TVS_LINESATROOT |
1826 TVS_SHOWSELALWAYS, r.left, r.top,
1827 r.right - r.left, r.bottom - r.top,
1828 hwnd, (HMENU) IDCX_TREEVIEW, hinst,
1829 NULL);
927d4fc5 1830 font = SendMessage(hwnd, WM_GETFONT, 0, 0);
1831 SendMessage(treeview, WM_SETFONT, font, MAKELPARAM(TRUE, 0));
32874aea 1832 tvfaff.treeview = treeview;
1833 memset(tvfaff.lastat, 0, sizeof(tvfaff.lastat));
1834 }
c96a8fef 1835
1836 /*
3ac9cd9f 1837 * Set up the tree view contents.
c96a8fef 1838 */
32874aea 1839 hsession = treeview_insert(&tvfaff, 0, "Session");
1840 treeview_insert(&tvfaff, 1, "Logging");
1841 treeview_insert(&tvfaff, 0, "Terminal");
1842 treeview_insert(&tvfaff, 1, "Keyboard");
1843 treeview_insert(&tvfaff, 1, "Bell");
1844 treeview_insert(&tvfaff, 0, "Window");
1845 treeview_insert(&tvfaff, 1, "Appearance");
d0cadfcd 1846 treeview_insert(&tvfaff, 1, "Behaviour");
32874aea 1847 treeview_insert(&tvfaff, 1, "Translation");
1848 treeview_insert(&tvfaff, 1, "Selection");
1849 treeview_insert(&tvfaff, 1, "Colours");
1850 treeview_insert(&tvfaff, 0, "Connection");
1851 if (dlgtype == 0) {
1852 treeview_insert(&tvfaff, 1, "Telnet");
1853 treeview_insert(&tvfaff, 1, "Rlogin");
1854 if (backends[3].backend != NULL) {
1855 treeview_insert(&tvfaff, 1, "SSH");
ca20bfcf 1856 /* XXX long name is ugly */
1857 /* XXX make it closed by default? */
1858 treeview_insert(&tvfaff, 2, "Auth");
32874aea 1859 treeview_insert(&tvfaff, 2, "Tunnels");
1860 }
1861 }
1862
1863 /*
1864 * Put the treeview selection on to the Session panel. This
1865 * should also cause creation of the relevant controls.
1866 */
1867 TreeView_SelectItem(treeview, hsession);
1868
1869 /*
1870 * Set focus into the first available control.
1871 */
1872 {
1873 HWND ctl;
1874 ctl = GetDlgItem(hwnd, IDC_HOST);
1875 if (!ctl)
1876 ctl = GetDlgItem(hwnd, IDC_CLOSEEXIT);
1877 SetFocus(ctl);
1878 }
c96a8fef 1879
1880 SetWindowLong(hwnd, GWL_USERDATA, 1);
dc35b97d 1881 sesslist_has_focus = 0;
c96a8fef 1882 return 0;
1cd246bb 1883 case WM_LBUTTONUP:
32874aea 1884 /*
1885 * Button release should trigger WM_OK if there was a
1886 * previous double click on the session list.
1887 */
1888 ReleaseCapture();
1889 if (readytogo)
1890 SendMessage(hwnd, WM_COMMAND, IDOK, 0);
1891 break;
c96a8fef 1892 case WM_NOTIFY:
927d4fc5 1893 if (LOWORD(wParam) == IDCX_TREEVIEW &&
32874aea 1894 ((LPNMHDR) lParam)->code == TVN_SELCHANGED) {
1895 HTREEITEM i =
1896 TreeView_GetSelection(((LPNMHDR) lParam)->hwndFrom);
927d4fc5 1897 TVITEM item;
32874aea 1898 int j;
c96a8fef 1899 char buffer[64];
78a79d97 1900
1901 SendMessage (hwnd, WM_SETREDRAW, FALSE, 0);
1902
32874aea 1903 item.hItem = i;
c96a8fef 1904 item.pszText = buffer;
1905 item.cchTextMax = sizeof(buffer);
927d4fc5 1906 item.mask = TVIF_TEXT;
32874aea 1907 TreeView_GetItem(((LPNMHDR) lParam)->hwndFrom, &item);
3ac9cd9f 1908 for (j = controlstartvalue; j < controlendvalue; j++) {
32874aea 1909 HWND item = GetDlgItem(hwnd, j);
1910 if (item)
1911 DestroyWindow(item);
1912 }
927d4fc5 1913 if (!strcmp(buffer, "Session"))
3ac9cd9f 1914 create_controls(hwnd, dlgtype, sessionpanelstart);
0965bee0 1915 if (!strcmp(buffer, "Logging"))
1916 create_controls(hwnd, dlgtype, loggingpanelstart);
c96a8fef 1917 if (!strcmp(buffer, "Keyboard"))
3ac9cd9f 1918 create_controls(hwnd, dlgtype, keyboardpanelstart);
c96a8fef 1919 if (!strcmp(buffer, "Terminal"))
3ac9cd9f 1920 create_controls(hwnd, dlgtype, terminalpanelstart);
156686ef 1921 if (!strcmp(buffer, "Bell"))
1922 create_controls(hwnd, dlgtype, bellpanelstart);
c96a8fef 1923 if (!strcmp(buffer, "Window"))
3ac9cd9f 1924 create_controls(hwnd, dlgtype, windowpanelstart);
4c4f2716 1925 if (!strcmp(buffer, "Appearance"))
3ac9cd9f 1926 create_controls(hwnd, dlgtype, appearancepanelstart);
d0cadfcd 1927 if (!strcmp(buffer, "Behaviour"))
1928 create_controls(hwnd, dlgtype, behaviourpanelstart);
9c964e85 1929 if (!strcmp(buffer, "Tunnels"))
3ac9cd9f 1930 create_controls(hwnd, dlgtype, tunnelspanelstart);
927d4fc5 1931 if (!strcmp(buffer, "Connection"))
3ac9cd9f 1932 create_controls(hwnd, dlgtype, connectionpanelstart);
c96a8fef 1933 if (!strcmp(buffer, "Telnet"))
3ac9cd9f 1934 create_controls(hwnd, dlgtype, telnetpanelstart);
c91409da 1935 if (!strcmp(buffer, "Rlogin"))
3ac9cd9f 1936 create_controls(hwnd, dlgtype, rloginpanelstart);
c96a8fef 1937 if (!strcmp(buffer, "SSH"))
3ac9cd9f 1938 create_controls(hwnd, dlgtype, sshpanelstart);
ca20bfcf 1939 if (!strcmp(buffer, "Auth"))
1940 create_controls(hwnd, dlgtype, sshauthpanelstart);
c96a8fef 1941 if (!strcmp(buffer, "Selection"))
3ac9cd9f 1942 create_controls(hwnd, dlgtype, selectionpanelstart);
c96a8fef 1943 if (!strcmp(buffer, "Colours"))
3ac9cd9f 1944 create_controls(hwnd, dlgtype, colourspanelstart);
c96a8fef 1945 if (!strcmp(buffer, "Translation"))
3ac9cd9f 1946 create_controls(hwnd, dlgtype, translationpanelstart);
1947
c8d7378d 1948 init_dlg_ctrls(hwnd, FALSE);
78a79d97 1949
1950 SendMessage (hwnd, WM_SETREDRAW, TRUE, 0);
1951 InvalidateRect (hwnd, NULL, TRUE);
c96a8fef 1952
32874aea 1953 SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
c96a8fef 1954 return 0;
1955 }
1956 break;
374330e2 1957 case WM_COMMAND:
c96a8fef 1958 /*
1959 * Only process WM_COMMAND once the dialog is fully formed.
1960 */
32874aea 1961 if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
1962 switch (LOWORD(wParam)) {
1963 case IDOK:
c8d7378d 1964 /* Behaviour of the "Open" button is different if the
1965 * session list has focus, *unless* the user just
1966 * double-clicked... */
1967 if (sesslist_has_focus && !readytogo) {
1968 if (!load_selected_session(hwnd)) {
1969 MessageBeep(0);
1970 return 0;
1971 }
1972 }
1973 /* If at this point we have a valid session, go! */
70133c0e 1974 if (*cfg.host) {
1975 if (requested_help) {
1976 WinHelp(hwnd, help_path, HELP_QUIT, 0);
1977 requested_help = FALSE;
1978 }
32874aea 1979 EndDialog(hwnd, 1);
70133c0e 1980 } else
32874aea 1981 MessageBeep(0);
1982 return 0;
70133c0e 1983 case IDC_HELPBTN:
1984 if (HIWORD(wParam) == BN_CLICKED ||
1985 HIWORD(wParam) == BN_DOUBLECLICKED) {
1986 if (help_path) {
1987 WinHelp(hwnd, help_path,
1988 help_has_contents ? HELP_FINDER : HELP_CONTENTS,
1989 0);
1990 requested_help = TRUE;
1991 }
1992 }
1993 break;
32874aea 1994 case IDCANCEL:
70133c0e 1995 if (requested_help) {
1996 WinHelp(hwnd, help_path, HELP_QUIT, 0);
1997 requested_help = FALSE;
1998 }
32874aea 1999 EndDialog(hwnd, 0);
2000 return 0;
2001 case IDC_PROTTELNET:
2002 case IDC_PROTRLOGIN:
2003 case IDC_PROTSSH:
2004 case IDC_PROTRAW:
2005 if (HIWORD(wParam) == BN_CLICKED ||
2006 HIWORD(wParam) == BN_DOUBLECLICKED) {
2007 int i = IsDlgButtonChecked(hwnd, IDC_PROTSSH);
2008 int j = IsDlgButtonChecked(hwnd, IDC_PROTTELNET);
2009 int k = IsDlgButtonChecked(hwnd, IDC_PROTRLOGIN);
2010 cfg.protocol =
2011 i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN :
2012 PROT_RAW;
2013 if ((cfg.protocol == PROT_SSH && cfg.port != 22)
2014 || (cfg.protocol == PROT_TELNET && cfg.port != 23)
2015 || (cfg.protocol == PROT_RLOGIN
2016 && cfg.port != 513)) {
2017 cfg.port = i ? 22 : j ? 23 : 513;
2018 SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE);
2019 }
374330e2 2020 }
32874aea 2021 break;
2022 case IDC_HOST:
2023 if (HIWORD(wParam) == EN_CHANGE)
2024 GetDlgItemText(hwnd, IDC_HOST, cfg.host,
2025 sizeof(cfg.host) - 1);
2026 break;
2027 case IDC_PORT:
2028 if (HIWORD(wParam) == EN_CHANGE) {
2029 GetDlgItemText(hwnd, IDC_PORT, portname, 31);
2030 if (isdigit(portname[0]))
2031 MyGetDlgItemInt(hwnd, IDC_PORT, &cfg.port);
2032 else {
2033 service = getservbyname(portname, NULL);
2034 if (service)
2035 cfg.port = ntohs(service->s_port);
2036 else
2037 cfg.port = 0;
2038 }
b278b14a 2039 }
32874aea 2040 break;
2041 case IDC_SESSEDIT:
2042 if (HIWORD(wParam) == EN_CHANGE) {
2043 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2044 (WPARAM) - 1, 0);
2045 GetDlgItemText(hwnd, IDC_SESSEDIT,
2046 savedsession, sizeof(savedsession) - 1);
2047 savedsession[sizeof(savedsession) - 1] = '\0';
2048 }
2049 break;
2050 case IDC_SESSSAVE:
2051 if (HIWORD(wParam) == BN_CLICKED ||
2052 HIWORD(wParam) == BN_DOUBLECLICKED) {
2053 /*
2054 * Save a session
2055 */
2056 char str[2048];
2057 GetDlgItemText(hwnd, IDC_SESSEDIT, str,
2058 sizeof(str) - 1);
2059 if (!*str) {
2060 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2061 LB_GETCURSEL, 0, 0);
2062 if (n == LB_ERR) {
2063 MessageBeep(0);
2064 break;
2065 }
2066 strcpy(str, sessions[n]);
2067 }
2068 save_settings(str, !!strcmp(str, "Default Settings"),
2069 &cfg);
2070 get_sesslist(FALSE);
2071 get_sesslist(TRUE);
c8d7378d 2072 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2073 FALSE, 0);
32874aea 2074 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2075 0, 0);
2076 for (i = 0; i < nsessions; i++)
2077 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2078 LB_ADDSTRING, 0,
2079 (LPARAM) (sessions[i]));
2080 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2081 (WPARAM) - 1, 0);
c8d7378d 2082 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2083 TRUE, 0);
2084 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2085 TRUE);
32874aea 2086 }
2087 break;
2088 case IDC_SESSLIST:
2089 case IDC_SESSLOAD:
c8d7378d 2090 if (LOWORD(wParam) == IDC_SESSLIST) {
2091 if (HIWORD(wParam) == LBN_SETFOCUS)
2092 sesslist_has_focus = 1;
2093 else if (HIWORD(wParam) == LBN_KILLFOCUS)
2094 sesslist_has_focus = 0;
2095 }
32874aea 2096 if (LOWORD(wParam) == IDC_SESSLOAD &&
2097 HIWORD(wParam) != BN_CLICKED &&
2098 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2099 if (LOWORD(wParam) == IDC_SESSLIST &&
2100 HIWORD(wParam) != LBN_DBLCLK) break;
c8d7378d 2101 /* Load the session selected in SESSLIST. */
2102 if (load_selected_session(hwnd) &&
2103 LOWORD(wParam) == IDC_SESSLIST) {
32874aea 2104 /*
2105 * A double-click on a saved session should
2106 * actually start the session, not just load it.
2107 * Unless it's Default Settings or some other
2108 * host-less set of saved settings.
2109 */
2110 if (*cfg.host) {
2111 readytogo = TRUE;
2112 SetCapture(hwnd);
2113 }
374330e2 2114 }
32874aea 2115 break;
2116 case IDC_SESSDEL:
2117 if (HIWORD(wParam) == BN_CLICKED ||
2118 HIWORD(wParam) == BN_DOUBLECLICKED) {
2119 int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
2120 LB_GETCURSEL, 0, 0);
2121 if (n == LB_ERR || n == 0) {
2122 MessageBeep(0);
2123 break;
2124 }
2125 del_settings(sessions[n]);
2126 get_sesslist(FALSE);
2127 get_sesslist(TRUE);
c8d7378d 2128 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2129 FALSE, 0);
32874aea 2130 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
2131 0, 0);
2132 for (i = 0; i < nsessions; i++)
2133 SendDlgItemMessage(hwnd, IDC_SESSLIST,
2134 LB_ADDSTRING, 0,
2135 (LPARAM) (sessions[i]));
2136 SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
2137 (WPARAM) - 1, 0);
c8d7378d 2138 SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
2139 TRUE, 0);
2140 InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
2141 TRUE);
374330e2 2142 }
32874aea 2143 case IDC_PINGEDIT:
2144 if (HIWORD(wParam) == EN_CHANGE)
2145 MyGetDlgItemInt(hwnd, IDC_PINGEDIT,
2146 &cfg.ping_interval);
2147 break;
2184a5d9 2148 case IDC_NODELAY:
2149 if (HIWORD(wParam) == BN_CLICKED ||
2150 HIWORD(wParam) == BN_DOUBLECLICKED)
2151 cfg.tcp_nodelay =
2152 IsDlgButtonChecked(hwnd, IDC_NODELAY);
2153 break;
32874aea 2154 case IDC_DEL008:
2155 case IDC_DEL127:
2156 if (HIWORD(wParam) == BN_CLICKED ||
2157 HIWORD(wParam) == BN_DOUBLECLICKED)
2158 cfg.bksp_is_delete =
2159 IsDlgButtonChecked(hwnd, IDC_DEL127);
2160 break;
2161 case IDC_HOMETILDE:
2162 case IDC_HOMERXVT:
2163 if (HIWORD(wParam) == BN_CLICKED ||
2164 HIWORD(wParam) == BN_DOUBLECLICKED)
2165 cfg.rxvt_homeend =
2166 IsDlgButtonChecked(hwnd, IDC_HOMERXVT);
2167 break;
2168 case IDC_FUNCTILDE:
2169 case IDC_FUNCLINUX:
2170 case IDC_FUNCXTERM:
2171 case IDC_FUNCVT400:
2172 case IDC_FUNCVT100P:
2173 case IDC_FUNCSCO:
2174 if (HIWORD(wParam) == BN_CLICKED ||
2175 HIWORD(wParam) == BN_DOUBLECLICKED)
2176 switch (LOWORD(wParam)) {
2177 case IDC_FUNCTILDE:
2178 cfg.funky_type = 0;
2179 break;
2180 case IDC_FUNCLINUX:
2181 cfg.funky_type = 1;
2182 break;
2183 case IDC_FUNCXTERM:
2184 cfg.funky_type = 2;
2185 break;
2186 case IDC_FUNCVT400:
2187 cfg.funky_type = 3;
2188 break;
2189 case IDC_FUNCVT100P:
2190 cfg.funky_type = 4;
2191 break;
2192 case IDC_FUNCSCO:
2193 cfg.funky_type = 5;
2194 break;
2195 }
2196 break;
2197 case IDC_KPNORMAL:
2198 case IDC_KPAPPLIC:
2199 if (HIWORD(wParam) == BN_CLICKED ||
2200 HIWORD(wParam) == BN_DOUBLECLICKED) {
2201 cfg.app_keypad =
2202 IsDlgButtonChecked(hwnd, IDC_KPAPPLIC);
2203 cfg.nethack_keypad = FALSE;
f37caa11 2204 }
32874aea 2205 break;
2206 case IDC_KPNH:
2207 if (HIWORD(wParam) == BN_CLICKED ||
2208 HIWORD(wParam) == BN_DOUBLECLICKED) {
2209 cfg.app_keypad = FALSE;
2210 cfg.nethack_keypad = TRUE;
2211 }
2212 break;
2213 case IDC_CURNORMAL:
2214 case IDC_CURAPPLIC:
2215 if (HIWORD(wParam) == BN_CLICKED ||
2216 HIWORD(wParam) == BN_DOUBLECLICKED)
2217 cfg.app_cursor =
2218 IsDlgButtonChecked(hwnd, IDC_CURAPPLIC);
2219 break;
2220 case IDC_NOAPPLICC:
2221 if (HIWORD(wParam) == BN_CLICKED ||
2222 HIWORD(wParam) == BN_DOUBLECLICKED)
2223 cfg.no_applic_c =
2224 IsDlgButtonChecked(hwnd, IDC_NOAPPLICC);
2225 break;
2226 case IDC_NOAPPLICK:
2227 if (HIWORD(wParam) == BN_CLICKED ||
2228 HIWORD(wParam) == BN_DOUBLECLICKED)
2229 cfg.no_applic_k =
2230 IsDlgButtonChecked(hwnd, IDC_NOAPPLICK);
2231 break;
2232 case IDC_ALTF4:
2233 if (HIWORD(wParam) == BN_CLICKED ||
2234 HIWORD(wParam) == BN_DOUBLECLICKED)
2235 cfg.alt_f4 = IsDlgButtonChecked(hwnd, IDC_ALTF4);
2236 break;
2237 case IDC_ALTSPACE:
2238 if (HIWORD(wParam) == BN_CLICKED ||
2239 HIWORD(wParam) == BN_DOUBLECLICKED)
2240 cfg.alt_space =
2241 IsDlgButtonChecked(hwnd, IDC_ALTSPACE);
2242 break;
2243 case IDC_ALTONLY:
2244 if (HIWORD(wParam) == BN_CLICKED ||
2245 HIWORD(wParam) == BN_DOUBLECLICKED)
2246 cfg.alt_only =
2247 IsDlgButtonChecked(hwnd, IDC_ALTONLY);
2248 break;
2249 case IDC_ECHOBACKEND:
2250 case IDC_ECHOYES:
2251 case IDC_ECHONO:
2252 if (HIWORD(wParam) == BN_CLICKED ||
2253 HIWORD(wParam) == BN_DOUBLECLICKED) {
2254 if (LOWORD(wParam) == IDC_ECHOBACKEND)
2255 cfg.localecho = LD_BACKEND;
2256 if (LOWORD(wParam) == IDC_ECHOYES)
2257 cfg.localecho = LD_YES;
2258 if (LOWORD(wParam) == IDC_ECHONO)
2259 cfg.localecho = LD_NO;
2260 }
2261 break;
2262 case IDC_EDITBACKEND:
2263 case IDC_EDITYES:
2264 case IDC_EDITNO:
2265 if (HIWORD(wParam) == BN_CLICKED ||
2266 HIWORD(wParam) == BN_DOUBLECLICKED) {
2267 if (LOWORD(wParam) == IDC_EDITBACKEND)
2268 cfg.localedit = LD_BACKEND;
2269 if (LOWORD(wParam) == IDC_EDITYES)
2270 cfg.localedit = LD_YES;
2271 if (LOWORD(wParam) == IDC_EDITNO)
2272 cfg.localedit = LD_NO;
2273 }
2274 break;
2275 case IDC_ANSWEREDIT:
2276 if (HIWORD(wParam) == EN_CHANGE)
2277 GetDlgItemText(hwnd, IDC_ANSWEREDIT, cfg.answerback,
2278 sizeof(cfg.answerback) - 1);
2279 break;
2280 case IDC_ALWAYSONTOP:
2281 if (HIWORD(wParam) == BN_CLICKED ||
2282 HIWORD(wParam) == BN_DOUBLECLICKED)
2283 cfg.alwaysontop =
2284 IsDlgButtonChecked(hwnd, IDC_ALWAYSONTOP);
2285 break;
8f57d753 2286 case IDC_FULLSCREENONALTENTER:
2287 if (HIWORD(wParam) == BN_CLICKED ||
2288 HIWORD(wParam) == BN_DOUBLECLICKED)
2289 cfg.fullscreenonaltenter =
2290 IsDlgButtonChecked(hwnd, IDC_FULLSCREENONALTENTER);
2291 break;
32874aea 2292 case IDC_SCROLLKEY:
2293 if (HIWORD(wParam) == BN_CLICKED ||
2294 HIWORD(wParam) == BN_DOUBLECLICKED)
2295 cfg.scroll_on_key =
2296 IsDlgButtonChecked(hwnd, IDC_SCROLLKEY);
2297 break;
2298 case IDC_SCROLLDISP:
2299 if (HIWORD(wParam) == BN_CLICKED ||
2300 HIWORD(wParam) == BN_DOUBLECLICKED)
2301 cfg.scroll_on_disp =
2302 IsDlgButtonChecked(hwnd, IDC_SCROLLDISP);
2303 break;
2304 case IDC_COMPOSEKEY:
2305 if (HIWORD(wParam) == BN_CLICKED ||
2306 HIWORD(wParam) == BN_DOUBLECLICKED)
2307 cfg.compose_key =
2308 IsDlgButtonChecked(hwnd, IDC_COMPOSEKEY);
2309 break;
2310 case IDC_CTRLALTKEYS:
2311 if (HIWORD(wParam) == BN_CLICKED ||
2312 HIWORD(wParam) == BN_DOUBLECLICKED)
2313 cfg.ctrlaltkeys =
2314 IsDlgButtonChecked(hwnd, IDC_CTRLALTKEYS);
2315 break;
a5f3e637 2316 case IDC_TELNETKEY:
2317 if (HIWORD(wParam) == BN_CLICKED ||
2318 HIWORD(wParam) == BN_DOUBLECLICKED)
2319 cfg.telnet_keyboard =
2320 IsDlgButtonChecked(hwnd, IDC_TELNETKEY);
2321 break;
32874aea 2322 case IDC_WRAPMODE:
2323 if (HIWORD(wParam) == BN_CLICKED ||
2324 HIWORD(wParam) == BN_DOUBLECLICKED)
2325 cfg.wrap_mode =
2326 IsDlgButtonChecked(hwnd, IDC_WRAPMODE);
2327 break;
2328 case IDC_DECOM:
2329 if (HIWORD(wParam) == BN_CLICKED ||
2330 HIWORD(wParam) == BN_DOUBLECLICKED)
2331 cfg.dec_om = IsDlgButtonChecked(hwnd, IDC_DECOM);
2332 break;
2333 case IDC_LFHASCR:
2334 if (HIWORD(wParam) == BN_CLICKED ||
2335 HIWORD(wParam) == BN_DOUBLECLICKED)
2336 cfg.lfhascr =
2337 IsDlgButtonChecked(hwnd, IDC_LFHASCR);
2338 break;
2339 case IDC_ROWSEDIT:
2340 if (HIWORD(wParam) == EN_CHANGE)
2341 MyGetDlgItemInt(hwnd, IDC_ROWSEDIT, &cfg.height);
2342 break;
2343 case IDC_COLSEDIT:
2344 if (HIWORD(wParam) == EN_CHANGE)
2345 MyGetDlgItemInt(hwnd, IDC_COLSEDIT, &cfg.width);
2346 break;
2347 case IDC_SAVEEDIT:
2348 if (HIWORD(wParam) == EN_CHANGE)
2349 MyGetDlgItemInt(hwnd, IDC_SAVEEDIT, &cfg.savelines);
2350 break;
2351 case IDC_CHOOSEFONT:
c0a18295 2352 {
2353 HDC hdc = GetDC(0);
2354 lf.lfHeight = -MulDiv(cfg.fontheight,
2355 GetDeviceCaps(hdc, LOGPIXELSY),
2356 72);
2357 ReleaseDC(0, hdc);
2358 }
32874aea 2359 lf.lfWidth = lf.lfEscapement = lf.lfOrientation = 0;
2360 lf.lfItalic = lf.lfUnderline = lf.lfStrikeOut = 0;
2361 lf.lfWeight = (cfg.fontisbold ? FW_BOLD : 0);
2362 lf.lfCharSet = cfg.fontcharset;
2363 lf.lfOutPrecision = OUT_DEFAULT_PRECIS;
2364 lf.lfClipPrecision = CLIP_DEFAULT_PRECIS;
2365 lf.lfQuality = DEFAULT_QUALITY;
2366 lf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
2367 strncpy(lf.lfFaceName, cfg.font,
2368 sizeof(lf.lfFaceName) - 1);
2369 lf.lfFaceName[sizeof(lf.lfFaceName) - 1] = '\0';
2370
2371 cf.lStructSize = sizeof(cf);
2372 cf.hwndOwner = hwnd;
2373 cf.lpLogFont = &lf;
2374 cf.Flags = CF_FIXEDPITCHONLY | CF_FORCEFONTEXIST |
2375 CF_INITTOLOGFONTSTRUCT | CF_SCREENFONTS;
2376
2377 if (ChooseFont(&cf)) {
2378 strncpy(cfg.font, lf.lfFaceName, sizeof(cfg.font) - 1);
2379 cfg.font[sizeof(cfg.font) - 1] = '\0';
2380 cfg.fontisbold = (lf.lfWeight == FW_BOLD);
2381 cfg.fontcharset = lf.lfCharSet;
2382 cfg.fontheight = cf.iPointSize / 10;
2383 fmtfont(fontstatic);
2384 SetDlgItemText(hwnd, IDC_FONTSTATIC, fontstatic);
2385 }
2386 break;
2387 case IDC_BELL_DISABLED:
2388 case IDC_BELL_DEFAULT:
2389 case IDC_BELL_WAVEFILE:
2390 case IDC_BELL_VISUAL:
2391 if (HIWORD(wParam) == BN_CLICKED ||
2392 HIWORD(wParam) == BN_DOUBLECLICKED) {
2393 if (LOWORD(wParam) == IDC_BELL_DISABLED)
2394 cfg.beep = BELL_DISABLED;
2395 if (LOWORD(wParam) == IDC_BELL_DEFAULT)
2396 cfg.beep = BELL_DEFAULT;
2397 if (LOWORD(wParam) == IDC_BELL_WAVEFILE)
2398 cfg.beep = BELL_WAVEFILE;
2399 if (LOWORD(wParam) == IDC_BELL_VISUAL)
2400 cfg.beep = BELL_VISUAL;
2401 }
2402 break;
f8a28d1f 2403 case IDC_B_IND_DISABLED:
2404 case IDC_B_IND_FLASH:
2405 case IDC_B_IND_STEADY:
2406 if (HIWORD(wParam) == BN_CLICKED ||
2407 HIWORD(wParam) == BN_DOUBLECLICKED) {
2408 if (LOWORD(wParam) == IDC_B_IND_DISABLED)
2409 cfg.beep_ind = B_IND_DISABLED;
2410 if (LOWORD(wParam) == IDC_B_IND_FLASH)
2411 cfg.beep_ind = B_IND_FLASH;
2412 if (LOWORD(wParam) == IDC_B_IND_STEADY)
2413 cfg.beep_ind = B_IND_STEADY;
2414 }
2415 break;
32874aea 2416 case IDC_BELL_WAVEBROWSE:
2417 memset(&of, 0, sizeof(of));
03169ad0 2418#ifdef OPENFILENAME_SIZE_VERSION_400
32874aea 2419 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
03169ad0 2420#else
32874aea 2421 of.lStructSize = sizeof(of);
03169ad0 2422#endif
32874aea 2423 of.hwndOwner = hwnd;
2424 of.lpstrFilter = "Wave Files\0*.WAV\0AllFiles\0*\0\0\0";
2425 of.lpstrCustomFilter = NULL;
2426 of.nFilterIndex = 1;
2427 of.lpstrFile = filename;
2428 strcpy(filename, cfg.bell_wavefile);
2429 of.nMaxFile = sizeof(filename);
2430 of.lpstrFileTitle = NULL;
2431 of.lpstrInitialDir = NULL;
2432 of.lpstrTitle = "Select Bell Sound File";
2433 of.Flags = 0;
2434 if (GetOpenFileName(&of)) {
2435 strcpy(cfg.bell_wavefile, filename);
2436 SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2437 cfg.bell_wavefile);
2438 }
2439 break;
2440 case IDC_BELL_WAVEEDIT:
2441 if (HIWORD(wParam) == EN_CHANGE)
2442 GetDlgItemText(hwnd, IDC_BELL_WAVEEDIT,
2443 cfg.bell_wavefile,
2444 sizeof(cfg.bell_wavefile) - 1);
2445 break;
2446 case IDC_BELLOVL:
2447 if (HIWORD(wParam) == BN_CLICKED ||
2448 HIWORD(wParam) == BN_DOUBLECLICKED)
2449 cfg.bellovl =
2450 IsDlgButtonChecked(hwnd, IDC_BELLOVL);
2451 break;
2452 case IDC_BELLOVLN:
2453 if (HIWORD(wParam) == EN_CHANGE)
2454 MyGetDlgItemInt(hwnd, IDC_BELLOVLN, &cfg.bellovl_n);
2455 break;
2456 case IDC_BELLOVLT:
2457 if (HIWORD(wParam) == EN_CHANGE)
2458 MyGetDlgItemFlt(hwnd, IDC_BELLOVLT, &cfg.bellovl_t,
2459 1000);
2460 break;
2461 case IDC_BELLOVLS:
2462 if (HIWORD(wParam) == EN_CHANGE)
2463 MyGetDlgItemFlt(hwnd, IDC_BELLOVLS, &cfg.bellovl_s,
2464 1000);
2465 break;
2466 case IDC_BLINKTEXT:
2467 if (HIWORD(wParam) == BN_CLICKED ||
2468 HIWORD(wParam) == BN_DOUBLECLICKED)
2469 cfg.blinktext =
2470 IsDlgButtonChecked(hwnd, IDC_BLINKTEXT);
2471 break;
2472 case IDC_BCE:
2473 if (HIWORD(wParam) == BN_CLICKED ||
2474 HIWORD(wParam) == BN_DOUBLECLICKED)
2475 cfg.bce = IsDlgButtonChecked(hwnd, IDC_BCE);
2476 break;
2477 case IDC_WINNAME:
2478 if (HIWORD(wParam) == BN_CLICKED ||
2479 HIWORD(wParam) == BN_DOUBLECLICKED)
2480 cfg.win_name_always =
2481 IsDlgButtonChecked(hwnd, IDC_WINNAME);
2482 break;
2483 case IDC_HIDEMOUSE:
2484 if (HIWORD(wParam) == BN_CLICKED ||
2485 HIWORD(wParam) == BN_DOUBLECLICKED)
2486 cfg.hide_mouseptr =
2487 IsDlgButtonChecked(hwnd, IDC_HIDEMOUSE);
2488 break;
2489 case IDC_SUNKENEDGE:
2490 if (HIWORD(wParam) == BN_CLICKED ||
2491 HIWORD(wParam) == BN_DOUBLECLICKED)
2492 cfg.sunken_edge =
2493 IsDlgButtonChecked(hwnd, IDC_SUNKENEDGE);
2494 break;
5a73255e 2495 case IDC_WINBEDIT:
2496 if (HIWORD(wParam) == EN_CHANGE)
2497 MyGetDlgItemInt(hwnd, IDC_WINBEDIT,
2498 &cfg.window_border);
2499 if (cfg.window_border > 32)
2500 cfg.window_border = 32;
2501 break;
32874aea 2502 case IDC_CURBLOCK:
2503 if (HIWORD(wParam) == BN_CLICKED ||
2504 HIWORD(wParam) == BN_DOUBLECLICKED)
2505 cfg.cursor_type = 0;
2506 break;
2507 case IDC_CURUNDER:
2508 if (HIWORD(wParam) == BN_CLICKED ||
2509 HIWORD(wParam) == BN_DOUBLECLICKED)
2510 cfg.cursor_type = 1;
2511 break;
2512 case IDC_CURVERT:
2513 if (HIWORD(wParam) == BN_CLICKED ||
2514 HIWORD(wParam) == BN_DOUBLECLICKED)
2515 cfg.cursor_type = 2;
2516 break;
2517 case IDC_BLINKCUR:
2518 if (HIWORD(wParam) == BN_CLICKED ||
2519 HIWORD(wParam) == BN_DOUBLECLICKED)
2520 cfg.blink_cur =
2521 IsDlgButtonChecked(hwnd, IDC_BLINKCUR);
2522 break;
2523 case IDC_SCROLLBAR:
2524 if (HIWORD(wParam) == BN_CLICKED ||
2525 HIWORD(wParam) == BN_DOUBLECLICKED)
2526 cfg.scrollbar =
2527 IsDlgButtonChecked(hwnd, IDC_SCROLLBAR);
2528 break;
a401e5f3 2529 case IDC_SCROLLBARFULLSCREEN:
2530 if (HIWORD(wParam) == BN_CLICKED ||
2531 HIWORD(wParam) == BN_DOUBLECLICKED)
2532 cfg.scrollbar_in_fullscreen =
2533 IsDlgButtonChecked(hwnd, IDC_SCROLLBARFULLSCREEN);
2534 break;
ad5c93cc 2535 case IDC_RESIZETERM:
2536 case IDC_RESIZEFONT:
2537 case IDC_RESIZENONE:
0ed2f48e 2538 case IDC_RESIZEEITHER:
32874aea 2539 if (HIWORD(wParam) == BN_CLICKED ||
ad5c93cc 2540 HIWORD(wParam) == BN_DOUBLECLICKED) {
2541 cfg.resize_action =
2542 IsDlgButtonChecked(hwnd,
2543 IDC_RESIZETERM) ? RESIZE_TERM :
2544 IsDlgButtonChecked(hwnd,
2545 IDC_RESIZEFONT) ? RESIZE_FONT :
0ed2f48e 2546 IsDlgButtonChecked(hwnd,
2547 IDC_RESIZEEITHER) ? RESIZE_EITHER :
ad5c93cc 2548 RESIZE_DISABLED;
2549 }
5a73255e 2550 break;
32874aea 2551 case IDC_WINEDIT:
2552 if (HIWORD(wParam) == EN_CHANGE)
2553 GetDlgItemText(hwnd, IDC_WINEDIT, cfg.wintitle,
2554 sizeof(cfg.wintitle) - 1);
2555 break;
2556 case IDC_COEALWAYS:
2557 case IDC_COENEVER:
2558 case IDC_COENORMAL:
2559 if (HIWORD(wParam) == BN_CLICKED ||
2560 HIWORD(wParam) == BN_DOUBLECLICKED) {
2561 cfg.close_on_exit =
2562 IsDlgButtonChecked(hwnd,
2563 IDC_COEALWAYS) ? COE_ALWAYS :
2564 IsDlgButtonChecked(hwnd,
2565 IDC_COENEVER) ? COE_NEVER :
2566 COE_NORMAL;
2567 }
2568 break;
2569 case IDC_CLOSEWARN:
2570 if (HIWORD(wParam) == BN_CLICKED ||
2571 HIWORD(wParam) == BN_DOUBLECLICKED)
2572 cfg.warn_on_close =
2573 IsDlgButtonChecked(hwnd, IDC_CLOSEWARN);
2574 break;
2575 case IDC_TTEDIT:
2576 if (HIWORD(wParam) == EN_CHANGE)
2577 GetDlgItemText(hwnd, IDC_TTEDIT, cfg.termtype,
2578 sizeof(cfg.termtype) - 1);
2579 break;
2580 case IDC_LGFEDIT:
2581 if (HIWORD(wParam) == EN_CHANGE)
2582 GetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename,
2583 sizeof(cfg.logfilename) - 1);
2584 break;
2585 case IDC_LGFBUTTON:
2586 memset(&of, 0, sizeof(of));
e1c8e0ed 2587#ifdef OPENFILENAME_SIZE_VERSION_400
32874aea 2588 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
e1c8e0ed 2589#else
32874aea 2590 of.lStructSize = sizeof(of);
e1c8e0ed 2591#endif
32874aea 2592 of.hwndOwner = hwnd;
2593 of.lpstrFilter = "All Files\0*\0\0\0";
2594 of.lpstrCustomFilter = NULL;
2595 of.nFilterIndex = 1;
2596 of.lpstrFile = filename;
2597 strcpy(filename, cfg.logfilename);
2598 of.nMaxFile = sizeof(filename);
2599 of.lpstrFileTitle = NULL;
2600 of.lpstrInitialDir = NULL;
2601 of.lpstrTitle = "Select session log file";
2602 of.Flags = 0;
2603 if (GetSaveFileName(&of)) {
2604 strcpy(cfg.logfilename, filename);
2605 SetDlgItemText(hwnd, IDC_LGFEDIT, cfg.logfilename);
374330e2 2606 }
32874aea 2607 break;
2608 case IDC_LSTATOFF:
2609 case IDC_LSTATASCII:
2610 case IDC_LSTATRAW:
2611 if (HIWORD(wParam) == BN_CLICKED ||
2612 HIWORD(wParam) == BN_DOUBLECLICKED) {
2613 if (IsDlgButtonChecked(hwnd, IDC_LSTATOFF))
2614 cfg.logtype = 0;
2615 if (IsDlgButtonChecked(hwnd, IDC_LSTATASCII))
2616 cfg.logtype = 1;
2617 if (IsDlgButtonChecked(hwnd, IDC_LSTATRAW))
2618 cfg.logtype = 2;
374330e2 2619 }
32874aea 2620 break;
2621 case IDC_LSTATXASK:
2622 case IDC_LSTATXAPN:
2623 case IDC_LSTATXOVR:
2624 if (HIWORD(wParam) == BN_CLICKED ||
2625 HIWORD(wParam) == BN_DOUBLECLICKED) {
2626 if (IsDlgButtonChecked(hwnd, IDC_LSTATXASK))
2627 cfg.logxfovr = LGXF_ASK;
2628 if (IsDlgButtonChecked(hwnd, IDC_LSTATXAPN))
2629 cfg.logxfovr = LGXF_APN;
2630 if (IsDlgButtonChecked(hwnd, IDC_LSTATXOVR))
2631 cfg.logxfovr = LGXF_OVR;
374330e2 2632 }
32874aea 2633 break;
2634 case IDC_TSEDIT:
2635 case IDC_R_TSEDIT:
2636 if (HIWORD(wParam) == EN_CHANGE)
2637 GetDlgItemText(hwnd, LOWORD(wParam), cfg.termspeed,
2638 sizeof(cfg.termspeed) - 1);
2639 break;
2640 case IDC_LOGEDIT:
2641 if (HIWORD(wParam) == EN_CHANGE)
2642 GetDlgItemText(hwnd, IDC_LOGEDIT, cfg.username,
2643 sizeof(cfg.username) - 1);
2644 break;
2645 case IDC_RLLUSEREDIT:
2646 if (HIWORD(wParam) == EN_CHANGE)
2647 GetDlgItemText(hwnd, IDC_RLLUSEREDIT,
2648 cfg.localusername,
2649 sizeof(cfg.localusername) - 1);
2650 break;
2651 case IDC_EMBSD:
2652 case IDC_EMRFC:
2653 cfg.rfc_environ = IsDlgButtonChecked(hwnd, IDC_EMRFC);
2654 break;
8faa456c 2655 case IDC_TPASSIVE:
2656 case IDC_TACTIVE:
2657 cfg.passive_telnet =
2658 IsDlgButtonChecked(hwnd, IDC_TPASSIVE);
2659 break;
32874aea 2660 case IDC_ENVADD:
2661 if (HIWORD(wParam) == BN_CLICKED ||
2662 HIWORD(wParam) == BN_DOUBLECLICKED) {
2663 char str[sizeof(cfg.environmt)];
2664 char *p;
2665 GetDlgItemText(hwnd, IDC_VAREDIT, str,
2666 sizeof(str) - 1);
2667 if (!*str) {
2668 MessageBeep(0);
2669 break;
2670 }
2671 p = str + strlen(str);
2672 *p++ = '\t';
2673 GetDlgItemText(hwnd, IDC_VALEDIT, p,
2674 sizeof(str) - 1 - (p - str));
2675 if (!*p) {
2676 MessageBeep(0);
2677 break;
2678 }
2679 p = cfg.environmt;
2680 while (*p) {
2681 while (*p)
2682 p++;
2683 p++;
2684 }
2685 if ((p - cfg.environmt) + strlen(str) + 2 <
2686 sizeof(cfg.environmt)) {
2687 strcpy(p, str);
2688 p[strlen(str) + 1] = '\0';
2689 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING,
2690 0, (LPARAM) str);
2691 SetDlgItemText(hwnd, IDC_VAREDIT, "");
2692 SetDlgItemText(hwnd, IDC_VALEDIT, "");
2693 } else {
2694 MessageBox(hwnd, "Environment too big",
2695 "PuTTY Error", MB_OK | MB_ICONERROR);
2696 }
374330e2 2697 }
32874aea 2698 break;
2699 case IDC_ENVREMOVE:
2700 if (HIWORD(wParam) != BN_CLICKED &&
2701 HIWORD(wParam) != BN_DOUBLECLICKED) break;
2702 i =
2703 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_GETCURSEL, 0,
2704 0);
2705 if (i == LB_ERR)
2706 MessageBeep(0);
2707 else {
2708 char *p, *q;
2709
2710 SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_DELETESTRING,
2711 i, 0);
2712 p = cfg.environmt;
2713 while (i > 0) {
2714 if (!*p)
2715 goto disaster;
2716 while (*p)
2717 p++;
2718 p++;
2719 i--;
2720 }
2721 q = p;
374330e2 2722 if (!*p)
2723 goto disaster;
374330e2 2724 while (*p)
32874aea 2725 p++;
2726 p++;
2727 while (*p) {
2728 while (*p)
2729 *q++ = *p++;
374330e2 2730 *q++ = *p++;
32874aea 2731 }
2732 *q = '\0';
2733 disaster:;
374330e2 2734 }
32874aea 2735 break;
2736 case IDC_NOPTY:
2737 if (HIWORD(wParam) == BN_CLICKED ||
2738 HIWORD(wParam) == BN_DOUBLECLICKED)
2739 cfg.nopty = IsDlgButtonChecked(hwnd, IDC_NOPTY);
2740 break;
2741 case IDC_COMPRESS:
2742 if (HIWORD(wParam) == BN_CLICKED ||
2743 HIWORD(wParam) == BN_DOUBLECLICKED)
2744 cfg.compression =
2745 IsDlgButtonChecked(hwnd, IDC_COMPRESS);
2746 break;
2747 case IDC_BUGGYMAC:
2748 if (HIWORD(wParam) == BN_CLICKED ||
2749 HIWORD(wParam) == BN_DOUBLECLICKED)
2750 cfg.buggymac =
2751 IsDlgButtonChecked(hwnd, IDC_BUGGYMAC);
2752 break;
cb4d4768 2753 case IDC_SSH2DES:
2754 if (HIWORD(wParam) == BN_CLICKED ||
2755 HIWORD(wParam) == BN_DOUBLECLICKED)
2756 cfg.ssh2_des_cbc =
2757 IsDlgButtonChecked(hwnd, IDC_SSH2DES);
2758 break;
32874aea 2759 case IDC_AGENTFWD:
2760 if (HIWORD(wParam) == BN_CLICKED ||
2761 HIWORD(wParam) == BN_DOUBLECLICKED)
2762 cfg.agentfwd =
2763 IsDlgButtonChecked(hwnd, IDC_AGENTFWD);
2764 break;
5bb641e1 2765 case IDC_CHANGEUSER:
2766 if (HIWORD(wParam) == BN_CLICKED ||
2767 HIWORD(wParam) == BN_DOUBLECLICKED)
2768 cfg.change_username =
2769 IsDlgButtonChecked(hwnd, IDC_CHANGEUSER);
2770 break;
ca20bfcf 2771 case IDC_CIPHERLIST:
2772 case IDC_CIPHERUP:
2773 case IDC_CIPHERDN:
2774 handle_prefslist(&cipherlist,
2775 cfg.ssh_cipherlist, CIPHER_MAX,
2776 0, hwnd, wParam, lParam);
32874aea 2777 break;
2778 case IDC_SSHPROT1:
2779 case IDC_SSHPROT2:
2780 if (HIWORD(wParam) == BN_CLICKED ||
2781 HIWORD(wParam) == BN_DOUBLECLICKED) {
2782 if (IsDlgButtonChecked(hwnd, IDC_SSHPROT1))
2783 cfg.sshprot = 1;
2784 else if (IsDlgButtonChecked(hwnd, IDC_SSHPROT2))
2785 cfg.sshprot = 2;
2786 }
2787 break;
2788 case IDC_AUTHTIS:
2789 if (HIWORD(wParam) == BN_CLICKED ||
2790 HIWORD(wParam) == BN_DOUBLECLICKED)
2791 cfg.try_tis_auth =
2792 IsDlgButtonChecked(hwnd, IDC_AUTHTIS);
2793 break;
f091e308 2794 case IDC_AUTHKI:
2795 if (HIWORD(wParam) == BN_CLICKED ||
2796 HIWORD(wParam) == BN_DOUBLECLICKED)
2797 cfg.try_ki_auth =
2798 IsDlgButtonChecked(hwnd, IDC_AUTHKI);
2799 break;
32874aea 2800 case IDC_PKEDIT:
2801 if (HIWORD(wParam) == EN_CHANGE)
2802 GetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile,
2803 sizeof(cfg.keyfile) - 1);
2804 break;
2805 case IDC_CMDEDIT:
2806 if (HIWORD(wParam) == EN_CHANGE)
2807 GetDlgItemText(hwnd, IDC_CMDEDIT, cfg.remote_cmd,
2808 sizeof(cfg.remote_cmd) - 1);
2809 break;
2810 case IDC_PKBUTTON:
2811 memset(&of, 0, sizeof(of));
7cca0d81 2812#ifdef OPENFILENAME_SIZE_VERSION_400
32874aea 2813 of.lStructSize = OPENFILENAME_SIZE_VERSION_400;
7cca0d81 2814#else
32874aea 2815 of.lStructSize = sizeof(of);
7cca0d81 2816#endif
32874aea 2817 of.hwndOwner = hwnd;
2818 of.lpstrFilter = "All Files\0*\0\0\0";
2819 of.lpstrCustomFilter = NULL;
2820 of.nFilterIndex = 1;
2821 of.lpstrFile = filename;
2822 strcpy(filename, cfg.keyfile);
2823 of.nMaxFile = sizeof(filename);
2824 of.lpstrFileTitle = NULL;
2825 of.lpstrInitialDir = NULL;
7c0f5956 2826 of.lpstrTitle = "Select Private Key File";
32874aea 2827 of.Flags = 0;
2828 if (GetOpenFileName(&of)) {
2829 strcpy(cfg.keyfile, filename);
2830 SetDlgItemText(hwnd, IDC_PKEDIT, cfg.keyfile);
374330e2 2831 }
32874aea 2832 break;
2833 case IDC_RAWCNP:
2834 cfg.rawcnp = IsDlgButtonChecked(hwnd, IDC_RAWCNP);
b90840c3 2835 break;
a7419ea4 2836 case IDC_RTFPASTE:
2837 cfg.rtf_paste = IsDlgButtonChecked(hwnd, IDC_RTFPASTE);
2838 break;
32874aea 2839 case IDC_MBWINDOWS:
2840 case IDC_MBXTERM:
2841 cfg.mouse_is_xterm = IsDlgButtonChecked(hwnd, IDC_MBXTERM);
2842 break;
6908fed7 2843 case IDC_SELTYPELEX:
2844 case IDC_SELTYPERECT:
2845 cfg.rect_select = IsDlgButtonChecked(hwnd, IDC_SELTYPERECT);
2846 break;
b90840c3 2847 case IDC_MOUSEOVERRIDE:
2848 cfg.mouse_override = IsDlgButtonChecked(hwnd, IDC_MOUSEOVERRIDE);
2849 break;
32874aea 2850 case IDC_CCSET:
2851 {
2852 BOOL ok;
2853 int i;
2854 int n = GetDlgItemInt(hwnd, IDC_CCEDIT, &ok, FALSE);
2855
2856 if (!ok)
2857 MessageBeep(0);
2858 else {
4eeb7d09 2859 for (i = 0; i < 128; i++)
32874aea 2860 if (SendDlgItemMessage
2861 (hwnd, IDC_CCLIST, LB_GETSEL, i, 0)) {
2862 char str[100];
2863 cfg.wordness[i] = n;
2864 SendDlgItemMessage(hwnd, IDC_CCLIST,
2865 LB_DELETESTRING, i, 0);
2866 sprintf(str, "%d\t(0x%02X)\t%c\t%d", i, i,
2867 (i >= 0x21 && i != 0x7F) ? i : ' ',
2868 cfg.wordness[i]);
2869 SendDlgItemMessage(hwnd, IDC_CCLIST,
2870 LB_INSERTSTRING, i,
2871 (LPARAM) str);
2872 }
2873 }
374330e2 2874 }
32874aea 2875 break;
2876 case IDC_BOLDCOLOUR:
2877 if (HIWORD(wParam) == BN_CLICKED ||
2878 HIWORD(wParam) == BN_DOUBLECLICKED) {
2879 int n, i;
2880 cfg.bold_colour =
2881 IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
c8d7378d 2882 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
2883 FALSE, 0);
32874aea 2884 n =
2885 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2886 LB_GETCOUNT, 0, 0);
2887 if (n != 12 + 10 * cfg.bold_colour) {
2888 for (i = n; i-- > 0;)
2889 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2890 LB_DELETESTRING, i, 0);
2891 for (i = 0; i < 22; i++)
2892 if (cfg.bold_colour || permcolour[i])
2893 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2894 LB_ADDSTRING, 0,
2895 (LPARAM) colours[i]);
2896 }
c8d7378d 2897 SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
2898 TRUE, 0);
2899 InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
2900 TRUE);
374330e2 2901 }
32874aea 2902 break;
2903 case IDC_PALETTE:
2904 if (HIWORD(wParam) == BN_CLICKED ||
2905 HIWORD(wParam) == BN_DOUBLECLICKED)
2906 cfg.try_palette =
2907 IsDlgButtonChecked(hwnd, IDC_PALETTE);
2908 break;
2909 case IDC_COLOURLIST:
2910 if (HIWORD(wParam) == LBN_DBLCLK ||
2911 HIWORD(wParam) == LBN_SELCHANGE) {
c8d7378d 2912 int i =
2913 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2914 LB_GETCURSEL,
2915 0, 0);
32874aea 2916 if (!cfg.bold_colour)
2917 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
2918 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
2919 FALSE);
2920 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
2921 FALSE);
2922 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
2923 FALSE);
2924 }
2925 break;
2926 case IDC_CHANGE:
2927 if (HIWORD(wParam) == BN_CLICKED ||
2928 HIWORD(wParam) == BN_DOUBLECLICKED) {
2929 static CHOOSECOLOR cc;
2930 static DWORD custom[16] = { 0 }; /* zero initialisers */
c8d7378d 2931 int i =
2932 SendDlgItemMessage(hwnd, IDC_COLOURLIST,
2933 LB_GETCURSEL,
2934 0, 0);
32874aea 2935 if (!cfg.bold_colour)
2936 i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
2937 cc.lStructSize = sizeof(cc);
2938 cc.hwndOwner = hwnd;
2939 cc.hInstance = (HWND) hinst;
2940 cc.lpCustColors = custom;
2941 cc.rgbResult =
2942 RGB(cfg.colours[i][0], cfg.colours[i][1],
2943 cfg.colours[i][2]);
2944 cc.Flags = CC_FULLOPEN | CC_RGBINIT;
2945 if (ChooseColor(&cc)) {
2946 cfg.colours[i][0] =
2947 (unsigned char) (cc.rgbResult & 0xFF);
2948 cfg.colours[i][1] =
2949 (unsigned char) (cc.rgbResult >> 8) & 0xFF;
2950 cfg.colours[i][2] =
2951 (unsigned char) (cc.rgbResult >> 16) & 0xFF;
2952 SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
2953 FALSE);
2954 SetDlgItemInt(hwnd, IDC_GVALUE, cfg.colours[i][1],
2955 FALSE);
2956 SetDlgItemInt(hwnd, IDC_BVALUE, cfg.colours[i][2],
2957 FALSE);
2958 }
2959 }
2960 break;
4eeb7d09 2961 case IDC_CODEPAGE:
875b193f 2962 if (HIWORD(wParam) == CBN_SELCHANGE) {
2963 int index = SendDlgItemMessage(hwnd, IDC_CODEPAGE,
2964 CB_GETCURSEL, 0, 0);
2965 SendDlgItemMessage(hwnd, IDC_CODEPAGE, CB_GETLBTEXT,
2966 index, (LPARAM)cfg.line_codepage);
b8ae1f0f 2967 } else if (HIWORD(wParam) == CBN_EDITCHANGE) {
2968 GetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage,
2969 sizeof(cfg.line_codepage) - 1);
2970 } else if (HIWORD(wParam) == CBN_KILLFOCUS) {
2971 strcpy(cfg.line_codepage,
2972 cp_name(decode_codepage(cfg.line_codepage)));
2973 SetDlgItemText(hwnd, IDC_CODEPAGE, cfg.line_codepage);
32874aea 2974 }
2975 break;
a9c02454 2976 case IDC_CAPSLOCKCYR:
2977 if (HIWORD(wParam) == BN_CLICKED ||
2978 HIWORD(wParam) == BN_DOUBLECLICKED) {
2979 cfg.xlat_capslockcyr =
2980 IsDlgButtonChecked (hwnd, IDC_CAPSLOCKCYR);
2981 }
2982 break;
32874aea 2983 case IDC_VTXWINDOWS:
2984 case IDC_VTOEMANSI:
2985 case IDC_VTOEMONLY:
2986 case IDC_VTPOORMAN:
4eeb7d09 2987 case IDC_VTUNICODE:
32874aea 2988 cfg.vtmode =
2989 (IsDlgButtonChecked(hwnd, IDC_VTXWINDOWS) ? VT_XWINDOWS
2990 : IsDlgButtonChecked(hwnd,
2991 IDC_VTOEMANSI) ? VT_OEMANSI :
2992 IsDlgButtonChecked(hwnd,
2993 IDC_VTOEMONLY) ? VT_OEMONLY :
4eeb7d09 2994 IsDlgButtonChecked(hwnd,
2995 IDC_VTUNICODE) ? VT_UNICODE :
32874aea 2996 VT_POORMAN);
2997 break;
2998 case IDC_X11_FORWARD:
2999 if (HIWORD(wParam) == BN_CLICKED ||
3000 HIWORD(wParam) == BN_DOUBLECLICKED)
3001 cfg.x11_forward =
3002 IsDlgButtonChecked(hwnd, IDC_X11_FORWARD);
3003 break;
d74d141c 3004 case IDC_LPORT_ALL:
3005 if (HIWORD(wParam) == BN_CLICKED ||
3006 HIWORD(wParam) == BN_DOUBLECLICKED)
3007 cfg.lport_acceptall =
3008 IsDlgButtonChecked(hwnd, IDC_LPORT_ALL);
3009 break;
32874aea 3010 case IDC_X11_DISPLAY:
3011 if (HIWORD(wParam) == EN_CHANGE)
3012 GetDlgItemText(hwnd, IDC_X11_DISPLAY, cfg.x11_display,
3013 sizeof(cfg.x11_display) - 1);
3014 break;
d74d141c 3015 case IDC_PFWDADD:
3016 if (HIWORD(wParam) == BN_CLICKED ||
3017 HIWORD(wParam) == BN_DOUBLECLICKED) {
3018 char str[sizeof(cfg.portfwd)];
3019 char *p;
3020 if (IsDlgButtonChecked(hwnd, IDC_PFWDLOCAL))
3021 str[0] = 'L';
3022 else
3023 str[0] = 'R';
3024 GetDlgItemText(hwnd, IDC_SPORTEDIT, str+1,
3025 sizeof(str) - 2);
3026 if (!str[1]) {
3027 MessageBox(hwnd,
3028 "You need to specify a source port number",
3029 "PuTTY Error", MB_OK | MB_ICONERROR);
3030 break;
3031 }
3032 p = str + strlen(str);
3033 *p++ = '\t';
3034 GetDlgItemText(hwnd, IDC_DPORTEDIT, p,
3035 sizeof(str) - 1 - (p - str));
3036 if (!*p || !strchr(p, ':')) {
3037 MessageBox(hwnd,
3038 "You need to specify a destination address\n"
3039 "in the form \"host.name:port\"",
3040 "PuTTY Error", MB_OK | MB_ICONERROR);
3041 break;
3042 }
3043 p = cfg.portfwd;
3044 while (*p) {
3045 while (*p)
3046 p++;
3047 p++;
3048 }
3049 if ((p - cfg.portfwd) + strlen(str) + 2 <
3050 sizeof(cfg.portfwd)) {
3051 strcpy(p, str);
3052 p[strlen(str) + 1] = '\0';
3053 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_ADDSTRING,
3054 0, (LPARAM) str);
3055 SetDlgItemText(hwnd, IDC_SPORTEDIT, "");
3056 SetDlgItemText(hwnd, IDC_DPORTEDIT, "");
3057 } else {
3058 MessageBox(hwnd, "Too many forwardings",
3059 "PuTTY Error", MB_OK | MB_ICONERROR);
3060 }
3061 }
3062 break;
3063 case IDC_PFWDREMOVE:
3064 if (HIWORD(wParam) != BN_CLICKED &&
3065 HIWORD(wParam) != BN_DOUBLECLICKED) break;
3066 i = SendDlgItemMessage(hwnd, IDC_PFWDLIST,
3067 LB_GETCURSEL, 0, 0);
3068 if (i == LB_ERR)
3069 MessageBeep(0);
3070 else {
3071 char *p, *q;
3072
3073 SendDlgItemMessage(hwnd, IDC_PFWDLIST, LB_DELETESTRING,
3074 i, 0);
3075 p = cfg.portfwd;
3076 while (i > 0) {
3077 if (!*p)
3078 goto disaster2;
3079 while (*p)
3080 p++;
3081 p++;
3082 i--;
3083 }
3084 q = p;
3085 if (!*p)
3086 goto disaster2;
3087 while (*p)
3088 p++;
3089 p++;
3090 while (*p) {
3091 while (*p)
3092 *q++ = *p++;
3093 *q++ = *p++;
3094 }
3095 *q = '\0';
3096 disaster2:;
3097 }
3098 break;
374330e2 3099 }
374330e2 3100 return 0;
70133c0e 3101 case WM_HELP:
3102 if (help_path) {
3103 int id = ((LPHELPINFO)lParam)->iCtrlId;
3104 char *cmd = help_context_cmd(id);
3105 if (cmd) {
3106 WinHelp(hwnd, help_path, HELP_COMMAND, (DWORD)cmd);
3107 requested_help = TRUE;
3108 } else {
3109 MessageBeep(0);
3110 }
3111 }
3112 break;
374330e2 3113 case WM_CLOSE:
70133c0e 3114 if (requested_help) {
3115 WinHelp(hwnd, help_path, HELP_QUIT, 0);
3116 requested_help = FALSE;
3117 }
32874aea 3118 EndDialog(hwnd, 0);
374330e2 3119 return 0;
c9def1b8 3120
3121 /* Grrr Explorer will maximize Dialogs! */
3122 case WM_SIZE:
3123 if (wParam == SIZE_MAXIMIZED)
32874aea 3124 force_normal(hwnd);
c9def1b8 3125 return 0;
ca20bfcf 3126
3127 default:
3128 /*
3129 * Handle application-defined messages eg. DragListBox
3130 */
3131 /* First find out what the number is (once). */
3132 if (draglistmsg == WM_NULL)
3133 draglistmsg = RegisterWindowMessage (DRAGLISTMSGSTRING);
3134
3135 if (msg == draglistmsg) {
3136 /* Only process once dialog is fully formed. */
3137 if (GetWindowLong(hwnd, GWL_USERDATA) == 1) switch (LOWORD(wParam)) {
3138 case IDC_CIPHERLIST:
3139 return handle_prefslist(&cipherlist,
3140 cfg.ssh_cipherlist, CIPHER_MAX,
3141 1, hwnd, wParam, lParam);
3142 }
3143 }
3144 return 0;
3145
374330e2 3146 }
3147 return 0;
3148}
3149
32874aea 3150static int CALLBACK MainDlgProc(HWND hwnd, UINT msg,
3151 WPARAM wParam, LPARAM lParam)
3152{
374330e2 3153 if (msg == WM_COMMAND && LOWORD(wParam) == IDOK) {
374330e2 3154 }
c96a8fef 3155 if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
374330e2 3156 EnableWindow(hwnd, 0);
f5eca4f8 3157 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
374330e2 3158 EnableWindow(hwnd, 1);
32874aea 3159 SetActiveWindow(hwnd);
374330e2 3160 }
32874aea 3161 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 0);
374330e2 3162}
3163
32874aea 3164static int CALLBACK ReconfDlgProc(HWND hwnd, UINT msg,
3165 WPARAM wParam, LPARAM lParam)
3166{
3167 return GenericMainDlgProc(hwnd, msg, wParam, lParam, 1);
374330e2 3168}
3169
32874aea 3170void defuse_showwindow(void)
3171{
301b66db 3172 /*
3173 * Work around the fact that the app's first call to ShowWindow
3174 * will ignore the default in favour of the shell-provided
3175 * setting.
3176 */
3177 {
32874aea 3178 HWND hwnd;
3179 hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
3180 NULL, NullDlgProc);
3181 ShowWindow(hwnd, SW_HIDE);
f5eca4f8 3182 SetActiveWindow(hwnd);
32874aea 3183 DestroyWindow(hwnd);
301b66db 3184 }
3185}
3186
32874aea 3187int do_config(void)
3188{
374330e2 3189 int ret;
3190
3191 get_sesslist(TRUE);
6584031a 3192 savedsession[0] = '\0';
32874aea 3193 ret =
3194 DialogBox(hinst, MAKEINTRESOURCE(IDD_MAINBOX), NULL, MainDlgProc);
374330e2 3195 get_sesslist(FALSE);
3196
3197 return ret;
3198}
3199
32874aea 3200int do_reconfig(HWND hwnd)
3201{
374330e2 3202 Config backup_cfg;
3203 int ret;
3204
3205 backup_cfg = cfg; /* structure copy */
32874aea 3206 ret =
3207 DialogBox(hinst, MAKEINTRESOURCE(IDD_RECONF), hwnd, ReconfDlgProc);
374330e2 3208 if (!ret)
3209 cfg = backup_cfg; /* structure copy */
c9def1b8 3210
374330e2 3211 return ret;
3212}
3213
32874aea 3214void logevent(char *string)
3215{
71346075 3216 char timebuf[40];
3217 time_t t;
3218
c5e9c988 3219 if (nevents >= negsize) {
374330e2 3220 negsize += 64;
32874aea 3221 events = srealloc(events, negsize * sizeof(*events));
374330e2 3222 }
71346075 3223
3224 time(&t);
32874aea 3225 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S\t",
3226 localtime(&t));
71346075 3227
32874aea 3228 events[nevents] = smalloc(strlen(timebuf) + strlen(string) + 1);
71346075 3229 strcpy(events[nevents], timebuf);
3230 strcat(events[nevents], string);
9ad90448 3231 if (logbox) {
32874aea 3232 int count;
3233 SendDlgItemMessage(logbox, IDN_LIST, LB_ADDSTRING,
3234 0, (LPARAM) events[nevents]);
3235 count = SendDlgItemMessage(logbox, IDN_LIST, LB_GETCOUNT, 0, 0);
3236 SendDlgItemMessage(logbox, IDN_LIST, LB_SETTOPINDEX, count - 1, 0);
9ad90448 3237 }
bce816e7 3238 nevents++;
374330e2 3239}
3240
32874aea 3241void showeventlog(HWND hwnd)
3242{
374330e2 3243 if (!logbox) {
32874aea 3244 logbox = CreateDialog(hinst, MAKEINTRESOURCE(IDD_LOGBOX),
3245 hwnd, LogProc);
3246 ShowWindow(logbox, SW_SHOWNORMAL);
374330e2 3247 }
9ecf8e5a 3248 SetActiveWindow(logbox);
374330e2 3249}
3250
32874aea 3251void showabout(HWND hwnd)
3252{
3253 DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
374330e2 3254}
3255
d4857987 3256void verify_ssh_host_key(char *host, int port, char *keytype,
32874aea 3257 char *keystr, char *fingerprint)
3258{
d5859615 3259 int ret;
374330e2 3260
d5859615 3261 static const char absentmsg[] =
32874aea 3262 "The server's host key is not cached in the registry. You\n"
3263 "have no guarantee that the server is the computer you\n"
3264 "think it is.\n"
3265 "The server's key fingerprint is:\n"
3266 "%s\n"
3267 "If you trust this host, hit Yes to add the key to\n"
3268 "PuTTY's cache and carry on connecting.\n"
d0718310 3269 "If you want to carry on connecting just once, without\n"
3270 "adding the key to the cache, hit No.\n"
3271 "If you do not trust this host, hit Cancel to abandon the\n"
32874aea 3272 "connection.\n";
d5859615 3273
3274 static const char wrongmsg[] =
32874aea 3275 "WARNING - POTENTIAL SECURITY BREACH!\n"
3276 "\n"
3277 "The server's host key does not match the one PuTTY has\n"
3278 "cached in the registry. This means that either the\n"
3279 "server administrator has changed the host key, or you\n"
3280 "have actually connected to another computer pretending\n"
3281 "to be the server.\n"
3282 "The new key fingerprint is:\n"
3283 "%s\n"
3284 "If you were expecting this change and trust the new key,\n"
3285 "hit Yes to update PuTTY's cache and continue connecting.\n"
3286 "If you want to carry on connecting but without updating\n"
3287 "the cache, hit No.\n"
3288 "If you want to abandon the connection completely, hit\n"
3289 "Cancel. Hitting Cancel is the ONLY guaranteed safe\n" "choice.\n";
d5859615 3290
3291 static const char mbtitle[] = "PuTTY Security Alert";
de3df031 3292
32874aea 3293 char message[160 +
c8d7378d 3294 /* sensible fingerprint max size */
32874aea 3295 (sizeof(absentmsg) > sizeof(wrongmsg) ?
3296 sizeof(absentmsg) : sizeof(wrongmsg))];
de3df031 3297
3298 /*
d5859615 3299 * Verify the key against the registry.
de3df031 3300 */
d4857987 3301 ret = verify_host_key(host, port, keytype, keystr);
d5859615 3302
32874aea 3303 if (ret == 0) /* success - key matched OK */
3304 return;
3305 if (ret == 2) { /* key was different */
3306 int mbret;
3307 sprintf(message, wrongmsg, fingerprint);
3308 mbret = MessageBox(NULL, message, mbtitle,
3309 MB_ICONWARNING | MB_YESNOCANCEL);
3310 if (mbret == IDYES)
3311 store_host_key(host, port, keytype, keystr);
3312 if (mbret == IDCANCEL)
3313 exit(0);
de3df031 3314 }
32874aea 3315 if (ret == 1) { /* key was absent */
3316 int mbret;
3317 sprintf(message, absentmsg, fingerprint);
3318 mbret = MessageBox(NULL, message, mbtitle,
d0718310 3319 MB_ICONWARNING | MB_YESNOCANCEL);
3320 if (mbret == IDYES)
3321 store_host_key(host, port, keytype, keystr);
3322 if (mbret == IDCANCEL)
32874aea 3323 exit(0);
de3df031 3324 }
de3df031 3325}
e1c8e0ed 3326
3327/*
ca20bfcf 3328 * Ask whether the selected cipher is acceptable (since it was
3329 * below the configured 'warn' threshold).
3330 * cs: 0 = both ways, 1 = client->server, 2 = server->client
3331 */
3332void askcipher(char *ciphername, int cs)
3333{
3334 static const char mbtitle[] = "PuTTY Security Alert";
3335 static const char msg[] =
3336 "The first %.35scipher supported by the server\n"
3337 "is %.64s, which is below the configured\n"
3338 "warning threshold.\n"
3339 "Do you want to continue with this connection?\n";
3340 /* guessed cipher name + type max length */
3341 char message[100 + sizeof(msg)];
3342 int mbret;
3343
3344 sprintf(message, msg,
3345 (cs == 0) ? "" :
3346 (cs == 1) ? "client-to-server " :
3347 "server-to-client ",
3348 ciphername);
3349 mbret = MessageBox(NULL, message, mbtitle,
3350 MB_ICONWARNING | MB_YESNO);
3351 if (mbret == IDYES)
3352 return;
3353 else
3354 exit(0);
3355}
3356
3357/*
e1c8e0ed 3358 * Ask whether to wipe a session log file before writing to it.
3359 * Returns 2 for wipe, 1 for append, 0 for cancel (don't log).
3360 */
32874aea 3361int askappend(char *filename)
3362{
e1c8e0ed 3363 static const char mbtitle[] = "PuTTY Log to File";
3364 static const char msgtemplate[] =
3365 "The session log file \"%.*s\" already exists.\n"
3366 "You can overwrite it with a new session log,\n"
3367 "append your session log to the end of it,\n"
3368 "or disable session logging for this session.\n"
3369 "Hit Yes to wipe the file, No to append to it,\n"
3370 "or Cancel to disable logging.";
3371 char message[sizeof(msgtemplate) + FILENAME_MAX];
3372 int mbret;
32874aea 3373 if (cfg.logxfovr != LGXF_ASK) {
3374 return ((cfg.logxfovr == LGXF_OVR) ? 2 : 1);
9f89f96e 3375 }
e1c8e0ed 3376 sprintf(message, msgtemplate, FILENAME_MAX, filename);
3377
3378 mbret = MessageBox(NULL, message, mbtitle,
32874aea 3379 MB_ICONQUESTION | MB_YESNOCANCEL);
e1c8e0ed 3380 if (mbret == IDYES)
3381 return 2;
3382 else if (mbret == IDNO)
3383 return 1;
3384 else
3385 return 0;
3386}
7bedb13c 3387
3388/*
3389 * Warn about the obsolescent key file format.
3390 */
3391void old_keyfile_warning(void)
3392{
3393 static const char mbtitle[] = "PuTTY Key File Warning";
3394 static const char message[] =
3395 "You are loading an SSH 2 private key which has an\n"
3396 "old version of the file format. This means your key\n"
3397 "file is not fully tamperproof. Future versions of\n"
3398 "PuTTY may stop supporting this private key format,\n"
3399 "so we recommend you convert your key to the new\n"
3400 "format.\n"
3401 "\n"
3402 "You can perform this conversion by loading the key\n"
3403 "into PuTTYgen and then saving it again.";
3404
3405 MessageBox(NULL, message, mbtitle, MB_OK);
3406}