简体   繁体   中英

AfxMessageBox going on background

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM