失去焦点和得到焦点响应的是: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.
当窗口得到或失去焦点时,会触发这个消息.
我们接收到这个消息后,可以判断到底是哪一种状态.
对应的处理是: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.
当窗口得到或失去焦点时,会触发这个消息.
我们接收到这个消息后,可以判断到底是哪一种状态.
-
C/C++ code
-
void CXXXDlg::OnActivate( UINT nState, CWnd * pWndOther, BOOL bMinimized ) { CDialog::OnActivate(nState, pWndOther, bMinimized); if (WA_ACTIVE == nState) { ...... } else if (WA_INACTIVE == nState) { ...... } else { ...... } }