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. dialog box constantly reappearing

dialog box constantly reappearing

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
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.
  • E Offline
    E Offline
    elephantstar
    wrote on last edited by
    #1

    Hi there, I have a group of three checkboxes. When I click on CheckBox2, a dialog box appears asking for user input. What it's suppose to do is when a user cancels a selection it should default to the first checkbox by making a call to CheckRadioButton. It does default but once the user clicks away from the application, the dialog box reappears as if the function to open up the dialog box is called once again. I isolated the problem and found that its the CheckRadioButton() that causes it. I don't know how or why but its the main source of the problem. How can I correct this? Please see my code below. Thanks. void CCheckBox::OnCheckBox2 { CMyDialog dlg; int nRet = -1; nRet = dlg.DoModal(); // Handle the return value from DoModal switch ( nRet ) { case -1: AfxMessageBox("Dialog box could not be created!"); break; case IDOK: { ..code... break; } case IDABORT: { OnCheckBox1(); break; } case IDCANCEL: { OnCheckBox1(); break; } default: break; }; } void CCheckBox::OnCheckBox1() { CheckRadioButton(IDC_RADIO1, IDC_RADIO3, IDC_RADIO1); }

    V R 2 Replies Last reply
    0
    • E elephantstar

      Hi there, I have a group of three checkboxes. When I click on CheckBox2, a dialog box appears asking for user input. What it's suppose to do is when a user cancels a selection it should default to the first checkbox by making a call to CheckRadioButton. It does default but once the user clicks away from the application, the dialog box reappears as if the function to open up the dialog box is called once again. I isolated the problem and found that its the CheckRadioButton() that causes it. I don't know how or why but its the main source of the problem. How can I correct this? Please see my code below. Thanks. void CCheckBox::OnCheckBox2 { CMyDialog dlg; int nRet = -1; nRet = dlg.DoModal(); // Handle the return value from DoModal switch ( nRet ) { case -1: AfxMessageBox("Dialog box could not be created!"); break; case IDOK: { ..code... break; } case IDABORT: { OnCheckBox1(); break; } case IDCANCEL: { OnCheckBox1(); break; } default: break; }; } void CCheckBox::OnCheckBox1() { CheckRadioButton(IDC_RADIO1, IDC_RADIO3, IDC_RADIO1); }

      V Offline
      V Offline
      valikac
      wrote on last edited by
      #2

      Sounds like recursive calls. Kuphryn

      E 1 Reply Last reply
      0
      • E elephantstar

        Hi there, I have a group of three checkboxes. When I click on CheckBox2, a dialog box appears asking for user input. What it's suppose to do is when a user cancels a selection it should default to the first checkbox by making a call to CheckRadioButton. It does default but once the user clicks away from the application, the dialog box reappears as if the function to open up the dialog box is called once again. I isolated the problem and found that its the CheckRadioButton() that causes it. I don't know how or why but its the main source of the problem. How can I correct this? Please see my code below. Thanks. void CCheckBox::OnCheckBox2 { CMyDialog dlg; int nRet = -1; nRet = dlg.DoModal(); // Handle the return value from DoModal switch ( nRet ) { case -1: AfxMessageBox("Dialog box could not be created!"); break; case IDOK: { ..code... break; } case IDABORT: { OnCheckBox1(); break; } case IDCANCEL: { OnCheckBox1(); break; } default: break; }; } void CCheckBox::OnCheckBox1() { CheckRadioButton(IDC_RADIO1, IDC_RADIO3, IDC_RADIO1); }

        R Offline
        R Offline
        rw104
        wrote on last edited by
        #3

        Are you calling UpdateData in the right place\correctly? Sounds like the associated member variable is not being kept up-to date as you are expecting. You may already know this, but its a possiblilty all the same!! X|

        E 1 Reply Last reply
        0
        • V valikac

          Sounds like recursive calls. Kuphryn

          E Offline
          E Offline
          elephantstar
          wrote on last edited by
          #4

          But how is it recursive on the dialog box when all I am doing is checking the first check box? I can see it being recursive in that everytime I call CheckRadioButton() to check the first button it calls OnCheckBox1() again. I still don't understand why it would recursively call the dialog box as well. Help please. Thanks!

          1 Reply Last reply
          0
          • R rw104

            Are you calling UpdateData in the right place\correctly? Sounds like the associated member variable is not being kept up-to date as you are expecting. You may already know this, but its a possiblilty all the same!! X|

            E Offline
            E Offline
            elephantstar
            wrote on last edited by
            #5

            I inserted UpdateData() at the beginning of both OnCheckBox1() and OnCheckBox2() and UpdateData(FALSE) at the end of each but it still doesn't work. It just doesn't like CheckRadioButton(button1, button2, button3) in OnCheckBox1(). That's what causes it to be recursive. Any ideas? Thanks.

            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