none
Ways to Color the PushButton other than OWNER_DRAW RRS feed

  • Question

  • Hi,

    Iam working in WIN32Application development for WEC7 device. I needs to fill the PushButtons background with color.

    I tried using CreateSolidBrush() and Rectangle(). They filled the whole button with color making the text inside the button invisible.

    SetTextColor() is not helping either. Baiscally I wants to color my button with some color with my text having different color.

    Any Help is appreciated.


    • Edited by m_syd_ahmed Wednesday, November 14, 2018 11:50 AM
    Wednesday, November 14, 2018 7:26 AM

All replies

  • I apologize but I am travelling and don't have Visual Studio to try this and give you a clear answer.

    I don't have experience with PushButton, but Button has a background color - so I assume PushButton does also.  You can set the background color, which would leave the foreground (text) color visible.

    If you want to move forward with your rectangle idea, you would need to move the text from your button to the rectangle since the rectangle is covering the button.


    Bruce Eitman
    Senior Enginer
    Bruce.Eitman AT Synopsys DOT com
    My BLOG http://geekswithblogs.net/bruceeitman
    I work for
    Synopsys

    Wednesday, November 14, 2018 4:42 PM
    Moderator
  • Hi Bruce,

    Thanks for your reply. My push button is having default gray background. I am trying to change that background by trying different APIs. But they either completely fill the button or not at all. I am unable to change background alone.

    Can you please point me to any link to set the background alone? Also please share some more detail regarding moving text to rectangle.

    Thanks,

    Syed

    Thursday, November 15, 2018 5:11 AM
  • To change the background of button, most suggestion seems to be SetBkColor(). But, I have read in some forum, that SetBkColor() won't change the background, we still needs to call Rectangle or FillRect function to change after that.

    If I Call those functions, my Button text is invisible. Tried using DrawText() after Rectangle, but still text is invisible.

    Also, strangely Rectangle() fills the button but FillRect() doesn't

    Thursday, November 15, 2018 12:07 PM