可以用WM_ACTIVATE消息来替代
消息: WM_ACTIVATE
参数:
fActive = LOWORD(wParam); // activation flag
fMinimized = (BOOL)HIWORD(wParam); // minimized flag
hwndPrevious= (HWND)lParam; // window handle
fActive 参数主要定义了该窗口发生了什么事情,即该窗口是被激活还是被取消。该信息保存在 wParam 的低阶字中,可以取以下的值:
--------------------------------------------------------------------------------------
值 描述
--------------------------------------------------------------------------------------
WA_CLICKACTIVE 通过鼠标单击激活了该窗口
WA_ACTIVE 通过鼠标以外的工具(如键盘)激活了该窗口
WA_INACTIVE 取消该窗口的激活
--------------------------------------------------------------------------------------
示例代码:
case WM_ACTIVATE:
{
// test if window is being activated
if(LOWORD(wParam)!=WA_INACTIVE)
{
// application is being activated
}
else
{
// application is being deactivated
}
}
break;