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.

commented: The man is a legend :) +1

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

Ill have to start putting you as a co-author in my papers :) thanks again

Please DON'T

I wont, i wont, dont worry, i was only joking :)

Please DON'T

LOL :P

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.