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. Help!! How to change the ListBox and EditBox background & text color without using MFC!! Thanks..

Help!! How to change the ListBox and EditBox background & text color without using MFC!! Thanks..

Scheduled Pinned Locked Moved C / C++ / MFC
c++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.
  • J Offline
    J Offline
    Jason Hsu
    wrote on last edited by
    #1

    Hi. I had tried using LBS_OWNERDRAWFIXED function when I create a new window for LISTBOX. I can received the WM_DRAWITEM message and changed the text with background color then send text to display (I used 'TextOut' function.) as far, the work is find , there will be able display which one message with color I want to display on listbox window, but when next message "WM_PAINT" will clear all, let the window blank. can you tell me what's wrong I got?? If possible that I can got the Listbox item HDC directly without using LBS_OWNERDRAWFIXED?? If can then how about the EditBox HDC?? Thanks for you helps. Jason.

    K 1 Reply Last reply
    0
    • J Jason Hsu

      Hi. I had tried using LBS_OWNERDRAWFIXED function when I create a new window for LISTBOX. I can received the WM_DRAWITEM message and changed the text with background color then send text to display (I used 'TextOut' function.) as far, the work is find , there will be able display which one message with color I want to display on listbox window, but when next message "WM_PAINT" will clear all, let the window blank. can you tell me what's wrong I got?? If possible that I can got the Listbox item HDC directly without using LBS_OWNERDRAWFIXED?? If can then how about the EditBox HDC?? Thanks for you helps. Jason.

      K Offline
      K Offline
      Kurt 0
      wrote on last edited by
      #2

      The WM_CTLCOLORLISTBOX message is sent to the parent window of a list box before the system draws the list box. WM_CTCOLOREDIT too. By responding to this message, the parent window can set the text and background colors of the list box by using the given display device context handle. WM_CTLCOLORLISTBOX hdcLB = (HDC) wParam;// handle to list box display context hwndLB = (HWND) lParam; // handle to list box This is for 32 bit only for 16 you have just WM_CTLCOLOR and then need to switch on the WPARAM

      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