X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=blobdiff_plain;f=windlg.c;h=7ee5c97a2ce13811fc439175279b013dc998318a;hb=f1ece56e40435efdf8eaeb2b11b34d73ee3f4a22;hp=6c4d26c3dee07c402f89e7a5355acb87de6fb32f;hpb=b1a4532be20f94761520ae8664d10b157fbe5edc;p=PuTTY.git diff --git a/windlg.c b/windlg.c index 6c4d26c3..7ee5c97a 100644 --- a/windlg.c +++ b/windlg.c @@ -2038,10 +2038,22 @@ static int GenericMainDlgProc(HWND hwnd, UINT msg, cfg.protocol = i ? PROT_SSH : j ? PROT_TELNET : k ? PROT_RLOGIN : PROT_RAW; - if ((cfg.protocol == PROT_SSH && cfg.port != 22) - || (cfg.protocol == PROT_TELNET && cfg.port != 23) - || (cfg.protocol == PROT_RLOGIN - && cfg.port != 513)) { + /* + * When switching using the arrow keys, we + * appear to get two of these messages, both + * mentioning the target button in + * LOWORD(wParam), but one of them called while + * the previous button is still checked. This + * causes an unnecessary reset of the port + * number field, which we fix by ensuring here + * that the button selected is indeed the one + * checked. + */ + if (IsDlgButtonChecked(hwnd, LOWORD(wParam)) && + ((cfg.protocol == PROT_SSH && cfg.port != 22) + || (cfg.protocol == PROT_TELNET && cfg.port != 23) + || (cfg.protocol == PROT_RLOGIN + && cfg.port != 513))) { cfg.port = i ? 22 : j ? 23 : 513; SetDlgItemInt(hwnd, IDC_PORT, cfg.port, FALSE); }