首先引入网上搜索到的关于这两个消息比较靠谱的区别:
在响应WM_CREATE消息响应函数的时候,对话框及子控件还未创建完成,亦是说只是通知系统说要开始创建窗口啦,这个消息响应完之后,对话框和子控件才开始创建。因此在此消息响应函数中无法对控件进行修改和初始化。
而WM_INITDIALOG消息响应函数是在程序运行时,当其对话框和子控件全部创建完毕,将要显示内容的时候发送的消息。因此可以在WM_INITDIALOG消息响应函数中添加对编辑框控件的初始化和修改。
其实,最权威的解释永远都来自MSDN,摘要如下:
The WM_CREATE message is sent when an application requests that a window be created by calling theCreateWindowEx or CreateWindow function. (The message is sent before the function returns.) The window procedure of the new window receives this message after the window is created, but before the window becomes visible.
The WM_INITDIALOG message is sent to the dialog box procedure immediately before a dialog box is displayed. Dialog box procedures typically use this message to initialize controls and carry out any other initialization tasks that affect the appearance of the dialog box.