Bringing specific window to top seems to be easy. However, some function which should do those kinds of things are not work actually. Thus, following code is the way to bring window to top attaching thread input to target window.


if(::GetForegroundWindow() != GetSafeHwnd()) { 
HWND hActiveWnd = ::GetForegroundWindow(); 
if( hActiveWnd ) { 
DWORD dwActiveTid = GetWindowThreadProcessId(hActiveWnd, NULL); 
DWORD dwCurTid = GetCurrentThreadId(); 

if(dwCurTid != dwActiveTid) { 
if(AttachThreadInput(dwCurTid, dwActiveTid, TRUE)) { 
BringWindowToTop(); 
AttachThreadInput(dwCurTid, dwActiveTid, FALSE); 
}

+ Recent posts