请问对一个对话筐来说create和OnCreate函数有什么异同?

解决方案 »

  1.   

    创建非模态对话框时调用create函数。
    OnCreate函数是Cwnd类的消息响应函数。
    他们实现的功能是不一样的。
      

  2.   

    Create是从CWnd派生的虚函数
    virtual BOOL Create (LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
    好象很少改写它OnCreate是处理消息的成员函数,在调用CreateWindow/CreateWindowEx等函数创建窗口时被调用对对话框来说,Create虚函数不会被调用
      

  3.   

    Create 是他用,OnCreate 是自用
      

  4.   

    MSDN中说的很清楚:CWnd::OnCreate  
    afx_msg int OnCreate( LPCREATESTRUCT lpCreateStruct );Return ValueOnCreate must return 0 to continue the creation of the CWnd object. If the application returns –1, the window will be destroyed.ParameterslpCreateStructPoints to a CREATESTRUCT structure that contains information about the CWnd object being created.ResThe framework calls this member function when an application requests that the Windows window be created by calling the Create or CreateEx member function. The CWnd object receives this call after the window is created but before it becomes visible. OnCreate is called before the Create or CreateEx member function returns. Override this member function to perform any needed initialization of a derived class. The CREATESTRUCT structure contains copies of the parameters used to create the window.Note   This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.我的理解就是:
    在你要创建窗口调用Create时,应用程序框架给你最后一次机会允许你在OnCreate中改变将要创建好的窗口的属性,如风格,位置等,或者初始化。