I have a main window (WinMain) that on Windows only (doesn’t happen on Mac) is randomly activating when it doesn’t have focus, bringing it to the front periodically. I’m trying to figure out what in my code is causing this, but setting a break point for the window’s activate event doesn’t show anything in the stack besides the main thread.
I’ve also set breakpoints throughout the entire app for anything calling WinMain.show, but none of those are called before it activates.
Is there a good way to easily trace what might be calling the window.show function?
Nope no other window is opening or closing. WinMain (document window) is open in the background, a second document window is being used in the foreground, WinMain randomly activates and takes focus. When debugging the breakpoint shows that it has activated but doesn’t show what called the activate method.
Yes all instances of WinMain.Show have a breakpoint set and none are coming up. I set a breakpoint for all 1263 matches of just the “.show” string in the project and none of those break when debugging. Is there another method that would cause a document window to come to the front on Windows?
Maybe too obvious of a question, but is the offending window set to be an implicit instance?
I feel like I had similar behavior in the past with a Window which where this was set (and I didn’t mean for it to be).
I think it was this combined with some bad naming and bad (non-existent) encapsulation which was causing the window to get focus when I was calling a routine I thought was in a module, but was actually in the window. (this was a number of years ago)
I’m not saying it’s not, but if you can’t reproduce it in a small project, it’s less likely that it’s a bug in the framework and more likely a bug in your code.
This is in a desktop app, and the issue still occurs when loading a basically blank page with just text into the HTMLViewer. I’ve also checked all the custom code for the HTML loaded page and nothing in there related to focus.
If the page you’re loading in to the HTMLViewer is that simple and you’re seeing this issue, it sounds like it’s time to open a Feedback Case and let the engineers take a peek.
Native doesn’t come to the front unless something on the page takes keyboard focus (like https://www.google.com) where as https://www.xojo.com/ doesn’t take focus and doesn’t come to front.
Webkit comes to the front even on pages that don’t take focus like https://www.xojo.com/
I’d say it was a bug as you should be able to, for example, load a page in the background and bring it to the front if/when needed in code rather than at load time.
Ah you’re right! It’s a Webkit html viewer in the app but in sample app I was attempting to make I didn’t think to set that for Windows. After changing to Webkit it becomes reproducible.
The problem is that Webkit rendering is basically required for this app, since Native is a lot less… good.