问题
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