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. ATL / WTL / STL
  4. control ID not found, Resolved

control ID not found, Resolved

Scheduled Pinned Locked Moved ATL / WTL / STL
csharpc++helpphpvisual-studio
7 Posts 3 Posters 5 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.
  • B Offline
    B Offline
    bkelly13
    wrote on last edited by
    #1

    Windows 7, Visual Studio 2008, MFC, C++, dialog Making this short, after failing elsewhere I created a test project. The dialog has one edit box with the default ID of IDC_EDIT1. A button was created and the following code added for that button.

    void Cvs_2008_get_port_numberDlg::OnBnClickedButton1()
    {
    UINT port_number;
    BOOL status = FALSE;
    int last_error = 0;

    port\_number = m\_box\_get\_port\_number.GetDlgItemInt( IDC\_EDIT1, &status );
    last\_error = GetLastError(); 
    

    }

    Run the code, type in 123 in the edit box, press the button, and port_number gets zero. last_error gets value 1421, Control ID not found. Some searching indicated that there may be a windows problem: http://www.errorfixes.net/error-1421-windows-7.php[^] But I find myself skeptical of that. Do I have a simple error that I can correct? Or is this a deeper problem?

    Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

    L 1 Reply Last reply
    0
    • B bkelly13

      Windows 7, Visual Studio 2008, MFC, C++, dialog Making this short, after failing elsewhere I created a test project. The dialog has one edit box with the default ID of IDC_EDIT1. A button was created and the following code added for that button.

      void Cvs_2008_get_port_numberDlg::OnBnClickedButton1()
      {
      UINT port_number;
      BOOL status = FALSE;
      int last_error = 0;

      port\_number = m\_box\_get\_port\_number.GetDlgItemInt( IDC\_EDIT1, &status );
      last\_error = GetLastError(); 
      

      }

      Run the code, type in 123 in the edit box, press the button, and port_number gets zero. last_error gets value 1421, Control ID not found. Some searching indicated that there may be a windows problem: http://www.errorfixes.net/error-1421-windows-7.php[^] But I find myself skeptical of that. Do I have a simple error that I can correct? Or is this a deeper problem?

      Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      What is m_box_get_port_number in the above code? I would have expected to see something more like:

      BOOL status = TRUE;
      port\_number = GetDlgItemInt( IDC\_EDIT1, &status );
      if (status = FALSE)
          last\_error = GetLastError();
      

      // ...

      Also, where is the button that this handler refers to: on the dialog or the main window?

      B 1 Reply Last reply
      0
      • L Lost User

        What is m_box_get_port_number in the above code? I would have expected to see something more like:

        BOOL status = TRUE;
        port\_number = GetDlgItemInt( IDC\_EDIT1, &status );
        if (status = FALSE)
            last\_error = GetLastError();
        

        // ...

        Also, where is the button that this handler refers to: on the dialog or the main window?

        B Offline
        B Offline
        bkelly13
        wrote on last edited by
        #3

        I state up front that I am not experienced with GUIs. My tasks include VS MFS dialogs to control how the app runs and show its performance, but the app is a number cruncher and has no significant user interface. Once started there is no user interaction. The problem is probably a beginner's error so do not hesitate to ask or point out the basics. This test app is an MFC dialog and has only one dialog. I don't know your intent in differentiating between "dialog or main window." It is only a few steps beyond a just created MFC dialog project. So far in the test project there is one edit box, one check box, and one button. A right click on the edit box produced a drop down and "Add variable" was selected. The name used was m_box_get_port_number. I added the check for status per your code and it is returned with value 0, false. The error code remains 1421. The one button has the event handler shown in the OP and runs that code. Is all that of any use?

        Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

        L 1 Reply Last reply
        0
        • B bkelly13

          I state up front that I am not experienced with GUIs. My tasks include VS MFS dialogs to control how the app runs and show its performance, but the app is a number cruncher and has no significant user interface. Once started there is no user interaction. The problem is probably a beginner's error so do not hesitate to ask or point out the basics. This test app is an MFC dialog and has only one dialog. I don't know your intent in differentiating between "dialog or main window." It is only a few steps beyond a just created MFC dialog project. So far in the test project there is one edit box, one check box, and one button. A right click on the edit box produced a drop down and "Add variable" was selected. The name used was m_box_get_port_number. I added the check for status per your code and it is returned with value 0, false. The error code remains 1421. The one button has the event handler shown in the OP and runs that code. Is all that of any use?

          Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          If I understand what you are saying you have an MFC application that is a dialog; that's fairly standard. Within the dialog are a few controls, one of which is an edit box. You then say, "A right click on the edit box produced a drop down and "Add variable" was selected.". That part I don't understand, an edit box is just that, a box that you type text into which allows simple editing. What I would expect to happen would be that you would type something into the edit box, and then click the button. Your button handler would be something like:

          void Cvs_2008_get_port_numberDlg::OnBnClickedButton1()
          {
          UINT port_number;
          BOOL status;
          int last_error = 0;

          port\_number = GetDlgItemInt( IDC\_EDIT1, &status );
          if (status == FALSE)
              last\_error = GetLastError(); 
          

          // ...
          // store the port number somewhere

          When you prefix your call to GetDlgItemInt with m_box_get_port_number (the edit box variable name) you are trying to find the item IDC_EDIT1 within the edit control. But the edit control does not have a child window with that ID so the call fails.

          B 1 Reply Last reply
          0
          • L Lost User

            If I understand what you are saying you have an MFC application that is a dialog; that's fairly standard. Within the dialog are a few controls, one of which is an edit box. You then say, "A right click on the edit box produced a drop down and "Add variable" was selected.". That part I don't understand, an edit box is just that, a box that you type text into which allows simple editing. What I would expect to happen would be that you would type something into the edit box, and then click the button. Your button handler would be something like:

            void Cvs_2008_get_port_numberDlg::OnBnClickedButton1()
            {
            UINT port_number;
            BOOL status;
            int last_error = 0;

            port\_number = GetDlgItemInt( IDC\_EDIT1, &status );
            if (status == FALSE)
                last\_error = GetLastError(); 
            

            // ...
            // store the port number somewhere

            When you prefix your call to GetDlgItemInt with m_box_get_port_number (the edit box variable name) you are trying to find the item IDC_EDIT1 within the edit control. But the edit control does not have a child window with that ID so the call fails.

            B Offline
            B Offline
            bkelly13
            wrote on last edited by
            #5

            Hello Richard,

            Quote:

            You then say, "A right click on the edit box produced a drop down and "Add variable" was selected.". That part I don't understand, an edit box is just that, a box that you type text into which allows simple editing.

            My understanding was that to get the value from a control a variable had to be attached to the control. A right click on that control solicits a dialog to add said variable. This method works when I want to get the state of a check box. However, Now it is clear that this method does not work with the edit control. Following your template, heck, the exact code you wrote, I am able to get the value entered. I need to take care when examining the results. A zero return value is legitimate only when status is also TRUE. If status is FALSE, then the returned integer is to be regarded as invalid. OK, I will work with that. I thank you for the time you spent explaining this. Edit: Now I realize, or think I do, that my code was trying to reach inside that edit box, which is really a window itself, and try to find another control with that ID of IDC_EDIT1.

            Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

            S L 2 Replies Last reply
            0
            • B bkelly13

              Hello Richard,

              Quote:

              You then say, "A right click on the edit box produced a drop down and "Add variable" was selected.". That part I don't understand, an edit box is just that, a box that you type text into which allows simple editing.

              My understanding was that to get the value from a control a variable had to be attached to the control. A right click on that control solicits a dialog to add said variable. This method works when I want to get the state of a check box. However, Now it is clear that this method does not work with the edit control. Following your template, heck, the exact code you wrote, I am able to get the value entered. I need to take care when examining the results. A zero return value is legitimate only when status is also TRUE. If status is FALSE, then the returned integer is to be regarded as invalid. OK, I will work with that. I thank you for the time you spent explaining this. Edit: Now I realize, or think I do, that my code was trying to reach inside that edit box, which is really a window itself, and try to find another control with that ID of IDC_EDIT1.

              Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

              S Offline
              S Offline
              sankarsan parida
              wrote on last edited by
              #6

              good

              Sankarsan Parida

              1 Reply Last reply
              0
              • B bkelly13

                Hello Richard,

                Quote:

                You then say, "A right click on the edit box produced a drop down and "Add variable" was selected.". That part I don't understand, an edit box is just that, a box that you type text into which allows simple editing.

                My understanding was that to get the value from a control a variable had to be attached to the control. A right click on that control solicits a dialog to add said variable. This method works when I want to get the state of a check box. However, Now it is clear that this method does not work with the edit control. Following your template, heck, the exact code you wrote, I am able to get the value entered. I need to take care when examining the results. A zero return value is legitimate only when status is also TRUE. If status is FALSE, then the returned integer is to be regarded as invalid. OK, I will work with that. I thank you for the time you spent explaining this. Edit: Now I realize, or think I do, that my code was trying to reach inside that edit box, which is really a window itself, and try to find another control with that ID of IDC_EDIT1.

                Thank you for your time If you work with telemetry, please check this bulletin board: www.irigbb.com

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                bkelly13 wrote:

                A right click on that control solicits a dialog

                I get it now, you were talking about the MFC Class Wizard being used when you develop the application; a long time since I used MFC.

                bkelly13 wrote:

                Now I realize, or think I do, that my code was trying to reach inside that edit box ...

                Yes, you got it. Glad you got things working.

                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