Posted 16 February 2018, 6:33 pm EST
Hi, I am Geri, and I am Jacob’s coworker. I have done some additional testing on this issue, so maybe this will help clarify. To review, our application is written in COBOL, and we have a COBOL window that “hosts” a C# UserControl which has FlexGrid on it. It works quite well. However, we discovered an issue when using filtering. We click on the arrow button in the column header, and the Filter window opens. If we close it by clicking either Apply or Cancel, focus returns to FlexGrid. But if we click anywhere off the panel instead of the either of those buttons, focus changes to the most recently active desktop window, which usually displays over the top of our app.
As I was testing, I displayed a message during the FormClosed event. It looked like it fired 2 times. The first time it brought focus to the most recently active window, and the second time, it brought focus to the second most recently active window. This made me think that maybe focus was moving down a stack or list of active windows. And because the COBOL “window” is not a true active window, it is never registered in this stack or list, and it is skipped when focus is transferred. If this is indeed what is happening, I don’t know if it can be “fixed”. I tried putting a Form on the UserControl to see if that would give a “parent anchor”, but the same behavior occurred, likely because it is still hosted by COBOL.
However, we see that when the Apply or Cancel buttons are clicked, focus returns to FlexGrid, as we would expect it too. I recognize that it is pretty simple to trigger behavior from a button click, and more difficult to trigger from a mouse movement or loss of focus. But it would seem logical to ALWAYS transfer focus from the Filter window to FlexGrid, regardless of the reason for the Filter window closing. Even if a different desktop window becomes active while the Filter window is open, I would expect the Filter window to close (momentarily returning focus to FlexGrid) before the new active window comes to focus.
Is it possible to verify any of this? I’m not very experienced with system-level programming. And by the way, this all tests fine in a pure C# environment, probably because of some “default” Windows behavior when it comes to transferring focus.