The application is of MFC. Sometimes I need to activate the window and display it at the topmost of the screen when it's deactivated, or hidden, or minimized. Here's what I did:
AfxGetMainWnd()->BringWindowToTop();
AfxGetMainWnd()->SetActiveWindow();
AfxGetMainWnd()->SetForegroundWindow();
if(AfxGetMainWnd()->IsIconic())
AfxGetMainWnd()->ShowWindow(SW_SHOWNORMAL);
else
AfxGetMainWnd()->ShowWindow(SW_SHOW);
AfxGetMainWnd()->UpdateWindow();
But I found sometimes the window was not activated and was still convered by window of other appliactions. Is there anything wrong with my approach? How should I fix this?
Thank you very much!