let's say i have a big application with a few child windows inside of it. ( example )
Now, i am trying to undock one of those "inside windows" to a new serperated window, which i can move all over the place!
What i have done so far:
HWND oldHWND = SetParent(hwnd, NULL);
SendMessage(oldHWND, WM_SYSCOMMAND, SC_CLOSE, 0);
All this works very well, but i am not able to move the new window and i am not able to close it, because there is no window frame and no close button.
Do you have any suggestions for me?
Thank you very much!
Register a suitable window class for your undocked "floating" window with a frame/close button etc, and then make the undocked window a child of that.
Related
When I call SetParent() on a child window passing hWndNewParent as null, the child window now has it own window, however I can't move it anymore, and its also moved to 0x0.
Is there any window style or something else I could apply/do to make this able to move the window?
Edit:
I was able to get the window moving again by disabling the window style: WS_DISABLED and enabling WS_DLGFRAME / WS_BORDER.
Another issue: the window doesn't respond to clicks. When I click the empty area left in the parent window, the click does work in the child window, but when I click in the child window itself, the clicks don't work. They are on the same process.
So I have the following code:
QString splashImageFilePath = ":/images/Splashscreens/startup.png";
QSplashScreen * splash = new QSplashScreen();
splash->setPixmap(QPixmap(splashImageFilePath));
splash->show();
splash->raise();
This runs fine and the splash screen shows up exactly like I want it to but it doesn't show an icon in the taskbar and so it is possible to click on another window and never be able to see the splash bar ever again (it hides behind other windows).
I've already tried to use the window flag Qt::WindowStaysOnTopHint but if I use this, there's still no icon in the taskbar and now it's always on top of all other windows (which I don't want).
I've looked through a few window flags so far and have googled for quite a while I'm trying to show it.
Also, I know I can give the constructor a parent, but this code is inside the main.cpp and so I don't have a way of giving it a parent window (a QWidget with an empty constructor also didn't work).
TLDR: I want my QSplashScreen to have an icon in the task bar.
Thank you in advance!
A little late, but I ran into the same problem and fixed it using WinAPI directly:
QSplashScreen splash;
splash.setPixmap(QPixmap(splashImageFilePath));
// ensure that taskbar icon is shown while the splash screen is active
int exstyle = GetWindowLong(reinterpret_cast<HWND>(splash.winId()), GWL_EXSTYLE);
SetWindowLong(reinterpret_cast<HWND>(splash.winId()), GWL_EXSTYLE, exstyle & ~WS_EX_TOOLWINDOW);
splash.show();
It is possible to set application-switching window as a Modal window (see definition)?
I mean, this window appears when I press Alt+Ctrl+Tab button at the same time and allows me navigate between opened applications typing "tab" key.
The problem appears when I push/click outside the window (Application-switching window lost focus and disappears).
Are there any way to avoid this problem in C++ MFC? I have tried calling:
CWnd* appSwitchingWnd = GetTopWindow();
appSwitchingWnd .SetFocus();
But it doesn't works...
I will appreciate any kind of help.
I've created a popup window with SW_SHOWNA.
The problem is when I move the main window behind the popup window the popup window stays at the same place.
Is there any way to catch the click on the title bar (or other technique) of the main window behind the popup window and to close the popup window?
thanks a lot!
mike.
Yes, just do it. I would however not react to the click, as it makes your behavior mouse-bound. From your description, it seems you want to close the popup on a window move, so trap that message (WM_WINDOWPOSCHANGING) instead. This will catch keyboard-initiated moves as well.
I am creating a program that displays a popup at certain times (just like some chat clients for example) on which the user can click. However, I do not want to take away the focus from the current application.
The way I'm doing it now is by using a HWND with WS_POPUPWINDOW and minimizing and then restoring the window. However, this steals the focus from the current application. Setting foreground or hiding and showing a window did not make it appear on the foreground. I would like to be able to keep using a HWND so I can use other elements in this window, but I have no idea how to give it foreground without stealing focus.
I use win32 and c++.
To show without activating:
ShowWindow(hwnd, SW_SHOWNOACTIVATE);
To raise without activating:
SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
Unfortunately this is not working for me. The window is created with CreateWindowExA and is showed using ShowWindow(hwnd, SW_SHOWNOACTIVATE) however the keyboard focus is still stolen from the window which has the focus at the moment of the creation. (The window is created with layered and trasparent attributes by using SetWindowLong() and SetLayeredWindowAttributes() ).
PS: The window which has the focus is not parent of the new created window.
Solved: It worked when I removed the SetForegroundWindow call. This function cause the window passed as parameter to be activated.