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

    change color and font-color of a MFC-Button

    I use VC++6 and it's dialog editor to graphically create dilaogs.
    How can I change the background color of all my buttons (about 100) from default grey to black and the font-color to white?
    thx

  2. #2
    Join Date
    Nov 2003
    Posts
    74
    Probably the easiest way would be to do it in the code if the ID's for your buttons are consecutive because then you would just have to create the brush object and the font object and use a for loop.

  3. #3
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    'CButton' is the only control that does not respond to the 'OnCtlColor()' message handler even though the MSDN (http://msdn.microsoft.com) explains it that way. To change the color of a 'CButton' control you have to set the style to ownerdrawn and do it yourself.

    You will find a complete 'CColorButton' class at http://www.codeguru.com/buttonctrl/color_button.shtml. This class does not allow you to change the color at run-time...you will find a modified control at http://www.codeguru.com/buttonctrl/ClrButton.html

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