Re: How to know when my application is active
Wouldn't this work ?
-SM
----------------------
static bool bSkip = false;
void CVcClientView::OnActivateFrame(UINT nState, CFrameWnd*
pDeactivateFrame)
{
if(bSkip)
{
CView::OnActivateFrame(nState, pDeactivateFrame);
return;
}
if (nState==WA_INACTIVE && !m_bAlreadyDeactivated)
{
m_bAlreadyDeactivated = TRUE;
m_bAlreadyActivated = FALSE;
TRACE(_T("Deactivate\n"));
ActivateApp2(FALSE);
} // if (nState==WA_INACTIVE)
else if(nState !=WA_INACTIVE && !m_bAlreadyActivated)
{
m_bAlreadyDeactivated = FALSE;
m_bAlreadyActivated = TRUE;
TRACE(_T("Activate\n"));
ActivateApp2(TRUE);
}
}
void CVcClientView::ActivateApp2(BOOL activate)
{
if(activate)
{
bSkip = true;
::SetWindowPos(m_App2Hwnd,HWND_TOPMOST,0,0,0,0,
SWP_NOMOVE | SWP_DRAWFRAME);
bSkip = false;
}
else
{
bSkip = true;
::SetWindowPos(m_App2Hwnd,HWND_NOTOPMOST,0,0,0,0,
SWP_NOMOVE | SWP_DRAWFRAME);
bSkip = false;
}
}