AfxMessageBox going on background

故事扮演 提交于 2021-01-29 04:23:17

问题


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

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