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. set edit box to read only

set edit box to read only

Scheduled Pinned Locked Moved C / C++ / MFC
question
5 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.
  • A Offline
    A Offline
    acerunner316
    wrote on last edited by
    #1

    Hi, I am trying to set an edit box to read-only during runtime. I tried the two codes below, both caused the program to close. m)CEditData.SendMessage(ES_READONLY); and m_CEditData.SetReadOnly(TRUE); How can I toggle the read-only style without crashing? Thanks

    D M H P 4 Replies Last reply
    0
    • A acerunner316

      Hi, I am trying to set an edit box to read-only during runtime. I tried the two codes below, both caused the program to close. m)CEditData.SendMessage(ES_READONLY); and m_CEditData.SetReadOnly(TRUE); How can I toggle the read-only style without crashing? Thanks

      D Offline
      D Offline
      DKScherpy
      wrote on last edited by
      #2

      Try calling the function CEdit::ModifyStyle and passing in ES_READONLY. See http://msdn2.microsoft.com/en-gb/library/0xhz2t1c(VS.80).aspx for ModifyStyle and http://msdn2.microsoft.com/en-us/library/f7yhsd2b(VS.80).aspx and look at the parameters for the CEdit::CreateFunction

      1 Reply Last reply
      0
      • A acerunner316

        Hi, I am trying to set an edit box to read-only during runtime. I tried the two codes below, both caused the program to close. m)CEditData.SendMessage(ES_READONLY); and m_CEditData.SetReadOnly(TRUE); How can I toggle the read-only style without crashing? Thanks

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

        also, make sure the control's HWND is created befory trying any methods to set the read-only style. Mark

        1 Reply Last reply
        0
        • A acerunner316

          Hi, I am trying to set an edit box to read-only during runtime. I tried the two codes below, both caused the program to close. m)CEditData.SendMessage(ES_READONLY); and m_CEditData.SetReadOnly(TRUE); How can I toggle the read-only style without crashing? Thanks

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

          What happens if you use of ModifyStyle instead SendMessage


          WhiteSky


          1 Reply Last reply
          0
          • A acerunner316

            Hi, I am trying to set an edit box to read-only during runtime. I tried the two codes below, both caused the program to close. m)CEditData.SendMessage(ES_READONLY); and m_CEditData.SetReadOnly(TRUE); How can I toggle the read-only style without crashing? Thanks

            P Offline
            P Offline
            prasad_som
            wrote on last edited by
            #5

            acerunner316 wrote:

            m)CEditData.SendMessage(ES_READONLY); and m_CEditData.SetReadOnly(TRUE);

            Where it takes you in the code if you see callstack during debugging. There is no harm using these functions, if used this way,

            m_ed.Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
            CRect(10, 10, 100, 100), this, 1);
            m_ed.SetReadOnly(TRUE);

            -- modified at 0:54 Friday 15th December, 2006

            Prasad Notifier using ATL | Operator new[],delete[][^]

            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