MFC MessageBox 未显示在所有 Windows 的顶部 [英] MFC MessageBox Not Showing at Top Of All Windows

查看:69
本文介绍了MFC MessageBox 未显示在所有 Windows 的顶部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 VC++ 中创建了一个应用程序,问题是如果发生错误,我会显示 MessageBox.但是 MessageBox 没有显示在前面.我必须按 ALT 键才能进入该应用程序.我的应用程序变为非活动状态,直到我按下 ALT.并在 MessageBox 上按 OK.

i have created an Application in VC++, the Problem is that if an Error Occurs i display the MessageBox. but that MessageBox doesn't show at front. i have to press ALT key to become in-front of that application. My Application becomes in-active until i press ALT. and Press OK on the MessageBox.

这是附加的代码.

MessageBox(NULL,"Invalid File, Parsing is going to be terminate");

AfxMessageBox("Win32 MessageMes​​sage",MB_OK | MB_ICONEXCLAMATION | MB_TOPMOST);

如果有人帮助我,我将不胜感激

i wil very grateful if somebody helps me

推荐答案

需要传递 Handle 才能在 Screen 上显示 Messagebox,您可以使用 HWND WINAPI GetDesktopWindow(void);函数获取桌面的句柄并将其传递到 MessageBox() 函数中.

You need to pass Handle to display Messagebox on Screen, You can use HWND WINAPI GetDesktopWindow(void); function to get the Handle of Desktop and pass this in MessageBox () function.

您可以从

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633504%28v=vs.85%29.aspx

GetDesktopWindoe 检索桌面窗口的句柄.桌面窗口覆盖整个屏幕.桌面窗口是在其上绘制其他窗口的区域.所以这也适用于 OpenGL.

GetDesktopWindoe retrieves a handle to the desktop window. The desktop window covers the entire screen. The desktop window is the area on top of which other windows are painted. So this will work for OpenGL as well.

这篇关于MFC MessageBox 未显示在所有 Windows 的顶部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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