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. Dialog box Static text

Dialog box Static text

Scheduled Pinned Locked Moved C / C++ / MFC
help
5 Posts 4 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
    karmendra_js
    wrote on last edited by
    #1

    I have a dialog box with an Editbox. I just want to have an Static text int he dialog box which will display number of characters present in the Editbox Thanks a lot for your time and help.

    T C T 3 Replies Last reply
    0
    • K karmendra_js

      I have a dialog box with an Editbox. I just want to have an Static text int he dialog box which will display number of characters present in the Editbox Thanks a lot for your time and help.

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

      CString str = "";

      ((CEdit*)GetDlgItem(IDC_MY_EDIT))->GetWindowText(str);
      str.Format("%d", str.GetLength());
      ((CStatic*)GetDlgItem(IDC_My_STATIC))->SetWindowText(str);


      TOXCCT >>> GEII power
      [toxcct][VisualCalc]

      1 Reply Last reply
      0
      • K karmendra_js

        I have a dialog box with an Editbox. I just want to have an Static text int he dialog box which will display number of characters present in the Editbox Thanks a lot for your time and help.

        C Offline
        C Offline
        Cedric Moonen
        wrote on last edited by
        #3

        What you can do is set the text of your static control whenever something changes in the EditBox. Here how to do that: 1) Go to class wizzard and add a handler function for the 'change text' message (I don't remember which message exactly. 2) In this handler function Retrieve the text of your EditBox (GetWindowText) and calculate his length (with strlen). 3) Format this value in a new string (with sprintf) and set the text of the static control (SetWindowText)

        T 1 Reply Last reply
        0
        • K karmendra_js

          I have a dialog box with an Editbox. I just want to have an Static text int he dialog box which will display number of characters present in the Editbox Thanks a lot for your time and help.

          T Offline
          T Offline
          ThatsAlok
          wrote on last edited by
          #4

          Handle the EN_CHANGE message on Edit Box :- here is handller and IDC_EDIT1 is ID of Edit Box and IDC_STATIC_TEST is ID of the static box.

          void CNegCtrlDlg::OnChangeEdit1()
          {
          CString str;
          this->GetDlgItemText(IDC_EDIT1,str);

          // Set number of the charecter in static box'
          SetDlgItemInt(IDC_STATIC_TEXT,str.GetLength());

          }

          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

          cheers, Alok Gupta VC Forum Q&A :- I/ IV

          1 Reply Last reply
          0
          • C Cedric Moonen

            What you can do is set the text of your static control whenever something changes in the EditBox. Here how to do that: 1) Go to class wizzard and add a handler function for the 'change text' message (I don't remember which message exactly. 2) In this handler function Retrieve the text of your EditBox (GetWindowText) and calculate his length (with strlen). 3) Format this value in a new string (with sprintf) and set the text of the static control (SetWindowText)

            T Offline
            T Offline
            ThatsAlok
            wrote on last edited by
            #5

            cedric moonen wrote: What you can do is set the text of your static control whenever something changes in the EditBox. Here how to do that:

            Ohh I miss DeadLine :((:(

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta VC Forum Q&A :- I/ IV

            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