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. CEdit Control password style switch

CEdit Control password style switch

Scheduled Pinned Locked Moved C / C++ / MFC
c++designquestion
6 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.
  • R Offline
    R Offline
    RomTibi
    wrote on last edited by
    #1

    I build an app w/VC++6 :laugh: . I design a window with an EDIT CONTROL (IDD_MYEDIT), associate a CEdit control (m_myedit). I switched on the PASSWORD style of the control. Can be triggered this style on or off during the program running? :confused:

    36. When you surround an army, leave an outlet free. ... Do not press a desperate foe too hard. SUN-TZU - Art of War

    L M 2 Replies Last reply
    0
    • R RomTibi

      I build an app w/VC++6 :laugh: . I design a window with an EDIT CONTROL (IDD_MYEDIT), associate a CEdit control (m_myedit). I switched on the PASSWORD style of the control. Can be triggered this style on or off during the program running? :confused:

      36. When you surround an army, leave an outlet free. ... Do not press a desperate foe too hard. SUN-TZU - Art of War

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

      This should do it:

      void ToggleStyle(HWND hEdit)
      {
      if(SendMessage(hEdit,EM_GETPASSWORDCHAR,0,0) == '*')
      SendMessage(hEdit,EM_SETPASSWORDCHAR,0,0);
      else
      SendMessage(hEdit,EM_SETPASSWORDCHAR,(WPARAM)'*',0);
      SetFocus(hEdit);
      }

      You can have a look here[^] for an explanation, if you're interested :)

      R 1 Reply Last reply
      0
      • L Lost User

        This should do it:

        void ToggleStyle(HWND hEdit)
        {
        if(SendMessage(hEdit,EM_GETPASSWORDCHAR,0,0) == '*')
        SendMessage(hEdit,EM_SETPASSWORDCHAR,0,0);
        else
        SendMessage(hEdit,EM_SETPASSWORDCHAR,(WPARAM)'*',0);
        SetFocus(hEdit);
        }

        You can have a look here[^] for an explanation, if you're interested :)

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

        Thx I will try it tomorrow. It is 2105.:thumbsup:

        36. When you surround an army, leave an outlet free. ... Do not press a desperate foe too hard. SUN-TZU - Art of War

        1 Reply Last reply
        0
        • R RomTibi

          I build an app w/VC++6 :laugh: . I design a window with an EDIT CONTROL (IDD_MYEDIT), associate a CEdit control (m_myedit). I switched on the PASSWORD style of the control. Can be triggered this style on or off during the program running? :confused:

          36. When you surround an army, leave an outlet free. ... Do not press a desperate foe too hard. SUN-TZU - Art of War

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

          As far as I know, and according to the docs[^], after the edit control has been created, the ES_PASSWORD style can't be changed.

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

          L 1 Reply Last reply
          0
          • M Mark Salsbery

            As far as I know, and according to the docs[^], after the edit control has been created, the ES_PASSWORD style can't be changed.

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

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

            That's true, you can't add or remove ES_PASSWORD directly with SetWindowLong, but with EM_SETPASSWORDCHAR[^] you can still have the desired effect.

            M 1 Reply Last reply
            0
            • L Lost User

              That's true, you can't add or remove ES_PASSWORD directly with SetWindowLong, but with EM_SETPASSWORDCHAR[^] you can still have the desired effect.

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

              Cool thanks!

              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