I am working on a program for Windows, and only on Windows xp 32 bit my bug happens.
The thing is that when Windows is in sleep mode and I wake it up and my GUI is messed up.
My program is connected to a server, and when the computer is waking up, the connection is broken. My GUI is going to the Login panel and doing a re-connection, but for some reason, the GUI display is only showing the animation of the re-connection, with all the rest of the components from the last screen also displayed.
What it should be showing is a blank screen with-reconnecting animation.
I want to catch the event/message that the system is passing to my application when it is waking up to clear the screen before reconnecting.
Is there any way to do so?
Related
Location updates stops being delivered to application in background after about a 20 minutes. Application is not closed because when I click on app icon it is brought back from background in state I left it and then updates starts comming again. I can also see that in top right corner of task bar there is little arrow when it is displayed I got the updates, when it disappears I'm not receiving updates. I'm getting GPS data every 5 seconds, keep it in some queue and every minute I connect to my server via tcp socket and send these updates. When top right arrow disappears my app no longer connects to the server (and it should even with empty data) so I assume that app is in some suspend mode.
I have written app in Qt/QML and then converted the project to XCode. I have checked "Background Modes" (Location updates, Background fetch) in Capabilities. I have in plist file UIBackgroundModes fetch,location. I have also NSLocationWhenInUse NSLocationAlways and NSLocationAlwaysAndWhenInUse UsageDescription And App in system checking has
settings->myapp->location->Always
Maybe the problem is that app is suspended or put to sleep. In some other project I have used some code to prevent screen fading with some simple code:
void IosLockHelper::setTimerDisabled() {
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];
}
Is this this case? But I don't want to have screen turned on all time.
It should continue sending gps location to my server in some intervals it can be 1,5 minutes.
I'm testing on iOS 12.3.1 and with Qt 5.12.3
Thanks in advance
Marek
OK, I get it: focus stealing is evil. Or at least it is 99.9% of the time. But I really need to steal the focus reliably on Windows 8, and so far I'm thwarted by the hordes of people insisting focus stealing is always evil.
Scenario: we run a custom application on an ordinary PC running Windows 8.1 (soon to be Windows 10). The screen, keyboard and mouse sit roughly 5m off the ground up some stairs that the forklift operator really shouldn't climb. The one input device they have is a numeric keypad on an extender cable down at their level. Everything they need to do they can do from that keypad... so long as some evil program hasn't stolen our application's focus, or some remote user hasn't logged out and left another application with focus.
The application is essentially a maximised desktop application - it fills the screen (but is not strictly a "full screen" or "topmost" application), and therefore allows other applications to appear in front of it when required. But when the mouse goes idle, we want this application to resume its "normal" position in front of all other applications so that it gets focus and the numeric keypad input will work reliably.
On Windows 7, using SetForegroundWindow() (enabled by AllowSetForegroundWindow() works fine - the application can be brought back to the front and resume focus. On Windows 8, SetForegroundWindow() only results in the taskbar icon flashing, but the application does not regain focus, forcing our user to climb the stairs... where the full keyboard and mouse is too tempting for them not to press buttons they shouldn't, and chaos typically ensues.
So please sir: can our (MFC, desktop) application steal back the focus once the mouse has gone idle for 1 minute, because it is more or less the only application that should normally be running anyway. If that is permitted, how do we steal it reliably?
Configure hotkeys on numeric keypad (RegisterHotKey).
Pressing a registered hotkey gives you the foreground activation love by Raymond Chen
After you call the RegisterHotKey function to register a hotkey, the
window manager will send you a WM_HOTKEY message when the user presses
that hotkey, and along with it, you will get the foreground love. If
you call SetForegroundWindow from inside your hotkey handler, the
foreground window will change according to your instructions.
Possible solution (with major limitations): do nothing extra; wait.
One of our service technicians observed that on the third or fourth attempt to regain focus using AllowSetForegroundWindow() and SetForegroundWindow() as had been working on Windows 7, Windows 8 finally allowed our application to regain focus. It is not clear what the conditions are that make this work, or if it works reliably, but we have now observed our application regaining focus from beneath Chrome, from beneath another (self-developed) MFC application, and from beneath a third party application - all desktop applications. Approximately 3-4 minutes needed to elapse in each case before focus was surrendered back to our (desktop) application.
However, we have not witnessed it regain focus from beneath metro applications, and nor do we expect it (e.g. hit the Windows key and leave the system lingering on the Start screen).
In our (restricted) situation, we are willing to take the gamble that our users will not launch a metro application that obscures our desktop application, at least not without restoring our application, since their business relies on it. Our main concern is that one of our busy service technicians will log in remotely, get distracted, and carelessly leave one of our desktop utilities with the focus. Waiting 3-4 minutes appears to be a solution to this specific scenario.
I would try it in this way:
Setup a timer in you application. That checks GetForegroundWindow on a regular basis.
If GetForgroundWindow does not belong to your process (GetWindowThreadProcessId)
If a different process onws the foreground window use AttachThreadInput and attach your input queue to the input queue of the other process.
Now use SetForegoundWindow and detach the thread input again.
Now you can use SetFocus as needed to control the input focus of your program.
Is there a way in QT to detect when the system is entering screensaver (in windows)?
keep in mind, that my process is a background process and isn't active all the time, so i can't use this as an Qevent... and i don't want to try and figure out if the user hasn't touched the keyboard or mouse for x time, only to detect if the pc has opened the screen saver... any ideas?
I was using the PlaySound function in one C++ application under Windows.
When this application is running a local var command PlaySound and it starts to play a WAV file.
But when you click on the minimize dialog box of my application, the sound continues playing, when the logical rule must be silenced or muted until you maximize the application again.
The question is:
Is there application-state within Windows to detect when application is minimized?
In order to set the waveOutSetVolume function with 0x00 = mute.
Have your app's window catch the WM_SYSCOMMAND message and check it for the SC_MINIMIZE, SC_MAXIMIZE, and SC_RESTORE notifications.
Your application will receive a WM_WINDOWPOSCHANGED message when the application window has been minimized or maximized. Check the WINDOWPOS struct in lParam to determine the new state. You can then turn the sound off or on, respectively. (Note: this message is also sent when the window is moved, sent to back, etc. So check the lParam.)
If the application is currently minimized can be checked with IsIconic.
And I don't find it logical that the sound has to stop playing when the application is minimized. It's a multitasking OS after all. I want it to do things in parallel.
I have a CView which I would like to host a DirectShow renderer.
I did not write the original code, I am simply cleaning up and moving the code to VS2005. This necessitated an upgrade of certain third party tools and so I'm trying to change the code a bit without having a full understanding of DX/DirectShow.
The problem is that my app hangs when I run
hr = gcap.pFg->QueryInterface(IID_IVideoWindow, (void **)&gcap.pVW);
[trimmed some code]
gcap.pVW->put_Owner((OAHWND) m_pDockWnd->GetSafeHwnd()); // We own the window now
m_pDockWnd is the CView. I can do this when in preview mode, but not when in capture mode. In capture mode, it hangs the app.
If I don't own the render window, there is no problem (although the capture window is owned by the desktop, which won't work for me).
Also, the capture window shows a busy cursor when it is owned by the desktop--probably it's actually not working then either, but it's at least not hanging the app. By hang I mean that the app does not respond to user input, but background threads continue to run.
Update: We were using an old version of DirectX (Aug '06). I compiled/linked against the DirectShow stuff packaged with the Vista SDK and .... no dice.
I've got a resolution for this.
The video stream as getting started from a thread without a message pump, this was causing the video window to become non-responsive. (I guess XP was more tolerant of this, maybe the new display driver model in Vista mucked it up.) Anyways, once I did a SendMessage to the main app window and started the video capture from there, everything seems to work!