请问对一个对话筐来说create和OnCreate函数有什么异同?
解决方案 »
- (帮顶就给分)如何使用CLongBinary类型绑定ntext类型字段?
- 怎么在vie类窗口中获取他的CRect
- 不用定时器,如何实现到达某个特定时刻,处理某个函数???????
- 请问,有什么好的书系统的介绍windows界面编程
- 头痛得很。。。
- theApp如何获得文档指针?
- 谁能提供点VC自带的ActiveX控件的用法?比如Microsoft DataGrid Control的
- OpenGL与MFC,奇怪的问题,无法理解
- 实时系统的调度算法的VC++源码
- vc++ 大数据查询
- 套接字API(Socket API)程序的编译环境是什么?家庭PC上能调试Socket API程序吗?
- 高分送上,请教内存释放问题。
OnCreate函数是Cwnd类的消息响应函数。
他们实现的功能是不一样的。
virtual BOOL Create (LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext = NULL);
好象很少改写它OnCreate是处理消息的成员函数,在调用CreateWindow/CreateWindowEx等函数创建窗口时被调用对对话框来说,Create虚函数不会被调用
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中改变将要创建好的窗口的属性,如风格,位置等,或者初始化。