Skip to content

Fix WebBrowser control blocks accelerators of buttons on form#14717

Open
JayashreeSF3546 wants to merge 1 commit into
dotnet:mainfrom
JayashreeSF3546:Fix_Issue_8862
Open

Fix WebBrowser control blocks accelerators of buttons on form#14717
JayashreeSF3546 wants to merge 1 commit into
dotnet:mainfrom
JayashreeSF3546:Fix_Issue_8862

Conversation

@JayashreeSF3546

@JayashreeSF3546 JayashreeSF3546 commented Jul 8, 2026

Copy link
Copy Markdown

Fixes #8862

Proposed changes

  • Fix WebBrowser mnemonic handling in WebBrowserBase by correcting the IsAccelerator(...) condition.
  • Ensure the hosted ActiveX browser processes only its own accelerators instead of claiming unrelated form/user-control mnemonics.
  • Restore expected button/form mnemonic behavior when a WebBrowser is present in the control hierarchy.

Customer Impact

  • Fixes a regression where Alt+<mnemonic> keys (for example Alt+B, Alt+O) were blocked when a WebBrowser control existed on the form/user control.
  • Restores expected keyboard accessibility and usability for buttons and form-level accelerators.

Regression?

  • Yes

Risk

  • Low to moderate.
  • The change is limited to WebBrowser mnemonic/accelerator handling and corrects inverted IsAccelerator(...) logic.
  • Potential impact is limited to cases that previously relied on the incorrect behavior where WebBrowser handled keys that were not its own accelerators.

Screenshots

NA

Test methodology

  • Added regression test coverage for a UserControl containing TextBox, Panel, WebBrowser, and a mnemonic Button.
  • Verified that button mnemonics work when WebBrowser appears before the button in tab order.
  • Verified that form-level mnemonics (for example &OK) are not blocked by WebBrowser.

Accessibility testing

  • N/A – no UI changes.

Test environment(s)

  • Windows 11
  • .NET SDK: 11.0.100-preview.3.26170.106
Microsoft Reviewers: Open in CodeFlow

Comment thread src/test/unit/System.Windows.Forms/WebBrowserBaseTests.cs
PInvoke.GetCursorPos(out Point p);
msg.pt = p;
if (!PInvoke.IsAccelerator(new HandleRef<HACCEL>(this, controlInfo.hAccel), controlInfo.cAccel, &msg, lpwCmd: null))
if (PInvoke.IsAccelerator(new HandleRef<HACCEL>(this, controlInfo.hAccel), controlInfo.cAccel, &msg, lpwCmd: null))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the  !  in the current WinForms code was introduced during the .NET Framework → .NET port — a genuine regression. The PR restores the original

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WebBrowser control blocks accelerators of buttons on form

2 participants