Windows focus / Windows Shutdown Problems
Hi All,
I am have 2 annoying problems with the Windows version of my program. I mostly use Linux and neither of these occur there, so I'm hoping someone who uses Windows a lot might be able to help.
1) My program runs mostly in the icon tray, and uses a pop-up to alert users when they have new messages. The popup is a QDialog with the following in the constructor:
setWindowFlags( Qt:: Dialog | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::X11BypassWindowManagerHint );
This works great on Linux, but on Windows causes the pop-up to steal focus. I have tried playing with just about every windows flag I can find, but there seems to be no way for a widget to be On Top in Windows but not steal focus when it first appears with QT, although I have seen it done with GTK and Visual C++. Any ideas?
2) I modified the TrayIcon example so that my program minimized instead of shutting down when someone clicks the close button. To exit the program the Tray-icon Context menu is used.
The problem is that on Windows, if the App is open (And the main window showing) and you shutdown or restart Windows, the program is minimized, and windows halts it's shutdown.
Is there any way to detect if the close came from outside the program or from a user clicking the close button?
Thanks loads
Re: Windows focus / Windows Shutdown Problems
1. What window flags are set in the examples you've seen?
2. Override winEvent and look for the WM_QUERYENDSESSION. More details on http://msdn2.microsoft.com/en-us/library/aa376890.aspx. You should set the result param of winEvent to a non-zero value, so the shut-down/restart won't halt. When you catch this event you should also close your app.
Re: Windows focus / Windows Shutdown Problems
I am trying to use the winEvent, but every time I try to do anything with the message, I get this error:
error: invalid use of undefined type 'struct tagMSG'
Which headers should that be defined in?
Re: Windows focus / Windows Shutdown Problems
Try
Code:
#include <qt_windows.h>
Re: Windows focus / Windows Shutdown Problems
That doesn't exist on Linux, so explains why I never found it. Will check my windows install when I get home.
As for the Focus stealing problem, never actually seen any source from programs that manage ok, but look at MSN messenger, that has popups that don't steal focus.. I just wish I knew how!
Re: Windows focus / Windows Shutdown Problems
Quote:
That doesn't exist on Linux, so explains why I never found it. Will check my windows install when I get home.
You asked for a Windows solution.
Quote:
As for the Focus stealing problem, never actually seen any source from programs that manage ok, but look at MSN messenger, that has popups that don't steal focus.. I just wish I knew how!
Try searching codeproject.com, maybe you find something there. Still, you can find a Windows-only solution there.
Re: Windows focus / Windows Shutdown Problems
Quote:
Originally Posted by
marcel
You asked for a Windows solution.
Yes I did, and thanks for helping me find the correct include. I was just saying that the reason I hadn't found it initially (and I did search a fair bit) was because it doesn't exist on the Linux install, I really should have also looked on Windows!