The difference between modal and non-modal dialogs in MFC

Could you help me get comprehensive knowledge about the differences between modal and non-modal dialogs by providing me with excellent links to textbooks? For example, can you explain to me about the programs that are linked here ? Are they modal and non-modal?
I knew that developing a dialogue using only codes means non-modal, but creating a dialogue using Toolbox means modal, but as far as I'm looking, I get more confused. Can you help me understand more?

+4
source share
4 answers

The difference between modal and non-modal dialogs is not limited to MFC.

When a modal dialogue is open, you cannot interact with anything other than this modal dialogue inside your program if the modal dialogue is open. Most dialogs are modal, for example, the File-Save As dialogs are modal.

On the other hand, a modeless dialogue behaves like a normal window, you can do whatever you want while it is open. The Microsoft Word Proofing dialog box is an example of such a dialog.

The link mentioned in your question has nothing to do with modal and non-modal dialogs.

Modal dialogs are trivial in MFC.

Modeless dialogs are a bit more complicated, but you can find many tutorials by searching the google "mfc modess dialog tutorial".

+11
source

Modal dialogs are created by calling the DoModal member function of your derived CDialog class in MFC or using the DialogBox API .

Modeless dialogs are created by calling the Create () (or CreateIndirect ) member function of your derived CDialog class in MFC or using the CreateDialog API.

The above links also explain what else needs to be done to support modal and non-modal dialog boxes, for MFC, this MSDN link has some additional information.

+5
source

DialogBox model: 1. The model dialog box. We can share a window with one window (i.e.). Inside we can open a child window (auxiliary window) until we close this window, while we are communicating with the parent window Example: save, save as 2.Create a DialogBox model to call domodel () 3.closeing time, when you call end dialog.this DialogBox doesn't delete, just hide 4. There is one child message loop in the DialogBox model

Modelless DialogBox: 1. When we can open the window (owner window) at the same time, we can also link the child window. Ex.in notebook, word,

2.Model Creating DialogBox - call the Create () window and ShowWindow () 3. If you want to close the window window with a call Here the window is destroyed 4.Here arrays The parent window will open

0
source

Modal dialog box:

  • After opening the modal dialog box, we cannot access the parent EX window: Save as, OpenDialog Box.
  • A modal dialog box invoking the Cdialog constructor and the DoModel method and created on the stack.
  • The modal dialog box is closed by calling the EndDialog() function, it hides the dialog box.
  • It pauses the parent window's message loop and starts its own message loop.

Modeless Dialog Box:

  • After opening the modess dialog box, we can access the parent window.
  • Model created on call

     CDialog::Create(......); CDialog::Show Window(.....) 

    method. And created in the heap.

  • The Modeless dialog box is closed, destroying the window by calling Destroy Window() .
  • It does not have its own message loop; it depends on the message loop of the parent window. The parent window forwards the message to the child window.
0
source

Source: https://habr.com/ru/post/1498556/


All Articles