PDSOE: Toolbar windows disappear behind main window

Posted by Patrick Tingen on 23-Jun-2015 01:45

We have created some extra tooling to support part of our development process in OE11.4. These tools have been added to the PDS toolbar via the extensibility mode of Eclipse. But when I start my program, its window sometimes disappears behind the main PDS window. And sometimes it does not. I cannot find a pattern in this, but it is quite annoying. 

I tried to pull my window to the front using the Windows API SetForegroundWindow but this does not seem to help.

Anny suggestions?

All Replies

Posted by Patrick Tingen on 23-Jun-2015 01:54

Found an explanation myself at stackoverflow.com/.../issue-with-setforegroundwindow-in-net

It seems that this is by design to protect users from applications stealing focus. I changed the code to first enable all widgets, then APPLY "ENTRY" to the first widget and then finally run SetForegroundWindow. This will ensure that my application has focus and is thus allowed by Windows to bring the window to the front.

I have yet to test it thoroughly but first tests are promising.

Posted by Matt Gilarde on 23-Jun-2015 02:56

The key to many issues where an application loses focus is to make sure that there is always an enabled control in the active window. Once there's no enabled control Windows will select a new foreground window and you lose focus. I've run into this when displaying modal windows, too. The natural thing to do is to disable the main window and then display the modal window but if you do it in that order the application loses focus. What you need to do is display the modal window first and then disable the main window. This way focus is always in an enabled control.

I guess I have no real point other than to commiserate about Windows focus issues. I'm glad you were able to figure yours out. stackoverflow is a great resource.

Posted by Patrick Tingen on 23-Jun-2015 04:37

Well, it seems that I cheered too early, because the problem is not yet solved.

Since my "main window" is Eclipse, I take it there is not much I can do about it?

This thread is closed