Cview class creation process

Source: Internet
Author: User

Bool a: createview (lpctstr lpszlabel, cruntimeclass * pviewclass, ccreatecontext * pcontext)
{
Crect rect, client;
Assert (pviewclass & pcontext );

// Cwnd * pparent = NULL;
Cwnd * pwnd = NULL;
Int dwstyle = 0;

Pwnd = (cwnd *) pviewclass-> Createobject ();

If (! Pwnd) return false;

//
Assert (pwnd );
If (! Pwnd-> Create (null, null, dwstyle, rect, this, 13576 + m_viewlist.getcount ()))
{
Trace0 ("Warning: couldn't create client area for Tab View \ n ");
// Pwnd will be cleaned up by postncdestroy
Return false;

}

.............

}

Bool cwnd: Create (lpctstr lpszclassname,
Lpctstr lpszwindowname, DWORD dwstyle,
Const rect & rect,
Cwnd * pparentwnd, uint NID,
Ccreatecontext * pcontext)

{
// Can't use for desktop or pop-up windows (use createex instead)
Assert (pparentwnd! = NULL );
Assert (dwstyle & ws_popup) = 0 );

Return
Createex (0, lpszclassname, lpszwindowname,
Dwstyle | ws_child,
Rect. Left, rect. Top,
Rect. Right-rect. Left, rect. Bottom-rect. Top,
Pparentwnd-> getsafehwnd (), (hmenu) (uint_ptr) NID, (lpvoid) pcontext );
}

Bool cwnd: createex (DWORD dwexstyle, lpctstr lpszclassname,
Lpctstr lpszwindowname, DWORD dwstyle,
Int X, int y, int nwidth, int nheight,
Hwnd hwndparent, hmenu nidorhmenu, lpvoid lpparam)
{
Assert (lpszclassname = NULL | afxisvalidstring (lpszclassname) |
Afxisvalidatom (lpszclassname ));
Ensure_arg (lpszwindowname = NULL | afxisvalidstring (lpszwindowname ));

// Allow modification of several common create parameters
Createstruct Cs;
CS. dwexstyle = dwexstyle;
CS. lpszclass = lpszclassname;
CS. lpszname = lpszwindowname;
CS. Style = dwstyle;
CS. x = X;
CS. Y = y;
CS. Cx = nwidth;
CS. Cy = nheight;
CS. hwndparent = hwndparent;
CS. hmenu = nidorhmenu;
CS. hinstance = AfxGetInstanceHandle ();
CS. lpcreateparams = lpparam;

If (! Precreatewindow (CS ))
{
Postncdestroy ();
Return false;
}

Afxhookwindowcreate (this );
Hwnd =: afxctxcreateappswex (CS. dwexstyle, CS. lpszclass,
CS. lpszname, CS. style, CS. X, CS. Y, CS. CX, CS. Cy,
CS. hwndparent, CS. hmenu, CS. hinstance, CS. lpcreateparams );

# Ifdef _ debug
If (hwnd = NULL)
{
Trace (traceappmsg, 0, "Warning: window creation failed: getlasterror returns 0x % 8.8x \ n ",
Getlasterror ());
}
# Endif

If (! Afxunhookwindowcreate ())
Postncdestroy (); // cleanup if createmediawex fails too soon

If (hwnd = NULL)
Return false;
Assert (hwnd = m_hwnd); // shold have been set in send MSG hook
Return true;
}

Bool cview: precreatewindow (createstruct & CS)
{
Assert (CS. Style & ws_child );

If (CS. lpszclass = NULL)
{
Verify (afxdeferregisterclass (afx_wndframeorview_reg ));
CS. lpszclass = _ afxwndframeorview; // color_window background
}

If (CS. Style & ws_border)
{
CS. dwexstyle | = ws_ex_clientedge;
CS. Style & = ~ Ws_border;
}

Return true;
}

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.