非模式对话框,比如搜索对话框,当对话框打开时,可以去操作其它的功能,这时怎么知道用户重新选择非模式对话框???

解决方案 »

  1.   

    CWnd::OnActivate
    afx_msg void OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized );ParametersnStateSpecifies whether the CWnd is being activated or deactivated. It can be one of the following values: WA_INACTIVE   The window is being deactivated. 
    WA_ACTIVE   The window is being activated through some method other than a mouse click (for example, by use of the keyboard interface to select the window). 
    WA_CLICKACTIVE   The window is being activated by a mouse click. 
    pWndOtherPointer to the CWnd being activated or deactivated. The pointer can be NULL, and it may be temporary.bMinimizedSpecifies the minimized state of the CWnd being activated or deactivated. A value of TRUE indicates the window is minimized. If TRUE, the CWnd is being activated; otherwise deactivated.ResThe framework calls this member function when a CWnd object is being activated or deactivated. First, the main window being deactivated has OnActivate called, and then the main window being activated has OnActivate called.If the CWnd object is activated with a mouse click, it will also receive an OnMouseActivate member function call.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.CWnd Overview |  Class Members |  Hierarchy ChartSee Also   WM_MOUSEACTIVATE, WM_NCACTIVATE,WM_ACTIVATE
    --------------------------------------------------------------------------------
    Send feedback to MSDN.Look here for MSDN Online resources.
      

  2.   

    dialog中好像没有OnActivate虚函数
      

  3.   

    CWnd是CDialog的基類 我確定。
      

  4.   

    add window message handle中添加或者用GetFourgroundWindow()来判断是否它为当前窗口