Prevent window from being clicked in while another window is open - c++

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.

Related

Is it possible to create an MDI window to the dialog-based window instead of the frame window?

I know you can create an MDI window to Frame window but what about dialog-based window is it possible to create MDI window to it too or it is just exclusive for Frame window only?
or Is it possible to create an MDI client window then create an MDI child Frame window to dialog-based window?
Can it be done? Probably. Is it a good idea? Probably not.
The main issue is that both MDI and dialogs want to control focus and keyboard handling.
You definitely need to use CreateDialog and not DialogBox to create the main window because you need control of the message loop. TranslateMDISysAccel and IsDialogMessage can help you a little bit but you probably need some custom handling that determines if the active/focused window is a MDI child frame or a normal dialog control and prioritize messages for MDI or the dialog. The most difficult being tabbing out of the MDI child frame window and back into the dialog. The last one you could work around by adding a custom key like F6 to set the focus back to the dialog.
Raymond Chen did a blog post series about dialogs, some of them about how you can write your own dialog class and/or custom dlgproc handling.
Even with full control of the message loop and some control over the dialog, you might still end up having to subclass the dialog and/or the MDI client window to handle specific messages.

Ghost Window/Bitmap lingers after closing window - MFC SDI

Environment: MFC frame based SDI application
Problem: After closing modal dialog boxes, the bitmap stays displayed/the window beneath doesn't repaint.
Dialog creation:
PortSettings Dlg;
Dlg.DoModal();
I've tried explicitly setting OnCancel() for the dialog class,
void PortSettings::OnCancel()
{CDialog::OnCancel();}
tried calling RedrawWindow from the parent window and the Dialog OnCancel.
This issue happens for all the dialog boxes, and other modal windows that open (Like a file browser) I assume because I am using MFC I've somehow interfered with the underlying Window Proc but I'm not sure how to investigate or what to try.
Solution was multifaceted:
Dialog Window Properties affect the image lingering - in my case, it was necessary to change the dialog frame to "thin" style.
After the Dlg.DoModal() call, call ParentWnd->RedrawWindow(). In the Parent Window's OnPaint, I added a fillSolidRect to repaint the background white. This section is controlled with Boolean logic to only repaint immediately after a dialog closes to avoid flickering.

Application-switching window as a modal window

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.

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

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.