How to embed view in Dialog

Source: Internet
Author: User

Embedding a view in a dialog is not as complicated as you think. follow the steps below.

1. Create a child-type cframewnd and place it in the correct position.

2. Set ccreatecontext correctly

3. Create a view and cframewnd are associated. 4. Show it!


Check the Code:

Cwnd * pposwnd = getdlgitem (idc_view_positon );
Crect rect;
Pposwnd-> getwindowrect (& rect );
Crect rectview = rect;
Screentoclient (& rect );

M_pframe = new cframewnd ();
M_pframe-> Create (null, null, ws_child | ws_visible, rect, this );

M_pframe-> screentoclient (& rectview );

M_pdoc = static_cast <cdlgviewdoc *> (runtime_class (cdlgviewdoc)-> Createobject ());

Ccreatecontext context;
Context. m_pnewviewclass = runtime_class (cdlgviewview );
Context. m_pcurrentdoc = m_pdoc;
Context. m_pnewdoctemplate = NULL;
Context. m_plastview = NULL;
Context. m_pcurrentframe = m_pframe;

Cview * pview = static_cast <cview *> (runtime_class (cdlgviewview)-> Createobject ());
If (! Pview)
Return false;
If (! Pview-> Create (null, null, afx_ws_default_view, rectview, m_pframe, afx_idw_pane_first, & context ))
Return false;
Pview-> showwindow (sw_show );
Pview-> oninitialupdate ();

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