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. Changing a disabled edit ctrl's color.

Changing a disabled edit ctrl's color.

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
7 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.
  • L Offline
    L Offline
    Like2Byte
    wrote on last edited by
    #1

    I'm having trouble figuring out how to change the color of text in an edit control when it is disabled; such that the light grey (disabled) is black instead. Let's just say I have an edit control ('IDC_EDIT1'). CFont font; //in header font.CreatePointFont(280, "Arial Bold"); CWnd *pWnd = ((CWnd*)GetDlgItem(IDC_EDIT1); pWnd->EnableWindow(FALSE); //disables window //now I'd like to change the color of the text so it stays black. Any help would be greatly appreciated.

    M 1 Reply Last reply
    0
    • L Like2Byte

      I'm having trouble figuring out how to change the color of text in an edit control when it is disabled; such that the light grey (disabled) is black instead. Let's just say I have an edit control ('IDC_EDIT1'). CFont font; //in header font.CreatePointFont(280, "Arial Bold"); CWnd *pWnd = ((CWnd*)GetDlgItem(IDC_EDIT1); pWnd->EnableWindow(FALSE); //disables window //now I'd like to change the color of the text so it stays black. Any help would be greatly appreciated.

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

      What about making the edit control read-only instead of disabling it? Mark

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

      L 1 Reply Last reply
      0
      • M Mark Salsbery

        What about making the edit control read-only instead of disabling it? Mark

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

        L Offline
        L Offline
        Like2Byte
        wrote on last edited by
        #3

        Hrm, actually that a good idea; but, I don't know how to do that, either. I searched the web a little and found ES_READONLY. Further reading landed me EM_SETREADONLY. As I understand it, I need to call SendMessage to the window (editcontrol) I tried: pWnd->SendMessage(EM_SETREADONLY); and pWnd->SendMessage(ES_READONLY); But neither work - I am still able to edit the contents. What am I missing? thanks.

        M 1 Reply Last reply
        0
        • L Like2Byte

          Hrm, actually that a good idea; but, I don't know how to do that, either. I searched the web a little and found ES_READONLY. Further reading landed me EM_SETREADONLY. As I understand it, I need to call SendMessage to the window (editcontrol) I tried: pWnd->SendMessage(EM_SETREADONLY); and pWnd->SendMessage(ES_READONLY); But neither work - I am still able to edit the contents. What am I missing? thanks.

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

          Like2Byte wrote:

          I tried: pWnd->SendMessage(EM_SETREADONLY);

          Try: pWnd->SendMessage(EM_SETREADONLY, (WPARAM)TRUE); Mark

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

          L 1 Reply Last reply
          0
          • M Mark Salsbery

            Like2Byte wrote:

            I tried: pWnd->SendMessage(EM_SETREADONLY);

            Try: pWnd->SendMessage(EM_SETREADONLY, (WPARAM)TRUE); Mark

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

            L Offline
            L Offline
            Like2Byte
            wrote on last edited by
            #5

            Ah, geez. :doh: I'm going to go put my head in the sand. Gimme 10 minutes. Sincerely, thanks for the help!

            M 1 Reply Last reply
            0
            • L Like2Byte

              Ah, geez. :doh: I'm going to go put my head in the sand. Gimme 10 minutes. Sincerely, thanks for the help!

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

              Like2Byte wrote:

              I'm going to go put my head in the sand.

              Haha - that's the hard way to code! :)

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

              L 1 Reply Last reply
              0
              • M Mark Salsbery

                Like2Byte wrote:

                I'm going to go put my head in the sand.

                Haha - that's the hard way to code! :)

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

                L Offline
                L Offline
                led mike
                wrote on last edited by
                #7

                Mark Salsbery wrote:

                that's the hard way to code!

                No, that's the new age way to code. Having your head in the sand, or other equally dark places, is fine as long as you keep typing!

                led mike

                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