如何激活应用程序窗口并将其显示在屏幕的最上方? [英] How to activate a window of an application and display it at the topmost of the screen?

查看:147
本文介绍了如何激活应用程序窗口并将其显示在屏幕的最上方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

该应用程序是MFC的.有时,当我关闭,隐藏或最小化窗口时,我需要激活该窗口并将其显示在屏幕的最上方.这是我所做的:

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?

非常感谢!

推荐答案

尝试 SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_SHOWWINDOW);

try SetWindowPos(hwnd,HWND_TOPMOST,0,0,0,0,SWP_SHOWWINDOW);

它应该在所有窗口上都可以使用,因为所有窗口都具有相同的句柄类型.

it should work on all windows, since all windows have the same handle type.

这篇关于如何激活应用程序窗口并将其显示在屏幕的最上方?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆