How to handle messages of sub window in MFC.
I created a menu and when I'm clicking the menu, the program creates a dialog window.
How do I close the menu window when its dialog window is closed?
If dialog is modal:
Close the parent window after returning from DoModal;
You don't return from DoModal until the dialog is closed.
If dialog is not modal:
When you initialize the dialog, send a pointer of the parent to the dialog.
Close the parent using the pointer, where you capture the dialog close event.
Related
On Windows, when a window opens on top of another window, the parent window will not be clickable, and will make a "ding" sound and its titlebar will flash. It will do this until the other window is closed. How do I recreate this in Win32?
The words you are looking for are modal and modeless.
Modal dialogs won't let the user interact with the parent window until they've been dismissed.
This document covers the Win32 API for creating modal dialogs.
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.
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
So i have created a main window inside of which i have created a 2 child windows. They all have different WindowProcs. At the WM_CREATE message of the main window I am giving focus to one of the child windows with SetFocus(...). After I display a MessageBox from the child window proc the focus is set back to main window. How can I maintain focus on the child window?
When the message box window is destroyed, Windows makes another top-level window the active window. If that’s not what you want, it is up to you to respond to the WM_SETFOCUS message that your main (top-level) window will receive and use SetFocus() to direct the focus to the child.
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.