MFC has a class called CDialog which is a CWnd derived class
that is specifically used for the creation and display of dialog
boxes on screen - both modal and modeless dialogs are
supported. Modeless dialogs are created using Create() and you
have to destroy them on your own using DestroyWindow() and
they behave just like any normal modeless window. Modal
dialogs are created and shown using the formidable DoModal()
method of the CDialog class. And you close a modal dialog by
calling EndDialog() or alternatively by calling OnOK() or
OnCancel() both of which internally call EndDialog(). The
CDialog::EndDialog method will call the EndDialog Win32
API function which is defined in user32.dll. EndDialog (the API
function) will not immediately close the dialog, rather it will set
a flag which will instruct the message queue to exit the loop,
destroy the dialog window and enable the parent window. So far
so good; everything seems so peaceful and serene, and the little
birds in the tree across the yard are tweeting in a beautiful
voice. |