CWnd* pWnd;
assign a window to pWnd (new, Create, Attach, GetDlgItem....)
.....
pWnd->GetSafeHwnd(); //returns NULL if no hwnd
(pWnd->GetSafeHwnd() != CWnd::GetForegroundWindow()->GetSafeHwnd()) //true if the foreground (active) window is a different window
pWnd->IsIconic(); returns true if minimised