When My program restore window from Tray, Why not bring to the top?
-
When right click my tray icon, show the menu, And there is a menu item "Restore window". When click this menu item, it should restore window. My code implement "Restore window" below:
void CWinSearchDlg::OnTrayRestoreWnd()
{
DestroyTray();
ShowWindow(SW_SHOW);
::BringWindowToTop(this->GetSafeHwnd());
::SetForegroundWindow(this->GetSafeHwnd());
::SetActiveWindow(this->GetSafeHwnd());
}I've tried the code in red font, but when restore the window, It doesn't bring to the top. Please give me a sign!
-
When right click my tray icon, show the menu, And there is a menu item "Restore window". When click this menu item, it should restore window. My code implement "Restore window" below:
void CWinSearchDlg::OnTrayRestoreWnd()
{
DestroyTray();
ShowWindow(SW_SHOW);
::BringWindowToTop(this->GetSafeHwnd());
::SetForegroundWindow(this->GetSafeHwnd());
::SetActiveWindow(this->GetSafeHwnd());
}I've tried the code in red font, but when restore the window, It doesn't bring to the top. Please give me a sign!
-
Thank for your reply first. SetWindowPos Not Working too. I even try to put them in different order. Please do me a favor.
-
When right click my tray icon, show the menu, And there is a menu item "Restore window". When click this menu item, it should restore window. My code implement "Restore window" below:
void CWinSearchDlg::OnTrayRestoreWnd()
{
DestroyTray();
ShowWindow(SW_SHOW);
::BringWindowToTop(this->GetSafeHwnd());
::SetForegroundWindow(this->GetSafeHwnd());
::SetActiveWindow(this->GetSafeHwnd());
}I've tried the code in red font, but when restore the window, It doesn't bring to the top. Please give me a sign!
Did you check the return values for the above (Red colored) function calls ? The other possibility is that (if the functions return success), the window might have brought up to top, but your some other code might be changing the order again. Or, calling SetForegroundWindow() before displaying your context menu might help you.
-Malli...! :rose:****