// JP opened flex table

Click to See Complete Forum and Search --> : SetForegroundWindow in Windows98/NT5


adrian accinelli
July 9th, 1998, 06:35 PM
I am trying to find a way around the new behaviour of

SetForegroundWindow in Windows 98 and NT 5.


Now it performs a FlashWindowEx call instead of allowing

an application to force its window into the foreground.


Anyone have a workaround?


Undocumented flag?


FYI: SystemParameterInfo( SPI_SETFOREGROUNDFLASHCOUNT, 0 )

causes the window to flash forever.


Thanks in advance,

Adrian

Ewald
July 10th, 1998, 03:44 AM
Hi Adrian,


use instead of SPI_SETFOREGROUNDFLASHCOUNT the flag SPI_SETFOREGROUNDLOCKTIMEOUT with zero as value.


Ewald

Vlad Losev
July 23rd, 1998, 02:57 PM
Use AttachThreadInput to connect input state with the active thread. This will cause Windows 98 to perform SetForegroundWindow as in Win95. It also works in NT 5.0.


Try this code (error check omitted):


DWORD dwThreadId = GetCurrentThreadId();

DWORD dwActiveThreadId = NULL;


CWnd* pActiveWnd = GetForegroundWindow();


dwActiveThreadId = GetWindowThreadProcessId( pActiveWnd->m_hWnd, NULL );


AttachThreadInput( dwThreadId, dwActiveThreadId, TRUE );


pPopup->SetForegroundWindow();


AttachThreadInput( dwThreadId, dwActiveThreadId, FALSE );


This workaround works in my code, but AttachThreadInput() has some side effects, you may want to consult documentation on it.

//JP added flex table