MFC中OnActivate函数解析

 

失去焦点和得到焦点响应的是:ON_WM_ACTIVATE()
对应的处理是:afx_msg void OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized);


nState有三种状态:
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.
当窗口得到或失去焦点时,会触发这个消息.
我们接收到这个消息后,可以判断到底是哪一种状态.

 

void CXXXDlg::OnActivate( UINT nState, CWnd* pWndOther, BOOL bMinimized )  
{  
 CDialog::OnActivate(nState, pWndOther, bMinimized);  
  if (WA_ACTIVE == nState)  
  {
    ......
  }
  else if (WA_INACTIVE == nState) 
  {
    ......
  }
  else
  {
    ......
  }
}

 

原文链接:http://blog.csdn.net/xiashengfu/article/details/7938084

 

 

 

posted @ 2013-12-17 15:11  新坐标  阅读(1520)  评论(0编辑  收藏  举报