Welcome Guest Search | Active Topics | Sign In | Register

Bug when switching back and forth with popup Options
TELUS Buyers
Posted: Friday, October 21, 2022 9:18:04 AM
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
eo_support
Posted: Friday, October 21, 2022 3:39:09 PM
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.aspx

Thanks!
TELUS Buyers
Posted: Monday, October 24, 2022 8:50:03 AM
Rank: Member
Groups: Member

Joined: 5/9/2017
Posts: 14
Done!

Thank you
TELUS Buyers
Posted: Thursday, October 27, 2022 2:39:06 PM
Rank: Member
Groups: Member

Joined: 5/9/2017
Posts: 14
Any updates on this one?
eo_support
Posted: Friday, October 28, 2022 10:03:18 AM
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!
TELUS Buyers
Posted: Monday, October 31, 2022 8:51:40 AM
Rank: Member
Groups: Member

Joined: 5/9/2017
Posts: 14
Thanks!
eo_support
Posted: Monday, October 31, 2022 1:02:50 PM
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!
TELUS Buyers
Posted: Wednesday, November 2, 2022 9:12:07 AM
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.
eo_support
Posted: Wednesday, November 2, 2022 1:25:58 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
You are very welcome and thanks for confirming that it works!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.