Create a Modeless Dialog Box as Child Window





4.00/5 (9 votes)
Nov 10, 2000

298044

3321
Simple step by step article explaining how to create a modeless dialog box as child window.
This article is part of the drag and drop interface samples.
- Serializing ASCII Data
- Modeless child dialog
- Modeless sibling dialog
- The drag source
- The MFC drop target
- The TBTextTarget class
To create the modeless dialog as sibling, follow this link.
Follow these steps:
- Create a new dialog resource and use the Class Wizard for making a new
CDialog
based class for it; let's call itCDropDialog
. - In your
CFormView
-derived class, add a (private
) member variable of typeCDropDialog*
as a container for the modeless dialog class, let's call itm_pModeless
. In the constructor of your view, make sure you initializem_pModeless
toNULL
. - In your appropriate message handler, let's call it
OnModeless
, do the following:void CInterfaceView::OnModeless() { // Display the modal dialog box if (!m_pModeless) m_pModeless = new CDropDialog; if (!::IsWindow(m_pModeless->GetSafeHwnd())) m_pModeless->Create(IDD_DIALOG1, this); m_pModeless->ShowWindow(SW_SHOW); }
In the destructor of the parent window, proof if the dialog has been closed and release the memory:
CInterfaceView::~CInterfaceView()
{
if (m_pModeless)
{
if (::IsWindow(m_pModeless->GetSafeHwnd()))
m_pModeless->EndDialog(IDCANCEL);
delete m_pModeless;
}
}
License
This article has no explicit license attached to it, but may contain usage terms in the article text or the download files themselves. If in doubt, please contact the author via the discussion board below.
A list of licenses authors might use can be found here.