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. General Programming
  3. C / C++ / MFC
  4. Closing AfxMessageBox

Closing AfxMessageBox

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
5 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.
  • S Offline
    S Offline
    Sunil P V
    wrote on last edited by
    #1

    Hi All, I have a dialog (say CMyDlg) from which i show a message box(AfxMessageBox). I call the DoModal() of the CMyDlg. After a while with the same instance of CMyDlg i close the dialog by calling EndDialog. My Question:: 1. If the message box is shown, is it possible to close that first and then close the CMyDlg. Main Condition :(( : I am not supposed to use the ::FindWindow for the AfxMessageBox since the message box title will keep changing with time. Please help. Regards Sunil

    Sunil

    I M 2 Replies Last reply
    0
    • S Sunil P V

      Hi All, I have a dialog (say CMyDlg) from which i show a message box(AfxMessageBox). I call the DoModal() of the CMyDlg. After a while with the same instance of CMyDlg i close the dialog by calling EndDialog. My Question:: 1. If the message box is shown, is it possible to close that first and then close the CMyDlg. Main Condition :(( : I am not supposed to use the ::FindWindow for the AfxMessageBox since the message box title will keep changing with time. Please help. Regards Sunil

      Sunil

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      You're going to struggle. But you don't *have* to use MessageBox - there's nothing stopping you using a second dialog that you designed and have code control over - then you can post messages (ie, WM_COMMAND/IDCANCEL, WM_CLOSE) more easily. MessageBox is a very useful straitjacket, but it still restricts you. Iain.

      Plz sir... CPallini CPallini abuz drugz, plz plz help urgent.

      1 Reply Last reply
      0
      • S Sunil P V

        Hi All, I have a dialog (say CMyDlg) from which i show a message box(AfxMessageBox). I call the DoModal() of the CMyDlg. After a while with the same instance of CMyDlg i close the dialog by calling EndDialog. My Question:: 1. If the message box is shown, is it possible to close that first and then close the CMyDlg. Main Condition :(( : I am not supposed to use the ::FindWindow for the AfxMessageBox since the message box title will keep changing with time. Please help. Regards Sunil

        Sunil

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        sunilpv1982 wrote:

        1. If the message box is shown, is it possible to close that first and then close the CMyDlg.

        Possible, maybe, but it doesn't make much sense. Why are trying to use modal dialogs modelessly?

        sunilpv1982 wrote:

        I am not supposed to use the ::FindWindow for the AfxMessageBox since the message box title will keep changing with time.

        How did you find the window to change its title? Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        S 1 Reply Last reply
        0
        • M Mark Salsbery

          sunilpv1982 wrote:

          1. If the message box is shown, is it possible to close that first and then close the CMyDlg.

          Possible, maybe, but it doesn't make much sense. Why are trying to use modal dialogs modelessly?

          sunilpv1982 wrote:

          I am not supposed to use the ::FindWindow for the AfxMessageBox since the message box title will keep changing with time.

          How did you find the window to change its title? Mark

          Mark Salsbery Microsoft MVP - Visual C++ :java:

          S Offline
          S Offline
          Sunil P V
          wrote on last edited by
          #4

          Hi Mark, Thanks for replying.

          Mark Salsbery wrote:

          Possible, maybe, but it doesn't make much sense. Why are trying to use modal dialogs modelessly?

          If i use CMyDlg in a modeless fashion(also providing a parent window handle), the user will still be able to control the parent window. I want the user to respond within a timeout value. If there is no response then close the CMyDlg window and any message boxes opened within CMyDlg.

          Mark Salsbery wrote:

          How did you find the window to change its title?

          AfxMessageBox/MessageBox has a title. The ::FindWindow API gives the handle to the window by passing the title. In my case the title displayed in the MessageBox keeps changing with time(as a result of some SQL query).

          Sunil

          M 1 Reply Last reply
          0
          • S Sunil P V

            Hi Mark, Thanks for replying.

            Mark Salsbery wrote:

            Possible, maybe, but it doesn't make much sense. Why are trying to use modal dialogs modelessly?

            If i use CMyDlg in a modeless fashion(also providing a parent window handle), the user will still be able to control the parent window. I want the user to respond within a timeout value. If there is no response then close the CMyDlg window and any message boxes opened within CMyDlg.

            Mark Salsbery wrote:

            How did you find the window to change its title?

            AfxMessageBox/MessageBox has a title. The ::FindWindow API gives the handle to the window by passing the title. In my case the title displayed in the MessageBox keeps changing with time(as a result of some SQL query).

            Sunil

            M Offline
            M Offline
            Mark Salsbery
            wrote on last edited by
            #5

            sunilpv1982 wrote:

            the user will still be able to control the parent window

            You can disable the parent window. That's what MFC does to simulate a modal dialog. Mark

            Mark Salsbery Microsoft MVP - Visual C++ :java:

            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