CWnd::Create
Visual Studio 2010
Creates the specified child window and attaches it to the CWnd object.
virtual BOOL Create( LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, Const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL );
Use the AfxRegisterWndClass function to register window classes. User defined window classes are available in the module where they are registered.
The CWnd::OnCreate method is called before the Create method returns, and before the window becomes visible.
// Dynamically create static control using CWnd::Create, // instead of with CStatic::Create, which doesn't // need the "STATIC" class name. void CMyDlg::OnCreateStatic() { // m_pWndStatic is a CWnd* member of CMyDlg m_pWndStatic = new CWnd; m_pWndStatic->Create(_T("STATIC"), _T("Hi"), WS_CHILD | WS_VISIBLE, CRect(0, 0, 20, 20), this, 1234); }
The ID of a child window can no longer be 0.
http://connect.microsoft.com/VisualStudio/feedback/details/648513/cwnd-precreatewindow-change-causing-problems
Any child window must now have an ID other than zero.
CWnd::PreCreateWindow will assign one for you if you do not assign one.
This is in order for GetDlgItem to work correctly.
The change fixes a crash in managed/native interop scenarios.
There is a TRACE statement in CWnd::Create which attempts to alert the developer of the problem.
Any child window must now have an ID other than zero.
CWnd::PreCreateWindow will assign one for you if you do not assign one.
This is in order for GetDlgItem to work correctly.
The change fixes a crash in managed/native interop scenarios.
There is a TRACE statement in CWnd::Create which attempts to alert the developer of the problem.
- 3/16/2011
- GregM