CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2001
    Posts
    401

    How to change the color of a button background

    I am using a Class CxTargetButton for the buttons in my Dialog,
    Now even afetr tryuing to use Message reflection, the background color of the buttons is not changing.

    I can see the following method being called
    HBRUSH CxTargetButton::CtlColor(CDC* p_DC, UINT nCtl)
    {
    p_DC->SetBkColor(RGB(255,255,255));
    p_DC->SetTextColor(RGB(255,0,0));
    return (HBRUSH)m_Brush;

    }

    But the background color is not changed to white as I want it to.


    The method DrawItem has been overridden in the class, can that be causing this issue...

    Pauli

  2. #2
    Join Date
    Nov 2001
    Posts
    401

    I have some other controls there as well..

    And I have tried the same for them but still nothing, they have the same grey background.


    I am changing the background color of the Dialog in the dialogs CTLColor handler, and for rest of the controlls using CTLCOLOR reflection am trying to use CtlColor to change the color

  3. #3
    Join Date
    Aug 1999
    Location
    Wisconsin
    Posts
    507
    For styled buttons of all types, I highly recommend using the
    CButtonST class by Davide Calabro, at:

    http://www.codeproject.com/buttonctrl/cbuttonst.asp

  4. #4
    Join Date
    Nov 2002
    Location
    Los Angeles, California
    Posts
    3,863
    Can I ask what is CxTargetButton?
    Anyway, depending on what this class does, you could just derive
    from this class and handle DrawItem. Change the backgound color and then call the bass class implementation of DrawItem.
    Again this depends on what this button class is.
    Wakeup in the morning and kick the day in the teeth!! Or something like that.

    "i don't want to write leak free code or most efficient code, like others traditional (so called expert) coders do."

  5. #5
    Join Date
    Apr 1999
    Location
    Jerusalem, Israel
    Posts
    304
    if you are using manifest (win XP style) the reflection functions won't change a thing.

    i don't know why... i asked this question a half a year ago...
    no one told me how to solve this... except one who told me about API functions...
    i tried to change the color of CheckBox when i click on it.

    See my thread...
    InfraRed.
    Please rate my post, if it helped you.

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