MFC MessageBox Not Showing at Top Of All Windows

别说谁变了你拦得住时间么 提交于 2020-12-11 02:51:09

问题


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.

Here is the Code Attached.

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

AfxMessageBox("Win32 MessageMessage",MB_OK | MB_ICONEXCLAMATION | MB_TOPMOST);

i wil very grateful if somebody helps me


回答1:


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.

You can get more help from

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

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.



来源:https://stackoverflow.com/questions/8848441/mfc-messagebox-not-showing-at-top-of-all-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!