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. clistbox greying

clistbox greying

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

    Need to grey out the background of a ClistBox on pressing button grey on a dialog. The list can contain items which should also be greyed out and on pressing button enable list the list should be enabled with all its items using wm_ctlcolor message with appropriate brush works, but when the list has items the portion with those items are white while rest is grey.

    S 1 Reply Last reply
    0
    • S SVPG

      Need to grey out the background of a ClistBox on pressing button grey on a dialog. The list can contain items which should also be greyed out and on pressing button enable list the list should be enabled with all its items using wm_ctlcolor message with appropriate brush works, but when the list has items the portion with those items are white while rest is grey.

      S Offline
      S Offline
      sps itsec46
      wrote on last edited by
      #2

      You have to enable the transparent background mode for the DC in the WM_CTLCOLOR method BEFORE returning the new brush:

      HBRUSH CSampleDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
      {
      HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
       
      // TODO: Change any attributes of the DC here
       
      // !!! Set background transparent !!!
      pDC->SetBkMode(TRANSPARENT); // <<<<<<<<< Items will be transparent, showing the new bk brush
       
      if (pWnd->GetDlgCtrlID() == IDC_MYLISTBOX)
      {
      if(m_bGrayed)
      return (HBRUSH)GetStockObject(GRAY_BRUSH);
      else
      return (HBRUSH)GetStockObject(WHITE_BRUSH);
      }
       
      // TODO: Return a different brush if the default is not desired
      return hbr;
      }

      Regards, mYkel

      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