一个对话框对应的类中有个函数叫OnInitDialog(),请问什么时候会执行这个函数?是点击这个对话框的时候吗?非常感谢!!!!

解决方案 »

  1.   

    对话框初始化的时候,会调用OnInitDialog()
      

  2.   

    在对话框生产前 初始化工作,比如你可以让一些参数在那里赋值,等等,你debug时候跟踪一下就知道了
      

  3.   

    OnInitDialog()就是初始化函数,当你对话框出现在你眼前的时候,就已经被调用了
      

  4.   

    系统发WM_INITDIALOG给对话框窗口时。。
      

  5.   

    调用这个成员函数是对WM_INITDIALOG消息作出的反应。这条消息是在对话框即将显示之前,在Create ,CreateIndirect或DoModal调用期间发出的
      

  6.   

    我也没工夫查具体是什么时间执行的这个函数的,但是这个问题确实很重要。
    我一般都假设它是在创建对话框窗口之后、显示对话框窗口之前执行的这个函数。
    我按这样的假设处理对话框好像还都没遇到什么问题。
    View类里面的OnInitialUpdate()和这个好像一个样子。
      

  7.   

    MSDN
    ------------------------
    This message is sent to the dialog box during the Create, CreateIndirect, or DoModal calls, which occur immediately before the dialog box is displayed. Override this member function if you need to perform special processing when the dialog box is initialized. In the overridden version, first call the base class OnInitDialog but disregard its return value. You will normally return TRUE from your overridden member function. Windows calls the OnInitDialog function through the standard global dialog-box procedure common to all Microsoft Foundation Class Library dialog boxes, rather than through your message map, so you do not need a message-map entry for this member function.