|
Rank: Member Groups: Member
Joined: 5/9/2017 Posts: 14
|
I have an application that has a main window, and in this window, a simple button that opens a popup that contains a WebControl/WebView.
So when we click on the button, the popup is shown and the google webpage loads.
We can type some text in the search box, and the problem appears when we switch to another app (like explorer) and we come back to the search box. Sometimes, the problem doesn't appear at the first time and we have to switch a couple of times from the search box, to explorer, and come back to the search box.
When the problem appears, the application icon in the taskbar is flashing, and if we hold the tab key on the keyboard, we see that the focus changes in the explorer app. To resolve the problem, we can still switch apps, or we can only click on the main window, and come back to the search box.
We are using EO.WebBrowser v2022.2.49
If needed I can post a simple code app to reproduce.
Thank you
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, Yes. Please send a test app to us. See here for more details: https://www.essentialobjects.com/forum/test_project.aspxThanks!
|
|
Rank: Member Groups: Member
Joined: 5/9/2017 Posts: 14
|
Done!
Thank you
|
|
Rank: Member Groups: Member
Joined: 5/9/2017 Posts: 14
|
Any updates on this one?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi,
Sorry about the delay. This is just to let you know that we are still working on this issue. We have observed a number of issues with your test app:
1. We are able to reproduce the issue you mentioned on Windows 10, but not on Windows 11; 2. We have also noticed another issue where focus is not properly switched out of the WebView when focusing on another control (such as textbox) in the same popup;
We are working on this and hopefully can get to the bottom of this. We will reply here again as soon as we have an update.
Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/9/2017 Posts: 14
|
Thanks!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, We have been able to trace the root of the problem to the WS_EX_NOACTIVATE window style set on the Popup window. This style tells Windows that this window should NOT receive keyboard focus. This is the desired behavior for most popup window (for example, a drop down menu). However it is obviously not the desired behavior in your case. The easiest way to resolve this issue is to remove this style. You can use the following code:
Code: C#
[DllImport("user32.dll")]
public static extern int GetWindowLong(IntPtr hWnd, int nIndex);
[DllImport("user32.dll")]
private static extern IntPtr SetWindowLong(IntPtr hWnd, int nIndex, int newVlaue);
private void Button_Click(object sender, RoutedEventArgs e)
{
popupTest.IsOpen = !popupTest.IsOpen;
if (popupTest.IsOpen)
{
//The following code uses Windows API GetWindowLong/SetWindowLong to
//remove WS_EX_NOACTIVATE from the popup window
//Get the Popup's window handle
IntPtr handle = ((HwndSource)PresentationSource.FromVisual(popupTest.Child)).Handle;
//Get GWL_EXSTYLE
int exStyle = GetWindowLong(handle, -20/*GWL_EXSTYLE*/);
//Remove WS_EX_NOACTIVATE
exStyle &= ~0x08000000; //Remove WS_EX_NOACTIVATE
//Set the new EXSTYLE with WS_EX_NOACTIVATE removed
SetWindowLong(handle, -20, exStyle);
}
}
Please let us know if this resolves the issue for you. Thanks!
|
|
Rank: Member Groups: Member
Joined: 5/9/2017 Posts: 14
|
Hi,
We just finished QA on the provided solution and it works.
Thank you for you usual support it's greatly appreciated.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
You are very welcome and thanks for confirming that it works!
|
|