Hey All,

I am having a problem with the function "SetForegroundWindow". From googling I am readin that it does not work for MSVC 6 MFC on a vista machine???? I am trying to write code that will check if a window is open, if the window is open bring the window to the foreground, if the window is not open open window:

FILE * pFile = fopen ("EvolveTraffic.exe", "rt");
if (pFile==NULL)
{	ShellExecute(this->m_hWnd,"open",
    "\EvolveTraffic.exe","","", SW_SHOW );
}

else
{

		HWND hWnd = ::FindWindow(NULL,"EvolveTraffic.exe");
		SetForegroundWindow(hWnd);
}

I am getting a compile error "'SetForegroundWindow' : function does not take 1 parameters". I am completely stumped here, any help would be greatly appreciated, thanks.

Colm

In MFC there are two versions of that function, one global and the other a method of CWnd. The compiler is assuming you want the CWnd version. Just add global scope operator :: like you did with FindWindow() and it will compile correctly.

Comments
The man is a legend :)

Thanks Ancient Dragon, you are becoming my saviour :) Ill have to start putting you as a co-author in my papers :) thanks again

This question has already been answered. Start a new discussion instead.