Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

BringWindowToTop is hanging on vista..

385 views
Skip to first unread message

rajend...@gmail.com

unread,
Nov 18, 2007, 7:03:13 AM11/18/07
to
Hi

i have an application which shows dialogbox on top of all
application . I am using the following code sequence..


BOOL BringWindowOnTop(HWND hWnd)
{
#ifdef _VISTA
// TODO:
// following code for non vista is hanging in vista when used,
// need to figure out the reason and fix it
return TRUE;
#else
HWND hwndForeground = GetForegroundWindow();

// gets the current top most window on the screen.
DWORD dwFGProcessId = 0;
DWORD dwFGThreadId = GetWindowThreadProcessId(hwndForeground,
&dwFGProcessId);

DWORD dwThisThreadId = GetCurrentThreadId();

// attaches the current thread to window on top
AttachThreadInput(dwThisThreadId, dwFGThreadId, TRUE);

::ShowWindow(hWnd, SW_RESTORE);

// Now the window on top is also in the set of windows we are
intersted,
// so bring window on top will put us on top of all windows
BringWindowToTop(hWnd);
SetFocus(hWnd);

// detach from the previously attached thread
AttachThreadInput(dwThisThreadId, dwFGThreadId, FALSE);
return 0;
#endif
}

This api is called from dialogbox in Oninitdialog method it works fine
on xp system but it hanges
on vista when ::ShowWindow(hWnd, SW_RESTORE); is called .


Here the forground window is windows explorer .
and current thread is a user mode application thread which is
different form windows explorer.

Can you please tell me how to fix this on vista ?

Thanks
Rajender saini

rajend...@gmail.com

unread,
Nov 21, 2007, 1:18:28 AM11/21/07
to

No body is replying , are u able to understand my question?

0 new messages