static int nevents = 0, negsize = 0;
static int readytogo;
+static int sesslist_has_focus;
void force_normal(HWND hwnd)
{
IDC_BELL_WAVESTATIC,
IDC_BELL_WAVEEDIT,
IDC_BELL_WAVEBROWSE,
+ IDC_B_IND_STATIC,
+ IDC_B_IND_DISABLED,
+ IDC_B_IND_FLASH,
+ IDC_B_IND_STEADY,
IDC_BELLOVL,
IDC_BELLOVLNSTATIC,
IDC_BELLOVLN,
(cfg.fontheight < 0 ? -cfg.fontheight : cfg.fontheight));
}
-static void init_dlg_ctrls(HWND hwnd)
+/* 2nd arg: NZ => don't redraw session list (use when loading
+ * a new session) */
+static void init_dlg_ctrls(HWND hwnd, int keepsess)
{
int i;
char fontstatic[256];
SetDlgItemText(hwnd, IDC_HOST, cfg.host);
SetDlgItemText(hwnd, IDC_SESSEDIT, savedsession);
- {
+ if (!keepsess) {
int i, n;
n = SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_GETCOUNT, 0, 0);
for (i = n; i-- > 0;)
cfg.beep == BELL_WAVEFILE ? IDC_BELL_WAVEFILE :
cfg.beep ==
BELL_VISUAL ? IDC_BELL_VISUAL : IDC_BELL_DEFAULT);
+ CheckRadioButton(hwnd, IDC_B_IND_DISABLED, IDC_B_IND_STEADY,
+ cfg.beep_ind ==
+ B_IND_DISABLED ? IDC_B_IND_DISABLED : cfg.beep_ind ==
+ B_IND_FLASH ? IDC_B_IND_FLASH : cfg.beep_ind ==
+ B_IND_STEADY ? IDC_B_IND_STEADY : IDC_B_IND_DISABLED);
SetDlgItemText(hwnd, IDC_BELL_WAVEEDIT, cfg.bell_wavefile);
CheckDlgButton(hwnd, IDC_BELLOVL, cfg.bellovl);
SetDlgItemInt(hwnd, IDC_BELLOVLN, cfg.bellovl_n, FALSE);
IDC_LSTATXAPN);
{
char *p = cfg.environmt;
+ SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_RESETCONTENT, 0, 0);
while (*p) {
SendDlgItemMessage(hwnd, IDC_ENVLIST, LB_ADDSTRING, 0,
(LPARAM) p);
}
if (panel == bellpanelstart) {
- /* The Bell panel. Accelerators used: [acgo] bdsm wt */
+ /* The Bell panel. Accelerators used: [acgo] bdsm wit */
struct ctlpos cp;
ctlposinit(&cp, hwnd, 80, 3, 13);
bartitle(&cp, "Options controlling the terminal bell",
editbutton(&cp, "Custom sound file to play as a bell:",
IDC_BELL_WAVESTATIC, IDC_BELL_WAVEEDIT,
"Bro&wse...", IDC_BELL_WAVEBROWSE);
+ radioline(&cp, "Taskbar/caption &indication on bell:",
+ IDC_B_IND_STATIC, 3, "Disabled", IDC_B_IND_DISABLED,
+ "Flashing", IDC_B_IND_FLASH, "Steady", IDC_B_IND_STEADY,
+ NULL);
endbox(&cp);
beginbox(&cp, "Control the bell overload behaviour",
IDC_BOX_BELL2);
}
}
+/*
+ * Helper function to load the session selected in SESSLIST
+ * if any, as this is done in more than one place in
+ * GenericMainDlgProc(). 0 => failure.
+ */
+static int load_selected_session(HWND hwnd)
+{
+ int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
+ LB_GETCURSEL, 0, 0);
+ int isdef;
+ if (n == LB_ERR) {
+ MessageBeep(0);
+ return 0;
+ }
+ isdef = !strcmp(sessions[n], "Default Settings");
+ load_settings(sessions[n], !isdef, &cfg);
+ init_dlg_ctrls(hwnd, TRUE);
+ if (!isdef)
+ SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
+ else
+ SetDlgItemText(hwnd, IDC_SESSEDIT, "");
+ /* Restore the selection, which will have been clobbered by
+ * SESSEDIT handling. */
+ SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL, n, 0);
+ return 1;
+}
+
/*
* This function is the configuration box.
*/
}
SetWindowLong(hwnd, GWL_USERDATA, 1);
+ sesslist_has_focus = 0;
return 0;
case WM_LBUTTONUP:
/*
if (!strcmp(buffer, "Translation"))
create_controls(hwnd, dlgtype, translationpanelstart);
- init_dlg_ctrls(hwnd);
+ init_dlg_ctrls(hwnd, FALSE);
SetFocus(((LPNMHDR) lParam)->hwndFrom); /* ensure focus stays */
return 0;
if (GetWindowLong(hwnd, GWL_USERDATA) == 1)
switch (LOWORD(wParam)) {
case IDOK:
+ /* Behaviour of the "Open" button is different if the
+ * session list has focus, *unless* the user just
+ * double-clicked... */
+ if (sesslist_has_focus && !readytogo) {
+ if (!load_selected_session(hwnd)) {
+ MessageBeep(0);
+ return 0;
+ }
+ }
+ /* If at this point we have a valid session, go! */
if (*cfg.host)
EndDialog(hwnd, 1);
else
&cfg);
get_sesslist(FALSE);
get_sesslist(TRUE);
+ SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
+ FALSE, 0);
SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
0, 0);
for (i = 0; i < nsessions; i++)
(LPARAM) (sessions[i]));
SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
(WPARAM) - 1, 0);
+ SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
+ TRUE, 0);
+ InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
+ TRUE);
}
break;
case IDC_SESSLIST:
case IDC_SESSLOAD:
+ if (LOWORD(wParam) == IDC_SESSLIST) {
+ if (HIWORD(wParam) == LBN_SETFOCUS)
+ sesslist_has_focus = 1;
+ else if (HIWORD(wParam) == LBN_KILLFOCUS)
+ sesslist_has_focus = 0;
+ }
if (LOWORD(wParam) == IDC_SESSLOAD &&
HIWORD(wParam) != BN_CLICKED &&
HIWORD(wParam) != BN_DOUBLECLICKED) break;
if (LOWORD(wParam) == IDC_SESSLIST &&
HIWORD(wParam) != LBN_DBLCLK) break;
- {
- int n = SendDlgItemMessage(hwnd, IDC_SESSLIST,
- LB_GETCURSEL, 0, 0);
- int isdef;
- if (n == LB_ERR) {
- MessageBeep(0);
- break;
- }
- isdef = !strcmp(sessions[n], "Default Settings");
- load_settings(sessions[n], !isdef, &cfg);
- init_dlg_ctrls(hwnd);
- if (!isdef)
- SetDlgItemText(hwnd, IDC_SESSEDIT, sessions[n]);
- else
- SetDlgItemText(hwnd, IDC_SESSEDIT, "");
- }
- if (LOWORD(wParam) == IDC_SESSLIST) {
+ /* Load the session selected in SESSLIST. */
+ if (load_selected_session(hwnd) &&
+ LOWORD(wParam) == IDC_SESSLIST) {
/*
* A double-click on a saved session should
* actually start the session, not just load it.
del_settings(sessions[n]);
get_sesslist(FALSE);
get_sesslist(TRUE);
+ SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
+ FALSE, 0);
SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_RESETCONTENT,
0, 0);
for (i = 0; i < nsessions; i++)
(LPARAM) (sessions[i]));
SendDlgItemMessage(hwnd, IDC_SESSLIST, LB_SETCURSEL,
(WPARAM) - 1, 0);
+ SendDlgItemMessage(hwnd, IDC_SESSLIST, WM_SETREDRAW,
+ TRUE, 0);
+ InvalidateRect(GetDlgItem(hwnd, IDC_SESSLIST), NULL,
+ TRUE);
}
case IDC_PINGEDIT:
if (HIWORD(wParam) == EN_CHANGE)
cfg.beep = BELL_VISUAL;
}
break;
+ case IDC_B_IND_DISABLED:
+ case IDC_B_IND_FLASH:
+ case IDC_B_IND_STEADY:
+ if (HIWORD(wParam) == BN_CLICKED ||
+ HIWORD(wParam) == BN_DOUBLECLICKED) {
+ if (LOWORD(wParam) == IDC_B_IND_DISABLED)
+ cfg.beep_ind = B_IND_DISABLED;
+ if (LOWORD(wParam) == IDC_B_IND_FLASH)
+ cfg.beep_ind = B_IND_FLASH;
+ if (LOWORD(wParam) == IDC_B_IND_STEADY)
+ cfg.beep_ind = B_IND_STEADY;
+ }
+ break;
case IDC_BELL_WAVEBROWSE:
memset(&of, 0, sizeof(of));
#ifdef OPENFILENAME_SIZE_VERSION_400
int n, i;
cfg.bold_colour =
IsDlgButtonChecked(hwnd, IDC_BOLDCOLOUR);
+ SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
+ FALSE, 0);
n =
SendDlgItemMessage(hwnd, IDC_COLOURLIST,
LB_GETCOUNT, 0, 0);
LB_ADDSTRING, 0,
(LPARAM) colours[i]);
}
+ SendDlgItemMessage(hwnd, IDC_COLOURLIST, WM_SETREDRAW,
+ TRUE, 0);
+ InvalidateRect(GetDlgItem(hwnd, IDC_COLOURLIST), NULL,
+ TRUE);
}
break;
case IDC_PALETTE:
case IDC_COLOURLIST:
if (HIWORD(wParam) == LBN_DBLCLK ||
HIWORD(wParam) == LBN_SELCHANGE) {
- int i = SendDlgItemMessage(hwnd, IDC_COLOURLIST,
- LB_GETCURSEL,
- 0, 0);
+ int i =
+ SendDlgItemMessage(hwnd, IDC_COLOURLIST,
+ LB_GETCURSEL,
+ 0, 0);
if (!cfg.bold_colour)
i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
SetDlgItemInt(hwnd, IDC_RVALUE, cfg.colours[i][0],
HIWORD(wParam) == BN_DOUBLECLICKED) {
static CHOOSECOLOR cc;
static DWORD custom[16] = { 0 }; /* zero initialisers */
- int i = SendDlgItemMessage(hwnd, IDC_COLOURLIST,
- LB_GETCURSEL,
- 0, 0);
+ int i =
+ SendDlgItemMessage(hwnd, IDC_COLOURLIST,
+ LB_GETCURSEL,
+ 0, 0);
if (!cfg.bold_colour)
i = (i < 3 ? i * 2 : i == 3 ? 5 : i * 2 - 2);
cc.lStructSize = sizeof(cc);
}
if (msg == WM_COMMAND && LOWORD(wParam) == IDCX_ABOUT) {
EnableWindow(hwnd, 0);
- DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
- GetParent(hwnd), AboutProc);
+ DialogBox(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX), hwnd, AboutProc);
EnableWindow(hwnd, 1);
SetActiveWindow(hwnd);
}
hwnd = CreateDialog(hinst, MAKEINTRESOURCE(IDD_ABOUTBOX),
NULL, NullDlgProc);
ShowWindow(hwnd, SW_HIDE);
+ SetActiveWindow(hwnd);
DestroyWindow(hwnd);
}
}
"%s\n"
"If you trust this host, hit Yes to add the key to\n"
"PuTTY's cache and carry on connecting.\n"
- "If you do not trust this host, hit No to abandon the\n"
+ "If you want to carry on connecting just once, without\n"
+ "adding the key to the cache, hit No.\n"
+ "If you do not trust this host, hit Cancel to abandon the\n"
"connection.\n";
static const char wrongmsg[] =
static const char mbtitle[] = "PuTTY Security Alert";
-
char message[160 +
- /* sensible fingerprint max size */
+ /* sensible fingerprint max size */
(sizeof(absentmsg) > sizeof(wrongmsg) ?
sizeof(absentmsg) : sizeof(wrongmsg))];
int mbret;
sprintf(message, absentmsg, fingerprint);
mbret = MessageBox(NULL, message, mbtitle,
- MB_ICONWARNING | MB_YESNO);
- if (mbret == IDNO)
+ MB_ICONWARNING | MB_YESNOCANCEL);
+ if (mbret == IDYES)
+ store_host_key(host, port, keytype, keystr);
+ if (mbret == IDCANCEL)
exit(0);
- store_host_key(host, port, keytype, keystr);
}
}