Chtmlview allows you to browse Web pages in Dialog

Source: Internet
Author: User
Tags protected constructor

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
}

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.