If I have a global floating window on Windows I need to leave one other window open or the app quits.
Is there a way to get around this? I need one window that stays above all others in the OS, and nothing else in the app showing.
Sett App.AllowAutoQuit
to False?
But then when I actually want it to quit because I’m intentionally closing the last window, it doesn’t.
Check to see if this global floating window is open in App.CancelClosing?
There’s a lot of ways you can potentially go about this. You could probably set App.AllowAutoQuit
to False when you open the window, then True when you close it?
I’ve tried all of this. It’s something to do with the global floating window.
Testing a few different methods, it looks like there’s a bug in the framework here. The CancelClosing event of the Global Floating Window only fires after it’s been effectively closed.
You should create an issue.
I think I’m seeing the same.
I need a workaround today, so I’m going to keep plugging away.
The same is True for Floating Window. I’m still working on it too.
if I leave a window that is hidden, I can override it. I now have to figure out how closing the window by the button can recognize that it is a “quit” situation.
Yeah, I’m not having any luck. If your goal is to keep the window above all other windows on the system, you can use SetWindowPos with HWND_TOPMOST on Windows with any other type of window. Here’s a thread with the declares.
Thanks. I’ll try that.
Actually the workaround is pretty simple. I just hang onto a hidden window and when track if the window closing has a “isSwitching” boolean set. If not, I close the hidden window and quit.
Luckily in my app there are very few places that I’d need to track to manage this.
When I get a moment I’ll post a bug.
Thanks for the sounding board today.
Interesting. I tried that by creating a new hidden window programmatically and tracking it in a subclass of the Global Floating Window and that had no effect. Both the Global Floating Window and the programmatically created window were closed when the main window was closed.
At any rate, glad you’ve got a solution that works for you.
I also had to instantiate the global floating window from the app class (just not a window that was closing).
Yeah, I tried that, and also tried instantiating from a timer and a timer.CallLater in an App method.
If your window must close the app, set App.AllowAutoQuit to false (to fix your issue of automatic quitting) and add “Quit” in the global floating window’s close event.
Or that is broken too?
We covered that above. It doesn’t work.
I’ve read the whole discussion. You referred to the CancelClosing event of the global floating window firing after the window has been effectively closed.
I’m proposing to use the Close event to issue a “Quit” command (blindly, regardless of whether the window closed or not), not quite the same thing.
Thats not the problem. The problem is that the Global Floating Window cannot be the only window open under normal, expected conditions.