-=> Quoting Neil Heller to Jerry Coffin
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;
Why? Your this pointer is already of type CDialog. In fact, all of the
CDialog member variables are already part of Modeless! You'll save yourself
a lot of work by leaving the derivation in place:
class Modeless : public CDialog
{
// new stuff, overriding stuff
Modeless(LPSZ lpszParam) : CDialog(lpszParam) {} //?
// or:
// Modeless(LPSZ lpszParam) { Create(lpszParam); }
};
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> }
NH> I keep getting a syntax error: "cannot convert int to * char".
NH> "Create()" (according to the documentation) can take either type LPSZ
NH> or int. Can you give me a pointer in the proper direction?
Due to the wonders of the Windows API, you get to do the following:
Modeless abc((LPSZ)IDD_DIALOG1);
The constructor will call the create for you now. You may want to have a
boolean flag catch the return from Create so you can test its success, or you
could throw an exception if Create fails, and catch it at the constructor.
... Smoking sections in restaurants are like urinating sections in pools.
--- FastEcho 1.46
---------------
* Origin: House of Fire BBS - Toronto - (416)601-0085 - v.34 (1:250/536)
|