TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: NEIL HELLER
from: JERRY COFFIN
date: 1997-07-12 01:00:00
subject: Modeless dialog boxes

On (10 Jul 97) Neil Heller wrote to Jerry Coffin...
 NH> I have run into a real stone wall in trying to construct a modeless
 NH> dialog box in MSVC + MFC.  First I constructed a class derived from
 NH> CDialog called Modeless.  In that class I have a member pointer:
 NH> CDialog * m_pModelessDialog;
Your dialog class is derived from CDialog - there's no need for it to
contain a pointer to a CDialog because it IS a CDialog.
 NH> Then in the source file:
 NH> Modeless abc;
 NH> abc.m_pModelessDialog = new Modeless;
 NH> if (!abc.m_pModelessDialog->Create(IDD_DIALOG1) {
 NH>     AfxMessageBox("Dialog creation failed",MB_OK);
 NH>     exit(1);
 NH> }
I _seriously_ doubt that you want a modeless dialog to be an automatic
variable - the dialog is going to be destroyed on command, not when you
leave whatever scope this code happens to be in.
I did a quick AppWizard app and added a menu entry to create a dialog,
linked to code to create a modeless dialog like this:
void CStuffView::OnDialog()
{
    modeless *dlg = new modeless;
    if ( !dlg->Create(MODELESS)) {
        AfxMessageBox("Unable to create dialog.", MB_OK);
        PostQuitMessage(1);
    }
}
Destroying the dialog was handled like this:
void modeless::OnButton1()
{
    DestroyWindow();
}
Obviously I also had to create a dialog template named MODELESS, with a
button to tell when its job was done.  This compiled and ran just fine.
However, none of this should have actually stopped your code from
compiling - it almost sounds like your MFC header might have somehow
gotten the prototype for one version of CDialog::Create deleted from the
file so the compiler no longer sees it.  However, it's hard to believe
that a header could be munged and only affect one prototype unless this
happened by operator error.
    Later,
    Jerry.
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.