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 the BG color of a multiline edit box

Changing the BG color of a multiline edit box

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
2 Posts 2 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
    Mohammad A Gdeisat
    wrote on last edited by
    #1

    Hi all, I have three questions about changing an edit box BG color: I am trying to change the background color of a multi line edit box, I use the WM_CTLCOLOR message and it works but: First: initially, when the color changes, the area that changes is only the first line of the edit box (the first line has the desired background color, while the other lines have the white(default) background color), and as I add lines (Enter Key) the following line changes color and so on. how to solve this situation? I want the whole control to be painted with the desired bg color. Second, Even when I change the color of a single line edit box, the color changes, but there still small rectangles of the default bg color in the bottom and the right side of the edit box, it really doesnt exactly have the same effect as writing in VB: Text1.BGColor=vbBlack Why?!!! Thrid and last, When I use the WM_CTLCOLOR message to change my edit box bg color, if the Locked state of the edit box is set, the color is not changed at all, I dont think its wrong to have a locked edit box with a black bg color. how to solve this? I hope I will find some help here. Regards, Mohammad Gdeisat

    C 1 Reply Last reply
    0
    • M Mohammad A Gdeisat

      Hi all, I have three questions about changing an edit box BG color: I am trying to change the background color of a multi line edit box, I use the WM_CTLCOLOR message and it works but: First: initially, when the color changes, the area that changes is only the first line of the edit box (the first line has the desired background color, while the other lines have the white(default) background color), and as I add lines (Enter Key) the following line changes color and so on. how to solve this situation? I want the whole control to be painted with the desired bg color. Second, Even when I change the color of a single line edit box, the color changes, but there still small rectangles of the default bg color in the bottom and the right side of the edit box, it really doesnt exactly have the same effect as writing in VB: Text1.BGColor=vbBlack Why?!!! Thrid and last, When I use the WM_CTLCOLOR message to change my edit box bg color, if the Locked state of the edit box is set, the color is not changed at all, I dont think its wrong to have a locked edit box with a black bg color. how to solve this? I hope I will find some help here. Regards, Mohammad Gdeisat

      C Offline
      C Offline
      Christopher Lloyd
      wrote on last edited by
      #2

      You should be using WM_CTLCOLOREDIT. Also you should return the handle of the brush that Windows should use to paint the background of the control. If you just use SetBkColor and don't return a brush handle then I seem to recall that you get the results you describe. Hope that's of some help.

      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