I am working on a messenging tool. The message box is part of the whole application. I need a window to go to the front when some messages appear. I am using this code:
if( m_hwnd == NULL || !::IsWindow(m_hwnd) )
return E_UNEXPECTED;
if(::IsIconic(m_hwnd))
{
::ShowWindowAsync( m_hwnd, SW_RESTORE );
}
::SetWindowPos(m_hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ASYNCWINDOWPOS | SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
::SetForegroundWindow(m_hwnd);
if( pvbProcessed != NULL )
*pvbProcessed = VARIANT_TRUE;
return S_OK;
I even tried to make TOPMOST, but in some cases it does not work. I also tried :: BringToFront ().
Can anyone help or explain why it is not working? This is a known limitation for Microsoft.
source
share