How do you change the parent of a modeless dialog in MFC? - mfc

Imagine I have model dialog A.
It creates a modeless dialog B.
Dialog A then displays a pop up modal dialog C.
Is it possible to temporarily set the parent of the modeless dialog B to the pop up C?
Does that make sense? At the moment it looks like the parent can only be set at creation time.

Related

What is the proper way to create Cancel Button that closes dialog in GTK+?

The question is for GTK+ programing in C++.
I have a main window with a button that activates a dialog window. The dialog window has OK and CANCEL buttons. I did it that way so when I hit the cancel button the dialog is closed. But once it is closed I cannot call it again with the button in the main window.
I have tried to call the dialog delete-event on the button click. I also tried to call the dialog destroy event when the button is clicked. But in both cases the dialog is destroyed and it does not show when I click the button that calls the dialog.
I suppose this is a follow up of your other question on the topic:
How to properly close a dialog made in Glade?
If it was created using GtkBuilder, if you destroy the window, it's really destroyed: GtkBuilder has created the widgets at parsing time, not when you call get_object, and won't create them again. So I think you should just hide the dialog with something like gtk_widget_hide_on_delete, and show it again when you click on the button in your main dialog.

how to forbid dialog show in the windows taskbar in Qt programming when I open a new dialog?

how to forbid dialog show in the windows taskbar in Qt programming when I open a new dialog?
when I open a new a dialog in the main window.In the windows taskbar always show a new dialog task,I don't want it shows. how to do it?
Quoting from QDialog:
A dialog is always a top-level widget, but if it has a parent, its default location is centered on top of the parent's top-level widget (if it is not top-level itself). It will also share the parent's taskbar entry.
Use the overload of the QWidget::setParent() function to change the ownership of a QDialog widget.
If Dialog's parent is set to None then it opens another window, and i have two entries in taskbar.
If Dialog's parent is set to mainwindow - the dialog is shown inside the main window and share taskbar entry.

How to create multiple Dialogues?

In a Project I am using multiple dialogues so in that my requirement is while I am initiating dialog if it is modal then it should come top else it should be behind the parent window...so suggest me how to do it???
Modal dialog always come to the top of the parent window. But what is the else case? You have a non-Modal dialog that should stay behind the Parent window? This doesn't make sense to me.
But if you want to have a non-modal dialog behind the parent window (or any other window) you need to define NULL for the dialog as a parent (owner window). Than you can change the Z-order of the top level window to be behind/after the parent window (use SetWindowPos for this).
Please note that the user can always change the Z-Order of top-level windows when he clicks on it.
Remember: If the window is owned by a parent it is always on top of the owned window.

When called ShowWindow(SW_HIDE) in OnClose method has painting issues MFC

I've created a Modaless dialog inside a dialog A which displays some content. I've overridden ONClose() event of Modalless dialog and hidden the modaless dialog inside it and sends the message to dialog A to load the content again. Now the problem is whenever I've launched the modaless dialog and moved that dialog inside the main dialog and then closed the dialog. The portion of the dialog displayed inside the dialog A is not re-painted.
In Debugging I found that Dialog A is actually painted after modaless dialog got closed in the client area of Dialog A and then after the On Close Event done in Modaless dialog, the portion of the modaless dialog which has painted is lost and that portion is background as white( I've handled EraseBackgroung to white).
Any suggestion would be helpful.
Thanks

Use dialog controls without stealing focus

I have a modeless CDialog that contains controls, some CButtons and a CScrollbar. The CDialog is parented off of an edit box that I want to keep focus at all times. The problem is that whenever the user uses the controls, clicking a button or on the scrollbar, the control steals focus from the edit box, causing both the parent window to draw without focus (grayed-out header bar), and causing the control to take all the keyboard input. Is there a way for the controls to respond to mouse actions but not steal focus?
The controls and the dialog are all created with WS_CHILD. The controls are parented off the dialog, and the dialog is parented off of the edit box.
I've tried setting focus back after the controls are used, but that causes the parent window to flicker as it loses and then regains focus. Basically I want something that works like a combo box, where the scroll bar can be clicked or dragged around, but keyboard input still goes to the dialog itself, not just the scroll bar, and the whole thing never loses focus.
I haven't done anything like this for a long time, so I'm sure there are a million little details, but I think the starting point is to override the handling of WM_MOUSEACTIVATE.
I am a little confused about child-parent relationship you described.
Can you explain what do you mean by:
The CDialog is parented off of an edit box that I want to keep focus at all times
Any window hosting other windows inside of the client area is a parent of those windows. It is impossible to create window without WS_CHILD that is contained by other window.
Therefore all dialog’s controls are children of this dialog. It is also possible that child window hosts another child window.
CDialog is just an MFC representation of a dialog window; the same applies to other controls. For example CButton is an MFC class that wraps handle of the window’s window that is predefined as window button control.
Dialog never has focus unless is empty (does not have any controls). If dialog contains even one control, this control always has focus.
What focus means is that any given window receives mouse and keyboard messages. Only one control can have focus at any given time. In order for scroll bar to process mouse click or keyboard to move slider, scroll bar must have focus; therefore some other control must give it up.
Combo box drop box (I think this is what you are referring to) is not a child of the dialog. It is a popup window that for the duration has keyboard focus and captures mouse. When it drops down, dialog is deactivated and once dropdown hides, dialog state is changed back to active hence focus never changes, it returns to the control that had focus when dialog was deactivated.
What you are trying to do is probably possible but it would require a lot of coding. Probably hooking messages would do the job but I think it would be going against the stream.