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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How can I get the ID code for

How can I get the ID code for

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
6 Posts 5 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.
  • M Offline
    M Offline
    mwolf122
    wrote on last edited by
    #1

    I put some CEdit to the dialog, use the same function OnChangeEdit1, when the context of edit box is changed, such as, ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1) ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit1) ON_EN_CHANGE(IDC_EDIT3, OnChangeEdit1) the problem is, I can not decide which edit box has called the function, How can I get the ID for it?

    H R 2 Replies Last reply
    0
    • M mwolf122

      I put some CEdit to the dialog, use the same function OnChangeEdit1, when the context of edit box is changed, such as, ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1) ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit1) ON_EN_CHANGE(IDC_EDIT3, OnChangeEdit1) the problem is, I can not decide which edit box has called the function, How can I get the ID for it?

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Does this code helpful?

      void CdddDlg::OnEnChangeEdit1()
      {
      if(GetFocus()==GetDlgItem(IDC_EDIT1))
      MessageBox(_T("editbox1"));

      if(GetFocus()==GetDlgItem(IDC_EDIT2))
      MessageBox(_T("editbox2"));
      }

      T 1 Reply Last reply
      0
      • H Hamid Taebi

        Does this code helpful?

        void CdddDlg::OnEnChangeEdit1()
        {
        if(GetFocus()==GetDlgItem(IDC_EDIT1))
        MessageBox(_T("editbox1"));

        if(GetFocus()==GetDlgItem(IDC_EDIT2))
        MessageBox(_T("editbox2"));
        }

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        ...and for a syntactical point of view, you should always put curved braces for if statements, even it then contains only one instruction...

        J H 2 Replies Last reply
        0
        • T toxcct

          ...and for a syntactical point of view, you should always put curved braces for if statements, even it then contains only one instruction...

          J Offline
          J Offline
          Justin Perez
          wrote on last edited by
          #4

          toxcct wrote:

          ...and for a syntactical point of view, you should always put curved braces for if statements, even it then contains only one instruction...

          I always put curly braces for if statements, even if it would only be a one-liner. About a month ago, however, I started doing one-liners without the braces. I ran into so many problems from doing this. It took me quite a while to get re-accustomed to my old ways. It's funny, you would think it wouldn't cause any problems, but it did for me.

          "If an Indian asked a programming question in the forest, would it still be urgent?" - John Simmons / outlaw programmer I get all the news I need from the weather report - Paul Simon (from "The Only Living Boy in New York")

          1 Reply Last reply
          0
          • T toxcct

            ...and for a syntactical point of view, you should always put curved braces for if statements, even it then contains only one instruction...

            H Offline
            H Offline
            Hamid Taebi
            wrote on last edited by
            #5

            Thank you for your advice.;)

            1 Reply Last reply
            0
            • M mwolf122

              I put some CEdit to the dialog, use the same function OnChangeEdit1, when the context of edit box is changed, such as, ON_EN_CHANGE(IDC_EDIT1, OnChangeEdit1) ON_EN_CHANGE(IDC_EDIT2, OnChangeEdit1) ON_EN_CHANGE(IDC_EDIT3, OnChangeEdit1) the problem is, I can not decide which edit box has called the function, How can I get the ID for it?

              R Offline
              R Offline
              Roger Broomfield
              wrote on last edited by
              #6

              Step 1. Ensure that IDC_EDIT1,IDC_EDIT2,IDC_EDIT3 are consecutive ID's ie 1001,1002,1003 Step 2. instead of 3 separate ON_EN_CHANGE's inside the ClassWizard part of the MESSAGE_MAP use on ON_CONTROL_RANGE outside of the ClassWizard part of the MESSAGE_MAP ON_CONTROL_RANGE(EN_CHANGE, IDC_EDIT1, IDC_EDIT3, OnChangeEdit1) Step 3. change the declaration of OnChangeEdit1 to void YourClass::OnChangeEdit1(UINT nIDCtl) see ON_CONTROL_RANGE[^]

              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