问题
In a connection check i am showing a modal dialog to ensure the connection. But to give people escape from the modal dialog i want to a message box to keep try connection or exit the application.
Source Code :
void CRoboVibMainFrame::OpenSystemSettingsDialog(int activeTabIndex /*= 0*/)
{
while (activeTabIndex >= 0)
{
m_settingsDialog = std::make_unique<SettingsDialog>(this,activeTabIndex);
m_settingsDialog->DoModal();
activeTabIndex = GetNotConnectedPSVControl();
if (AfxMessageBox(Polytec::Text::ToMessageString(IDS_PSV_SYSTEM_EXIT_WINDOW_MSG), MB_YESNO) == IDNO)
{
::ExitProcess(0);
break;
}
}
}
But the Messagebox is alway showing in the background. I want it on front. What is wrong in my code? Please suggest.
回答1:
I was able to bring the AfxMessageBox to front by this fix :
CWnd::PostMessage(WM_SYSKEYDOWN);
I am not sure if this is the only way. But it fixed my issues. This can help someone.
来源:https://stackoverflow.com/questions/38457967/afxmessagebox-going-on-background