Click to See Complete Forum and Search --> : Fnding active window


August 5th, 1999, 11:31 PM
Hi,
I want to create a Program, which finds active windows.

I'm using MFC.

thanks for your help!1

Black racer

Gregory64
August 5th, 1999, 11:59 PM
If your mean active View window than by this way you may rich you active View window from anywhere.
1. In your View class create static function GetView()
2 Implement it like this

CMyView* CMyView::GetView()
{
CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
CView * pView = pFrame->GetActiveView();
if ( !pView )
return NULL;
if ( ! pView->IsKindOf( RUNTIME_CLASS(CMyView) ) )
return NULL;
return (CMyView *) pView;
}



Since it static function you my call it from everywhere like this
CMyViev::GetView();
If you mean Main Window use
AfxGetMainWnd()

Hope it help

ChristianM
August 6th, 1999, 07:30 AM
try :
GetActiveWindow();