How to keep dialogs on top of main window always on top in Qt? - c++

I modified a Qt application to set main window to always be on top using the setWindowFlags(Qt::WindowStaysOnTopHint);. Now all of the dialogs appear underneath the main window, and the app gets "locked", as you need to close the modal to continue, but the modal is behind the always on top window. I did fix the one dialog by using dialog->setWindowFlags(Qt::WindowStaysOnTopHint);. Does this mean I have to do the same for every dialog? Or is ther an easier or proper way to set the main window always on top?

Related

making Modaless dialog on top

I have application in which I will create multiple modalless dialogs, and I want the modaless dialog to be in top without making it top most in setwindowpos(), any alternate way??
I want to do this because , when I click on window the opened modaless dialog should exist as it is but focus will be on window, if I make top most it wil not allow to keep other windows on top

Hide main MFC window while modal dialog is active?

I have a native C++ MFC app. It has a main window based on CWnd, and user action can create a modal dialog. While the dialog is active, I want the main window to disappear, the dialog to be visible, and the main window's icon to remain in the task bar.
How can I accomplish this?
If I hide the main window (ShowWindow(SW_HIDE)), the task bar icon disappears. If I minimize the main window (SW_MINIMIZE), the icon remains. However, since the dialog is owned by the main window, this also hides the dialog.
After the dialog is created, clicking on the task bar icon makes the dialog visible. Naturally, I do not want to require the user to do this.
Even if I insert ShowWindow(SW_SHOW) in the dialog's OnInit handler, the dialog remains not visible. Spy++ shows that its visible bit is set, though. Same is true if I add SetWindowActive to OnInit.
I am not interested in changing the UI design. While the dialog is active, the user interacts only with it, and is not interested in anything in the main window. Therefore, the main window should disappear.
Using Windows VS2005 under WinXP32.
Well, in the block of code where you create the dialog and show it modal, you can do whatever you want to the main window of your app (show/hide) as long as you make the desktop window the parent of your dialog. Usually, the constructor for CDialog and derivatives takes a default argument of NULL for the parent window in which the framework ends up substituting AfxGetMainWnd(). Instead pass CWnd::GetDesktopWindow() as the parent of your dialog and then you should probably be able to hide your main window. However, you still might have a problem with the taskbar--but I'll let someone else give hints since I know nothing offhand about it.
In OnInitDialog, add following codes
//Set windows size zero, the windows disappear.
MoveWindow(0,0,0,0);
//If you want it invisible on taskbar. add following codes.
DWORD dwStyle = GetWindowLong(GetSafeHwnd(), GWL_EXSTYLE);
dwStyle &=~WS_EX_APPWINDOW;
dwStyle |= WS_EX_TOOLWINDOW;
SetWindowLong(GetSafeHwnd(), GWL_EXSTYLE, dwStyle);
You're fighting the OS. A modal dialog, by definition, disables but does not hide the "main" (parent) window. If you wanted another window, make a second one, but don't tell the OS to treat it as a modal dialog over the first window.
Perhaps you can resize the main window to a really small size and always keep it behind the modal dialog.

Moving layered windows concurrently in win32

i am trying to implement a custom tab control in my win32 window, for that i have used a layered window which is child of the main app window (for the main tab control) and independent windows for individual tab items.
My problem: Whenever i move the main app window, the control window moves along with it (because its the child window) where as the individual tab item windows remain on their position. Can anyone guide me how to to get the tab items windows move along with the main app window concurrently? I can not set the item windows as child of the app, so please base your suggestions on that.
You should redesign your tab to be a child window. Otherwise your attempts to make it work is nothing but a desperate try to fix the thing made bad in first place.
Still if you feel like sticking the original plan, you need to hook/subclass the main app window and handle its movement and sizing messages (WM_MOVING and friends) so that your handler could update your popup/tab window position respectively.

Insert an UI into another MFC Dialog

I have one MFC application (exe) that contains two panes in its main UI. This application loads another DLL that also contains one dialog. How can I programatically place a Dialog defined into the DLL, and put it into (within) the pane of the MFC application? The question is not how to programatically retrieve the dialog from the DLL but how to put this dialog 'on the top' (within, inside) of one UI pane that belongs to the application?
My goal is to customize the UI of the application with dialog(s) retrieved from a dll and give the user the feeling that these dialogs all belong to one application UI. Thanks for any hint.
I have some applications with this feature, often with a tab control to alternate between windows.
First I set a frame in the container window, invisible to the user. The frame is just a placeholder to where the dialog window will be.
Then I make an instance of the dialog window as a global variable in the container class, I create the dialog window as a modeless window (using Create(), not DoModal()), move the window to the same RECT of the frame control, and call ShowWindow() to show the window.
Am I understanding you correctly that you don't want the dialogs to appear as dialogs, but rather as content of another window, or as a pane?
In other words, you want to get rid of the dialog's title bar and embed the dialog's content into another window, is that right?
That is possible. You would need to create the dialog without the title bar (change the window style) and make sure that you create the dialog's window as a childwindow of the window where you want the content to go. I can explain this further but I first would like to know if I'm understanding you correctly.

Class(Child window )destructor not getting called

I have created a window which has a toolbar with some icons, and I launch one more window clicking on the available icon from the main window.
First window is created using CreateWindowEx method.
the one I click using an icon is created using dialog resource.
So without closing dialog, I directly close the main window. I see that dialog window is not getting closed.
When I debug, control does not come to destructor of second window.
When I close them individually (i.e dialog first) and then main window next,then everything is fine.
Please help,that what might be missing when I close the main window.
I mean class desctructor is not getting called.
Handle your main window's message WM_CLOSE and check, whether the dialog window is open or not. If dialog window is open, just close it using the handle you got returned while loading it from resources.