Making a lauched QT applicatioin get Focus in windows - c++

Currently whenever my application starts it does not appear in the foreground. It appears on the taskbar but it does not get focus. I tried doing the following
application.setActiveWindow(&w);//w if my form widget
but this just makes it blink. Any suggestion on how I could set the focus to my application.

Related

How to make Qt MainWindow always on top AND above start menu in Windows 11

I'm trying to make a widget tool that stays above EVERYTHING.
Following the other stackoverflow post, I set the flag
setWindowFlags(Qt::WindowStaysOnTopHint);
and use a timer to constantly raise the window.
Now it can stay above all normal windows and other always-on-top windows. But it will still get blocked if the Start menu is open.

Windows Forms - ShowDialog with a parent - why doesn't clicking on the parent activate the dialog when main window is maximized

I'm seeing non-standard behavior (as compared to tools like Word and Visual Studio 2013) in my C++ Windows Forms application. We use Application::Run and then ShowDialog to show various modal dialogs. When one of the modal dialogs is up and I place another application window partially in front of the modal dialog, I can click on part of the modal dialog and it brings it back into the foreground as I expect.
However, if I instead click on part of the main window (shown with Application::Run) the modal dialog isn't brought to the foreground. This makes it hard to bring my application back so I can work on it. Ideas?
A simple MFC app created in VS2013 works as it should too. You can witness this with the About box which is shown with DoModal. I would have expected ShowDialog and DoModal to be equivalents. A simple C++/CLI or C# winforms application acts fine.
And this only happens in out application when our main window is maximized.
It turns out that is caused by our use of the Syncfusion UI libraries. They will be fixing the bug.

QT - Check if QT app is the app in focus

Here is what I want to do :
Check if my Qt app on windows is an app on the front or minimized.
If its minimized then draw the users attention by making it blink.
Now how can i detect if the app is minimized or on the background ?
I believe this is what you are looking for:
http://qt-project.org/doc/qt-5/qwidget.html#isActiveWindow-prop
then, you can call QWidget::activateWindow().
Looking at the notes:
if you are calling this when the application is not currently the active one then it will not make it the active window. It will change the color of the taskbar entry to indicate that the window has changed in some way.
This sounds exactly like this blink effect you are trying to achieve.
(Links are for Qt5, but this already exists in Qt4: http://qt-project.org/doc/qt-4.8/qwidget.html#activateWindow)

Adding custom controls to a console window

Is it possible to add custom controls to a console window? You can use GetConsoleWindow() to get the window's handle, and then add your own menu items or consume all its events. I can't find any examples of people adding extra controls though.
I am developing a small, high performance serial terminal app. It is a console application - RichTextBox is too slow and has issues that make it unsuitable for VT100 terminal emulation.
I want to add some little graphics to show the state of the serial control lines (RTS/CTS/DTR/RI etc.) and perhaps a capture on/off toggle button. Ideally I'd like to add them to the window title bar. Bitmaps are all that are required.
After lots of research I found that it isn't easy, or even possible really.
You can add controls to the window with CreateWindow(), but of course only in the client area which is taken up entirely by the console text box. However, you can at least create floating controls that way, which hover over the text to provide status info etc.
You can put controls in the window borders but only with some hacking on XP or a new API that was introduced with Vista. The problem with this API is that it requires you to draw your own program icon and title text, and the console window doesn't seem to cope with it very well.
You can't add your own menu items because the console window doesn't pass the messages.
In the end I used the function keys for everything and gave a status indication by changing the console window icon.

Popup windows are behind window but it is rendered front?

I am updating the webkit embeded to my program however I come across a new problem about popup windows (MessageBox or File/Folder chooser dialogs).
For instance, if I invoke a javascript alert() clicking on a link, the MessageBox is rendered in front of the webkit window and looks like it is clickable, however when it is clicked the webkit window gain the focus and the MessageBox goes back of the webkit window. After that everything works as usual.
This problem does not happens if I invoke the alert() with keyboard.
So given the clues, what could be the solution, any tips ?
OS: Win7
In win/webview.cpp WM_CANCELMODE message invokes a function. Comment out, problem is solved.