TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: NEIL HELLER
from: DARIN MCBRIDE
date: 1997-07-13 18:57:00
subject: Modeless dialog boxes

 -=> 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)

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™.