1. derive a cdocument class and set the dialog box to the friends of the class, for example:
Class cxxdlg;
Class cmydocument: Public cdocument
{
Declare_dyncreate (cmydocument)
Friend class cxxdlg;
Public:
Cmydocument ();
Virtual ~ Cmydocument ();
# Ifndef _ win32_wce
Virtual void serialize (carchive & AR); // rewrite for document I/O
# Endif
# Ifdef _ debug
Virtual void assertvalid () const;
# Ifndef _ win32_wce
Virtual void dump (cdumpcontext & DC) const;
# Endif
# Endif
Protected:
Virtual bool onnewdocument ();
Declare_message_map ()
};
2. derive a cdocument class and set the dialog box to the friends of the class, for example:
Class cxxdlg;
Class cmylogshview: Public chtmlview
{
Declare_dyncreate (cmylogshview)
Friend class cxxdlg;
Protected:
Cmylogshview (); // dynamically create the protected constructor used
Virtual ~ Cmylogshview ();
Public:
# Ifdef _ debug
Virtual void assertvalid () const;
Virtual void dump (cdumpcontext & DC) const;
# Endif
Protected:
Virtual void dodataexchange (cdataexchange * PDX); // supported by DDX/DDV
Declare_message_map ()
};
3. Define a function for creating htmlview in cxxdlg (you do not need to define it, of course ):
Cmylogshview * cxxdlg: createmylogshview (void)
{
Ccreatecontext pcontext;
Cwnd * pframewnd = this;
Pcontext. m_pcurrentdoc = new cmydocument;
Pcontext. m_pnewviewclass = runtime_class (cmylogshview );
Cmylogshview * pmylogshview =
(Cmylogshview *) (cframewnd *) pframewnd)-> createview (& pcontext );
If (pmylogshview = NULL)
{
Return NULL;
}
Pmylogshview-> showwindow (sw_normal );
Crect rectwindow;
Getwindowrect (rectwindow );
Rectwindow. Left-= 5;
Rectwindow. Right + = 15;
Rectwindow. Top-= 22; // These are used to set the htmlview location, and can be set as reasonable as I personally think.
Pmylogshview-> movewindow (rectwindow );
Return pmylogshview;
}
I call createmylogshview () in the oninitdialog () function of cxxdlg, as follows:
Bool cxxdlg: oninitdialog ()
{
Cdialog: oninitdialog ();
.....
.....
......
// Todo: add additional initialization here
Cmylogshview * pmylogshview;
Pmylogshview = createmylogshview ();
Return true; // return true unless you set the focus to a control
}