Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. C / C++ / MFC
  3. Dialog box prohibits subsequent MessageBox

Dialog box prohibits subsequent MessageBox

Scheduled Pinned Locked Moved C / C++ / MFC
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KeithW
    wrote on last edited by
    #1

    I'm a Windows programming beginner, been programming DOS for some time, starting to make the switch and I'm having a niggly bit of trouble trying to display a messagebox immediately after a dialog.DoModal() . Has anyone out there seen this type of behaviour where any messagebox call after a dialog box fails to be displayed? Did I miss something obvious? The application was created as an simple MFC GUI app. Your help is much appreciated. //********************************************************************* dlg.m_strWarningtext.Format(strMsgBuf); nResponse = dlg.DoModal(); // >>>>> At this point, any messagebox call returns IDOK without even being displayed. if (nResponse == IDOK) { // Do stuff sprintf(strMsgBuf,"Messagebox text "); nRetVal = MessageBox( NULL, (LPCTSTR)strMsgBuf, "Error", MB_OK | MB_ICONERROR ); // >>>>> nRetVal is always == IDOK and the messagebox won't display } else if (nResponse == IDCANCEL) { // Do stuff } //*********************************************************************

    C M 2 Replies Last reply
    0
    • K KeithW

      I'm a Windows programming beginner, been programming DOS for some time, starting to make the switch and I'm having a niggly bit of trouble trying to display a messagebox immediately after a dialog.DoModal() . Has anyone out there seen this type of behaviour where any messagebox call after a dialog box fails to be displayed? Did I miss something obvious? The application was created as an simple MFC GUI app. Your help is much appreciated. //********************************************************************* dlg.m_strWarningtext.Format(strMsgBuf); nResponse = dlg.DoModal(); // >>>>> At this point, any messagebox call returns IDOK without even being displayed. if (nResponse == IDOK) { // Do stuff sprintf(strMsgBuf,"Messagebox text "); nRetVal = MessageBox( NULL, (LPCTSTR)strMsgBuf, "Error", MB_OK | MB_ICONERROR ); // >>>>> nRetVal is always == IDOK and the messagebox won't display } else if (nResponse == IDCANCEL) { // Do stuff } //*********************************************************************

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      I don't know the answer, but if you're using MFC, replace the last two lines with nRetVal = AfxMessageBox("MessageBox Test"); Christian The content of this post is not necessarily the opinion of my yadda yadda yadda. To understand recursion, we must first understand recursion.

      1 Reply Last reply
      0
      • K KeithW

        I'm a Windows programming beginner, been programming DOS for some time, starting to make the switch and I'm having a niggly bit of trouble trying to display a messagebox immediately after a dialog.DoModal() . Has anyone out there seen this type of behaviour where any messagebox call after a dialog box fails to be displayed? Did I miss something obvious? The application was created as an simple MFC GUI app. Your help is much appreciated. //********************************************************************* dlg.m_strWarningtext.Format(strMsgBuf); nResponse = dlg.DoModal(); // >>>>> At this point, any messagebox call returns IDOK without even being displayed. if (nResponse == IDOK) { // Do stuff sprintf(strMsgBuf,"Messagebox text "); nRetVal = MessageBox( NULL, (LPCTSTR)strMsgBuf, "Error", MB_OK | MB_ICONERROR ); // >>>>> nRetVal is always == IDOK and the messagebox won't display } else if (nResponse == IDCANCEL) { // Do stuff } //*********************************************************************

        M Offline
        M Offline
        Masaaki Onishi
        wrote on last edited by
        #3

        Hello, the codegurus around the world.;) If you use the debugger, you may find the reason. I think that ::MessageBox() should be called in if (response == IDOK) The other way is that we put MessageBox() in CMyDialog::OnOK(). We often tend to use MessageBox() to check something. But, TRACE, TRACE1, and so on works also in the debug mode.

        void CMyDialog::OnOK()
        {
        MessageBox("OK button works", "Test");
        TRACE ("OK button works")
        // In Debug mode, "OK button works" shows in Output windows;

         CDialog::OnOK();
        

        }

        Have a nice day! -Masaaki Onishi-

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups