CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Guest

    How do I change the background color of CListBox


    I tried this but nothing happens:

    HBRUSH CACUSHusPP::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);

    // TODO: Change any attributes of the DC here

    if ( nCtlColor == CTLCOLOR_LISTBOX )
    hbr = (HBRUSH)(LTGRAY_BRUSH);

    // TODO: Return a different brush if the default is not desired
    return hbr;
    }

    How is it done?

    D.B.


  2. #2
    Join Date
    May 1999
    Posts
    82

    Re: How do I change the background color of CListBox

    Use this instead

    HBRUSH CACUSHusPP::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
    HBRUSH hbr = CPropertyPage::OnCtlColor(pDC, pWnd, nCtlColor);

    // TODO: Change any attributes of the DC here

    if ( nCtlColor == CTLCOLOR_LISTBOX )
    pDC->SetBkColor(GetSysColor(LTGRAY_BRUSH));

    // TODO: Return a different brush if the default is not desired
    return hbr;
    }


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured